コード例 #1
0
 def testNotTooManyFeaturesByDefault(self):
     """
     A new instance of L{_FeatureAdder} must be marked on creation as not
     having too many features to plot.
     """
     featureAdder = _FeatureAdder()
     self.assertFalse(featureAdder.tooManyFeaturesToPlot)
コード例 #2
0
    def testTooManyFeatures(self):
        """
        If the sequence fetcher used by a L{_FeatureAdder} returns too many
        features, the C{text} and C{axis} methods on the figure must be called
        correctly and the C{add} call must return the sequences.
        """

        def fetcher(title, db="database"):
            feature = SeqFeature(type="site", qualifiers={"a": ["b"]})
            return SeqRecord(None, features=[feature] * 100)

        featureAdder = _FeatureAdder()
        featureAdder.WANTED_TYPES = ("site",)
        fig = plt.subplot(111)
        fig.text = MagicMock()
        fig.axis = MagicMock()
        result = featureAdder.add(fig, "title", 0, 300, identity, sequenceFetcher=fetcher)
        fig.text.assert_called_with(
            0.5,
            0.5,
            "Too many features to plot",
            horizontalalignment="center",
            verticalalignment="center",
            transform=ANY,
            fontsize=20,
        )
        fig.axis.assert_called_with([0, 300, -1, 1])
        self.assertTrue(isinstance(result, _FeatureList))
        self.assertEqual(100, len(result))
コード例 #3
0
    def testNoFeatures(self):
        """
        If the sequence fetcher used by a L{_FeatureAdder} returns no features
        the C{text} and C{axis} methods on the fig must both be called
        correctly and the C{add} method must return C{[]}.
        """
        def fetcher(title, db='database'):
            return SeqRecord(None)

        featureAdder = _FeatureAdder()
        featureAdder.WANTED_TYPES = ('site', )
        fig = plt.subplot(111, label=_randomLabel())
        fig.text = MagicMock()
        fig.axis = MagicMock()
        result = featureAdder.add(fig,
                                  'title',
                                  0,
                                  300,
                                  sequenceFetcher=fetcher)
        fig.text.assert_called_with(0.5,
                                    0.5,
                                    'No features found',
                                    horizontalalignment='center',
                                    verticalalignment='center',
                                    transform=ANY,
                                    fontsize=20)
        fig.axis.assert_called_with([0, 300, -1, 1])
        self.assertEqual([], result)
コード例 #4
0
 def testNotTooManyFeaturesByDefault(self):
     """
     A new instance of L{_FeatureAdder} must be marked on creation as not
     having too many features to plot.
     """
     featureAdder = _FeatureAdder()
     self.assertFalse(featureAdder.tooManyFeaturesToPlot)
コード例 #5
0
    def testOneFeatureRaisesNotImplementedError(self):
        """
        If the sequence fetcher used by a L{_FeatureAdder} returns a feature,
        the C{add} method must raise C{NotImplementedError} because the
        C{_displayFeatures} method is not implemented.
        """
        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])

        featureAdder = _FeatureAdder()
        featureAdder.WANTED_TYPES = ('site', )
        fig = plt.subplot(111)
        self.assertRaises(NotImplementedError,
                          featureAdder.add,
                          fig,
                          'title',
                          0,
                          300,
                          sequenceFetcher=fetcher)
コード例 #6
0
    def testTooManyFeatures(self):
        """
        If the sequence fetcher used by a L{_FeatureAdder} returns too many
        features, the C{text} and C{axis} methods on the figure must be called
        correctly and the C{add} call must return the sequences.
        """
        def fetcher(title, db='database'):
            location = FeatureLocation(100, 200)
            feature = SeqFeature(type='site', qualifiers={'a': ['b']},
                                 location=location)
            return SeqRecord(None, features=[feature] * 100)

        featureAdder = _FeatureAdder()
        featureAdder.WANTED_TYPES = ('site',)
        fig = plt.subplot(111)
        fig.text = MagicMock()
        fig.axis = MagicMock()
        result = featureAdder.add(fig, 'title', 0, 300,
                                  sequenceFetcher=fetcher)
        fig.text.assert_called_with(0.5, 0.5,
                                    'Too many features to plot',
                                    horizontalalignment='center',
                                    verticalalignment='center',
                                    transform=ANY, fontsize=20)
        fig.axis.assert_called_with([0, 300, -1, 1])
        self.assertTrue(isinstance(result, FeatureList))
        self.assertEqual(100, len(result))
