OpenMS
MSSpectrum Class Referencefinal

The representation of a 1D spectrum. More...

#include <OpenMS/KERNEL/MSSpectrum.h>

Inheritance diagram for MSSpectrum:
[legend]
Collaboration diagram for MSSpectrum:
[legend]

Classes

struct  Chunk
 Used to remember what subsets in a spectrum are sorted already to allow faster sorting of the spectrum. More...
 
struct  Chunks
 
struct  IMLess
 Comparator for the ion mobility. More...
 
struct  RTLess
 Comparator for the retention time. More...
 

Public Types

Base type definitions
typedef OpenMS::Peak1D PeakType
 Peak type. More...
 
typedef PeakType::CoordinateType CoordinateType
 Coordinate (m/z) type. More...
 
typedef std::vector< PeakTypeContainerType
 Spectrum base type. More...
 
typedef RangeManagerContainer< RangeMZ, RangeIntensityRangeManagerContainerType
 RangeManager. More...
 
typedef RangeManager< RangeMZ, RangeIntensityRangeManagerType
 
typedef OpenMS::DataArrays::FloatDataArray FloatDataArray
 Float data array vector type. More...
 
typedef std::vector< FloatDataArrayFloatDataArrays
 
typedef OpenMS::DataArrays::StringDataArray StringDataArray
 String data array vector type. More...
 
typedef std::vector< StringDataArrayStringDataArrays
 
typedef OpenMS::DataArrays::IntegerDataArray IntegerDataArray
 Integer data array vector type. More...
 
typedef std::vector< IntegerDataArrayIntegerDataArrays
 
Peak container iterator type definitions
typedef ContainerType::iterator Iterator
 Mutable iterator. More...
 
typedef ContainerType::const_iterator ConstIterator
 Non-mutable iterator. More...
 
typedef ContainerType::reverse_iterator ReverseIterator
 Mutable reverse iterator. More...
 
typedef ContainerType::const_reverse_iterator ConstReverseIterator
 Non-mutable reverse iterator. More...
 
- Public Types inherited from RangeManagerContainer< RangeMZ, RangeIntensity >
using ThisRangeType = typename RangeManager< RangeBases... >::ThisRangeType
 
- Public Types inherited from RangeManager< RangeBases... >
using ThisRangeType = RangeManager< RangeBases... >
 
- Public Types inherited from SpectrumSettings
enum  SpectrumType { UNKNOWN , CENTROID , PROFILE , SIZE_OF_SPECTRUMTYPE }
 Spectrum peak type. More...
 

Public Member Functions

Export methods from std::vector<Peak1D>
 MSSpectrum ()
 Constructor. More...
 
 MSSpectrum (const MSSpectrum &source)
 Copy constructor. More...
 
 MSSpectrum (MSSpectrum &&)=default
 Move constructor. More...
 
 ~MSSpectrum ()=default
 Destructor. More...
 
MSSpectrumoperator= (const MSSpectrum &source)
 Assignment operator. More...
 
MSSpectrumoperator= (MSSpectrum &&) &=default
 Move assignment operator. More...
 
MSSpectrumoperator= (const SpectrumSettings &source)
 Assignment operator. More...
 
bool operator== (const MSSpectrum &rhs) const
 Equality operator. More...
 
bool operator!= (const MSSpectrum &rhs) const
 Equality operator. More...
 
void updateRanges () override
 
Accessors for meta information

Returns the absolute retention time (in seconds)

double getRT () const
 
void setRT (double rt)
 Sets the absolute retention time (in seconds) More...
 
double getDriftTime () const
 Returns the ion mobility drift time (MSSpectrum::DRIFTTIME_NOT_SET means it is not set) More...
 
void setDriftTime (double dt)
 Sets the ion mobility drift time. More...
 
DriftTimeUnit getDriftTimeUnit () const
 Returns the ion mobility drift time unit. More...
 
String getDriftTimeUnitAsString () const
 returns the ion mobility drift time unit as string More...
 
void setDriftTimeUnit (DriftTimeUnit dt)
 Sets the ion mobility drift time unit. More...
 
UInt getMSLevel () const
 Returns the MS level. More...
 
void setMSLevel (UInt ms_level)
 Sets the MS level. More...
 
const StringgetName () const
 Returns the name. More...
 
void setName (const String &name)
 Sets the name. More...
 
Peak data array methods

These methods are used to annotate each peak in a spectrum with meta information. It is an intermediate way between storing the information in the peak's MetaInfoInterface and deriving a new peak type with members for this information.

These statements should help you chose which approach to use

  • Access to meta info arrays is slower than to a member variable
  • Access to meta info arrays is faster than to a MetaInfoInterface
  • Meta info arrays are stored when using mzML format for storing
