Skip to content

Commit

Permalink
subformula explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipbear committed Sep 11, 2024
1 parent 0605151 commit 0ebad05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/create_library/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create_library(compound_df, feature_df,
if df is None or df.empty:
return None, None

if filter_library:
if filter_library and ms2_explanation_cutoff > 0:
# Filter the merged dataframe
df = filter_df(df, ion_mode, ms2_explanation_cutoff=ms2_explanation_cutoff)

Expand Down
5 changes: 5 additions & 0 deletions bin/create_library/ms2_explanation_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def filter_by_ms2_explanation(row, explanation_cutoff=0.60):
precursor_formula=row['neutralized_formula'],
adduct=row['t_adduct'],
ms2_tol=0.01, ppm=False)

if subformla_list is None: # formula elements outside common elements
row['ms2_explained_intensity'] = 1.0
return row

for subformula in subformla_list:
explained_intensity += row['MS2'][:, 1][subformula.idx] if subformula.subform_list else 0.0
row['ms2_explained_intensity'] = explained_intensity / row['MS2'][:, 1].sum()
Expand Down

0 comments on commit 0ebad05

Please sign in to comment.