OpenMS  2.8.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
IDMapper Class Reference

Annotates an MSExperiment, FeatureMap or ConsensusMap with peptide identifications. More...

#include <OpenMS/ANALYSIS/ID/IDMapper.h>

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

Classes

struct  SpectraIdentificationState
 Result of a partitioning by identification state with mapPrecursorsToIdentifications(). More...
 

Public Types

enum  Measure { MEASURE_PPM = 0 , MEASURE_DA }
 

Public Member Functions

 IDMapper ()
 Default constructor. More...
 
 IDMapper (const IDMapper &cp)
 Copy C'Tor. More...
 
IDMapperoperator= (const IDMapper &rhs)
 Assignment. More...
 
void annotate (PeakMap &map, const std::vector< PeptideIdentification > &peptide_ids, const std::vector< ProteinIdentification > &protein_ids, const bool clear_ids=false, const bool map_ms1=false)
 Mapping method for peak maps. More...
 
void annotate (PeakMap &map, FeatureMap fmap, const bool clear_ids=false, const bool map_ms1=false)
 Mapping method for peak maps. More...
 
void annotate (FeatureMap &map, const std::vector< PeptideIdentification > &ids, const std::vector< ProteinIdentification > &protein_ids, bool use_centroid_rt=false, bool use_centroid_mz=false, const PeakMap &spectra=PeakMap())
 Mapping method for feature maps. More...
 
void annotate (ConsensusMap &map, const std::vector< PeptideIdentification > &ids, const std::vector< ProteinIdentification > &protein_ids, bool measure_from_subelements=false, bool annotate_ids_with_subelements=false, const PeakMap &spectra=PeakMap())
 Mapping method for consensus maps. More...
 
- Public Member Functions inherited from DefaultParamHandler
 DefaultParamHandler (const String &name)
 Constructor with name that is displayed in error messages. More...
 
 DefaultParamHandler (const DefaultParamHandler &rhs)
 Copy constructor. More...
 
virtual ~DefaultParamHandler ()
 Destructor. More...
 
virtual DefaultParamHandleroperator= (const DefaultParamHandler &rhs)
 Assignment operator. More...
 
virtual bool operator== (const DefaultParamHandler &rhs) const
 Equality operator. More...
 
void setParameters (const Param &param)
 Sets the parameters. More...
 
const ParamgetParameters () const
 Non-mutable access to the parameters. More...
 
const ParamgetDefaults () const
 Non-mutable access to the default parameters. More...
 
const StringgetName () const
 Non-mutable access to the name. More...
 
void setName (const String &name)
 Mutable access to the name. More...
 
const std::vector< String > & getSubsections () const
 Non-mutable access to the registered subsections. More...
 

Static Public Member Functions

static SpectraIdentificationState mapPrecursorsToIdentifications (const PeakMap &spectra, const std::vector< PeptideIdentification > &ids, double mz_tol=0.001, double rt_tol=0.001)
 Mapping of peptide identifications to spectra This helper function partitions all spectra into those that had: More...
 
- Static Public Member Functions inherited from DefaultParamHandler
static void writeParametersToMetaValues (const Param &write_this, MetaInfoInterface &write_here, const String &key_prefix="")
 Writes all parameters to meta values. More...
 

Protected Member Functions

void updateMembers_ () override
 This method is used to update extra member variables at the end of the setParameters() method. More...
 
double getAbsoluteMZTolerance_ (const double mz) const
 
bool isMatch_ (const double rt_distance, const double mz_theoretical, const double mz_observed) const
 check if distance constraint is fulfilled (using rt_tolerance_, mz_tolerance_ and measure_) More...
 
void checkHits_ (const std::vector< PeptideIdentification > &ids) const
 helper function that checks if all peptide hits are annotated with RT and MZ meta values More...
 
void getIDDetails_ (const PeptideIdentification &id, double &rt_pep, DoubleList &mz_values, IntList &charges, bool use_avg_mass=false) const
 
void increaseBoundingBox_ (DBoundingBox< 2 > &box)
 increase a bounding box by the given RT and m/z tolerances More...
 
bool checkMassType_ (const std::vector< DataProcessing > &processing) const
 
- Protected Member Functions inherited from DefaultParamHandler
void defaultsToParam_ ()
 Updates the parameters after the defaults have been set in the constructor. More...
 

Protected Attributes

double rt_tolerance_
 Allowed RT deviation. More...
 
double mz_tolerance_
 Allowed m/z deviation. More...
 
Measure measure_
 Measure used for m/z. More...
 
bool ignore_charge_
 Ignore charge states during matching? More...
 
- Protected Attributes inherited from DefaultParamHandler
Param param_
 Container for current parameters. More...
 
Param defaults_
 Container for default parameters. This member should be filled in the constructor of derived classes! More...
 
std::vector< Stringsubsections_
 Container for registered subsections. This member should be filled in the constructor of derived classes! More...
 