const FloatDataArraysgetFloatDataArrays () const
 Returns a const reference to the float meta data arrays. More...
 
FloatDataArraysgetFloatDataArrays ()
 Returns a mutable reference to the float meta data arrays. More...
 
void setFloatDataArrays (const FloatDataArrays &fda)
 Sets the float meta data arrays. More...
 
const StringDataArraysgetStringDataArrays () const
 Returns a const reference to the string meta data arrays. More...
 
StringDataArraysgetStringDataArrays ()
 Returns a mutable reference to the string meta data arrays. More...
 
void setStringDataArrays (const StringDataArrays &sda)
 Sets the string meta data arrays. More...
 
const IntegerDataArraysgetIntegerDataArrays () const
 Returns a const reference to the integer meta data arrays. More...
 
IntegerDataArraysgetIntegerDataArrays ()
 Returns a mutable reference to the integer meta data arrays. More...
 
void setIntegerDataArrays (const IntegerDataArrays &ida)
 Sets the integer meta data arrays. More...
 
Sorting peaks
void sortByIntensity (bool reverse=false)
 Lexicographically sorts the peaks by their intensity. More...
 
void sortByPosition ()
 Lexicographically sorts the peaks by their position. More...
 
void sortByPositionPresorted (const std::vector< Chunk > &chunks)
 Sort the spectrum, but uses the fact, that certain chunks are presorted. More...
 
bool isSorted () const
 Checks if all peaks are sorted with respect to ascending m/z. More...
 
template<class Predicate >
bool isSorted (const Predicate &lambda) const
 
template<class Predicate >
void sort (const Predicate &lambda)
 
- Public Member Functions inherited from RangeManagerContainer< RangeMZ, RangeIntensity >
virtual ~RangeManagerContainer ()=default
 D'tor. More...
 
const ThisRangeTypegetRange () const
 get range of current data (call updateRanges() before to ensure the range is accurate) More...
 
ThisRangeTypegetRange ()
 get mutable range, provided for efficiency reasons (avoid updateRanges(), if only minor changes were made) More...
 
- Public Member Functions inherited from RangeManager< RangeBases... >
bool operator== (const RangeManager &rhs) const
 
bool operator!= (const RangeManager &rhs) const
 
bool assignUnsafe (const RangeManager< RangeBasesOther... > &rhs)
 
auto & assign (const RangeManager< RangeBasesOther... > &rhs)
 
bool extendUnsafe (const RangeManager< RangeBasesOther... > &rhs)
 
void extend (const RangeManager< RangeBasesOther... > &rhs)
 
void scaleBy (const double factor)
 calls RangeBase::scale() for each dimension More...
 
void minSpanIfSingular (const double min_span)
 If any dimension is a single point, e.g. min==max, then extend this dimension by min_span / 2 on either side. More...
 
bool pushIntoUnsafe (const RangeManager< RangeBasesOther... > &rhs)
 
void pushInto (const RangeManager< RangeBasesOther... > &sandbox)
 
bool clampToUnsafe (const RangeManager< RangeBasesOther... > &rhs)
 
void clampTo (const RangeManager< RangeBasesOther... > &rhs)
 
const RangeBasegetRangeForDim (MSDim dim) const
 obtain a range dimension at runtime using dim More...
 
RangeBasegetRangeForDim (MSDim dim)
 obtain a range dimension at runtime using dim More...
 
HasRangeType hasRange () const
 is any/some/all dimension in this range populated? More...
 
bool containsAll (const RangeManager< RangeBasesOther... > &rhs) const
 
void clearRanges ()
 Resets all ranges. More...
 
ThisRangeTypeclear (const DIM_UNIT range)
 
void printRange (std::ostream &out) const
 print each dimension (base classes) to a stream More...
 
- Public Member Functions inherited from SpectrumSettings
 SpectrumSettings ()
 Constructor. More...
 
 SpectrumSettings (const SpectrumSettings &)=default
 Copy constructor. More...
 
 SpectrumSettings (SpectrumSettings &&)=default
 Move constructor. More...
 
 ~SpectrumSettings ()
 Destructor. More...
 
SpectrumSettingsoperator= (const SpectrumSettings &)=default
 
SpectrumSettingsoperator= (SpectrumSettings &&) &=default
 Move assignment operator. More...
 
bool operator== (const SpectrumSettings &rhs) const
 Equality operator. More...
 
bool operator!= (const SpectrumSettings &rhs) const
 Equality operator. More...
 
void unify (const SpectrumSettings &rhs)
 merge another spectrum setting into this one (data is usually appended, except for spectrum type which needs to be unambiguous to be kept) More...
 
