comparison GCMS/combine_output.py @ 14:346ff9ad8c7a

fix for rankfilter, removed pfd read functional
author linda.bakker@wur.nl <linda.bakker@wur.nl>
date Fri, 20 Mar 2015 17:10:04 +0100
parents 4393f982d18f
children fe4682eb938c
comparison
equal deleted inserted replaced
13:5a753524e525 14:346ff9ad8c7a
79 @param caslookup: matching record (dictionary) of one compound in the CasLookup output 79 @param caslookup: matching record (dictionary) of one compound in the CasLookup output
80 ''' 80 '''
81 # The ID in the RankFilter output contains the following 5 fields: 81 # The ID in the RankFilter output contains the following 5 fields:
82 rf_id = rankfilter['ID'].split('-') 82 rf_id = rankfilter['ID'].split('-')
83 try: 83 try:
84 name, formula = _remove_formula(rankfilter['Name'])
85 hit = [rf_id[0], # Centrotype 84 hit = [rf_id[0], # Centrotype
86 rf_id[1], # cent.Factor 85 rf_id[1], # cent.Factor
87 rf_id[2], # scan nr 86 rf_id[2], # scan nr
88 rf_id[3], # R.T. (umin) 87 rf_id[3], # R.T. (umin)
89 rf_id[4], # nr. Peaks 88 rf_id[4], # nr. Peaks
90 # Appending other fields 89 # Appending other fields
91 rankfilter['R.T.'], 90 rankfilter['R.T.'],
92 name, 91 rankfilter['Name'],
93 caslookup['FORMULA'] if not formula else formula, 92 rankfilter['Formula'],
94 rankfilter['Library'].strip(), 93 rankfilter['Library'].strip(),
95 rankfilter['CAS'].strip(), 94 rankfilter['CAS'].strip(),
96 rankfilter['Forward'], 95 rankfilter['Forward'],
97 rankfilter['Reverse'], 96 rankfilter['Reverse'],
98 ((float(rankfilter['Forward']) + float(rankfilter['Reverse'])) / 2), 97 ((float(rankfilter['Forward']) + float(rankfilter['Reverse'])) / 2),
118 raise error 117 raise error
119 118
120 return hit 119 return hit
121 120
122 121
123 def _remove_formula(name): 122
124 '''
125 The RankFilter Name field often contains the Formula as well, this function removes it from the Name
126 @param name: complete name of the compound from the RankFilter output
127 '''
128 name = name.split()
129 poss_formula = name[-1]
130 match = re.match("^(([A-Z][a-z]{0,2})(\d*))+$", poss_formula)
131 if match:
132 return ' '.join(name[:-1]), poss_formula
133 else:
134 return ' '.join(name), False
135 123
136 124
137 def _get_default_caslookup(): 125 def _get_default_caslookup():
138 ''' 126 '''
139 The Cas Lookup tool might not have found all compounds in the library searched, 127 The Cas Lookup tool might not have found all compounds in the library searched,