Closed wkumler closed 6 days ago
Chromatogram extraction function below:
import matplotlib.pyplot as plt
from pyteomics import mzml, mzmlb
import numpy as np
import pandas as pd
def get_chrom_mzmlb(file):
scan_dfs = []
for spectrum in mzmlb.MzMLb(file):
if spectrum['ms level'] == 1:
mz_vals=spectrum['m/z array']
int_vals = spectrum['intensity array']
bet_mzs = mz_vals[abs(mz_vals-118.0865)<=0.001]
bet_ints = int_vals[abs(mz_vals-118.0865)<=0.001]
rt_val = spectrum['scanList']['scan'][0]['scan start time']
if(len(bet_mzs)>0):
df_scan = pd.DataFrame({'mz':bet_mzs, 'int':bet_ints, 'rt':[rt_val]*len(bet_mzs)})
scan_dfs.append(df_scan)
return(pd.concat(scan_dfs, ignore_index=True))
chrom_data = get_chrom_mzmlb('210916_Poo_TruePooAmm-noIS-pos-Full_1.mzMLb')
plt.plot(chrom_data["rt"], chrom_data["int"])
plt.show()
mzMLb tasks:
Exactly the same as mzML except for the filename and the parser