SpectrumType getType () const
 returns the spectrum type (centroided (PEAKS) or profile data (RAW)) More...
 
void setType (SpectrumType type)
 sets the spectrum type More...
 
const StringgetNativeID () const
 returns the native identifier for the spectrum, used by the acquisition software. More...
 
void setNativeID (const String &native_id)
 sets the native identifier for the spectrum, used by the acquisition software. More...
 
const StringgetComment () const
 returns the free-text comment More...
 
void setComment (const String &comment)
 sets the free-text comment More...
 
const InstrumentSettingsgetInstrumentSettings () const
 returns a const reference to the instrument settings of the current spectrum More...
 
InstrumentSettingsgetInstrumentSettings ()
 returns a mutable reference to the instrument settings of the current spectrum More...
 
void setInstrumentSettings (const InstrumentSettings &instrument_settings)
 sets the instrument settings of the current spectrum More...
 
const AcquisitionInfogetAcquisitionInfo () const
 returns a const reference to the acquisition info More...
 
AcquisitionInfogetAcquisitionInfo ()
 returns a mutable reference to the acquisition info More...
 
void setAcquisitionInfo (const AcquisitionInfo &acquisition_info)
 sets the acquisition info More...
 
const SourceFilegetSourceFile () const
 returns a const reference to the source file More...
 
SourceFilegetSourceFile ()
 returns a mutable reference to the source file More...
 
void setSourceFile (const SourceFile &source_file)
 sets the source file More...
 
const std::vector< Precursor > & getPrecursors () const
 returns a const reference to the precursors More...
 
std::vector< Precursor > & getPrecursors ()
 returns a mutable reference to the precursors More...
 
void setPrecursors (const std::vector< Precursor > &precursors)
 sets the precursors More...
 
const std::vector< Product > & getProducts () const
 returns a const reference to the products More...
 
std::vector< Product > & getProducts ()
 returns a mutable reference to the products More...
 
void setProducts (const std::vector< Product > &products)
 sets the products More...
 
const std::vector< PeptideIdentification > & getPeptideIdentifications () const
 returns a const reference to the PeptideIdentification vector More...
 
std::vector< PeptideIdentification > & getPeptideIdentifications ()
 returns a mutable reference to the PeptideIdentification vector More...
 
void setPeptideIdentifications (const std::vector< PeptideIdentification > &identifications)
 sets the PeptideIdentification vector More...
 
void setDataProcessing (const std::vector< DataProcessingPtr > &data_processing)
 sets the description of the applied processing More...
 
std::vector< DataProcessingPtr > & getDataProcessing ()
 returns a mutable reference to the description of the applied processing More...
 
const std::vector< boost::shared_ptr< const DataProcessing > > getDataProcessing () const
 returns a const reference to the description of the applied processing More...
 
- Public Member Functions inherited from MetaInfoInterface
 MetaInfoInterface ()
 Constructor. More...
 
 MetaInfoInterface (const MetaInfoInterface &rhs)
 Copy constructor. More...
 
 MetaInfoInterface (MetaInfoInterface &&) noexcept
 Move constructor. More...
 
 ~MetaInfoInterface ()
 Destructor. More...
 
MetaInfoInterfaceoperator= (const MetaInfoInterface &rhs)
 Assignment operator. More...
 
MetaInfoInterfaceoperator= (MetaInfoInterface &&) noexcept
 Move assignment operator. More...
 
void swap (MetaInfoInterface &rhs)
 Swap contents. More...
 
bool operator== (const MetaInfoInterface &rhs) const
 Equality operator. More...
 
bool operator!= (const MetaInfoInterface &rhs) const
 Equality operator. More...
 
const DataValuegetMetaValue (const String &name) const
 Returns the value corresponding to a string, or DataValue::EMPTY if not found. More...
 
DataValue getMetaValue (const String &name, const DataValue &default_value) const
 Returns the value corresponding to a string, or a default value (e.g.: DataValue::EMPTY) if not found. More...
 
const DataValuegetMetaValue (UInt index) const
 Returns the value corresponding to the index, or DataValue::EMPTY if not found. More...
 
DataValue getMetaValue (UInt index, const DataValue &default_value) const
 Returns the value corresponding to the index, or a default value (e.g.: DataValue::EMPTY) if not found. More...
 
bool metaValueExists (const String &name) const
 Returns whether an entry with the given name exists. More...
 
bool metaValueExists (UInt index) const
 Returns whether an entry with the given index exists. More...
 
void setMetaValue (const String &name, const DataValue &value)
 Sets the DataValue corresponding to a name. More...
 
