MSChromatogram#

class pyopenms.MSChromatogram#

Bases: object

The representation of a chromatogram. Raw data access is proved by get_peaks and set_peaks, which yields numpy arrays Indexing and iteration yield copies of the peaks; write changes back with chrom[i] = peak Extra data arrays can be accessed through getFloatDataArrays / getIntegerDataArrays / getStringDataArrays See help(ChromatogramSettings) for information about meta-information

Usage:

precursor = chromatogram.getPrecursor()
product = chromatogram.getProduct()
rt, intensities = chromatogram.get_peaks()
__init__() → None#
__init__(arg: pyopenms.MSChromatogram, /) → None

Methods

__init__()

clear(clear_meta_data)

Clears all data and meta data.

clearMetaInfo()

Removes all meta values

clearRanges()

Clear all ranges

df_columns([columns, export_meta_values])

Returns a list of column names that to_df() would produce.

findNearest(rt)

Binary search for the peak nearest to a specific RT.

float_data_array_view(i)

Returns a live view of the float data array at index i.

float_data_array_views()

Returns a list of live views of the float data arrays (see float_data_array_view).

getAcquisitionInfo()

Returns the acquisition info

getChromatogramType()

Get the chromatogram type

getComment()

Returns the free-text comment

getDataProcessing()

Returns the description of the applied processing

getFloatDataArrays()

Returns the float data arrays

getInstrumentSettings()

Returns the instrument settings of the current chromatogram

getIntegerDataArrays()

Returns the integer data arrays

getKeys(keys)

Overloaded function.

getMZ()

Returns the mz of the product entry, makes sense especially for MRM scans

getMaxIntensity()

Get the maximum intensity value

getMaxRT()

Get the maximum RT value

getMetaValue(name)

Returns the value corresponding to a string, or DataValue::EMPTY if not found

getMinIntensity()

Get the minimum intensity value

getMinRT()

Get the minimum RT value

getName()

Returns the name

getNativeID()

Returns the native identifier for the chromatogram, used by the acquisition software.

getPrecursor()

Returns the precursors

getProduct()

Returns the product ion

getSourceFile()

Returns the source file

getStringDataArrays()

Returns the string data arrays

get_data_dict([columns, export_meta_values])

Returns a dictionary of NumPy arrays with RT, intensities, and metadata.

get_df(*args, **kwargs)

Deprecated: use to_df() instead.

get_df_columns(*args, **kwargs)

Deprecated: Use df_columns() instead.

get_peaks()

Returns a tuple of (rt_array, intensity_array) as numpy arrays

integer_data_array_view(i)

Returns a live view of the integer data array at index i.

integer_data_array_views()

Returns a list of live views of the integer data arrays (see integer_data_array_view).

isMetaEmpty()

Returns if the MetaInfo is empty

isSorted()

Checks if all peaks are sorted with respect to ascending RT

iter_float_data_array_views()

Yields live views of the float data arrays, one at a time (see float_data_array_view).

iter_integer_data_array_views()

Yields live views of the integer data arrays, one at a time (see integer_data_array_view).

iter_string_data_array_views()

Yields live views of the string data arrays, one at a time (see string_data_array_view).

metaRegistry()

Returns a reference to the MetaInfoRegistry

metaValueExists(name)

Returns whether an entry with the given name exists

peaks_struct()

Returns zero-copy structured array with fields 'rt' (float64) and 'intensity' (float32).

push_back(peak)

Append a peak

removeMetaValue(name)

Removes the DataValue corresponding to name if it exists

reserve(new_size)

Reserve space for peaks

resize(new_size)

Resize the peak array

setAcquisitionInfo(acquisition_info)

Sets the acquisition info

setChromatogramType(type)

Sets the chromatogram type

setComment(comment)

Sets the free-text comment

setDataProcessing(data_processing)

Sets the description of the applied processing

setFloatDataArrays(arrays)

Set the float data arrays

setInstrumentSettings(instrument_settings)

Sets the instrument settings of the current chromatogram

setIntegerDataArrays(arrays)

Set the integer data arrays

setMetaValue(name, value)

Sets the DataValue corresponding to a name

setName(name)

Sets the name

setNativeID(native_id)

Sets the native identifier for the chromatogram, used by the acquisition software.

setPrecursor(precursor)

Sets the precursors

setProduct(product)

Sets the product ion

setSourceFile(source_file)

Sets the source file

setStringDataArrays(arrays)

Set the string data arrays

set_peaks(rt, intensity[, metadata])

Overloaded function.

size()

Returns the number of peaks

sortByIntensity([reverse])

Lexicographically sorts the peaks by their intensity.

