Skip to content

Commit f45a7d0

Browse files
committed
Change error to warning for isotope reading challenges
1 parent 6851bc6 commit f45a7d0

1 file changed

Lines changed: 27 additions & 22 deletions

File tree

corems/mass_spectrum/input/massList.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def add_molecular_formula(self, mass_spec_obj, dataframe):
106106
mass_spec_mz_exp_list = mass_spec_obj.mz_exp
107107

108108
for df_index, mz_exp in enumerate(mz_exp_df):
109+
bad_mf = False
109110
counts = 0
110111

111112
ms_peak_index = list(mass_spec_mz_exp_list).index(float(mz_exp))
@@ -200,28 +201,32 @@ def add_molecular_formula(self, mass_spec_obj, dataframe):
200201
matched_isos.append(iso)
201202

202203
if len(matched_isos) == 0:
203-
raise ValueError("No isotopologue matched the formula_dict")
204-
mfobj = matched_isos[0]
205-
206-
# Add the mono isotopic index, confidence score and isotopologue similarity
207-
mfobj.mspeak_index_mono_isotopic = int(
208-
dataframe.iloc[df_index]["Mono Isotopic Index"]
209-
)
210-
211-
# Add the confidence score and isotopologue similarity and average MZ error score
212-
if "m/z Error Score" in dataframe:
213-
mfobj._mass_error_average_score = float(
214-
dataframe.iloc[df_index]["m/z Error Score"]
215-
)
216-
if "Confidence Score" in dataframe:
217-
mfobj._confidence_score = float(
218-
dataframe.iloc[df_index]["Confidence Score"]
219-
)
220-
if "Isotopologue Similarity" in dataframe:
221-
mfobj._isotopologue_similarity = float(
222-
dataframe.iloc[df_index]["Isotopologue Similarity"]
223-
)
224-
mass_spec_obj[ms_peak_index].add_molecular_formula(mfobj)
204+
#FIXME: This should not occur see https://code.emsl.pnl.gov/mass-spectrometry/corems/-/issues/190
205+
warnings.warn(f"No isotopologue matched the formula_dict: {formula_dict}")
206+
bad_mf = True
207+
else:
208+
bad_mf = False
209+
mfobj = matched_isos[0]
210+
211+
# Add the mono isotopic index, confidence score and isotopologue similarity
212+
mfobj.mspeak_index_mono_isotopic = int(
213+
dataframe.iloc[df_index]["Mono Isotopic Index"]
214+
)
215+
if not bad_mf:
216+
# Add the confidence score and isotopologue similarity and average MZ error score
217+
if "m/z Error Score" in dataframe:
218+
mfobj._mass_error_average_score = float(
219+
dataframe.iloc[df_index]["m/z Error Score"]
220+
)
221+
if "Confidence Score" in dataframe:
222+
mfobj._confidence_score = float(
223+
dataframe.iloc[df_index]["Confidence Score"]
224+
)
225+
if "Isotopologue Similarity" in dataframe:
226+
mfobj._isotopologue_similarity = float(
227+
dataframe.iloc[df_index]["Isotopologue Similarity"]
228+
)
229+
mass_spec_obj[ms_peak_index].add_molecular_formula(mfobj)
225230

226231

227232
class ReadMassList(MassListBaseClass):

0 commit comments

Comments
 (0)