void setMetaValue (UInt index, const DataValue &value)
 Sets the DataValue corresponding to an index. More...
 
void removeMetaValue (const String &name)
 Removes the DataValue corresponding to name if it exists. More...
 
void removeMetaValue (UInt index)
 Removes the DataValue corresponding to index if it exists. More...
 
void addMetaValues (const MetaInfoInterface &from)
 function to copy all meta values from one object to this one More...
 
void getKeys (std::vector< String > &keys) const
 Fills the given vector with a list of all keys for which a value is set. More...
 
void getKeys (std::vector< UInt > &keys) const
 Fills the given vector with a list of all keys for which a value is set. More...
 
bool isMetaEmpty () const
 Returns if the MetaInfo is empty. More...
 
void clearMetaInfo ()
 Removes all meta values. More...
 

Searching a peak or peak range

double retention_time_
 Retention time. More...
 
double drift_time_
 Drift time. More...
 
DriftTimeUnit drift_time_unit_
 Drift time unit. More...
 
UInt ms_level_
 MS level. More...
 
String name_
 Name. More...
 
FloatDataArrays float_data_arrays_
 Float data arrays. More...
 
StringDataArrays string_data_arrays_
 String data arrays. More...
 
IntegerDataArrays integer_data_arrays_
 Integer data arrays. More...
 
Size findNearest (CoordinateType mz) const
 Binary search for the peak nearest to a specific m/z. More...
 
Int findNearest (CoordinateType mz, CoordinateType tolerance) const
 Binary search for the peak nearest to a specific m/z given a +/- tolerance windows in Th. More...
 
Int findNearest (CoordinateType mz, CoordinateType tolerance_left, CoordinateType tolerance_right) const
 Search for the peak nearest to a specific m/z given two +/- tolerance windows in Th. More...
 
Int findHighestInWindow (CoordinateType mz, CoordinateType tolerance_left, CoordinateType tolerance_right) const
 Search for the peak with highest intensity among the peaks near to a specific m/z given two +/- tolerance windows in Th. More...
 
Iterator MZBegin (CoordinateType mz)
 Binary search for peak range begin. More...
 
Iterator MZBegin (Iterator begin, CoordinateType mz, Iterator end)
 Binary search for peak range begin. More...
 
Iterator MZEnd (CoordinateType mz)
 Binary search for peak range end (returns the past-the-end iterator) More...
 
Iterator MZEnd (Iterator begin, CoordinateType mz, Iterator end)
 Binary search for peak range end (returns the past-the-end iterator) More...
 
ConstIterator MZBegin (CoordinateType mz) const
 Binary search for peak range begin. More...
 
ConstIterator MZBegin (ConstIterator begin, CoordinateType mz, ConstIterator end) const
 Binary search for peak range begin. More...
 
ConstIterator MZEnd (CoordinateType mz) const
 Binary search for peak range end (returns the past-the-end iterator) More...
 
ConstIterator MZEnd (ConstIterator begin, CoordinateType mz, ConstIterator end) const
 Binary search for peak range end (returns the past-the-end iterator) More...
 
Iterator PosBegin (CoordinateType mz)
 Binary search for peak range begin. More...
 
Iterator PosBegin (Iterator begin, CoordinateType mz, Iterator end)
 Binary search for peak range begin. More...
 
ConstIterator PosBegin (CoordinateType mz) const
 Binary search for peak range begin. More...
 
ConstIterator PosBegin (ConstIterator begin, CoordinateType mz, ConstIterator end) const
 Binary search for peak range begin. More...
 
Iterator PosEnd (CoordinateType mz)
 Binary search for peak range end (returns the past-the-end iterator) More...
 
Iterator PosEnd (Iterator begin, CoordinateType mz, Iterator end)
 Binary search for peak range end (returns the past-the-end iterator) More...
 
ConstIterator PosEnd (CoordinateType mz) const
 Binary search for peak range end (returns the past-the-end iterator) More...
 
ConstIterator PosEnd (ConstIterator begin, CoordinateType mz, ConstIterator end) const
 Binary search for peak range end (returns the past-the-end iterator) More...
 
bool containsIMData () const
 
std::pair< Size, DriftTimeUnitgetIMData () const
 Get the Ion mobility data array's index and its associated unit. More...
 
void clear (bool clear_meta_data)
 Clears all data and meta data. More...
 
MSSpectrumselect (const std::vector< Size > &indices)
 
SpectrumSettings::SpectrumType getType (const bool query_data) const
 Determine if spectrum is profile or centroided using up to three layers of information. More...
 
ConstIterator getBasePeak () const
 
Iterator getBasePeak ()
 
PeakType::IntensityType calculateTIC () const
 compute the total ion count (sum of all peak intensities) More...
 