String error_name_
 Name that is displayed in error messages during the parameter checking. More...
 
bool check_defaults_
 If this member is set to false no checking if parameters in done;. More...
 
bool warn_empty_defaults_
 If this member is set to false no warning is emitted when defaults are empty;. More...
 

Detailed Description

Annotates an MSExperiment, FeatureMap or ConsensusMap with peptide identifications.

ProteinIdentifications are assigned to the whole map.

The retention time and mass-to-charge ratio of the PeptideIdentification as the respective "MZ" and "RT" members.

m/z-matching on peptide side can be done either with the precursor m/z value of the peptide identification or with the theoretical masses of the peptide hits (see "mz_reference" parameter).

See the documentation of the individual annotate methods for more in-depth information.

Parameters of this class are:

NameTypeDefaultRestrictionsDescription
rt_tolerance float5.0 min: 0.0RT tolerance (in seconds) for the matching
mz_tolerance float20.0 min: 0.0m/z tolerance (in ppm or Da) for the matching
mz_measure stringppm ppm, Daunit of 'mz_tolerance' (ppm or Da)
mz_reference stringprecursor precursor, peptidesource of m/z values for peptide identifications
ignore_charge stringfalse true, falseFor feature/consensus maps: Assign an ID independently of whether its charge state matches that of the (consensus) feature.

Note:

Class Documentation

◆ OpenMS::IDMapper::SpectraIdentificationState

struct OpenMS::IDMapper::SpectraIdentificationState

Result of a partitioning by identification state with mapPrecursorsToIdentifications().

Collaboration diagram for IDMapper::SpectraIdentificationState:
[legend]
Class Members
vector< Size > identified
vector< Size > no_precursors
vector< Size > unidentified

Member Enumeration Documentation

◆ Measure

enum Measure
Enumerator
MEASURE_PPM 
MEASURE_DA 

Constructor & Destructor Documentation

◆ IDMapper() [1/2]

IDMapper ( )

Default constructor.

◆ IDMapper() [2/2]

IDMapper ( const IDMapper cp)

Copy C'Tor.

Member Function Documentation

◆ annotate() [1/4]

void annotate ( ConsensusMap map,
const std::vector< PeptideIdentification > &  ids,
const std::vector< ProteinIdentification > &  protein_ids,
bool  measure_from_subelements = false,
bool  annotate_ids_with_subelements = false,
const PeakMap spectra = PeakMap() 
)

Mapping method for consensus maps.

If several consensus features lie inside the allowed deviation, the peptide identifications are mapped to all the consensus features.

Parameters
mapConsensusMap to receive the identifications
idsPeptideIdentification for the ConsensusFeatures
protein_idsProteinIdentification for the ConsensusMap
measure_from_subelementsDo distance estimate from FeatureHandles instead of Centroid
annotate_ids_with_subelementsStore map index of FeatureHandle in peptide identification?
spectraWhether precursors not contained in the identifications are annotated with an empty PeptideIdentification object containing the scan index.
Exceptions
Exception::MissingInformationis thrown if the MetaInfoInterface of ids does not contain 'MZ' and 'RT'

◆ annotate() [2/4]

void annotate ( FeatureMap map,
const std::vector< PeptideIdentification > &  ids,
const std::vector< ProteinIdentification > &  protein_ids,
bool  use_centroid_rt = false,
bool  use_centroid_mz = false,
const PeakMap spectra = PeakMap() 
)

Mapping method for feature maps.

If all features have at least one convex hull, peptide positions are matched against the bounding boxes of the convex hulls by default. If not, the positions of the feature centroids are used. The respective coordinates of the centroids are also used for matching (in place of the corresponding ranges from the bounding boxes) if use_centroid_rt or use_centroid_mz are true.

In any case, tolerance in RT and m/z dimension is applied according to the global parameters rt_tolerance and mz_tolerance. Tolerance is understood as "plus or minus x", so the matching range is actually increased by twice the tolerance value.

If several features (incl. tolerance) overlap the position of a peptide identification, the identification is annotated to all of them.

Parameters
mapFeatureMap to receive the identifications
idsPeptideIdentification for the ConsensusFeatures
protein_idsProteinIdentification for the ConsensusMap
use_centroid_rtWhether to use the RT value of feature centroids even if convex hulls are present
use_centroid_mzWhether to use the m/z value of feature centroids even if convex hulls are present
spectraWhether precursors not contained in the identifications are annotated with an empty PeptideIdentification object containing the scan index.
Exceptions
Exception::MissingInformationis thrown if entries of ids do not contain 'MZ' and 'RT' information.

◆ annotate() [3/4]

void annotate ( PeakMap map,
const std::vector< PeptideIdentification > &  peptide_ids,
const std::vector< ProteinIdentification > &  protein_ids,
const bool  clear_ids = false,
const bool  map_ms1 = false 
)

