def testOneFeatureAdjusted(self): """ If the sequence fetcher used by a L{_FeatureAdder} returns a feature, 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]) featureAdder = ProteinFeatureAdder() fig = plt.subplot(111) fig.plot = MagicMock() fig.axis = MagicMock() fig.legend = MagicMock() adjuster = lambda x: 3 * x result = featureAdder.add(fig, "title", 0, 300, adjuster, sequenceFetcher=fetcher) fig.plot.assert_called_with( [300, 600], [-0.0, -0.0], color=(0.2298057, 0.298717966, 0.75368315299999999, 1.0), linewidth=2 ) fig.axis.assert_called_with([0, 300, -0.4, 0.2]) fig.legend.assert_called_with( ["100-200 Site. a: b"], loc="lower center", shadow=True, bbox_to_anchor=(0.5, 1.4), ncol=2, fancybox=True ) self.assertTrue(isinstance(result, _FeatureList)) self.assertEqual(1, len(result))
def testOneFeature(self): """ If the sequence fetcher used by a L{_FeatureAdder} returns a feature, 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]) featureAdder = ProteinFeatureAdder() fig = plt.subplot(111) fig.plot = MagicMock() fig.axis = MagicMock() fig.legend = MagicMock() result = featureAdder.add(fig, 'title', 0, 300, sequenceFetcher=fetcher) fig.plot.assert_called_with( [100, 200], [-0.0, -0.0], color=(0.2298057, 0.298717966, 0.75368315299999999, 1.0), linewidth=2) fig.axis.assert_called_with([0, 300, -0.4, 0.2]) fig.legend.assert_called_with( ['100-200 Site. a: b'], loc='lower center', shadow=True, bbox_to_anchor=(0.5, 1.4), ncol=2, fancybox=True) self.assertTrue(isinstance(result, FeatureList)) self.assertEqual(1, len(result))
def testUnwantedFeature(self): """ If the sequence fetcher used by a L{_FeatureAdder} returns a feature whose type is not wanted, the figure's plot method must not be called and the C{add} method must return an empty feature list. """ def fetcher(title, db="database"): location = FeatureLocation(100, 200) feature = SeqFeature(type="unwanted", qualifiers={"a": ["b"]}, location=location) return SeqRecord(None, features=[feature]) featureAdder = ProteinFeatureAdder() fig = plt.subplot(111) fig.plot = MagicMock() result = featureAdder.add(fig, "title", 0, 300, identity, sequenceFetcher=fetcher) self.assertEqual([], fig.plot.call_args_list) self.assertEqual([], result)
def testUnwantedFeature(self): """ If the sequence fetcher used by a L{_FeatureAdder} returns a feature whose type is not wanted, the figure's plot method must not be called and the C{add} method must return an empty feature list. """ def fetcher(title, db='database'): location = FeatureLocation(100, 200) feature = SeqFeature(type='unwanted', qualifiers={'a': ['b']}, location=location) return SeqRecord(None, features=[feature]) featureAdder = ProteinFeatureAdder() fig = plt.subplot(111) fig.plot = MagicMock() result = featureAdder.add(fig, 'title', 0, 300, sequenceFetcher=fetcher) self.assertEqual([], fig.plot.call_args_list) self.assertEqual([], result)