SpectrumType getType () const
 returns the spectrum type (centroided (PEAKS) or profile data (RAW)) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MetaInfoInterface
static MetaInfoRegistrymetaRegistry ()
 Returns a reference to the MetaInfoRegistry. More...
 
- Static Public Attributes inherited from SpectrumSettings
static const std::string NamesOfSpectrumType [SIZE_OF_SPECTRUMTYPE]
 Names of spectrum types. More...
 
- Protected Member Functions inherited from RangeManager< RangeBases... >
void for_each_base_ (Visitor &&visitor)
 use fold expression to iterate over all RangeBases of RangeManager and apply a lambda (Visitor) for each one More...
 
void for_each_base_ (Visitor &&visitor) const
 .. and a const version More...
 
- Protected Member Functions inherited from MetaInfoInterface
void createIfNotExists_ ()
 Creates the MetaInfo object if it does not exist. More...
 
- Static Protected Member Functions inherited from RangeManager< RangeBases... >
static void static_for_each_base_ (Visitor &&visitor)
 use fold expression to iterate over all RangeBases of RangeManager and apply a lambda (Visitor) for each one (for static members) More...
 
- Protected Attributes inherited from SpectrumSettings
SpectrumType type_
 
String native_id_
 
String comment_
 
InstrumentSettings instrument_settings_
 
SourceFile source_file_
 
AcquisitionInfo acquisition_info_
 
std::vector< Precursorprecursors_
 
std::vector< Productproducts_
 
std::vector< PeptideIdentificationidentification_
 
std::vector< DataProcessingPtrdata_processing_
 
- Protected Attributes inherited from MetaInfoInterface
MetaInfometa_
 Pointer to the MetaInfo object (0 by default) More...
 

Detailed Description

The representation of a 1D spectrum.

It contains peak data and metadata about specific instrument settings, acquisition settings, description of the meta values used in the peaks and precursor info (SpectrumSettings).

Several MSSpectrum instances are contained in a peak map (MSExperiment), which is essentially a vector of spectra with additional information about the experiment.

Precursor info from SpectrumSettings should only be used if this spectrum is a tandem-MS spectrum. The precursor spectrum is the first spectrum in MSExperiment, that has a lower MS-level than the current spectrum.

Note
For range operations, see RangeUtils module!

Member Typedef Documentation

◆ ConstIterator

typedef ContainerType::const_iterator ConstIterator

Non-mutable iterator.

◆ ConstReverseIterator

typedef ContainerType::const_reverse_iterator ConstReverseIterator

Non-mutable reverse iterator.

◆ ContainerType

typedef std::vector<PeakType> ContainerType

Spectrum base type.

◆ CoordinateType

Coordinate (m/z) type.

◆ FloatDataArray

Float data array vector type.

◆ FloatDataArrays

typedef std::vector<FloatDataArray> FloatDataArrays

◆ IntegerDataArray

Integer data array vector type.

◆ IntegerDataArrays

typedef std::vector<IntegerDataArray> IntegerDataArrays

◆ Iterator

typedef ContainerType::iterator Iterator

Mutable iterator.

◆ PeakType

Peak type.

◆ RangeManagerContainerType

◆ RangeManagerType

◆ ReverseIterator

typedef ContainerType::reverse_iterator ReverseIterator

Mutable reverse iterator.

◆ StringDataArray

◆ StringDataArrays

typedef std::vector<StringDataArray> StringDataArrays

Constructor & Destructor Documentation

◆ MSSpectrum() [1/3]

Constructor.

◆ MSSpectrum() [2/3]

MSSpectrum ( const MSSpectrum source)

Copy constructor.

◆ MSSpectrum() [3/3]

MSSpectrum ( MSSpectrum &&  )
default

Move constructor.

◆ ~MSSpectrum()

~MSSpectrum ( )
default

Destructor.

Member Function Documentation

◆ calculateTIC()

PeakType::IntensityType calculateTIC ( ) const

compute the total ion count (sum of all peak intensities)

◆ clear()

void clear ( bool  clear_meta_data)

Clears all data and meta data.

Will delete (clear) all peaks contained in the spectrum as well as any associated data arrays (FloatDataArrays, IntegerDataArrays, StringDataArrays) by default. If clear_meta_data is true, then also all meta data (such as RT, drift time, ms level etc) will be deleted.

Parameters
clear_meta_dataIf true, all meta data is cleared in addition to the data.

