pyMSpec package

Submodules

pyMSpec.MSdataset module

class pyMSpec.MSdataset.MSdataset[source]
add_spectrum(profile_mzs=[], profile_intensities=[], centroids_mz=[], centroid_intensity=[], index=[])[source]
data_summary()[source]
get_spectrum(index)[source]

pyMSpec.centroid_detection module

pyMSpec.centroid_detection.estimate_centroid_simple_weighting(mzs, intensities, indices_list, peak_width_bins)[source]

Simple averaging to estimate the peak centroid Input:

mzs: profile spectrum mzs intensities: profile spectrum intensities indices_list: mz bin of local maxima
Output:
mzs_c: centroids mzs intensities_c: centroid intensity (==peak maxima)
pyMSpec.centroid_detection.gradient(mzs, intensities, **opt_args)[source]
pyMSpec.centroid_detection.gradient_purePython(mzs, intensities, min_intensity, peak_width_bins)[source]

This function takes a vector of intensities and finds local maxima based on turning points in the first differential. It is a trivial algorithm that assumes sufficient signal processing has been performed that the spectra are locally smooth. Input

mzs: list of mz values for profile spectrum intensities: list of intensity values. must be same length as mzs
Output:
mzs_c: list of apex mzs intensites_c: list of apex intensities
pyMSpec.centroid_detection.pick_max_(mzs, intensities, mzs_list, intensities_list, indices_list, weighted_bins)[source]

pyMSpec.instrument module

class pyMSpec.instrument.ConstantFWHM(resolving_power, at_mz=200)[source]

Bases: pyMSpec.instrument.ConstantResolvingPower

sigma_at_mz(mz)[source]
class pyMSpec.instrument.ConstantResolvingPower(resolving_power, at_mz=200)[source]

Bases: pyMSpec.instrument.Instrument

resolving_power_at_mz(mz)[source]
class pyMSpec.instrument.FTICR(resolving_power, at_mz=200)[source]

Bases: pyMSpec.instrument.Instrument

resolving_power_at_mz(mz)[source]
class pyMSpec.instrument.Instrument(resolving_power, at_mz=200)[source]
fwhm_at_mz(mz)[source]
generate_mz_axis(mz_min, mz_max, pts_per_fwhm=2)[source]

returns mz axis

get_isotope_pattern(formula_adduct_string, charge)[source]
get_principal_peak(formula_adduct_string, charge)[source]
points_per_mz(sigma)[source]
resolving_power_at_mz(mz)[source]
sigma_at_mz(mz)[source]
class pyMSpec.instrument.Orbitrap(resolving_power, at_mz=200)[source]

Bases: pyMSpec.instrument.Instrument

resolving_power_at_mz(mz)[source]
pyMSpec.instrument.Orbitrap_HF

alias of Orbitrap

pyMSpec.instrument.Synapt

alias of ConstantResolvingPower

pyMSpec.instrument.TOF

alias of ConstantResolvingPower

pyMSpec.instrument.TOF_reflector

alias of ConstantResolvingPower

pyMSpec.instrument.qTOF

alias of ConstantResolvingPower

pyMSpec.mass_spectrum module

class pyMSpec.mass_spectrum.MSn_spectrum(ms_level='')[source]

Bases: pyMSpec.mass_spectrum.MassSpectrum

a data container for fragmentation spectrum

add_transition(transitions)[source]
class pyMSpec.mass_spectrum.MassSpectrum(profile_spec=[], centroid_spec=[])[source]

a data container for a single mass spectrum includes methods for signal processing

add_centroids(mz_list, intensity_list)[source]
add_spectrum(mzs, intensities)[source]
get_spectrum(source='profile')[source]
normalise_spectrum(method='tic', method_args={})[source]
smooth_spectrum(method='sg_smooth', method_args={})[source]
pyMSpec.mass_spectrum.mass_spectrum

alias of MassSpectrum