sortByPosition()

Lexicographically sorts the peaks by their position (RT).

string_data_array_view(i)

Returns a live view of the string data array at index i.

string_data_array_views()

Returns a list of live views of the string data arrays (see string_data_array_view).

to_arrow([columns, export_meta_values])

Returns an Apache Arrow Table representation.

to_df([columns, export_meta_values])

Returns a pandas DataFrame representation.

updateRanges()

Recalculates the RT and intensity ranges of the chromatogram

clear(clear_meta_data: bool) → None#

Clears all data and meta data. Always deletes all peaks, associated data arrays (float, integer, string), and ranges. If clear_meta_data is True, also deletes the descriptive meta data (ChromatogramSettings, name).

clearMetaInfo() → None#

Removes all meta values

clearRanges() → None#

Clear all ranges

df_columns(columns='default', export_meta_values=True)#

Returns a list of column names that to_df() would produce.

findNearest(rt: float) → int#

Binary search for the peak nearest to a specific RT. Returns the index of the peak. The chromatogram must be sorted with respect to RT, otherwise the result is undefined. Raises an exception if the chromatogram is empty.

float_data_array_view(i: int) → pyopenms.FloatDataArray#

Returns a live view of the float data array at index i. Chain .data_view() on it for zero-copy numpy access into this object’s storage. The view aliases this object’s storage: edits through it are visible immediately, and it stays valid only until the data array list is resized or reordered. The parent object is kept alive automatically. For an owned copy use getFloatDataArrays()[i].

float_data_array_views()#

Returns a list of live views of the float data arrays (see float_data_array_view).

getAcquisitionInfo() → pyopenms.AcquisitionInfo#

Returns the acquisition info

getChromatogramType() → pyopenms.ChromatogramSettings.ChromatogramType#

Get the chromatogram type

getComment() → str#

Returns the free-text comment

getDataProcessing() → list[pyopenms.DataProcessing]#

Returns the description of the applied processing

getFloatDataArrays() → list[pyopenms.FloatDataArray]#

Returns the float data arrays

getInstrumentSettings() → pyopenms.InstrumentSettings#

Returns the instrument settings of the current chromatogram

getIntegerDataArrays() → list[pyopenms.IntegerDataArray]#

Returns the integer data arrays

getKeys(keys: list) → None#
getKeys() → list

Overloaded function.

  1. getKeys(keys: list) -> None

Fills the given list with all meta value keys

  1. getKeys() -> list

Returns all meta value keys as a list

getMZ() → float#

Returns the mz of the product entry, makes sense especially for MRM scans

getMaxIntensity() → float#

Get the maximum intensity value

getMaxRT() → float#

Get the maximum RT value

getMetaValue(name: str) → None | int | float | str | bytes | list[str] | list[int] | list[float]#

Returns the value corresponding to a string, or DataValue::EMPTY if not found

getMinIntensity() → float#

Get the minimum intensity value

getMinRT() → float#

Get the minimum RT value

getName() → str#

Returns the name

getNativeID() → str#

Returns the native identifier for the chromatogram, used by the acquisition software.

getPrecursor() → pyopenms.Precursor#

Returns the precursors

getProduct() → pyopenms.Product#

Returns the product ion

getSourceFile() → pyopenms.SourceFile#

Returns the source file

getStringDataArrays() → list[pyopenms.StringDataArray]#

Returns the string data arrays

get_data_dict(columns=None, export_meta_values=True)#

Returns a dictionary of NumPy arrays with RT, intensities, and metadata.

get_df(*args, **kwargs)#

Deprecated: use to_df() instead.

get_df_columns(*args, **kwargs)#

Deprecated: Use df_columns() instead.

get_peaks() → tuple#

Returns a tuple of (rt_array, intensity_array) as numpy arrays

integer_data_array_view(i: int) → pyopenms.IntegerDataArray#

Returns a live view of the integer data array at index i. Chain .data_view() on it for zero-copy numpy access into this object’s storage. The view aliases this object’s storage: edits through it are visible immediately, and it stays valid only until the data array list is resized or reordered. The parent object is kept alive automatically. For an owned copy use getIntegerDataArrays()[i].

integer_data_array_views()#

Returns a list of live views of the integer data arrays (see integer_data_array_view).

isMetaEmpty() → bool#

Returns if the MetaInfo is empty

isSorted() → bool#

Checks if all peaks are sorted with respect to ascending RT

iter_float_data_array_views()#

Yields live views of the float data arrays, one at a time (see float_data_array_view).

iter_integer_data_array_views()#

Yields live views of the integer data arrays, one at a time (see integer_data_array_view).