コード例 #7
0
    def testTooManyFeatures(self):
        """
        If the sequence fetcher used by a L{_FeatureAdder} returns too many
        features, the C{text} and C{axis} methods on the figure must be called
        correctly and the C{add} call must return the sequences.
        """
        def fetcher(title, db='database'):
            location = FeatureLocation(100, 200)
            feature = SeqFeature(type='site',
                                 qualifiers={'a': ['b']},
                                 location=location)
            return SeqRecord(None, features=[feature] * 100)

        featureAdder = _FeatureAdder()
        featureAdder.WANTED_TYPES = ('site', )
        fig = plt.subplot(111, label=_randomLabel())
        fig.text = MagicMock()
        fig.axis = MagicMock()
        result = featureAdder.add(fig,
                                  'title',
                                  0,
                                  300,
                                  sequenceFetcher=fetcher)
        fig.text.assert_called_with(0.5,
                                    0.5,
                                    'Too many features to plot',
                                    horizontalalignment='center',
                                    verticalalignment='center',
                                    transform=ANY,
                                    fontsize=20)
        fig.axis.assert_called_with([0, 300, -1, 1])
        self.assertTrue(isinstance(result, FeatureList))
        self.assertEqual(100, len(result))
コード例 #8
0
 def testYTicks(self):
     """
     A L{_FeatureAdder} must set the title of its figure.
     """
     fetcher = lambda title, db='database': None
     featureAdder = _FeatureAdder()
     fig = plt.subplot(111)
     fig.set_yticks = MagicMock()
     featureAdder.add(fig, 'title', 0, 100, sequenceFetcher=fetcher)
     fig.set_yticks.assert_called_with([])
コード例 #9
0
 def testTitle(self):
     """
     A L{_FeatureAdder} must set the title of its figure.
     """
     fetcher = lambda title, db="database": None
     featureAdder = _FeatureAdder()
     fig = plt.subplot(111)
     fig.set_title = MagicMock()
     featureAdder.add(fig, "title", 0, 100, identity, sequenceFetcher=fetcher)
     fig.set_title.assert_called_with("Target sequence features", fontsize=16)
コード例 #10
0
 def testYTicks(self):
     """
     A L{_FeatureAdder} must set the title of its figure.
     """
     fetcher = lambda title, db="database": None
     featureAdder = _FeatureAdder()
     fig = plt.subplot(111)
     fig.set_yticks = MagicMock()
     featureAdder.add(fig, "title", 0, 100, identity, sequenceFetcher=fetcher)
     fig.set_yticks.assert_called_with([])
コード例 #11
0
 def testTitle(self):
     """
     A L{_FeatureAdder} must set the title of its figure.
     """
     fetcher = lambda title, db='database': None
     featureAdder = _FeatureAdder()
     fig = plt.subplot(111)
     fig.set_title = MagicMock()
     featureAdder.add(fig, 'title', 0, 100, sequenceFetcher=fetcher)
     fig.set_title.assert_called_with('Target sequence features',
                                      fontsize=16)
コード例 #12
0
ファイル: test_features.py プロジェクト: acorg/dark-matter
    def testYTicks(self):
        """
        A L{_FeatureAdder} must set the title of its figure.
        """
        def fetcher(title, db='database'):
            return None

        featureAdder = _FeatureAdder()
        fig = plt.subplot(111)
        fig.set_yticks = MagicMock()
        featureAdder.add(fig, 'title', 0, 100, sequenceFetcher=fetcher)
        fig.set_yticks.assert_called_with([])
コード例 #13
0
    def testYTicks(self):
        """
        A L{_FeatureAdder} must set the title of its figure.
        """
        def fetcher(title, db='database'):
            return None

        featureAdder = _FeatureAdder()
        fig = plt.subplot(111, label=_randomLabel())
        fig.set_yticks = MagicMock()
        featureAdder.add(fig, 'title', 0, 100, sequenceFetcher=fetcher)
        fig.set_yticks.assert_called_with([])