Mapping method for peak maps.

The identifications stored in a PeptideIdentification instance can be added to the corresponding spectrum. Note that a PeptideIdentication is added to ALL spectra which are within the allowed RT and MZ boundaries.

Parameters
mapMSExperiment to receive the identifications
peptide_idsPeptideIdentification for the MSExperiment
protein_idsProteinIdentification for the MSExperiment
clear_idsReset peptide and protein identifications of each scan before annotating
map_ms1Attach Ids to MS1 spectra using RT mapping only (without precursor, without m/z)
Exceptions
Exception::MissingInformationis thrown if entries of peptide_ids do not contain 'MZ' and 'RT' information.

◆ annotate() [4/4]

void annotate ( PeakMap map,
FeatureMap  fmap,
const bool  clear_ids = false,
const bool  map_ms1 = false 
)

Mapping method for peak maps.

Add peptide identifications stored in a feature map to their corresponding spectrum.

This function converts the feature map to a vector of peptide identifications (all peptide IDs from each feature are taken) and calls the respective annotate() function. RT and m/z are taken from the peptides, or (if missing) from the feature itself.

Parameters
mapMSExperiment to receive the identifications
fmapFeatureMap with PeptideIdentifications for the MSExperiment
clear_idsReset peptide and protein identifications of each scan before annotating
map_ms1attach Ids to MS1 spectra using RT mapping only (without precursor, without m/z)

◆ checkHits_()

void checkHits_ ( const std::vector< PeptideIdentification > &  ids) const
protected

helper function that checks if all peptide hits are annotated with RT and MZ meta values

◆ checkMassType_()

bool checkMassType_ ( const std::vector< DataProcessing > &  processing) const
protected

try to determine the type of m/z value reported for features, return whether average peptide masses should be used for matching

◆ getAbsoluteMZTolerance_()

double getAbsoluteMZTolerance_ ( const double  mz) const
protected

compute absolute Da tolerance, for a given m/z, when measure is MEASURE_DA, the value is unchanged, for MEASURE_PPM it is computed according to currently allowed ppm tolerance

◆ getIDDetails_()

void getIDDetails_ ( const PeptideIdentification id,
double &  rt_pep,
DoubleList mz_values,
IntList charges,
bool  use_avg_mass = false 
) const
protected

get RT, m/z and charge value(s) of a PeptideIdentification

  • multiple m/z values are returned if "mz_reference" is set to "peptide" (one for each PeptideHit)
  • one m/z value is returned if "mz_reference" is set to "precursor"

◆ increaseBoundingBox_()

void increaseBoundingBox_ ( DBoundingBox< 2 > &  box)
protected

increase a bounding box by the given RT and m/z tolerances

◆ isMatch_()

bool isMatch_ ( const double  rt_distance,
const double  mz_theoretical,
const double  mz_observed 
) const
protected

check if distance constraint is fulfilled (using rt_tolerance_, mz_tolerance_ and measure_)

◆ mapPrecursorsToIdentifications()

static SpectraIdentificationState mapPrecursorsToIdentifications ( const PeakMap spectra,
const std::vector< PeptideIdentification > &  ids,
double  mz_tol = 0.001,
double  rt_tol = 0.001 
)
inlinestatic

Mapping of peptide identifications to spectra This helper function partitions all spectra into those that had:

  • no precursor (e.g. MS1 spectra),
  • at least one identified precursor,
  • or only unidentified precursor.
    Parameters
    spectraThe mass spectra
    idsThe peptide identifications
    mz_tolTolerance used to map to precursor m/z
    rt_tolTolerance used to map to spectrum retention time
    Note: mz/tol and rt_tol should, in principle, be zero (or close to zero under numeric inaccuracies).
Returns
A struct of vectors holding spectra indices of the partitioning.

References PeptideIdentification::getHits(), PeptideIdentification::getMZ(), SpectrumSettings::getPrecursors(), MSSpectrum::getRT(), PeptideIdentification::getRT(), IDMapper::SpectraIdentificationState::identified, IDMapper::SpectraIdentificationState::no_precursors, MSExperiment::size(), and IDMapper::SpectraIdentificationState::unidentified.

◆ operator=()

IDMapper& operator= ( const IDMapper rhs)

Assignment.

◆ updateMembers_()

void updateMembers_ ( )
overrideprotectedvirtual

This method is used to update extra member variables at the end of the setParameters() method.

Also call it at the end of the derived classes' copy constructor and assignment operator.

The default implementation is empty.

Reimplemented from DefaultParamHandler.

Member Data Documentation

◆ ignore_charge_

bool ignore_charge_
protected

Ignore charge states during matching?

◆ measure_

Measure measure_
protected

Measure used for m/z.

◆ mz_tolerance_

double mz_tolerance_
protected

Allowed m/z deviation.

◆ rt_tolerance_

double rt_tolerance_
protected

Allowed RT deviation.