def multiply(self, y): """Multiply profile and peaklist by Y. y (int or float) - multiplier factor """ # multiply spectrum if len(self.profile): self.profile = mod_signal.multiply(self.profile, y=y) # multiply peakslist self.peaklist.multiply(y) # clear buffers self.reset()
def extract_peaks(file,time_range): peak_data = {} run = pymzml.run.Reader(file+'.mzML') peak_data[file] = {} print(file) for spec in run: if spec.get('filter string')!= None and spec.get('total ion current') != None and spec.get('scan time') >= time_range[0] and spec.get('scan time') <= time_range[1]: if spec.get('filter string') in peak_data[file]: peak_data[file][spec.get('filter string')]['scan_count'] += 1 peak_data[file][spec.get('filter string')]['scan'] = mod_signal.combine(peak_data[file][spec.get('filter string')]['scan'], np.array(spec.peaks)) calculations.signal_filter(peak_data[file][spec.get('filter string')]['scan'],0.005) else: peak_data[file][spec.get('filter string')] = {} peak_data[file][spec.get('filter string')]['scan_count'] = 1 peak_data[file][spec.get('filter string')]['scan'] = np.array(spec.peaks) for scan in peak_data[file].keys(): peak_data[file][scan]['scan'] = mod_signal.multiply(peak_data[file][scan]['scan'],y=1.0/peak_data[file][scan]['scan_count']) with open(file+scan+'.np', 'wb') as f: np.save(f,peak_data[file][scan]['scan'])