iter_string_data_array_views()#

Yields live views of the string data arrays, one at a time (see string_data_array_view).

static metaRegistry() → pyopenms.MetaInfoRegistry#

Returns a reference to the MetaInfoRegistry

metaValueExists(name: str) → bool#

Returns whether an entry with the given name exists

peaks_struct() → object#

Returns zero-copy structured array with fields ‘rt’ (float64) and ‘intensity’ (float32).

push_back(peak: pyopenms.ChromatogramPeak) → None#

Append a peak

removeMetaValue(name: str) → None#

Removes the DataValue corresponding to name if it exists

reserve(new_size: int) → None#

Reserve space for peaks

resize(new_size: int) → None#

Resize the peak array

setAcquisitionInfo(acquisition_info: pyopenms.AcquisitionInfo) → None#

Sets the acquisition info

setChromatogramType(type: pyopenms.ChromatogramSettings.ChromatogramType) → None#

Sets the chromatogram type

setComment(comment: str) → None#

Sets the free-text comment

setDataProcessing(data_processing: collections.abc.Sequence[pyopenms.DataProcessing]) → None#

Sets the description of the applied processing

setFloatDataArrays(arrays: collections.abc.Sequence[pyopenms.FloatDataArray]) → None#

Set the float data arrays

setInstrumentSettings(instrument_settings: pyopenms.InstrumentSettings) → None#

Sets the instrument settings of the current chromatogram

setIntegerDataArrays(arrays: collections.abc.Sequence[pyopenms.IntegerDataArray]) → None#

Set the integer data arrays

setMetaValue(name: str, value: None | int | float | str | bytes | list[str] | list[int] | list[float]) → None#

Sets the DataValue corresponding to a name

setName(name: str) → None#

Sets the name

setNativeID(native_id: str) → None#

Sets the native identifier for the chromatogram, used by the acquisition software.

setPrecursor(precursor: pyopenms.Precursor) → None#

Sets the precursors

setProduct(product: pyopenms.Product) → None#

Sets the product ion

setSourceFile(source_file: pyopenms.SourceFile) → None#

Sets the source file

setStringDataArrays(arrays: collections.abc.Sequence[pyopenms.StringDataArray]) → None#

Set the string data arrays

set_peaks(rt: object, intensity: object, metadata: str = 'error') → None#
set_peaks(peaks: object, *, metadata: str = 'error') → None

Overloaded function.

  1. set_peaks(rt: object, intensity: object, metadata: str = 'error') -> None

Set peaks from rt and intensity arrays

The binary data arrays are not resized. metadata decides what happens when the new peak count would leave a non-empty float, string or integer data array mis-sized: error (the default) raises and leaves the container untouched, clear drops the arrays that no longer fit, and keep keeps them, leaving the container internally inconsistent. Arrays that are already the right length, and empty ones, are kept in every case, so replacing peaks with an equally long set never touches them.

  1. set_peaks(peaks: object, *, metadata: str = 'error') -> None

Set peaks from a tuple/list of (rt_array, intensity_array)

The binary data arrays are not resized. metadata decides what happens when the new peak count would leave a non-empty float, string or integer data array mis-sized: error (the default) raises and leaves the container untouched, clear drops the arrays that no longer fit, and keep keeps them, leaving the container internally inconsistent. Arrays that are already the right length, and empty ones, are kept in every case, so replacing peaks with an equally long set never touches them.

size() → int#

Returns the number of peaks

sortByIntensity(reverse: bool = False) → None#

Lexicographically sorts the peaks by their intensity. Sorts the peaks according to ascending intensity (lowest to highest) when reverse is False. When reverse is True, sorts by descending intensity (highest to lowest). Meta data arrays will be sorted accordingly

sortByPosition() → None#

Lexicographically sorts the peaks by their position (RT). Sorts the peaks according to ascending RT. Meta data arrays will be sorted accordingly

string_data_array_view(i: int) → pyopenms.StringDataArray#

Returns a live view of the string data array at index i. Chain .data_view() on it for zero-copy numpy access into this object’s storage. The view aliases this object’s storage: edits through it are visible immediately, and it stays valid only until the data array list is resized or reordered. The parent object is kept alive automatically. For an owned copy use getStringDataArrays()[i].

string_data_array_views()#

Returns a list of live views of the string data arrays (see string_data_array_view).

to_arrow(columns=None, export_meta_values=True)#

Returns an Apache Arrow Table representation.

to_df(columns=None, export_meta_values=True)#

Returns a pandas DataFrame representation.

updateRanges() → None#

Recalculates the RT and intensity ranges of the chromatogram