emzed.ms2 package¶
Submodules¶
Module contents¶
- emzed.ms2.attach_ms2_spectra(peak_table, mode='union', mz_tolerance=0.0013, print_final_report=True)[source]¶
takes peak_table with columns “rtmin”, “rtmax”, “mzmin”, “mzmax” and “peakmap” and extracts the ms2 spectra for these peaks.
the peak_table is modified in place, an extra column “ms2_spectra” is added. the content of such a cell in the table is always a list of spectra. for modes “union” and “intersection” this list contains one single spectrum.
- modes:
“all”: extracts a list of ms2 spectra per peak
“max_range”: extracts spec with widest m/z range
“max_signal”: extrats spec with maximal energy
“union”: merges all ms2 spectra from one peak to one spectrum containing all peaks
“intersection”: merges all ms2 spectra from one peak to one spectrum containing peaks which appear in all ms2 spectra.
mz_tolerance: only needed for modes “union” and “intersection”.
- print_final_report: prints some final report with diagnosis messages for testing
if mz_tolerance parameter fits, you shoud set this parameter to True if you are not sure if mz_tolerance fits to your machines resolution.
- emzed.ms2.export_sirius_files(peak_table, output_folder, abs_min_intensity=0.0, rel_min_intensity=0.0, *, overwrite=False)[source]¶
exports peaks with attached ms2 spectra as sirius .ms files to the specified folder.
- Parameters:
peak_table – peak table with column
spectra_ms2
. Columnsrt
andid
can be helpful to identify results in sirius, but are optional.output_folder – folder to write sirius files to.
abs_min_intensity – filter ms2 spectra by absolute minimal intensity. if rel_min_intensity is also specified peaks compliant to both criteria are exported.
rel_min_intensity – filter ms2 spectra by relatie minimal intensity compared to highest ms2 peak. if abs_min_intensity is also specified peaks compliant to both criteria are exported.
overwrite – set to
True
when the output folder already contains .ms files and you take the risk to potentially overwrite existing files.
- emzed.ms2.merge_spectra(spectra, mz_binning_width, is_ppm=False)[source]¶
merges spectra.
- Parameters:
spectra – list of Spectrum objects or PeakMap or PeakMap.spectra attribute, must be of same ms leve..
mz_binning_width – tolerance parameter for matching m/z values
is_ppm – indicates if mz_binning_width is in Da or ppm.
- Returns:
merged spectrum, return None if spectra is empty.