コード例 #14
0
ファイル: test_features.py プロジェクト: acorg/dark-matter
    def testTitle(self):
        """
        A L{_FeatureAdder} must set the title of its figure.
        """
        def fetcher(title, db='database'):
            return None

        featureAdder = _FeatureAdder()
        fig = plt.subplot(111)
        fig.set_title = MagicMock()
        featureAdder.add(fig, 'title', 0, 100, sequenceFetcher=fetcher)
        fig.set_title.assert_called_with('Target sequence features',
                                         fontsize=16)
コード例 #15
0
 def testOffline(self):
     """
     If the sequence fetcher used by a L{_FeatureAdder} returns C{None},
     the C{add} method of the L{_FeatureAdder} must return C{None}. The
     C{text} and C{axis} methods on the fig must both be called correctly.
     """
     fetcher = lambda title, db="database": None
     featureAdder = _FeatureAdder()
     fig = plt.subplot(111)
     fig.text = MagicMock()
     fig.axis = MagicMock()
     featureAdder.add(fig, "title", 0, 300, identity, sequenceFetcher=fetcher)
     fig.text.assert_called_with(100, 0, "You (or Genbank) appear to be offline.", fontsize=20)
     fig.axis.assert_called_with([0, 300, -1, 1])
コード例 #16
0
 def testOffline(self):
     """
     If the sequence fetcher used by a L{_FeatureAdder} returns C{None},
     the C{add} method of the L{_FeatureAdder} must return C{None}. The
     C{text} and C{axis} methods on the fig must both be called correctly.
     """
     fetcher = lambda title, db='database': None
     featureAdder = _FeatureAdder()
     fig = plt.subplot(111)
     fig.text = MagicMock()
     fig.axis = MagicMock()
     featureAdder.add(fig, 'title', 0, 300, sequenceFetcher=fetcher)
     fig.text.assert_called_with(100,
                                 0,
                                 'You (or Genbank) appear to be offline.',
                                 fontsize=20)
     fig.axis.assert_called_with([0, 300, -1, 1])
コード例 #17
0
ファイル: test_features.py プロジェクト: bamueh/dark-matter
    def testOneFeatureRaisesNotImplementedError(self):
        """
        If the sequence fetcher used by a L{_FeatureAdder} returns a feature,
        the C{add} method must raise C{NotImplementedError} because the
        C{_displayFeatures} method is not implemented.
        """
        def fetcher(title, db='database'):
            location = FeatureLocation(100, 200)
            feature = SeqFeature(type='site', qualifiers={'a': ['b']},
                                 location=location)
            return SeqRecord(None, features=[feature])

        featureAdder = _FeatureAdder()
        featureAdder.WANTED_TYPES = ('site',)
        fig = plt.subplot(111)
        self.assertRaises(NotImplementedError, featureAdder.add, fig, 'title',
                          0, 300, sequenceFetcher=fetcher)
コード例 #18
0
    def testOneFeatureRaisesNotImplementedError(self):
        """
        If the sequence fetcher used by a L{_FeatureAdder} returns a feature,
        the C{add} method must raise C{NotImplementedError} because the
        C{_displayFeatures} method is not implemented.
        """

        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])

        featureAdder = _FeatureAdder()
        featureAdder.WANTED_TYPES = ("site",)
        fig = plt.subplot(111)
        self.assertRaises(
            NotImplementedError, featureAdder.add, fig, "title", 0, 300, identity, sequenceFetcher=fetcher
        )
コード例 #19
0
 def testNoFeatures(self):
     """
     If the sequence fetcher used by a L{_FeatureAdder} returns no features
     the C{text} and C{axis} methods on the fig must both be called
     correctly and the C{add} method must return C{[]}.
     """
     fetcher = lambda title, db='database': SeqRecord(None)
     featureAdder = _FeatureAdder()
     featureAdder.WANTED_TYPES = ('site',)
     fig = plt.subplot(111)
     fig.text = MagicMock()
     fig.axis = MagicMock()
     result = featureAdder.add(fig, 'title', 0, 300,
                               sequenceFetcher=fetcher)
     fig.text.assert_called_with(0.5, 0.5,
                                 'No features found',
                                 horizontalalignment='center',
                                 verticalalignment='center',
                                 transform=ANY, fontsize=20)
     fig.axis.assert_called_with([0, 300, -1, 1])
     self.assertEqual([], result)