def test_getAssignedPeptidesMZandRTvalue(self): expectedResult = {'rt': '751.5624', 'protAccession': 'IPI00110850', 'mz': '462.240142822266'} mascot = parseMascot.Reader(testFolder+'test_mascot.xml') # make a read instance for result in mascot.getAssignedPeptidesMZandRTvalue(): actualResult = result self.assertDictEqual(expectedResult, actualResult)
def test_getAllElements(self): expectedElementcount = 108 mascot = parseMascot.Reader(testFolder+'test_mascot.xml') # make a Reader instance allElements = mascot.getAllElements() actualElementCount = 0 for element in allElements: actualElementCount += 1 self.assertEqual(expectedElementcount, actualElementCount)
def test_getAssignedPeptidesMZandRTvalue(self): expectedResult = {'mz': '335.222412109375','pep_calc_mr': '668.3534', 'pep_delta': '0.0769','pep_exp_mr': '668.4303','pep_exp_mz': '335.2224'\ ,'pep_exp_z': '2','pep_expect': '4e+02','pep_miss': '0','pep_num_match': None,'pep_scan_title': '335.222412109375_2270.0684'\ ,'pep_score': '12.72','pep_seq': 'FLDFK','pep_var_mod': None,'pep_var_mod_pos': None,'rt': '2270.0684'} mascot = parseMascot.Reader(testFolder+'test_mascot.xml') # make a read instance for result in mascot.getUnassignedPeptidesMZandRTvalue(): actualResult = result self.assertDictEqual(expectedResult, actualResult)
def test_fillMascot(self): expectedPeptideNumResult = 2 expectedPeptideResult = [(1,462.24009999999998,922.46569999999997, 2,923.45010000000002,-0.98440000000000005,1,20.309999999999999,75.0\ ,u'K',u'CDVDIRK',u'D',u'Label:13C(6)15N(2) (K); Label:13C(6)15N(4) (R)',u'0.0000065.0',None,u'462.240142822266_751.5624'\ ,3),(2,335.22239999999999,668.43029999999999,2,668.35339999999997,0.076899999999999996,0,12.720000000000001,400.0\ , None,u'FLDFK',None,None,None,None,u'335.222412109375_2270.0684',4)] expectedProtNumResult = 2 expectedProtResult = [(1, 462.24009999999998, 922.46569999999997, 2, 923.45010000000002, -0.98440000000000005, 1, 20.309999999999999, 75.0, u'K'\ , u'CDVDIRK', u'D', u'Label:13C(6)15N(2) (K); Label:13C(6)15N(4) (R)', u'0.0000065.0', None, u'462.240142822266_751.5624', 3) ,(2, 335.22239999999999, 668.43029999999999, 2, 668.35339999999997, 0.076899999999999996, 0, 12.720000000000001, 400.0, None\ , u'FLDFK', None, None, None, None, u'335.222412109375_2270.0684', 4)] mzMLinstance = pymzml.run.Reader( testFolder + 'mzml_test_file_1.mzML', 'MS:1000527') # make a Reader instance mascot = parseMascot.Reader(testFolder + 'test_mascot.xml') with database.ConnectSqlite(testDatabasePath + 'test_pyMSA_database.db') as sqlCon: fd = database.FillDatabase(sqlCon, 'test') fd.fillMsrun(testFolder + 'mzml_test_file_1.mzML') fd.fillSpectrum(mzMLinstance) fd.fillMascot(mascot) actualPeptideResult = [] self.cursor.execute("SELECT * FROM `MASCOT_peptide`") for result in self.cursor.fetchall(): actualPeptideResult.append(result) actualProteinResult = [] self.cursor.execute("SELECT * FROM `MASCOT_protein`") for result in self.cursor.fetchall(): actualProteinResult.append(result) self.assertEqual(expectedPeptideNumResult, len(actualPeptideResult)) self.assertListEqual(expectedPeptideResult, actualPeptideResult) self.assertEqual(expectedProtNumResult, len(actualPeptideResult)) self.assertListEqual(expectedProtResult, actualPeptideResult)
def test_fillMascotException(self): mascot = parseMascot.Reader(testFolder + 'test_mascot.xml') with database.ConnectSqlite(testDatabasePath + 'test_pyMSA_database.db') as sqlCon: fd = database.FillDatabase(sqlCon) self.assertRaises(RuntimeError, fd.fillMascot, mascot)
def test_Reader(self): expectedDict = {} actualDict = {} mascot = parseMascot.Reader(testFolder+'test_mascot.xml') # make a Reader instance