def fail_test(self): cc = pyqms.ChemicalComposition() failing_sequence_list = ['#Oxidation_w/o_pos', '#Oxidation_with_pos:1'] for failing_sequence in failing_sequence_list: with self.assertRaises(SystemExit) as system_exit_check: cc._parse_sequence_unimod_style(failing_sequence) self.assertEqual(system_exit_check.exception.code, 1) cc.clear() cc._parse_sequence_unimod_style('#;') assert len(cc.keys()) == 0 return
def check_unimod_pep_input(test_dict): if 'aa_compositions' not in test_dict.keys(): test_dict['aa_compositions'] = pyqms.knowledge_base.aa_compositions cc = pyqms.ChemicalComposition( test_dict['input'], aa_compositions=test_dict['aa_compositions']) print('hill:', cc.hill_notation_unimod()) print(cc.composition_of_aa_at_pos) print(cc.composition_of_mod_at_pos) assert cc.hill_notation_unimod() == test_dict['output'] if 'mod_pos_info' in test_dict.keys(): for mod_dict in test_dict['mod_pos_info']: cc_mods = cc.composition_of_mod_at_pos.get(mod_dict['pos'], None) assert cc_mods == mod_dict['cc_mods'] if 'aa_pos_info' in test_dict.keys(): for aa_dict in test_dict['aa_pos_info']: cc_aa = cc.composition_of_aa_at_pos.get(aa_dict['pos'], None) assert cc_aa == aa_dict['cc_mods']
def check_unimod_pep_input(test_dict): if "aa_compositions" not in test_dict.keys(): test_dict["aa_compositions"] = pyqms.knowledge_base.aa_compositions cc = pyqms.ChemicalComposition( test_dict["input"], aa_compositions=test_dict["aa_compositions"]) print("hill:", cc.hill_notation_unimod()) print(cc.composition_of_aa_at_pos) print(cc.composition_of_mod_at_pos) assert cc.hill_notation_unimod() == test_dict["output"] if "mod_pos_info" in test_dict.keys(): for mod_dict in test_dict["mod_pos_info"]: cc_mods = cc.composition_of_mod_at_pos.get(mod_dict["pos"], None) assert cc_mods == mod_dict["cc_mods"] if "aa_pos_info" in test_dict.keys(): for aa_dict in test_dict["aa_pos_info"]: cc_aa = cc.composition_of_aa_at_pos.get(aa_dict["pos"], None) assert cc_aa == aa_dict["cc_mods"]
def setUp(self): self.lib = pyqms.ChemicalComposition() self.water1 = pyqms.ChemicalComposition('+H2O') self.water_unimod_style_chemical_formula = pyqms.ChemicalComposition( '+H(2)16O(1)')
def generate_cc_test(self): cc = pyqms.ChemicalComposition('+H2O') cc_returned = cc.generate_cc_dict() assert len(cc_returned.keys()) == 2 return
def test__mass_with_cc_even_though_you_should_not_use_it(self): cc = pyqms.ChemicalComposition('+H2O') self.assertAlmostEqual(cc._mass(cc=cc), 18.0105646844)
def test_clear_removes_everything(self): cc = pyqms.ChemicalComposition('KLEINERTEST') cc.clear() self.assertEqual(str(cc), '')
def test_add_chemical_formulas(self): water1 = pyqms.ChemicalComposition('+H2O') water2 = pyqms.ChemicalComposition('+H2O') two_waters = water1 + water2 self.assertEqual(two_waters.hill_notation(), 'H4O2')
def check_hill_notation(aa, chemformula): cc = pyqms.ChemicalComposition(aa) cc.subtract_chemical_formula('H2O') print(aa, chemformula) print(cc) assert cc.hill_notation() == chemformula
def test__mass_with_heavy_isotopes_TMT6Plex_example(self): cc = pyqms.ChemicalComposition('#TMT6plex:0') self.assertAlmostEqual(cc._mass(cc=cc), 229.162932, 6)