Skip to content

Commit 89d263b

Browse files
committed
Make spectra_out subject to filtering steps
1 parent 54ede64 commit 89d263b

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

CandyCrunch/prediction.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,6 @@ def finalise_predictions(df_out,get_missing,pred_thresh,mode,modification,mass_t
14291429
df_out = canonicalize_biosynthesis(df_out, pred_thresh)
14301430
except ValueError:
14311431
pass
1432-
spectra_out = df_out.pop('peak_d').values.tolist()
14331432
# Calculate ppm error
14341433
valid_indices, ppm_errors = [], []
14351434
df_out = df_out[df_out['predictions'].apply(len)>0]
@@ -1454,6 +1453,7 @@ def finalise_predictions(df_out,get_missing,pred_thresh,mode,modification,mass_t
14541453
df_out['rel_abundance'] = df_out['rel_abundance'] / df_out['rel_abundance'].sum() * 100
14551454
else:
14561455
df_out.drop(['rel_abundance'], axis = 1, inplace = True)
1456+
spectra_out = df_out.pop('peak_d').values.tolist()
14571457
df_out.index.name = "m/z"
14581458
if plot_glycans:
14591459
from glycowork.motif.draw import plot_glycans_excel
@@ -1582,7 +1582,6 @@ def wrap_inference(spectra_filepath, glycan_class, model = candycrunch, glycans
15821582
df_out = df_out[df_out['predictions'].str.len() > 0]
15831583
# Reprioritize predictions based on how well they are explained by biosynthetic precursors in the same file (e.g., core 1 O-glycan making extended core 1 O-glycans more likely)
15841584
df_out = canonicalize_biosynthesis(df_out, pred_thresh)
1585-
spectra_out = df_out.pop('peak_d').values.tolist()
15861585
# Calculate ppm error
15871586
valid_indices, ppm_errors = [], []
15881587
for preds, obs_mass in zip(df_out['predictions'], df_out.index):
@@ -1608,6 +1607,7 @@ def wrap_inference(spectra_filepath, glycan_class, model = candycrunch, glycans
16081607
df_out['rel_abundance'] = df_out['rel_abundance'] / df_out['rel_abundance'].sum() * 100
16091608
else:
16101609
df_out.drop(['rel_abundance'], axis = 1, inplace = True)
1610+
spectra_out = df_out.pop('peak_d').values.tolist()
16111611
df_out.index.name = "m/z"
16121612
if plot_glycans:
16131613
from glycowork.motif.draw import plot_glycans_excel
@@ -1732,8 +1732,9 @@ def wrap_inference_batch(spectra_filepath_list, glycan_class, intra_cat_thresh,
17321732
mode, modification, mass_tag, filter_out, taxonomy_filter,
17331733
reduced, mass_tolerance, mass_dic)
17341734
# Finalize predictions
1735-
df_out = finalise_predictions(df_out, get_missing, pred_thresh, mode, modification,
1736-
mass_tag, multiplier, plot_glycans, file_label, spectra)
1735+
if len(df_out)>0:
1736+
df_out = finalise_predictions(df_out, get_missing, pred_thresh, mode, modification,
1737+
mass_tag, multiplier, plot_glycans, file_label, spectra)
17371738
inference_dfs[file_label] = df_out
17381739
all_outputs = pd.concat(inference_dfs.values())
17391740
combined_batch = all_outputs.pivot_table(index='top1_pred',columns='condition_label',values='rel_abundance',aggfunc='sum')

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "CandyCrunch"
7-
version = "0.5.1"
7+
version = "0.5.4"
88
description = "Package for predicting glycan structure from LC-MS/MS data"
99
readme = "README.md"
1010
authors = [

0 commit comments

Comments
 (0)