def testNotOffline(self): """ If the sequence fetcher does not return C{None} we must be marked as being online. """ def fetcher(title, db='database'): return SeqRecord(None) featureList = FeatureList('title', 'database', set(), sequenceFetcher=fetcher) self.assertEqual(False, featureList.offline)
def testNoFeaturesLength(self): """ If the sequence fetcher returns a record with no features, the L{FeatureList} instance must have length zero. """ def fetcher(title, db='database'): return SeqRecord(None) featureList = FeatureList('title', 'database', set(), sequenceFetcher=fetcher) self.assertEqual(0, len(featureList))
def testOfflineLength(self): """ If the sequence fetcher indicates we're offline, the feature list must have length zero. """ def fetcher(title, db='database'): return None featureList = FeatureList('title', 'database', set(), sequenceFetcher=fetcher) self.assertEqual(0, len(featureList))
def testOffline(self): """ If the sequence fetcher returns C{None} we must be marked as being offline. """ def fetcher(title, db='database'): return None featureList = FeatureList('title', 'database', set(), sequenceFetcher=fetcher) self.assertEqual(True, featureList.offline)
def testFetcherValueError(self): """ If the sequence fetcher throws a C{ValueError}, the feature list must have length zero and should not be marked as being offline. """ def fetcher(title, db): raise ValueError() featureList = FeatureList('title', 'database', set(), sequenceFetcher=fetcher) self.assertEqual(0, len(featureList)) self.assertEqual(False, featureList.offline)
def testNotSubfeature(self): """ If the sequence fetcher returns a record with a feature that is not a subfeature, it must not be marked as a subfeature. """ def fetcher(title, db='database'): location = FeatureLocation(100, 200) feature = SeqFeature(type='site', qualifiers={'a': ['b']}, location=location) return SeqRecord(None, features=[feature]) featureList = FeatureList('title', 'database', set(['site']), sequenceFetcher=fetcher) self.assertFalse(featureList[0].subfeature)
def testNoQualifiersLength(self): """ If the sequence fetcher returns a record with two features but neither of them has any qualifiers, the L{FeatureList} instance must still include both features. """ def fetcher(title, db='database'): location = FeatureLocation(100, 200) feature = SeqFeature(type='site', location=location) return SeqRecord(None, features=[feature, feature]) featureList = FeatureList('title', 'database', set(['site']), sequenceFetcher=fetcher) self.assertEqual(2, len(featureList))
def testWantedTypeLength(self): """ If the sequence fetcher returns a record with two features but only one of them has a wanted type ('site'), the L{FeatureList} instance must have length one. """ def fetcher(title, db='database'): location = FeatureLocation(100, 200) feature1 = SeqFeature(type='region', location=location) feature2 = SeqFeature(type='site', qualifiers={'a': ['b']}, location=location) return SeqRecord(None, features=[feature1, feature2]) featureList = FeatureList('title', 'database', set(['site']), sequenceFetcher=fetcher) self.assertEqual(1, len(featureList))
def testColors(self): """ If the sequence fetcher returns a record with 3 features, each must be assigned a correct color. """ def fetcher(title, db='database'): location = FeatureLocation(100, 200) feature = SeqFeature(type='site', qualifiers={'a': ['b']}, location=location) return SeqRecord(None, features=[feature] * 3) featureList = FeatureList('title', 'database', set(['site']), sequenceFetcher=fetcher) colormap = plt.cm.coolwarm colors = [colormap(i) for i in np.linspace(0.0, 0.99, 3)] for i in range(3): self.assertEqual(colors[i], featureList[i].color)
def testSubfeatures(self): """ If the sequence fetcher returns a record with a feature that has a subfeature, the L{FeatureList} instance must have length two and the second feature in the list must be a subfeature. """ def fetcher(title, db='database'): location = FeatureLocation(100, 200) subfeature = SeqFeature(type='site', qualifiers={'a': ['b']}, location=location) feature = SeqFeature(type='site', qualifiers={'a': ['b']}, sub_features=[subfeature], location=location) return SeqRecord(None, features=[feature]) featureList = FeatureList('title', 'database', set(['site']), sequenceFetcher=fetcher) self.assertEqual(2, len(featureList)) self.assertTrue(featureList[1].subfeature)
def testSubfeaturesWithoutParentFeature(self): """ If the sequence fetcher returns a record with a feature that has a subfeature, and the subfeature is wanted but the parent feature is not, the L{FeatureList} instance must have length one and the feature in the list must be a subfeature. """ def fetcher(title, db='database'): location = FeatureLocation(100, 200) subfeature = SeqFeature(type='region', qualifiers={'a': ['b']}, location=location) feature = SeqFeature(type='site', qualifiers={'a': ['b']}, sub_features=[subfeature], location=location) return SeqRecord(None, features=[feature]) featureList = FeatureList('title', 'database', set(['region']), sequenceFetcher=fetcher) self.assertEqual(1, len(featureList)) self.assertTrue(featureList[0].subfeature)