import pyopenms as oms import numpy as np def compute_chromatograms(rt,charge,intensity,start_c,end_c): value=[] for k in range(len(rt)): c = np.array(charge[k]) i = np.array(intensity[k]) value.append(np.sum(np.where(end_c > c > start_c, i, 0))) return value if __name__ == "__main__": e = oms.MSExperiment() oms.MzMLFile().load("data/STAPH140.mzML", e) e.updateRanges() rt = [] charge = [] intensity = [] for s in e : if s.getMSLevel() == 1: rt.append(s.getRT()) charge.append(s.get_peaks()[0]) intensity.append(s.get_peaks()[1]) val = compute_chromatograms(rt, charge, intensity, 400. ,400.5)