Esempio n. 1
0
 def testNoFeaturesLength(self):
     """
     If the sequence fetcher returns a record with no features, the
     L{_FeatureList} instance must have length zero.
     """
     fetcher = lambda title, db="database": SeqRecord(None)
     featureList = _FeatureList("title", "database", set(), identity, sequenceFetcher=fetcher)
     self.assertEqual(0, len(featureList))
Esempio n. 2
0
 def testNotOffline(self):
     """
     If the sequence fetcher does not return C{None} we must be marked as
     being online.
     """
     fetcher = lambda title, db="database": SeqRecord(None)
     featureList = _FeatureList("title", "database", set(), identity, sequenceFetcher=fetcher)
     self.assertEqual(False, featureList.offline)
Esempio n. 3
0
 def testOfflineLength(self):
     """
     If the sequence fetcher indicates we're offline, the feature list
     must have length zero.
     """
     fetcher = lambda title, db="database": None
     featureList = _FeatureList("title", "database", set(), identity, sequenceFetcher=fetcher)
     self.assertEqual(0, len(featureList))
Esempio n. 4
0
 def testOffline(self):
     """
     If the sequence fetcher returns C{None} we must be marked as being
     offline.
     """
     fetcher = lambda title, db="database": None
     featureList = _FeatureList("title", "database", set(), identity, sequenceFetcher=fetcher)
     self.assertEqual(True, featureList.offline)
Esempio n. 5
0
    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"):
            feature = SeqFeature(type="site", qualifiers={"a": ["b"]})
            return SeqRecord(None, features=[feature])

        featureList = _FeatureList("title", "database", set(["site"]), identity, sequenceFetcher=fetcher)
        self.assertFalse(featureList[0].subfeature)
Esempio n. 6
0
    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(), identity, sequenceFetcher=fetcher)
        self.assertEqual(0, len(featureList))
        self.assertEqual(False, featureList.offline)
Esempio n. 7
0
    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"):
            feature = SeqFeature(type="site")
            return SeqRecord(None, features=[feature, feature])

        featureList = _FeatureList("title", "database", set(["site"]), identity, sequenceFetcher=fetcher)
        self.assertEqual(2, len(featureList))
Esempio n. 8
0
    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"):
            feature1 = SeqFeature(type="region")
            feature2 = SeqFeature(type="site", qualifiers={"a": ["b"]})
            return SeqRecord(None, features=[feature1, feature2])

        featureList = _FeatureList("title", "database", set(["site"]), identity, sequenceFetcher=fetcher)
        self.assertEqual(1, len(featureList))
Esempio n. 9
0
    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"):
            subfeature = SeqFeature(type="site", qualifiers={"a": ["b"]})
            feature = SeqFeature(type="site", qualifiers={"a": ["b"]}, sub_features=[subfeature])
            return SeqRecord(None, features=[feature])

        featureList = _FeatureList("title", "database", set(["site"]), identity, sequenceFetcher=fetcher)
        self.assertEqual(2, len(featureList))
        self.assertTrue(featureList[1].subfeature)
Esempio n. 10
0
    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"):
            feature = SeqFeature(type="site", qualifiers={"a": ["b"]})
            return SeqRecord(None, features=[feature] * 3)

        featureList = _FeatureList("title", "database", set(["site"]), identity, 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)
Esempio n. 11
0
    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"):
            subfeature = SeqFeature(type="region", qualifiers={"a": ["b"]})
            feature = SeqFeature(type="site", qualifiers={"a": ["b"]}, sub_features=[subfeature])
            return SeqRecord(None, features=[feature])

        featureList = _FeatureList("title", "database", set(["region"]), identity, sequenceFetcher=fetcher)
        self.assertEqual(1, len(featureList))
        self.assertTrue(featureList[0].subfeature)