def parse_config(config_filename): # Save config values to dictionary config_dict = {} # initialize dictionay # Call Yinfeng's parseconfig.py module check_file_exist(config_filename) # Save all config values to dictionary all_config_dict = parseconfig.parseConfigKeyValues(config_filename) (modification_dict, element_modification_list_dict ) = parseconfig.getModificationDictionary(all_config_dict) # valiables were defined in global # pep_iden_str = '[Protein_Identification]' # cleave_after_str = 'Decoy_Prefix' # cleave_before_str = 'FDR_Filtering' # FDR_threshold_str = 'FDR_Threshold' # only save protein_identification config info to config_dict for key, value in all_config_dict.items(): if key == (pep_iden_str + search_name_str): config_dict[search_name_str] = value elif key == (pep_iden_str + FASTA_Database_str): config_dict[FASTA_Database_str] = value elif key == (pep_iden_str + Maximum_Missed_Cleavages_str): config_dict[Maximum_Missed_Cleavages_str] = value elif key == (pep_iden_str + Cleave_After_Residues_str): config_dict[Cleave_After_Residues_str] = value else: continue # return config dictionary return (config_dict, modification_dict, element_modification_list_dict, all_config_dict)
def parse_config(config_filename): # Save config values to dictionary config_dict = {} # initialize dictionay # Call Yinfeng's parseconfig.py module check_file_exist(config_filename) # Save all config values to dictionary all_config_dict = parseconfig.parseConfigKeyValues(config_filename) # valiables were defined in global # pep_iden_str = '[Protein_Identification]' # cleave_after_str = 'Decoy_Prefix' # cleave_before_str = 'FDR_Filtering' # FDR_threshold_str = 'FDR_Threshold' # only save protein_identification config info to config_dict for key, value in all_config_dict.items(): if key == (pep_iden_str + cleave_after_str): config_dict[cleave_after_str] = value elif key == (pep_iden_str + cleave_before_str): config_dict[cleave_before_str] = value elif key == (pro_iden_str + decoy_prefix_str): config_dict[decoy_prefix_str] = value else: continue # return config dictionary return config_dict
def parse_config(config_filename): # Save config values to dictionary config_dict = {} # initialize dictionay # Call Yinfeng's parseconfig.py module check_file_exist(config_filename) # Save all config values to dictionary all_config_dict = parseconfig.parseConfigKeyValues(config_filename) (modification_dict, element_modification_list_dict) = parseconfig.getModificationDictionary(all_config_dict) # valiables were defined in global # pep_iden_str = '[Protein_Identification]' # cleave_after_str = 'Decoy_Prefix' # cleave_before_str = 'FDR_Filtering' # FDR_threshold_str = 'FDR_Threshold' # only save protein_identification config info to config_dict for key, value in all_config_dict.items(): if key == (pep_iden_str + search_name_str): config_dict[search_name_str] = value elif key == (pep_iden_str + FASTA_Database_str): config_dict[FASTA_Database_str] = value elif key == (pep_iden_str + Maximum_Missed_Cleavages_str): config_dict[Maximum_Missed_Cleavages_str] = value elif key == (pep_iden_str + Cleave_After_Residues_str): config_dict[Cleave_After_Residues_str] = value else: continue # return config dictionary return (config_dict, modification_dict, element_modification_list_dict, all_config_dict)
def main(argv=None): # try to get arguments and error handling if argv is None: argv = sys.argv # parse options [config_filename, psm_filename, FT2_filename_list] = parse_options(argv) wholeDict = parseconfig.parseConfigKeyValues(config_filename) #sDecoy_Prefix = wholeDict.get("[Protein_Identification]Decoy_Prefix") sIdentification_HCD = wholeDict.get("[Isobaric_Chemical_Labeling]Identification_Scan{HCD}") if ("[Isobaric_Chemical_Labeling]Identification_Scan{CID}" in wholeDict) : sIdentification_CID = wholeDict.get("[Isobaric_Chemical_Labeling]Identification_Scan{CID}") sIdentification_CID = "" sMass_Tolerance_Reporter_Ions = wholeDict.get("[Isobaric_Chemical_Labeling]Mass_Tolerance_Reporter_Ions") sReporter_Ion_Key_dict = parseconfig.getConfigMasterKeyValue ("[Isobaric_Chemical_Labeling]Reporter_Ion", wholeDict) sIsotopic_Impurity_Correction = wholeDict.get("[Isobaric_Chemical_Labeling]Isotopic_Impurity_Correction") sReporter_Ion_Isotopic_Impurity_Distribution_Key_dict = {} if (sIsotopic_Impurity_Correction == "True") : sReporter_Ion_Isotopic_Impurity_Distribution_Key_dict = parseconfig.getConfigMasterKeyValue ("[Isobaric_Chemical_Labeling]Reporter_Ion_Isotopic_Impurity_Distribution", wholeDict) # print sReporter_Ion_Isotopic_Impurity_Distribution_Key_dict sTotal_Intensity_Normalization = wholeDict.get("[Isobaric_Chemical_Labeling]Total_Intensity_Normalization") sOnly_Use_Unique_Peptides = wholeDict.get("[Isobaric_Chemical_Labeling]Only_Use_Unique_Peptides") sPeptide_Modification_Symbol = wholeDict.get("[Isobaric_Chemical_Labeling]Peptide_Modification_Symbol") if (sPeptide_Modification_Symbol == "None") : sPeptide_Modification_Symbol = "" [All_FT2Scans_dict, Reporter_Ion_Key_list] = ReadAllFT2Files(FT2_filename_list, sIdentification_HCD, sIdentification_CID, sMass_Tolerance_Reporter_Ions, sReporter_Ion_Key_dict) Reporter_Ion_list = OrganizeReporterIon(Reporter_Ion_Key_list, sReporter_Ion_Key_dict) if (sIsotopic_Impurity_Correction == "True") : IsotopicImpurityCorrect(All_FT2Scans_dict, Reporter_Ion_list, sReporter_Ion_Isotopic_Impurity_Distribution_Key_dict) HandlePsmFile(psm_filename, All_FT2Scans_dict, Reporter_Ion_list, sTotal_Intensity_Normalization, sPeptide_Modification_Symbol)
def parse_config(config_filename): # Save all config values to dictionary all_config_dict = {} # initialize dictionay # Save config values to dictionary config_dict = {} # initialize dictionay # Call Yinfeng's parseconfig.py module check_file_exist(config_filename) all_config_dict = parseconfig.parseConfigKeyValues(config_filename) return all_config_dict
def main(argv=None): # try to get arguments and error handling if argv is None: argv = sys.argv # parse options [config_filename, psm_filename, FT2_filename_list] = parse_options(argv) wholeDict = parseconfig.parseConfigKeyValues(config_filename) #sDecoy_Prefix = wholeDict.get("[Protein_Identification]Decoy_Prefix") sIdentification_HCD = wholeDict.get( "[Isobaric_Chemical_Labeling]Identification_Scan{HCD}") if ("[Isobaric_Chemical_Labeling]Identification_Scan{CID}" in wholeDict): sIdentification_CID = wholeDict.get( "[Isobaric_Chemical_Labeling]Identification_Scan{CID}") sIdentification_CID = "" sMass_Tolerance_Reporter_Ions = wholeDict.get( "[Isobaric_Chemical_Labeling]Mass_Tolerance_Reporter_Ions") sReporter_Ion_Key_dict = parseconfig.getConfigMasterKeyValue( "[Isobaric_Chemical_Labeling]Reporter_Ion", wholeDict) sIsotopic_Impurity_Correction = wholeDict.get( "[Isobaric_Chemical_Labeling]Isotopic_Impurity_Correction") sReporter_Ion_Isotopic_Impurity_Distribution_Key_dict = {} if (sIsotopic_Impurity_Correction == "True"): sReporter_Ion_Isotopic_Impurity_Distribution_Key_dict = parseconfig.getConfigMasterKeyValue( "[Isobaric_Chemical_Labeling]Reporter_Ion_Isotopic_Impurity_Distribution", wholeDict) # print sReporter_Ion_Isotopic_Impurity_Distribution_Key_dict sTotal_Intensity_Normalization = wholeDict.get( "[Isobaric_Chemical_Labeling]Total_Intensity_Normalization") sOnly_Use_Unique_Peptides = wholeDict.get( "[Isobaric_Chemical_Labeling]Only_Use_Unique_Peptides") sPeptide_Modification_Symbol = wholeDict.get( "[Isobaric_Chemical_Labeling]Peptide_Modification_Symbol") if (sPeptide_Modification_Symbol == "None"): sPeptide_Modification_Symbol = "" [All_FT2Scans_dict, Reporter_Ion_Key_list ] = ReadAllFT2Files(FT2_filename_list, sIdentification_HCD, sIdentification_CID, sMass_Tolerance_Reporter_Ions, sReporter_Ion_Key_dict) Reporter_Ion_list = OrganizeReporterIon(Reporter_Ion_Key_list, sReporter_Ion_Key_dict) if (sIsotopic_Impurity_Correction == "True"): IsotopicImpurityCorrect( All_FT2Scans_dict, Reporter_Ion_list, sReporter_Ion_Isotopic_Impurity_Distribution_Key_dict) HandlePsmFile(psm_filename, All_FT2Scans_dict, Reporter_Ion_list, sTotal_Intensity_Normalization, sPeptide_Modification_Symbol)
def main(argv=None): # try to get arguments and error handling if argv is None: argv = sys.argv # parse options [config_filename, psm_filename, pro2psm_filename] = parse_options(argv) wholeDict = parseconfig.parseConfigKeyValues(config_filename) sOnly_Use_Unique_Peptides = wholeDict.get("[Isobaric_Chemical_Labeling]Only_Use_Unique_Peptides") sReporter_Ion_Key_dict = parseconfig.getConfigMasterKeyValue ("[Isobaric_Chemical_Labeling]Reporter_Ion", wholeDict) sPeptide_Modification_Symbol = wholeDict.get("[Isobaric_Chemical_Labeling]Peptide_Modification_Symbol") [ScansInfo_dict, sReporter_Ion_Names_list] = ReadPsmFile(psm_filename, len(sReporter_Ion_Key_dict)) HandlePro2psmFile(pro2psm_filename, ScansInfo_dict, sReporter_Ion_Names_list, sOnly_Use_Unique_Peptides, sPeptide_Modification_Symbol)
def main(argv=None): # try to get arguments and error handling if argv is None: argv = sys.argv (working_dir, config_filename) = parse_options(argv) wholeDict = parseconfig.parseConfigKeyValues( config_filename) sMaxEnrichmentLevel = wholeDict.get("[Stable_Isotope_Probing]Maximum_Enrichment_Level") sMinEnrichmentLevel = wholeDict.get("[Stable_Isotope_Probing]Minimum_Enrichment_Level") sEnrichmentLevelIncrement = wholeDict.get("[Stable_Isotope_Probing]Enrichment_Level_Increment") if ((sMaxEnrichmentLevel == None) or (sMinEnrichmentLevel == None) or (sEnrichmentLevelIncrement == None)) : print "Enrichment level information is incomplete." sys.exit(0) dMaxEnrichmentLevel = float(sMaxEnrichmentLevel[0:-1])/100 dMinEnrichmentLevel = float(sMinEnrichmentLevel[0:-1])/100 dEnrichmentLevelIncrement = float(sEnrichmentLevelIncrement[0:-1])/100 #print dMaxEnrichmentLevel, dMinEnrichmentLevel, dEnrichmentLevelIncrement sSIPElement = wholeDict.get("[Stable_Isotope_Probing]SIP_Element") sSIPElementIsotope = wholeDict.get("[Stable_Isotope_Probing]SIP_Element_Isotope") if ((sSIPElement == None) or (sSIPElementIsotope == None)) : print "SIP information is incomplete." sys.exit(0) iSIPElementIsotope = int(sSIPElementIsotope) #print sSIPElement, iSIPElementIsotope sElementMasses = wholeDict.get("[Peptide_Identification]Element_Masses{"+sSIPElement+"}") sElementPercent = wholeDict.get("[Peptide_Identification]Element_Percent{"+sSIPElement+"}") if ((sElementMasses == None) or (sElementPercent == None)) : print "[Peptide_Identification]Element {"+sSIPElement+"}" + "is not available" sys.exit(0) sElementMasses = sElementMasses.strip(",") sElementPercent = sElementPercent.strip(",") lsElementMasses = sElementMasses.split(",") lsElementPercent = sElementPercent.split(",") if (len(lsElementMasses) != len(lsElementPercent)) or (len(lsElementMasses) == 1): print "The number of elements is wrong" sys.exit(0) ldElementPercent = [] iSipElementIndex = -1 for i in range(len(lsElementPercent)) : ldElementPercent.append(float(lsElementPercent[i])) if (int(round(float(lsElementMasses[i]))) == iSIPElementIsotope) : iSipElementIndex = i if (iSipElementIndex == -1) : print "can't find the target element parcent." sys.exit(0) if (iSipElementIndex == 0) :################################# print "The first element can't be the target." sys.exit(0) GenerateSipConfig(config_filename, working_dir, lsElementPercent, dMaxEnrichmentLevel, dMinEnrichmentLevel, dEnrichmentLevelIncrement, iSipElementIndex, sSIPElement, iSIPElementIsotope)
def main(argv=None): # try to get arguments and error handling if argv is None: argv = sys.argv # parse options (config_filename, psm_filename) = parse_options(argv) wholeDict = parseconfig.parseConfigKeyValues(config_filename) sClusteringThreshold = wholeDict.get("[Stable_Isotope_Probing]Clustering_Threshold") sMinPSMPerIsotopicCluster = wholeDict.get("[Stable_Isotope_Probing]Min_PSM_Per_Isotopic_Cluster") global dClusteringThreshold global iMinPSMPerIsotopicCluster dClusteringThreshold = float(sClusteringThreshold[:-1]) iMinPSMPerIsotopicCluster = int(sMinPSMPerIsotopicCluster) HandleFiles(psm_filename)
def main(argv=None): # try to get arguments and error handling if argv is None: argv = sys.argv # parse options (config_filename, psm_filename) = parse_options(argv) wholeDict = parseconfig.parseConfigKeyValues(config_filename) sClusteringThreshold = wholeDict.get( "[Stable_Isotope_Probing]Clustering_Threshold") sMinPSMPerIsotopicCluster = wholeDict.get( "[Stable_Isotope_Probing]Min_PSM_Per_Isotopic_Cluster") global dClusteringThreshold global iMinPSMPerIsotopicCluster dClusteringThreshold = float(sClusteringThreshold[:-1]) iMinPSMPerIsotopicCluster = int(sMinPSMPerIsotopicCluster) HandleFiles(psm_filename)
def parse_options(argv): opts, args = getopt.getopt(argv[1:], "hw:c:o:", [ "help", "working-dir", "config-file", "output-file", ]) # Default working dir and config file working_dir = "./" config_file = "SiprosConfig.cfg" outputFileName = "" # Basic options for option, value in opts: if option in ("-h", "--help"): print "-c configurefile -w workingdirectory -o outputfile" sys.exit(1) if option in ("-w", "--working-dir"): working_dir = value if working_dir[-1] != '/': working_dir = working_dir + '/' if option in ("-c", "--config-file"): config_file = value if option in ("-o", "--output-file"): outputFileName = value pro2pep_filename_list = get_file_list_with_ext(working_dir, ".pro2pep.txt") pro2pepFileName = pro2pep_filename_list[0] wholeDict = parseconfig.parseConfigKeyValues(config_file) databaseFileName = wholeDict.get("[Peptide_Identification]FASTA_Database") if (outputFileName == ""): (pro2pepFileNameRoot, pro2pepFileNameExt) = os.path.splitext(pro2pepFileName) # ext is txt expandFileName = pro2pepFileNameRoot + ".expand.txt" (pro2pepFileNameRoot, pro2pepFileNameExt) = os.path.splitext( pro2pepFileNameRoot) # ext is pro2pep outputFileName = pro2pepFileNameRoot + ".pro2ptm.txt" #print outputFileName return [databaseFileName, pro2pepFileName, outputFileName, expandFileName]
def parse_options(argv): opts, args = getopt.getopt(argv[1:], "hw:c:o:", ["help", "working-dir", "config-file", "output-file",]) # Default working dir and config file working_dir = "./" config_file = "SiprosConfig.cfg" outputFileName = "" # Basic options for option, value in opts: if option in ("-h", "--help"): print "-c configurefile -w workingdirectory -o outputfile" sys.exit(1) if option in ("-w", "--working-dir"): working_dir = value if working_dir[-1] != '/': working_dir = working_dir + '/' if option in ("-c", "--config-file"): config_file = value if option in ("-o", "--output-file"): outputFileName = value pro2pep_filename_list = get_file_list_with_ext(working_dir, ".pro2pep.txt") pro2pepFileName = pro2pep_filename_list[0] wholeDict = parseconfig.parseConfigKeyValues(config_file) databaseFileName = wholeDict.get("[Peptide_Identification]FASTA_Database") if (outputFileName == "") : (pro2pepFileNameRoot, pro2pepFileNameExt) = os.path.splitext(pro2pepFileName) # ext is txt expandFileName = pro2pepFileNameRoot + ".expand.txt" (pro2pepFileNameRoot, pro2pepFileNameExt) = os.path.splitext(pro2pepFileNameRoot) # ext is pro2pep outputFileName = pro2pepFileNameRoot + ".pro2ptm.txt" #print outputFileName return [databaseFileName, pro2pepFileName, outputFileName, expandFileName]
def main(argv=None): # try to get arguments and error handling if argv is None: argv = sys.argv # parse options [config_filename, psm_filename, pro2psm_filename] = parse_options(argv) wholeDict = parseconfig.parseConfigKeyValues(config_filename) sOnly_Use_Unique_Peptides = wholeDict.get( "[Isobaric_Chemical_Labeling]Only_Use_Unique_Peptides") sReporter_Ion_Key_dict = parseconfig.getConfigMasterKeyValue( "[Isobaric_Chemical_Labeling]Reporter_Ion", wholeDict) sPeptide_Modification_Symbol = wholeDict.get( "[Isobaric_Chemical_Labeling]Peptide_Modification_Symbol") [ScansInfo_dict, sReporter_Ion_Names_list] = ReadPsmFile(psm_filename, len(sReporter_Ion_Key_dict)) HandlePro2psmFile(pro2psm_filename, ScansInfo_dict, sReporter_Ion_Names_list, sOnly_Use_Unique_Peptides, sPeptide_Modification_Symbol)
def ReadConfigureFile(sConfigure_Filename) : #Read configure file #sConfigure_Filename : configure file name # return value # compound_filename : path of database file; iDefault_Polarity: default polarity, 1 positive, -1 negative; iDefault_Charge_State: default charge state; iParentMassWindow_list : parent mass window; dMass_Tolerance_Parent_Ion: max error allowed for the precursor mass; dMass_Tolerance_Fragment_Ions: max error allowed for the peaks; bBreakRing : whether break ring bonds; iFragmentation_Depth: max depth of depth-first search will reach in the fragmentation tree; process_number: number of processes will created for parallel handling compounds; bRankSum: not used in this version; iPositive_Ion_Fragment_Mass_Windows_list: peak mass window for positive mode; iNegative_Ion_Fragment_Mass_Windows_list: peak mass window for negative mode. wholeDict = parseconfig.parseConfigKeyValues(sConfigure_Filename) compound_filename = wholeDict.get("[Metabolite_Identification]Metabolite_Database") #sIonization_Mode = wholeDict.get("[Metabolite_Identification]Ionization_Mode") sDefault_Polarity = wholeDict.get("[Metabolite_Identification]Default_Polarity") iDefault_Charge_State = int(wholeDict.get("[Metabolite_Identification]Default_Charge_State")) sParent_Mass_Windows = wholeDict.get("[Metabolite_Identification]Parent_Mass_Windows") sPositive_Ion_Fragment_Mass_Windows = wholeDict.get("[Metabolite_Identification]Positive_Ion_Fragment_Mass_Windows") sNegative_Ion_Fragment_Mass_Windows = wholeDict.get("[Metabolite_Identification]Negative_Ion_Fragment_Mass_Windows") dMass_Tolerance_Parent_Ion = float( wholeDict.get("[Metabolite_Identification]Mass_Tolerance_Parent_Ion") ) dMass_Tolerance_Fragment_Ions = float(wholeDict.get("[Metabolite_Identification]Mass_Tolerance_Fragment_Ions")) sBreak_rings = wholeDict.get("[Metabolite_Identification]Break_rings") iFragmentation_Depth = int(wholeDict.get("[Metabolite_Identification]Fragmentation_Depth")) process_number = int(wholeDict.get("[Metabolite_Identification]Number_of_Processes")) bRankSum = False if (sDefault_Polarity == "positive") : iDefault_Polarity = 1 else: iDefault_Polarity = -1 iParentMassWindow_list = ReadWindowInfo(sParent_Mass_Windows) iPositive_Ion_Fragment_Mass_Windows_list = ReadWindowInfo(sPositive_Ion_Fragment_Mass_Windows) iNegative_Ion_Fragment_Mass_Windows_list = ReadWindowInfo(sNegative_Ion_Fragment_Mass_Windows) #print iParentMassWindow_list, iPositive_Ion_Fragment_Mass_Windows_list, iNegative_Ion_Fragment_Mass_Windows_list if ((sBreak_rings == "true") or (sBreak_rings == "True") or (sBreak_rings == "TRUE")): bBreakRing = True else : bBreakRing = False return [compound_filename, iDefault_Polarity, iDefault_Charge_State, iParentMassWindow_list, dMass_Tolerance_Parent_Ion, dMass_Tolerance_Fragment_Ions, bBreakRing, iFragmentation_Depth, process_number, bRankSum, iPositive_Ion_Fragment_Mass_Windows_list, iNegative_Ion_Fragment_Mass_Windows_list]