Referenced by SpectraMerger::averageCentroidSpectra_(), SpectraMerger::averageProfileSpectra_(), MzMLSwathFileConsumer::consumeSwathSpectrum_(), ChromatogramTools::convertSpectraToChromatograms(), NucleicAcidSearchEngine::deisotopeAndSingleChargeMSSpectrum_(), WindowMower::filterPeakSpectrumForTopNInJumpingWindow(), MS2File::load(), DTA2DFile::load(), XMassFile::load(), DTAFile::load(), and SpectraMerger::mergeSpectra_().

◆ containsIMData()

bool containsIMData ( ) const

do the names of internal float metadata arrays contain any hint of ion mobility data, i.e. they are a child of 'MS:1002893 ! ion mobility array'? (for spectra which represent an IM-frame)

Referenced by MSExperiment::get2DPeakData(), and MSExperiment::get2DPeakDataIon().

◆ findHighestInWindow()

Int findHighestInWindow ( CoordinateType  mz,
CoordinateType  tolerance_left,
CoordinateType  tolerance_right 
) const

Search for the peak with highest intensity among the peaks near to a specific m/z given two +/- tolerance windows in Th.

Parameters
mzThe searched for mass-to-charge ratio searched
toleranceThe non-negative tolerance applied to both sides of mz
Returns
Returns the index of the peak or -1 if no peak present in tolerance window or if spectrum is empty
Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.
Peaks exactly on borders are considered in tolerance window.

◆ findNearest() [1/3]

Size findNearest ( CoordinateType  mz) const

Binary search for the peak nearest to a specific m/z.

Parameters
mzThe searched for mass-to-charge ratio searched
Returns
Returns the index of the peak.
Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.
Exceptions
Exception::Preconditionis thrown if the spectrum is empty (not only in debug mode)

Referenced by NucleicAcidSearchEngine::deisotopeAndSingleChargeMSSpectrum_().

◆ findNearest() [2/3]

Int findNearest ( CoordinateType  mz,
CoordinateType  tolerance 
) const

Binary search for the peak nearest to a specific m/z given a +/- tolerance windows in Th.

Parameters
mzThe searched for mass-to-charge ratio searched
toleranceThe non-negative tolerance applied to both sides of mz
Returns
Returns the index of the peak or -1 if no peak present in tolerance window or if spectrum is empty
Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.
Peaks exactly on borders are considered in tolerance window.

◆ findNearest() [3/3]

Int findNearest ( CoordinateType  mz,
CoordinateType  tolerance_left,
CoordinateType  tolerance_right 
) const

Search for the peak nearest to a specific m/z given two +/- tolerance windows in Th.

Parameters
mzThe searched for mass-to-charge ratio searched
tolerance_leftThe non-negative tolerance applied left of mz
tolerance_rightThe non-negative tolerance applied right of mz
Returns
Returns the index of the peak or -1 if no peak present in tolerance window or if spectrum is empty
Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.
Peaks exactly on borders are considered in tolerance window.
Search for the left border is done using a binary search followed by a linear scan

◆ getBasePeak() [1/2]

Iterator getBasePeak ( )

return the peak with the highest intensity. If the peak is not unique, the first peak in the container is returned. The function works correctly, even if the spectrum is unsorted.

◆ getBasePeak() [2/2]

ConstIterator getBasePeak ( ) const

return the peak with the highest intensity. If the peak is not unique, the first peak in the container is returned. The function works correctly, even if the spectrum is unsorted.

◆ getDriftTime()

double getDriftTime ( ) const

Returns the ion mobility drift time (MSSpectrum::DRIFTTIME_NOT_SET means it is not set)

Note
Drift times may be stored directly as an attribute of the spectrum (if they relate to the spectrum as a whole). In case of ion mobility spectra, the drift time of the spectrum will always be set here while the drift times attribute in the Precursor class may often be unpopulated.

Referenced by DimIM::map().

◆ getDriftTimeUnit()

DriftTimeUnit getDriftTimeUnit ( ) const

Returns the ion mobility drift time unit.

◆ getDriftTimeUnitAsString()

String getDriftTimeUnitAsString ( ) const

returns the ion mobility drift time unit as string

◆ getFloatDataArrays() [1/2]

FloatDataArrays& getFloatDataArrays ( )
inline

Returns a mutable reference to the float meta data arrays.

◆ getFloatDataArrays() [2/2]

◆ getIMData()

std::pair<Size, DriftTimeUnit> getIMData ( ) const

Get the Ion mobility data array's index and its associated unit.

This only works for spectra which represent an IM-frame, i.e. they have a float metadata array which is a child of 'MS:1002893 ! ion mobility array'?

Exceptions
Exception::MissingInformationif IM data is not present

Referenced by MSExperiment::get2DPeakData(), and MSExperiment::get2DPeakDataIon().

◆ getIntegerDataArrays() [1/2]

