示例#1
0
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'])
示例#2
0
def filter(signal,width=0.005):
    if not isinstance(signal, numpy.ndarray):
        raise TypeError, "Signals must be NumPy arrays!"
    if signal.dtype.name != 'float64':
        raise TypeError, "Signals data must be float64!"
    return calculations.signal_filter(signal, width)