pyMSpec.normalisation module

pyMSpec.normalisation.apply_normalisation(mzs, counts, type_str='', norm_args={})[source]

helper function to apply a normalisation function (with some input testing etc) :param counts: numpy array of values to normalise :param type_str: normalisation type to apply (name) :return: numpy array of normalised counts

pyMSpec.normalisation.check_zeros(counts)[source]

helper function to check if vector is all zero :param counts: :return: bool

pyMSpec.normalisation.mad(mzs, counts)[source]

normalisation function, divides each intensity by the median-absolute-deviation of all intensities :param counts: numpy array :return:counts normalised: numpy array

pyMSpec.normalisation.none(mzs, counts)[source]

does nothing, just returns input. is a dummy for programmatic case where a function must be supplied :param counts: numpy array :return: counts:

pyMSpec.normalisation.rms(mzs, counts)[source]

normalisation function, divides each intensity by the root-mean-square of all intensities :param counts: numpy array :return:counts normalised: numpy array

pyMSpec.normalisation.shift_and_scale(counts, scale=1.0, shift=0.0)[source]

applys the generic scaling a shifting operation :param counts: numpy array :param scale: float :param shift: float :return: numpy array of scaled and shifted values

pyMSpec.normalisation.sqrt(mzs, counts)[source]

normalisation function, returns the square root of intensities :param counts: numpy array :return:counts normalised: numpy array

pyMSpec.normalisation.tic(mzs, counts)[source]

normalisation function, divides each intensity by the sum of all intensities (each spectrum sums to 1) :param counts: numpy array :return:counts normalised: numpy array

pyMSpec.normalisation.tic_range(mzs, counts, range)[source]

normalisation function, divides each intensity by the sum of all intensities (each spectrum sums to 1) :param counts: numpy array :return:counts normalised: numpy array

pyMSpec.smoothing module

pyMSpec.smoothing.apodization(mzs, intensities, w_size=10)[source]

apodization with slepian window :param mzs: numpy array numpy array of mz values :param counts: numpy array numpy array of values to smooth :param w_size: int window size :return: mzs: numpy array :return: counts: numpy array

pyMSpec.smoothing.apply_smoothing(mzs, counts, type_str='', method_args={})[source]

helper function to apply a smoothing function (with some input testing etc) :param counts: numpy array of values to smooth :param type_str: smooting type to apply (name) :return: tuple (mzs: numpy array, counts: numpy array)

pyMSpec.smoothing.fast_change(mzs, intensities, diff_thresh=0.01)[source]

remove high frequency noise from the data :param mzs: numpy array numpy array of mz values :param counts: numpy array numpy array of values to smooth :param diff_thresh: float numeric change to remove :return: mzs: numpy array :return: counts: numpy array

pyMSpec.smoothing.median(mzs, intensities, w_size=3)[source]

apply median filter :param mzs: numpy array numpy array of mz values :param counts: numpy array numpy array of values to smooth :param w_size: int window size :return: mzs: numpy array :return: counts: numpy array

pyMSpec.smoothing.nosmooth(mzs, intensities)[source]

does nothing, just returns input. is a dummy for programmatic case where a function must be supplied :param counts: numpy array :return: mzs: numpy array :return: counts: numpy array

pyMSpec.smoothing.rebin(mzs, intensities, delta_mz=0.1)[source]

rebin spectrum :param mzs: numpy array numpy array of mz values :param counts: numpy array numpy array of values to smooth :param delta_mz: float, new mz bin width (constant across mz axis) :return: mzs: numpy array :return: counts: numpy array

pyMSpec.smoothing.sg_smooth(mzs, intensities, n_smooth=1, w_size=5)[source]

sav gol :param mzs: numpy array numpy array of mz values :param counts: numpy array numpy array of values to smooth :param n_smooth: int number of times to apply smoothing :param w_size: int window size :return: mzs: numpy array :return: counts: numpy array

Module contents