MSExperiment#

class pyopenms.MSExperiment(*args, **kwargs)#

Bases: MSExperiment

__init__(*args, **kwargs)#

Overload:

__init__(self) None

Overload:

__init__(self, in_0: MSExperiment) None

Methods

__init__(*args, **kwargs)

Overload:

addChromatogram(self, chromatogram)

addSpectrum(self, spec)

aggregateFromMatrix(self, ranges, ms_level, ...)

Aggregates intensity values for multiple m/z and RT ranges specified in a matrix

calculateTIC(self)

Returns the total ion chromatogram

clear(self, clear_meta_data)

Clear all spectra data and meta data (if called with True)

clearMetaDataArrays(self)

clearMetaInfo(self)

Removes all meta values

clearRanges(self)

Resets all range dimensions as empty

empty(self)

extractXICsFromMatrix(self, ranges, ...)

Extracts XIC chromatograms for multiple m/z and RT ranges specified in a matrix

get2DPeakData

Cython signature: tuple[np.array[float] rt, np.array[float] mz, np.array[float] inty] get2DPeakData(float min_rt, float max_rt, float min_mz, float max_mz, unsigned int ms_level)

get2DPeakDataIM

Cython signature: tuple[np.array[float] rt, np.array[float] mz, np.array[float] inty, np.array[float] ion_mobility] get2DPeakDataIM(float min_rt, float max_rt, float min_mz, float max_mz, unsigned int ms_level)

get2DPeakDataIMLong

Cython signature: tuple[np.array[float] rt, np.array[float] mz, np.array[float] inty, np.array[float] ion_mobility] get2DPeakDataIMLong(float min_rt, float max_rt, float min_mz, float max_mz, unsigned int ms_level)

get2DPeakDataLong

Cython signature: tuple[np.array[float] rt, np.array[float] mz, np.array[float] inty] get2DPeakDataLong(float min_rt, float max_rt, float min_mz, float max_mz, unsigned int ms_level)

getChromatogram

Cython signature: MSChromatogram getChromatogram(size_t id_)

getChromatograms(self)

getComment(self)

Returns the free-text comment

getContacts(self)

Returns a reference to the list of contact persons

getDateTime(self)

Returns the date the experiment was performed

getExperimentalSettings(self)

getFractionIdentifier(self)

Returns fraction identifier

getHPLC(self)

Returns a reference to the description of the HPLC run

getIdentifier(self)