IntegerDataArrays& getIntegerDataArrays ( )

Returns a mutable reference to the integer meta data arrays.

◆ getIntegerDataArrays() [2/2]

const IntegerDataArrays& getIntegerDataArrays ( ) const

Returns a const reference to the integer meta data arrays.

Referenced by MetaDataBrowser::add(), and DataFilters::passes().

◆ getMSLevel()

◆ getName()

const String& getName ( ) const

Returns the name.

◆ getRT()

◆ getStringDataArrays() [1/2]

StringDataArrays& getStringDataArrays ( )

Returns a mutable reference to the string meta data arrays.

◆ getStringDataArrays() [2/2]

const StringDataArrays& getStringDataArrays ( ) const

Returns a const reference to the string meta data arrays.

Referenced by MetaDataBrowser::add().

◆ getType() [1/2]

SpectrumType getType

returns the spectrum type (centroided (PEAKS) or profile data (RAW))

◆ getType() [2/2]

SpectrumSettings::SpectrumType getType ( const bool  query_data) const

Determine if spectrum is profile or centroided using up to three layers of information.

First, the SpectrumSettings are inquired and the type is returned unless it is unknown. Second, all data processing entries are searched for a centroiding step. If that is unsuccessful as well and query_data is true, the data is fed into PeakTypeEstimator().

Parameters
[query_data]If SpectrumSettings and DataProcessing information are not sufficient, should the data be queried? (potentially expensive)
Returns
The spectrum type (centroided, profile or unknown)

◆ isSorted() [1/2]

bool isSorted ( ) const

Checks if all peaks are sorted with respect to ascending m/z.

◆ isSorted() [2/2]

bool isSorted ( const Predicate &  lambda) const
inline

Checks if container is sorted by a certain user-defined property. You can pass any lambda function with [](Size index_1, Size index_2) –> bool which given two indices into MSSpectrum (either for peaks or data arrays) returns a weak-ordering. (you need to capture the MSSpectrum in the lambda and operate on it, based on the indices)

◆ MZBegin() [1/4]

ConstIterator MZBegin ( ConstIterator  begin,
CoordinateType  mz,
ConstIterator  end 
) const

Binary search for peak range begin.

Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.

◆ MZBegin() [2/4]

◆ MZBegin() [3/4]

ConstIterator MZBegin ( CoordinateType  mz) const

Binary search for peak range begin.

Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.

◆ MZBegin() [4/4]

Iterator MZBegin ( Iterator  begin,
CoordinateType  mz,
Iterator  end 
)

Binary search for peak range begin.

Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.

◆ MZEnd() [1/4]

ConstIterator MZEnd ( ConstIterator  begin,
CoordinateType  mz,
ConstIterator  end 
) const

Binary search for peak range end (returns the past-the-end iterator)

Note
Make sure the spectrum is sorted with respect to m/z. Otherwise the result is undefined.

◆ MZEnd() [2/4]

Iterator MZEnd ( CoordinateType  mz)

Binary search for peak range end (returns the past-the-end iterator)

Note
Make sure the spectrum is sorted with respect to m/z. Otherwise the result is undefined.

Referenced by IsotopeWaveletTransform< PeakType >::identifyCharge(), IsotopeWaveletTransform< PeakType >::initializeScan(), and IsotopeWaveletTransform< PeakType >::TransSpectrum::MZEnd().

◆ MZEnd() [3/4]

ConstIterator MZEnd ( CoordinateType  mz) const

Binary search for peak range end (returns the past-the-end iterator)

Note
Make sure the spectrum is sorted with respect to m/z. Otherwise the result is undefined.

◆ MZEnd() [4/4]

Iterator MZEnd ( Iterator  begin,
CoordinateType  mz,
Iterator  end 
)

Binary search for peak range end (returns the past-the-end iterator)

Note
Make sure the spectrum is sorted with respect to m/z. Otherwise the result is undefined.

◆ operator!=()

bool operator!= ( const MSSpectrum rhs) const
inline

Equality operator.

References OpenMS::Internal::operator==().

◆ operator=() [1/3]

MSSpectrum& operator= ( const MSSpectrum source)

Assignment operator.

◆ operator=() [2/3]

MSSpectrum& operator= ( const SpectrumSettings source)

Assignment operator.

◆ operator=() [3/3]

MSSpectrum& operator= ( MSSpectrum &&  ) &
default

Move assignment operator.

◆ operator==()

bool operator== ( const MSSpectrum rhs) const

Equality operator.

◆ PosBegin() [1/4]

ConstIterator PosBegin ( ConstIterator  begin,
CoordinateType  mz,
ConstIterator  end 
) const

Binary search for peak range begin.

