def test_core(self):
     "Test Thiopeptide.core"
     thio = Thiopeptide(20, 31, 32, 51)
     thio.core = "MAGICHAT"
     self.assertEqual('MAGICHAT', thio.core)
     assert thio.core_analysis
     thio.core = "MAGICXHAT"
     self.assertEqual('MAGICXHAT', thio.core)
     assert thio.core_analysis
예제 #2
0
 def test_init(self):
     "Test Thiopeptide instantiation"
     thio = Thiopeptide(31, 32, 51)
     assert isinstance(thio, Thiopeptide)
     self.assertEqual(31, thio.end)
     self.assertEqual(32, thio.score)
     self.assertEqual('', thio.thio_type)
     self.assertEqual('', thio.core)
     self.assertEqual(51, thio.rodeo_score)
     with self.assertRaisesRegex(AssertionError,
                                 "calculating weight without a core"):
         print(thio.molecular_weight)
    def test_result_vec_to_feature(self):
        "Test thiopeptides.result_vec_to_features()"
        loc = FeatureLocation(0, 165, strand=1)
        orig_feature = DummyCDS(0, 165, locus_tag='FAKE0001')
        vec = Thiopeptide(17, 23, 42, 51)
        seq = 'SCTSSCTSS'
        vec.thio_type = 'Type III'
        vec.core = seq
        vec.leader = "HEADHEADHEAD"
        orig_feature.translation = seq + vec.leader
        motif = result_vec_to_feature(orig_feature, vec)

        leader, core = motif.to_biopython()

        assert loc.start == leader.location.start
        assert loc.start + (12 * 3) == leader.location.end
        assert loc.strand == leader.location.strand
        assert motif.type == 'CDS_motif'
        assert motif.peptide_class == "thiopeptide"
        assert motif.peptide_subclass == "Type III"
        assert orig_feature.locus_tag == motif.locus_tag
        assert motif.rodeo_score == 51
        assert motif.score == 42
        self.assertAlmostEqual(motif.molecular_weight, 861.9, places=1)

        assert motif.leader == "HEADHEADHEAD"
        assert leader.location.end == core.location.start
        assert loc.end == core.location.end
        assert loc.strand == core.location.strand
        self.assertAlmostEqual(motif.monoisotopic_mass, 861.3, places=1)
        assert len(motif.alternative_weights) == 7
        for calc, expect in zip(
                motif.alternative_weights,
            [879.9, 897.9, 916.0, 934.0, 952.0, 970.0, 988.0]):
            self.assertAlmostEqual(calc, expect, places=1)
        assert not motif.amidation
        assert not motif.macrocycle
        assert not motif.tail
        assert motif.core_features == "Central ring: pyridine trisubstituted"
        assert motif.core == "SCTSSCTSS"
 def test_macrocycle_size(self):
     "Test Thiopeptide._predict_macrocycle"
     thio = Thiopeptide(20, 31, 32, 51)
     thio.core = "SAAAAAAAASC"
     self.assertEqual('26-member', thio.macrocycle)
     thio.core = "SAAAAAAAAASSSSSS"
     self.assertEqual('35-member', thio.macrocycle)
     thio.core = "SDDDDDDDDDSC"
     self.assertEqual('29-member', thio.macrocycle)
     thio.core = "TAAASDDDDDDDDSCDD"
     self.assertEqual('26-member', thio.macrocycle)
 def test_repr(self):
     "Test Thiopeptide representation"
     thio = Thiopeptide(20, 31, 32, 51)
     thio.core = "MAGIC"
     thio.thio_type = "Type I"
     thio.c_cut = "DUMMYC"
     thio.macrocycle = "dummy macro"
     expected = (
         "Thiopeptide(20..31, 32, 'MAGIC', 'Type I', -1.0(-1.0), dummy macro, False, "
         "Central ring: pyridine tetrasubstituted (hydroxyl group present); second macrocycle, "
         "DUMMYC)")
     self.assertEqual(expected, repr(thio))
    def test_weights(self):
        "Test Thiopeptide.alt_mature_weights"
        # includes all weights (even after maturation)
        thio = Thiopeptide(23, 42, 17, 51)
        thio.core = "MAGICCHATS"
        thio.amidation = True
        thio.thio_type = "Type I"

        mat_weights = thio.mature_alt_weights
        weight = mat_weights[0]
        mono = mat_weights[1]
        alt = mat_weights[2:]
        self.assertAlmostEqual(weight, 1051.1623)
        self.assertAlmostEqual(mono, 1050.367788)
        self.assertAlmostEqual(alt, [1069.1823, 1087.2023])

        thio.core = "MAGICCHATS"
        thio.amidation = False
        thio.thio_type = "Type I"
        # reset mature alt weights to calculate them again
        thio._mature_alt_weights = []

        mat_weights = thio.mature_alt_weights
        weight = mat_weights[0]
        mono = mat_weights[1]
        alt = mat_weights[2:]
        self.assertAlmostEqual(weight, 1121.1623)
        self.assertAlmostEqual(mono, 1120.367788)
        self.assertAlmostEqual(alt, [1139.1823, 1157.2023])

        thio.core = "MAGICCHATS"
        thio.amidation = True
        thio.thio_type = "Type II"
        # reset mature alt weights to calculate them again
        thio._mature_alt_weights = []

        mat_weights = thio.mature_alt_weights
        weight = mat_weights[0]
        mono = mat_weights[1]
        alt = mat_weights[2:]
        self.assertAlmostEqual(weight, 1097.1623)
        self.assertAlmostEqual(mono, 1096.367788)
        self.assertAlmostEqual(alt, [1115.1823, 1133.2023])