def test_custom_ion_types(self): peptide = Peptide('AAA', 2, []) peptide.fragment(ion_types={IonType.b: []}) self.assertIsNotNone(peptide.fragment_ions) self.assertTrue( all(ion.startswith('b') for _, ion, _ in peptide.fragment_ions))
def test_c_ions(self): peptide = Peptide('AFCWK', 1, []) peptide.fragment(ion_types={IonType.c: []}) expected = { 'c1[+]': 89.0709, 'c2[+]': 236.1394, 'c3[+]': 339.1485, 'c4[+]': 525.2279, } self._test_ions(expected, ions_to_dict(peptide.fragment_ions))
def test_x_ions(self): peptide = Peptide('AFCWK', 1, []) peptide.fragment(ion_types={IonType.x: []}) expected = { 'x1[+]': 173.0921, 'x2[+]': 359.1714, 'x3[+]': 462.1806, 'x4[+]': 609.2490, } self._test_ions(expected, ions_to_dict(peptide.fragment_ions))
def test_y_ions(self): peptide = Peptide('AFCWK', 1, []) peptide.fragment(ion_types={IonType.y: []}) expected = { 'y1[+]': 147.1128, 'y2[+]': 333.1921, 'y3[+]': 436.2013, 'y4[+]': 583.2697, } self._test_ions(expected, ions_to_dict(peptide.fragment_ions))
def test_z_ions(self): peptide = Peptide('AFCWK', 1, []) peptide.fragment(ion_types={IonType.z: []}) expected = { 'z1[+]': 131.0941, 'z2[+]': 317.1734, 'z3[+]': 420.1826, 'z4[+]': 567.2510, } self._test_ions(expected, ions_to_dict(peptide.fragment_ions))
def test_a_ions(self): peptide = Peptide('AFCWK', 1, []) peptide.fragment(ion_types={IonType.a: []}) expected = { 'a1[+]': 44.0495, 'a2[+]': 191.1179, 'a3[+]': 294.1271, 'a4[+]': 480.2064, } self._test_ions(expected, ions_to_dict(peptide.fragment_ions))
def test_b_ions(self): peptide = Peptide('AFCWK', 1, []) peptide.fragment(ion_types={IonType.b: []}) expected = { 'b1[+]': 72.0444, 'b2[+]': 219.1128, 'b3[+]': 322.1220, 'b4[+]': 508.2013, } self._test_ions(expected, ions_to_dict(peptide.fragment_ions))
def test_all_ion_types(self): peptide = Peptide('AAAMLPK', 2, []) peptide.fragment( ion_types={ IonType.b: [], IonType.y: [], IonType.a: [], IonType.c: [], IonType.z: [], IonType.precursor: [], IonType.imm: [] }) self.assertIsNotNone(peptide.fragment_ions)
def test_radical(self): peptide = Peptide('AAA', 2, [], radical=True) peptide.fragment( ion_types={ IonType.b: [], IonType.y: [], IonType.a: [], IonType.c: [], IonType.z: [], IonType.precursor: [], IonType.imm: [] }) self.assertIsNotNone(peptide.fragment_ions)
def test_neutral_losses(self): peptide = Peptide('AAAK', 2, []) peptide.fragment( ion_types={ IonType.b: ['NH3', ('testLoss', 9.)], IonType.precursor: ['CO2', ('testLoss2', 13.)], IonType.imm: [('testLoss3', 2.04), 'H2O'] }) expected_ions = {(44.049475632459, 'imm(A)', 0), (42.009475632459, '[imm1-testLoss3][+]', 1), (26.038910948429, '[imm1-H2O][+]', 1), (42.009475632459, '[imm2-testLoss3][+]', 2), (26.038910948429, '[imm2-H2O][+]', 2), (42.009475632459, '[imm3-testLoss3][+]', 3), (26.038910948429, '[imm3-H2O][+]', 3), (101.107324862499, 'imm(K)', 0), (72.044390252029, 'b1[+]', 1), (55.01784115090901, '[b1-NH3][+]', 1), (63.044390252029004, '[b1-testLoss][+]', 1), (143.081504037179, 'b2[+]', 2), (126.054954936059, '[b2-NH3][+]', 2), (134.081504037179, '[b2-testLoss][+]', 2), (214.118617822329, 'b3[+]', 3), (197.09206872120902, '[b3-NH3][+]', 3), (205.118617822329, '[b3-testLoss][+]', 3), (107.56294714460401, 'b3[2+]', 3), (99.04967259404401, '[b3-NH3][2+]', 3), (103.06294714460401, '[b3-testLoss][2+]', 3), (99.06732486249899, '[imm4-testLoss3][+]', 4), (83.096760178469, '[imm4-H2O][+]', 4), (21.508376049669, '[imm3-testLoss3][2+]', 3), (13.523093707653999, '[imm3-H2O][2+]', 3), (360.22414552154896, '[M+H][+]', 4), (316.234315521549, '[M-CO2][+]', 4), (347.22414552154896, '[M-testLoss2][+]', 4), (180.615710994214, '[M+H][2+]', 4), (158.620795994214, '[M-CO2][2+]', 4), (174.115710994214, '[M-testLoss2][2+]', 4), (50.037300664689, '[imm4-testLoss3][2+]', 4), (42.052018322674, '[imm4-H2O][2+]', 4)} self.assertEqual(expected_ions, set(peptide.fragment_ions))
def test_basic(self): peptide = Peptide('AAA', 2, []) ions = peptide.fragment() self.assertIsNotNone(ions)
def test_unknown_string_neutral_loss(self): peptide = Peptide('AAAK', 2, []) with self.assertRaises(KeyError): peptide.fragment(ion_types={IonType.b: ['test']})
def test_invalid_residue(self): peptide = Peptide('AUA', 2, []) with self.assertRaisesRegex(KeyError, r'Invalid residue detected: U'): peptide.fragment()
def test_basic_mod(self): peptide = Peptide('AAYK', 2, [ModSite(1., 2, 'testmod')]) ions = peptide.fragment() self.assertIsNotNone(ions)
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()
def test_basic(self): peptide = Peptide('AAA', 2, []) peptide.fragment() self.assertIsNotNone(peptide.fragment_ions) peptide.clean_fragment_ions() self.assertIsNone(peptide.fragment_ions)
def test_fragment_invalidation(self): peptide = Peptide('AAA', 2, []) peptide.fragment() self.assertIsNotNone(peptide.fragment_ions) peptide.seq = 'AA' self.assertIsNone(peptide.fragment_ions)
def test_basic_numpy(self): peptide = Peptide('AAA', np.int32(2), []) ions = peptide.fragment() self.assertIsNotNone(ions)