Alias for MZBegin()

Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.

◆ PosBegin() [2/4]

Iterator PosBegin ( CoordinateType  mz)

Binary search for peak range begin.

Alias for MZBegin()

Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.

◆ PosBegin() [3/4]

ConstIterator PosBegin ( CoordinateType  mz) const

Binary search for peak range begin.

Alias for MZBegin()

Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.

◆ PosBegin() [4/4]

Iterator PosBegin ( Iterator  begin,
CoordinateType  mz,
Iterator  end 
)

Binary search for peak range begin.

Alias for MZBegin()

Note
Make sure the spectrum is sorted with respect to m/z! Otherwise the result is undefined.

◆ PosEnd() [1/4]

ConstIterator PosEnd ( ConstIterator  begin,
CoordinateType  mz,
ConstIterator  end 
) const

Binary search for peak range end (returns the past-the-end iterator)

Alias for MZEnd()

Note
Make sure the spectrum is sorted with respect to m/z. Otherwise the result is undefined.

◆ PosEnd() [2/4]

Iterator PosEnd ( CoordinateType  mz)

Binary search for peak range end (returns the past-the-end iterator)

Alias for MZEnd()

Note
Make sure the spectrum is sorted with respect to m/z. Otherwise the result is undefined.

◆ PosEnd() [3/4]

ConstIterator PosEnd ( CoordinateType  mz) const

Binary search for peak range end (returns the past-the-end iterator)

Alias for MZEnd()

Note
Make sure the spectrum is sorted with respect to m/z. Otherwise the result is undefined.

◆ PosEnd() [4/4]

Iterator PosEnd ( Iterator  begin,
CoordinateType  mz,
Iterator  end 
)

Binary search for peak range end (returns the past-the-end iterator)

Alias for MZEnd()

Note
Make sure the spectrum is sorted with respect to m/z. Otherwise the result is undefined.

◆ select()

◆ setDriftTime()

void setDriftTime ( double  dt)

Sets the ion mobility drift time.

◆ setDriftTimeUnit()

void setDriftTimeUnit ( DriftTimeUnit  dt)

Sets the ion mobility drift time unit.

◆ setFloatDataArrays()

void setFloatDataArrays ( const FloatDataArrays fda)

Sets the float meta data arrays.

◆ setIntegerDataArrays()

void setIntegerDataArrays ( const IntegerDataArrays ida)

Sets the integer meta data arrays.

◆ setMSLevel()

◆ setName()

void setName ( const String name)

◆ setRT()

void setRT ( double  rt)

◆ setStringDataArrays()

void setStringDataArrays ( const StringDataArrays sda)

Sets the string meta data arrays.

◆ sort()

void sort ( const Predicate &  lambda)
inline

Sort by a user-defined property You can pass any lambda function with [](Size index_1, Size index_2) –> bool which given two indices into MSSpectrum (either for peaks or data arrays) returns a weak-ordering. (you need to capture the MSSpectrum in the lambda and operate on it, based on the indices)

◆ sortByIntensity()

void sortByIntensity ( bool  reverse = false)

Lexicographically sorts the peaks by their intensity.

Sorts the peaks according to ascending intensity. Meta data arrays will be sorted accordingly.

Referenced by WindowMower::filterPeakSpectrumForTopNInSlidingWindow(), NLargest::filterSpectrum(), and Scaler::filterSpectrum().

◆ sortByPosition()

◆ sortByPositionPresorted()

void sortByPositionPresorted ( const std::vector< Chunk > &  chunks)

Sort the spectrum, but uses the fact, that certain chunks are presorted.

Parameters
chunksa Chunk is an object that contains the start and end of a sublist of peaks in the spectrum, that is or isn't sorted yet (is_sorted member)

◆ updateRanges()

void updateRanges ( )
overridevirtual

implement this function to reflect the underlying data of the derived class (e.g. an MSSpectrum) Usually, call clearRanges() internally and then populate the dimensions.

Implements RangeManagerContainer< RangeMZ, RangeIntensity >.

Member Data Documentation

◆ drift_time_

double drift_time_
protected

Drift time.

◆ drift_time_unit_

DriftTimeUnit drift_time_unit_
protected

Drift time unit.

◆ float_data_arrays_

FloatDataArrays float_data_arrays_
protected

Float data arrays.

◆ integer_data_arrays_

IntegerDataArrays integer_data_arrays_
protected

Integer data arrays.

◆ ms_level_

UInt ms_level_
protected

MS level.

◆ name_

String name_
protected

Name.

◆ retention_time_

double retention_time_
protected

Retention time.

◆ string_data_arrays_

StringDataArrays string_data_arrays_
protected

String data arrays.