Retrieve document identifier (e.g.

getInstrument(self)

Returns a reference to the MS instrument description

getKeys(self, keys)

Fills the given vector with a list of all keys for which a value is set

getLoadedFilePath(self)

Returns the file_name which is the absolute path to the file loaded

getLoadedFileType(self)

Returns the file_type (e.g.

getMSLevels

Cython signature: list[int] getMSLevels()

getMaxIntensity(self)

Returns the maximum intensity

getMaxMZ(self)

Returns the maximum m/z

getMaxRT(self)

Returns the maximum RT

getMetaValue(self, in_0)

Returns the value corresponding to a string, or

getMinIntensity(self)

Returns the minimum intensity

getMinMZ(self)

Returns the minimum m/z

getMinRT(self)

Returns the minimum RT

getNrChromatograms(self)

Returns the number of chromatograms

getNrSpectra(self)

Returns the number of MS spectra

getPrecursorSpectrum(self, zero_based_index)

Returns the index of the precursor spectrum for spectrum at index @p zero_based_index

getPrimaryMSRunPath(self, toFill)

References to the first MS file(s) after conversions.

getProteinIdentifications(self)

Returns a reference to the protein ProteinIdentification vector

getSample(self)

Returns a reference to the sample description

getSize(self)

Returns the total number of peaks

getSourceFiles(self)

Returns a reference to the source data file

getSpectra(self)

getSpectrum

Cython signature: MSSpectrum getSpectrum(size_t id_)

get_df([ms_levels, long])

Generates a pandas DataFrame with all peaks in the MSExperiment

get_ion_df()

Generates a pandas DataFrame with all peaks and the ionic mobility in the MSExperiment

get_massql_df([ion_mobility])

Exports data from MSExperiment to pandas DataFrames to be used with MassQL.

isMetaEmpty(self)

Returns if the MetaInfo is empty

isSorted

Overload:

metaRegistry(self)

Returns a reference to the MetaInfoRegistry

metaValueExists(self, in_0)

Returns whether an entry with the given name exists

removeMetaValue(self, in_0)

Removes the DataValue corresponding to name if it exists

reserve(self, s)

reserveSpaceChromatograms(self, s)

reserveSpaceSpectra(self, s)

reset(self)

resize(self, s)

setChromatograms(self, chromatograms)

setComment(self, comment)

Sets the free-text comment

setContacts(self, contacts)

Sets the list of contact persons

setDateTime(self, date_time)

Sets the date the experiment was performed

setFractionIdentifier(self, fraction_identifier)

Sets the fraction identifier

setHPLC(self, hplc)

Sets the description of the HPLC run

setIdentifier(self, id)

Sets document identifier (e.g.

setInstrument(self, instrument)

Sets the MS instrument description

setLoadedFilePath(self, file_name)

Sets the file_name according to absolute path of the file loaded, preferably done whilst loading

setLoadedFileType(self, file_name)

Sets the file_type according to the type of the file loaded from, preferably done whilst loading

setMetaValue(self, in_0, in_1)

Sets the DataValue corresponding to a name

setProteinIdentifications(self, ...)

Sets the protein ProteinIdentification vector

setSample(self, sample)

Sets the sample description

setSourceFiles(self, source_files)

Sets the source data file

setSpectra(self, spectra)

size(self)

sortChromatograms

Overload:

sortSpectra

Overload:

swap(self, in_0)

updateRanges

Overload:

addChromatogram(self, chromatogram: MSChromatogram) None#
addSpectrum(self, spec: MSSpectrum) None#
aggregateFromMatrix(self, ranges: MatrixDouble, ms_level: int, mz_agg: bytes) List[List[float]]#

Aggregates intensity values for multiple m/z and RT ranges specified in a matrix

calculateTIC(self) MSChromatogram#

Returns the total ion chromatogram

clear(self, clear_meta_data: bool) None#

Clear all spectra data and meta data (if called with True)

clearMetaDataArrays(self) bool#
clearMetaInfo(self) None#

Removes all meta values

clearRanges(self) None#

Resets all range dimensions as empty

empty(self) bool#
extractXICsFromMatrix(self, ranges: MatrixDouble, ms_level: int, mz_agg: bytes) List[MSChromatogram]#

Extracts XIC chromatograms for multiple m/z and RT ranges specified in a matrix

get2DPeakData()#

Cython signature: tuple[np.array[float] rt, np.array[float] mz, np.array[float] inty] get2DPeakData(float min_rt, float max_rt, float min_mz, float max_mz, unsigned int ms_level)

get2DPeakDataIM()#

Cython signature: tuple[np.array[float] rt, np.array[float] mz, np.array[float] inty, np.array[float] ion_mobility] get2DPeakDataIM(float min_rt, float max_rt, float min_mz, float max_mz, unsigned int ms_level)

get2DPeakDataIMLong()#

Cython signature: tuple[np.array[float] rt, np.array[float] mz, np.array[float] inty, np.array[float] ion_mobility] get2DPeakDataIMLong(float min_rt, float max_rt, float min_mz, float max_mz, unsigned int ms_level)

get2DPeakDataLong()#

Cython signature: tuple[np.array[float] rt, np.array[float] mz, np.array[float] inty] get2DPeakDataLong(float min_rt, float max_rt, float min_mz, float max_mz, unsigned int ms_level)

getChromatogram()#

Cython signature: MSChromatogram getChromatogram(size_t id_)

getChromatograms(self) List[MSChromatogram]#
getComment(self) bytes | str | String#

Returns the free-text comment

getContacts(self) List[ContactPerson]#

Returns a reference to the list of contact persons

getDateTime(self) DateTime#

Returns the date the experiment was performed

getExperimentalSettings(self) ExperimentalSettings#
getFractionIdentifier(self) bytes | str | String#

Returns fraction identifier

getHPLC(self) HPLC#

Returns a reference to the description of the HPLC run

getIdentifier(self) bytes | str | String#

Retrieve document identifier (e.g. an LSID)

getInstrument(self) Instrument#

Returns a reference to the MS instrument description

getKeys(self, keys: List[bytes]) None#

Fills the given vector with a list of all keys for which a value is set

getLoadedFilePath(self) bytes | str | String#

Returns the file_name which is the absolute path to the file loaded

getLoadedFileType(self) int#

Returns the file_type (e.g. featureXML, consensusXML, mzData, mzXML, mzML, …) of the file loaded

getMSLevels()#

Cython signature: list[int] getMSLevels()

getMaxIntensity(self) float#

Returns the maximum intensity

getMaxMZ(self) float#

Returns the maximum m/z

getMaxRT(self) float#

Returns the maximum RT

getMetaValue(self, in_0: bytes | str | String) int | float | bytes | str | List[int] | List[float] | List[bytes]#

Returns the value corresponding to a string, or

getMinIntensity(self) float#

Returns the minimum intensity

getMinMZ(self) float#

Returns the minimum m/z

getMinRT(self) float#

Returns the minimum RT

getNrChromatograms(self) int#

Returns the number of chromatograms

getNrSpectra(self) int#

Returns the number of MS spectra

getPrecursorSpectrum(self, zero_based_index: int) int#

Returns the index of the precursor spectrum for spectrum at index @p zero_based_index

getPrimaryMSRunPath(self, toFill: List[bytes]) None#

References to the first MS file(s) after conversions. Used to trace results back to original data.

getProteinIdentifications(self) List[ProteinIdentification]#

Returns a reference to the protein ProteinIdentification vector

getSample(self) Sample#

Returns a reference to the sample description

getSize(self) int#

Returns the total number of peaks

getSourceFiles(self) List[SourceFile]#

Returns a reference to the source data file

getSpectra(self) List[MSSpectrum]#
getSpectrum()#

Cython signature: MSSpectrum getSpectrum(size_t id_)

get_df(ms_levels: List[int] = [], long: bool = False)#

Generates a pandas DataFrame with all peaks in the MSExperiment

Parameters: ms_levels (List[int]): Get only spectra with the given MS levels. Default is an empty list, which means all MS levels will be included. long (bool): set to True if you want to have a long/expanded/melted dataframe with one row per peak. Faster but

replicated RT information. If False, returns rows in the style: rt, _np.array(mz), _np.array(int)

Returns: pandas.DataFrame: feature information stored in a DataFrame

get_ion_df()#

Generates a pandas DataFrame with all peaks and the ionic mobility in the MSExperiment

Returns: pandas.DataFrame: feature information stored in a DataFrame

get_massql_df(ion_mobility=False)#

Exports data from MSExperiment to pandas DataFrames to be used with MassQL.

The Python module massql allows queries in mass spectrometry data (MS1 and MS2 data frames) in a SQL like fashion (mwang87/MassQueryLanguage).

Both dataframes contain the columns: ‘i’: intensity of a peak ‘i_norm’: intensity normalized by the maximun intensity in the spectrum ‘i_tic_norm’: intensity normalized by the sum of intensities (TIC) in the spectrum ‘mz’: mass to charge of a peak ‘scan’: number of the spectrum ‘rt’: retention time of the spectrum ‘polarity’: ion mode of the spectrum as integer value (positive: 1, negative: 2) ‘ion’: the ionic mobility of a peak if ion parameter is True

The MS2 dataframe contains additional columns: ‘precmz’: mass to charge of the precursor ion ‘ms1scan’: number of the corresponding MS1 spectrum ‘charge’: charge of the precursor ion

Parameters:

ion (bool): if True, returns the ion mobility of the peaks.

Returns: ms1_df (pandas.DataFrame): peak data of MS1 spectra ms2_df (pandas.DataFrame): peak data of MS2 spectra with precursor information

isMetaEmpty(self) bool#

Returns if the MetaInfo is empty

isSorted()#

Overload:

isSorted(self, check_mz: bool) bool

Checks if all spectra are sorted with respect to ascending RT

Overload:

isSorted(self) bool
metaRegistry(self) MetaInfoRegistry#

Returns a reference to the MetaInfoRegistry

metaValueExists(self, in_0: bytes | str | String) bool#

Returns whether an entry with the given name exists

removeMetaValue(self, in_0: bytes | str | String) None#

Removes the DataValue corresponding to name if it exists

reserve(self, s: int) None#
reserveSpaceChromatograms(self, s: int) None#
reserveSpaceSpectra(self, s: int) None#
reset(self) None#
resize(self, s: int) None#
setChromatograms(self, chromatograms: List[MSChromatogram]) None#
setComment(self, comment: bytes | str | String) None#

Sets the free-text comment

setContacts(self, contacts: List[ContactPerson]) None#

Sets the list of contact persons

setDateTime(self, date_time: DateTime) None#

Sets the date the experiment was performed

setFractionIdentifier(self, fraction_identifier: bytes | str | String) None#

Sets the fraction identifier

setHPLC(self, hplc: HPLC) None#

Sets the description of the HPLC run

setIdentifier(self, id: bytes | str | String) None#

Sets document identifier (e.g. an LSID)

setInstrument(self, instrument: Instrument) None#

Sets the MS instrument description

setLoadedFilePath(self, file_name: bytes | str | String) None#

Sets the file_name according to absolute path of the file loaded, preferably done whilst loading

setLoadedFileType(self, file_name: bytes | str | String) None#

Sets the file_type according to the type of the file loaded from, preferably done whilst loading

setMetaValue(self, in_0: bytes | str | String, in_1: int | float | bytes | str | List[int] | List[float] | List[bytes]) None#

Sets the DataValue corresponding to a name

setProteinIdentifications(self, protein_identifications: List[ProteinIdentification]) None#

Sets the protein ProteinIdentification vector

setSample(self, sample: Sample) None#

Sets the sample description

setSourceFiles(self, source_files: List[SourceFile]) None#

Sets the source data file

setSpectra(self, spectra: List[MSSpectrum]) None#
size(self) int#
sortChromatograms()#

Overload:

sortChromatograms(self, sort_rt: bool) None

Sorts chromatograms by m/z. If sort_rt=True also sort each chromatogram RT

Overload:

sortChromatograms(self) None
sortSpectra()#

Overload:

sortSpectra(self, sort_mz: bool) None

Sorts spectra by RT. If sort_mz=True also sort each peak in a spectrum by m/z

Overload:

sortSpectra(self) None
swap(self, in_0: MSExperiment) None#
updateRanges()#

Overload:

updateRanges(self) None

Recalculate global RT and m/z ranges after changes to the data has been made.

Overload:

updateRanges(self, msLevel: int) None

Recalculate RT and m/z ranges for a specific MS level