def test_progenesis(self): ## SONAR MSE compound_to_scan_mapping = progenesis_formatter.convert_to_feature_csv("./reference_input_file_for_formatter/Progenesis/SONAR_20_Yeast_Peaks.txt", \ "./progenesis_MSE_output.csv") self.assertTrue(filecmp.cmp("./progenesis_MSE_output.csv", "./reference_input_file_for_formatter/Progenesis/SONAR_20_Yeast_Peaks_output.csv", shallow=False)) progenesis_formatter.convert_mgf("./reference_input_file_for_formatter/Progenesis/SONAR_20_Yeast_MSMS.msp", "SONAR_20_Yeast_MSMS.mgf", compound_to_scan_mapping) self.assertTrue(filecmp.cmp("./SONAR_20_Yeast_MSMS.mgf", "./reference_input_file_for_formatter/Progenesis/SONAR_20_Yeast_MSMS.mgf", shallow=False)) ## CATECHIN MSE compound_to_scan_mapping = progenesis_formatter.convert_to_feature_csv("./reference_input_file_for_formatter/Progenesis/Neg_MSE_Catechin.txt", "./Neg_MSE_Catechin_output.csv") self.assertTrue(filecmp.cmp("./Neg_MSE_Catechin_output.csv", "./reference_input_file_for_formatter/Progenesis/Neg_MSE_Catechin_output.csv", shallow=False)) progenesis_formatter.convert_mgf("./reference_input_file_for_formatter/Progenesis/Neg_MSE_Catechin.msp", "Neg_MSE_Catechin.mgf", compound_to_scan_mapping) self.assertTrue(filecmp.cmp("./Neg_MSE_Catechin.mgf", "./reference_input_file_for_formatter/Progenesis/Neg_MSE_Catechin.mgf", shallow=False)) ## IMS compound_to_scan_mapping = progenesis_formatter.convert_to_feature_csv("./reference_input_file_for_formatter/Progenesis/161118_pos_IMS.txt", \ "./progenesis_IMS_output.csv") self.assertTrue(filecmp.cmp("./progenesis_IMS_output.csv", "./reference_input_file_for_formatter/Progenesis/161118_pos_IMS_output.csv", shallow=False)) progenesis_formatter.convert_mgf("./reference_input_file_for_formatter/Progenesis/161118_pos_IMS.msp", "161118_pos_IMS.mgf", compound_to_scan_mapping) self.assertTrue(filecmp.cmp("./161118_pos_IMS.mgf", "./reference_input_file_for_formatter/Progenesis/161118_pos_IMS.mgf", shallow=False)) #More input compound_to_scan_mapping = progenesis_formatter.convert_to_feature_csv("./reference_input_file_for_formatter/Progenesis/202005_IMS_w_tags.txt", \ "./progenesis_IMS_output.csv") self.assertTrue(filecmp.cmp("./progenesis_IMS_output.csv", "./reference_input_file_for_formatter/Progenesis/202005_IMS_w_tags_output.csv", shallow=False)) progenesis_formatter.convert_mgf("./reference_input_file_for_formatter/Progenesis/202005_IMS_w_tags.msp", "202005_IMS_w_tags.mgf", compound_to_scan_mapping) self.assertTrue(filecmp.cmp("./202005_IMS_w_tags.mgf", "./reference_input_file_for_formatter/Progenesis/202005_IMS_w_tags.mgf", shallow=False))
def main(): parser = argparse.ArgumentParser(description='Create parallel parameters') parser.add_argument('toolname', help='name of input tool') parser.add_argument('quantification_table', help='quantification_table') parser.add_argument('quantification_table_reformatted', help='quantification_table_reformatted') parser.add_argument('input_mgf', help='input_mgf') parser.add_argument('output_mgf', help='output_mgf') args = parser.parse_args() if args.toolname == "MZMINE2": print("MZMINE2") shutil.copyfile(args.input_mgf, args.output_mgf) mzmine2_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "OPENMS": print("OPENMS") shutil.copyfile(args.input_mgf, args.output_mgf) openms_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "OPTIMUS": print("OPTIMUS") shutil.copyfile(args.input_mgf, args.output_mgf) optimus_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "MSDIAL": print("MSDIAL") shutil.copyfile(args.input_mgf, args.output_mgf) msdial_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "METABOSCAPE": print("METABOSCAPE") shutil.copyfile(args.input_mgf, args.output_mgf) metaboscape_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "XCMS3": print("XCMS3") shutil.copyfile(args.input_mgf, args.output_mgf) xcms_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "PROGENESIS": print("PROGENESIS") compound_scan_mapping = progenesis_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) progenesis_formatter.convert_mgf(args.input_mgf, args.output_mgf, compound_scan_mapping)
def test_progenesis(self): progenesis_formatter.convert_to_feature_csv("./reference_input_file_for_formatter/Progensis_MSE/SONAR_20_Yeast_Peaks.csv", \ "./progenesis_output.csv")
def main(): parser = argparse.ArgumentParser(description='Create parallel parameters') parser.add_argument('toolname', help='name of input tool') parser.add_argument('quantification_table', help='quantification_table') parser.add_argument('quantification_table_reformatted', help='quantification_table_reformatted') parser.add_argument('input_spectra_folder', help='input_spectra_folder') parser.add_argument('output_mgf', help='output_mgf') parser.add_argument('workflowParameters', help='workflowParameters') args = parser.parse_args() input_filenames = glob.glob(os.path.join(args.input_spectra_folder, "*")) if args.toolname == "MZMINE2": print("MZMINE2") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) mzmine2_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "OPENMS": print("OPENMS") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) openms_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "OPTIMUS": print("OPTIMUS") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) optimus_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "MSDIAL": print("MSDIAL") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) msdial_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "METABOSCAPE": print("METABOSCAPE") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) metaboscape_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "XCMS3": print("XCMS3") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) xcms_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "PROGENESIS": print("PROGENESIS") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] compound_scan_mapping = progenesis_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) progenesis_formatter.convert_mgf(input_mgf, args.output_mgf, compound_scan_mapping) elif args.toolname == "MZTABM": print("MZTABM") workflow_parameters = proteosafe.parse_xml_file( args.workflowParameters) mangled_mapping = proteosafe.get_mangled_file_mapping( workflow_parameters) name_mangle_mapping = {} for key in mangled_mapping: demangled_name = mangled_mapping[key] name_mangle_mapping[os.path.basename( demangled_name)] = os.path.join(args.input_spectra_folder, key) compound_filename_mapping = mztabm_formatter.convert_to_feature_csv( args.quantification_table, args.quantification_table_reformatted) mztabm_formatter.create_mgf(input_filenames, args.output_mgf, compound_filename_mapping, name_mangle_mapping=name_mangle_mapping)
def main(): parser = argparse.ArgumentParser(description='Create parallel parameters') parser.add_argument('toolname', help='name of input tool') parser.add_argument('quantification_table', help='quantification_table') parser.add_argument('quantification_table_reformatted', help='quantification_table_reformatted') parser.add_argument('input_spectra_folder', help='input_spectra_folder') parser.add_argument('output_mgf', help='output_mgf') parser.add_argument('workflowParameters', help='workflowParameters') parser.add_argument('--QUANT_FILE_NORM', default="None", help='QUANT_FILE_NORM') args = parser.parse_args() input_filenames = glob.glob(os.path.join(args.input_spectra_folder, "*")) if args.toolname == "MZMINE2": print("MZMINE2") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) mzmine2_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "OPENMS": print("OPENMS") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) openms_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "OPTIMUS": print("OPTIMUS") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) optimus_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "MSDIAL": print("MSDIAL") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) msdial_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "METABOSCAPE": print("METABOSCAPE") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) metaboscape_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "XCMS3": print("XCMS3") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] shutil.copyfile(input_mgf, args.output_mgf) xcms_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted) elif args.toolname == "PROGENESIS": print("PROGENESIS") if len(input_filenames) != 1: print("Must input exactly 1 spectrum mgf file") exit(1) input_mgf = input_filenames[0] compound_scan_mapping = progenesis_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted) progenesis_formatter.convert_mgf(input_mgf, args.output_mgf, compound_scan_mapping) elif args.toolname == "MZTABM": print("MZTABM") workflow_parameters = proteosafe.parse_xml_file(args.workflowParameters) mangled_mapping = proteosafe.get_mangled_file_mapping(workflow_parameters) name_mangle_mapping = {} for key in mangled_mapping: demangled_name = mangled_mapping[key] name_mangle_mapping[os.path.basename(demangled_name)] = os.path.join(args.input_spectra_folder, key) compound_filename_mapping = mztabm_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted) mztabm_formatter.create_mgf(input_filenames, args.output_mgf, compound_filename_mapping, name_mangle_mapping=name_mangle_mapping) # Finally, we can renormlize the output try: if args.QUANT_FILE_NORM == "RowSum": import pandas as pd quant_df = pd.read_csv(args.quantification_table_reformatted, sep=",") quant_df = quant_df.loc[:, ~quant_df.columns.str.contains('^Unnamed')] for column in quant_df: if "Peak area" in column: quant_df[column] = quant_df[column] / sum(quant_df[column]) * 1000000 quant_df.to_csv(args.quantification_table_reformatted, sep=",", index=False) except: pass