emzed.ms_data¶
ImmutablePeakMap
¶
Bases: DbBackedModel
Immutable LCMS experiment wrapper backed by a SQLite database.
unique_id
property
¶
Stable content-based identifier for the peak map.
chromatogram(mzmin=None, mzmax=None, rtmin=None, rtmax=None, ms_level=None, precursormzmin=None, precursormzmax=None, polarity=None)
¶
Integrate a chromatogram over the given extraction window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mzmin
|
minimum fragment m/z included in the chromatogram. |
None
|
|
mzmax
|
maximum fragment m/z included in the chromatogram. |
None
|
|
rtmin
|
minimum retention time in seconds. |
None
|
|
rtmax
|
maximum retention time in seconds. |
None
|
|
ms_level
|
MS level to extract. If omitted, the lowest present level is used. |
None
|
|
precursormzmin
|
minimum precursor m/z for MSn extraction. |
None
|
|
precursormzmax
|
maximum precursor m/z for MSn extraction. |
None
|
|
polarity
|
optional polarity filter, either |
None
|
Returns:
| Type | Description |
|---|---|
|
|
close()
¶
Close the underlying database connection.
extract(mzmin=None, mzmax=None, rtmin=None, rtmax=None, imin=None, imax=None, mslevelmin=None, mslevelmax=None, precursormzmin=None, precursormzmax=None, polarity=None, *, target_db_file=None)
¶
Extract a sub-peakmap using RT, m/z, intensity, precursor, and polarity limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mzmin
|
minimum fragment m/z to keep. |
None
|
|
mzmax
|
maximum fragment m/z to keep. |
None
|
|
rtmin
|
minimum retention time in seconds. |
None
|
|
rtmax
|
maximum retention time in seconds. |
None
|
|
imin
|
minimum intensity to keep. |
None
|
|
imax
|
maximum intensity to keep. |
None
|
|
mslevelmin
|
minimum MS level to keep. |
None
|
|
mslevelmax
|
maximum MS level to keep. |
None
|
|
precursormzmin
|
minimum precursor m/z to keep for MSn spectra. |
None
|
|
precursormzmax
|
maximum precursor m/z to keep for MSn spectra. |
None
|
|
polarity
|
optional polarity filter, either |
None
|
|
target_db_file
|
optional output database path for the extracted result. |
None
|
Returns:
| Type | Description |
|---|---|
|
|
extract_for_precursors(mzs, mz_tol, *, target_db_file=None)
¶
Extract MSn spectra whose precursor windows match the given m/z values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mzs
|
precursor m/z values to match. |
required | |
mz_tol
|
absolute m/z tolerance used for matching. |
required | |
target_db_file
|
optional output database path for the extracted result. |
None
|
Returns:
| Type | Description |
|---|---|
|
|
filter(predicate, target_db_file=None)
¶
Create a new peak map containing spectra that match a predicate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate
|
callable receiving a spectrum and returning |
required | |
target_db_file
|
optional output database path for the filtered result. |
None
|
Returns:
| Type | Description |
|---|---|
|
|
get_dominating_peak_map()
¶
Return the lowest MS-level sub-peakmap as an MS1-style peak map.
get_precursors_mzs()
¶
Return all unique precursor-m/z tuples found in the peak map.
is_in_memory()
¶
Return True if the peak map is backed by an in-memory database.
is_open()
¶
Return True if the underlying database connection is open.
load(path, *, target_db_file=None, overwrite=False)
classmethod
¶
Load an mzML or mzXML file into an emzed peak-map database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
source mass-spectrometry file. |
required | |
target_db_file
|
optional output database path. If omitted, an in-memory database is used. |
None
|
|
overwrite
|
overwrite |
False
|
Returns:
| Type | Description |
|---|---|
|
|
ms_levels()
¶
Return the MS levels present in the peak map.
mz_range(ms_level=None)
¶
Return the m/z range for one MS level or for the full peak map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ms_level
|
optional MS level. |
None
|
mz_ranges(ms_level=None)
¶
Return the m/z ranges indexed by MS level.
open(path)
classmethod
¶
Open a peak map database without copying it into memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
path to an |
required |
Returns:
| Type | Description |
|---|---|
|
|
polarities()
¶
Return the set of ion polarities present in the peak map.
representing_mz_peak(mzmin, mzmax, rtmin, rtmax, ms_level=1)
¶
Return an intensity-weighted representative m/z inside a 2D window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mzmin
|
minimum m/z bound. |
required | |
mzmax
|
maximum m/z bound. |
required | |
rtmin
|
minimum retention time in seconds. |
required | |
rtmax
|
maximum retention time in seconds. |
required | |
ms_level
|
MS level to inspect. |
1
|
Returns:
| Type | Description |
|---|---|
|
representative m/z as |
rt_range(ms_level=None)
¶
Return the retention-time range for one MS level or for the full peak map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ms_level
|
optional MS level. |
None
|
rt_ranges(ms_level=None)
¶
Return the retention-time ranges indexed by MS level.
save(path, *, overwrite=False)
¶
Write the peak map to mzML or mzXML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
target output path. |
required | |
overwrite
|
overwrite an existing output file. |
False
|
scan_counts()
¶
Return the number of scans grouped by MS level.
split_by_precursors(mz_tol=0.0)
¶
Split the peak map into sub-peakmaps grouped by precursor m/z tuples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mz_tol
|
optional binning tolerance used to merge nearly identical precursor tuples. |
0.0
|
Returns:
| Type | Description |
|---|---|
|
|
summary()
¶
Return a compact table summarizing RT, m/z, scan counts, and polarities.
MSChromatogram
¶
Mass-spectrometry chromatogram with optional precursor annotation.
available_types
property
¶
Return the list of supported chromatogram type names.
intensities
property
¶
Intensity values of the chromatogram.
mz
property
¶
Target m/z of the chromatogram.
precursor_mz
property
¶
Precursor m/z associated with the chromatogram, if any.
rts
property
¶
Retention times of the chromatogram.
type
property
¶
Return the chromatogram type name.
rt_range()
¶
Return the chromatogram retention-time range.
PeakMap
¶
Bases: ImmutablePeakMap
Mutable variant of ImmutablePeakMap.
add_spectrum(spectrum)
¶
Reject direct mutation on immutable peak maps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectrum
|
spectrum that would otherwise be appended. |
required |
from_(clz, pm, *, target_db_file=None)
classmethod
¶
Copy a peak map into a mutable database-backed instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pm
|
source peak map. |
required | |
target_db_file
|
optional target database path for the copy. |
None
|
Returns:
| Type | Description |
|---|---|
|
|
merge(other)
¶
Merge another mutable peak map into this one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
peak map with non-overlapping scan numbers. |
required |
spectra_for_modification()
¶
contextmanager. in this context one can change spectra attributes like rt, ms_level, peaks or polarity