Exemple #1
0
 def test_peptides_not_equal_mods(self):
     peptide = Peptide('ATSMPLK', 2, [
         ModSite(23.01, 'nterm', 'testmod'),
         ModSite(19.24, 2, 'testmod2')
     ])
     peptide2 = Peptide('ATSMPLK', 3, [ModSite(23.01, 'nterm', 'testmod')])
     self.assertNotEqual(peptide, peptide2)
Exemple #2
0
 def test_peptides_equal_hash(self):
     peptide = Peptide('ATSMPLK', 2, [
         ModSite(23.01, 'nterm', 'testmod'),
         ModSite(19.24, 2, 'testmod2')
     ])
     peptide2 = Peptide('ATSMPLK', 2, [
         ModSite(23.01, 'nterm', 'testmod'),
         ModSite(19.24, 2, 'testmod2')
     ])
     self.assertEqual(hash(peptide), hash(peptide2))
Exemple #3
0
 def test_peptide_repr(self):
     peptide = Peptide('ATSMPLK', 2, [
         ModSite(23.01, 'nterm', 'testmod'),
         ModSite(19.24, 2, 'testmod2')
     ])
     expected_repr = \
         "<Peptide {'_seq': 'ATSMPLK', '_charge': 2, '_mods': " \
         "[ModSite(mass=23.01, site='nterm', mod='testmod'), "\
         "ModSite(mass=19.24, site=2, mod='testmod2')], 'mass_type': "\
         "<MassType.mono: 0>, 'radical': False, 'fragment_ions': None}>"
     self.assertEqual(expected_repr, repr(peptide))
Exemple #4
0
 def test_peptide_str(self):
     peptide = Peptide('ATSMPLK', 2, [
         ModSite(23.01, 'nterm', 'testmod'),
         ModSite(19.24, 2, 'testmod2')
     ])
     expected_str = \
         "<Peptide {'seq': 'ATSMPLK', 'charge': 2, 'mods': " \
         "[ModSite(mass=23.01, site='nterm', mod='testmod'), " \
         "ModSite(mass=19.24, site=2, mod='testmod2')], 'mass_type': " \
         "<MassType.mono: 0>, 'radical': False}>"
     self.assertEqual(expected_str, str(peptide))
Exemple #5
0
 def test_peptide_mass_mono_cterm_mod(self):
     """
     Tests that the calculated mono mass (with a C-terminal modification)
     is correct.
     """
     peptide = Peptide('AAA', 2, [ModSite(21.981943, 'cterm', 'Cation:Na')])
     self.assertAlmostEqual(253.10, peptide.mass, 2)
     self.assertAlmostEqual(127.56, peptide.mz, 2)
Exemple #6
0
    def test_mod_site_out_of_range(self):
        """
        Tests behaviour when a modification has a site beyond the peptide's
        length.

        """
        peptide = Peptide('ALPK', 2, [ModSite(1000., 100, 'TestMod')])
        self.assertAlmostEqual(427.28, peptide.mass, 2)
Exemple #7
0
 def test_peptide_mass_mono_nterm_mod(self):
     """
     Tests that the calculated mono mass (with an N-terminal modification)
     is correct.
     """
     peptide = Peptide('AAA', 2,
                       [ModSite(304.20536, 'nterm', 'iTRAQ8plex')])
     self.assertAlmostEqual(535.33, peptide.mass, 2)
     self.assertAlmostEqual(268.67, peptide.mz, 2)
Exemple #8
0
    def test_peptide_multiple_mods(self):
        """
        Tests that the calculated mono mass is correct for a peptide with many
        modifications.

        """
        peptide = Peptide('AYHGMLPWK', 3, [
            ModSite(304.20536, 'nterm', 'iTRAQ8plex'),
            ModSite(44.985078, 2, 'Nitro'),
            ModSite(15.994915, 5, 'Oxidation'),
            ModSite(15.994915, 7, 'Oxidation'),
            ModSite(31.989829, 8, 'Dioxidation'),
            ModSite(21.981943, 'cterm', 'Cation:Na')
        ])
        self.assertAlmostEqual(1536.70, peptide.mass, 2)
        self.assertAlmostEqual(513.24, peptide.mz, 2)
Exemple #9
0
 def test_peptides_not_equal_non_instance(self):
     peptide = Peptide('ATSMPLK', 2, [
         ModSite(23.01, 'nterm', 'testmod'),
         ModSite(19.24, 2, 'testmod2')
     ])
     self.assertNotEqual(peptide, ('ATSMPLK', 2))
Exemple #10
0
 def test_basic_mod_numpy(self):
     peptide = Peptide('AAYK', 2, [ModSite(1., np.int32(2), 'testmod')])
     with self.assertRaisesRegex(
             RuntimeError,
             r'Modification site was not an integer or a string'):
         peptide.fragment()
Exemple #11
0
 def test_basic_mod(self):
     peptide = Peptide('AAYK', 2, [ModSite(1., 2, 'testmod')])
     ions = peptide.fragment()
     self.assertIsNotNone(ions)