OpenMS
MetaboTargetedAssay.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Oliver Alka $
6 // $Authors: Oliver Alka $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 #include <map> //insert
13 
16 #include <OpenMS/ANALYSIS/ID/SiriusMSConverter.h> //SiriusMSFile
17 #include <OpenMS/FORMAT/DATAACCESS/SiriusFragmentAnnotation.h> //SiriusTargetDecoySpectra
18 
20 
21 namespace OpenMS
22 {
27  class OPENMS_DLLAPI MetaboTargetedAssay
28  {
29  public:
33  double precursor_int;
35  double precursor_mz;
36  double compound_rt;
42  std::vector<ReactionMonitoringTransition> potential_rmts;
43 
48  {
49  public:
52 
55  compound_info(std::move(info)),
56  target_decoy_spectra(std::move(td_spectra))
57  {}
58  };
59 
64  {
65  public:
68 
69  CompoundSpectrumPair() = default;
71  compound_info(std::move(info)),
72  spectrum(std::move(spectrum))
73  {}
74  };
75 
81  {
82  int target_index = -1;
83  int decoy_index = -1;
84  double target_mz = 0.0;
85  double target_rt = 0.0;
86  double decoy_mz = 0.0;
87  double decoy_rt = 0.0;
88  int target_file_number = 0;
89  int decoy_file_number = 0;
90  };
91 
109  static std::vector<MetaboTargetedAssay> extractMetaboTargetedAssay(const MSExperiment& spectra,
110  const FeatureMapping::FeatureToMs2Indices& feature_ms2_index,
111  const double& precursor_rt_tol,
112  const double& precursor_mz_distance,
113  const double& cosine_sim_threshold,
114  const double& transition_threshold,
115  const double& min_fragment_mz,
116  const double& max_fragment_mz,
117  const bool& method_consensus_spectrum,
118  const bool& exclude_ms2_precursor,
119  const unsigned int& file_counter);
120 
133  static std::vector<MetaboTargetedAssay> extractMetaboTargetedAssayFragmentAnnotation(const std::vector< CompoundTargetDecoyPair >& v_cmp_spec,
134  const double& transition_threshold,
135  const double& min_fragment_mz,
136  const double& max_fragment_mz,
137  const bool& use_exact_mass,
138  const bool& exclude_ms2_precursor);
139 
149  static std::vector< MetaboTargetedAssay::CompoundTargetDecoyPair > pairCompoundWithAnnotatedTDSpectraPairs(const std::vector<SiriusMSFile::CompoundInfo>& v_cmpinfo,
150  const std::vector<SiriusFragmentAnnotation::SiriusTargetDecoySpectra>& annotated_spectra);
162  static std::unordered_map< UInt64, std::vector<MetaboTargetedAssay> > buildAmbiguityGroup(const std::vector<MetaboTargetedAssay>& v_mta,
163  const double& ar_mz_tol,
164  const double& ar_rt_tol,
165  const String& ar_mz_tol_unit_res, size_t in_files_size);
166 
174  static void resolveAmbiguityGroup(std::unordered_map< UInt64, std::vector<MetaboTargetedAssay> >& map_mta_filter,
175  const double& total_occurrence_filter,
176  size_t in_files_size);
177 
178  protected:
179 
181  static constexpr float noise_threshold_constant_ = 1.1;
182 
186  static bool intensityLess_(const Peak1D& a, const Peak1D& b);
187 
191  static int getChargeFromAdduct_(const String& adduct);
192 
200  static void filterBasedOnTotalOccurrence_(std::vector<MetaboTargetedAssay>& mta, double total_occurrence_filter, size_t in_files_size);
201 
207  static void filterBasedOnMolFormAdductOccurrence_(std::vector<MetaboTargetedAssay>& mta);
208 
212  static void sortByPrecursorInt(std::vector<MetaboTargetedAssay>& vec_mta);
213  };
214 
215 } // namespace OpenMS
Stores preprocessed feature mapping information.
Definition: FeatureMapping.h:33
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
CompoundTargetDecoyPair stores a pair of CompoundInfo and MSSpectrum.
Definition: MetaboTargetedAssay.h:64
CompoundSpectrumPair(SiriusMSFile::CompoundInfo info, MSSpectrum spectrum)
Definition: MetaboTargetedAssay.h:70
SiriusMSFile::CompoundInfo compound_info
Definition: MetaboTargetedAssay.h:66
MSSpectrum spectrum
Definition: MetaboTargetedAssay.h:67
CompoundTargetDecoyPair stores a pair of CompoundInfo and MSSpectrum (target, decoy)
Definition: MetaboTargetedAssay.h:48
SiriusMSFile::CompoundInfo compound_info
Definition: MetaboTargetedAssay.h:50
CompoundTargetDecoyPair(SiriusMSFile::CompoundInfo info, SiriusFragmentAnnotation::SiriusTargetDecoySpectra td_spectra)
Definition: MetaboTargetedAssay.h:54
SiriusFragmentAnnotation::SiriusTargetDecoySpectra target_decoy_spectra
Definition: MetaboTargetedAssay.h:51
This class provides methods for the extraction of targeted assays for metabolomics.
Definition: MetaboTargetedAssay.h:28
static void filterBasedOnTotalOccurrence_(std::vector< MetaboTargetedAssay > &mta, double total_occurrence_filter, size_t in_files_size)
Filter one ambiguity group based on occurrence in samples (e.g. at least in 20% of the samples)
static int getChargeFromAdduct_(const String &adduct)
Gets charge from a singly charged adduct ([M+H]+/[M-H]-)
TargetedExperiment::Compound potential_cmp
compound information stored in a TargetedExperiment
Definition: MetaboTargetedAssay.h:41
static bool intensityLess_(const Peak1D &a, const Peak1D &b)
Compare two peaks based on their intensity.
String molecular_formula
< (putative) molecular formula
Definition: MetaboTargetedAssay.h:37
double transition_quality_score
transitions quality score (not yet used)
Definition: MetaboTargetedAssay.h:34
String compound_name
compound name
Definition: MetaboTargetedAssay.h:39
std::vector< ReactionMonitoringTransition > potential_rmts
vector of transitions belonging to the compound
Definition: MetaboTargetedAssay.h:42
static std::vector< MetaboTargetedAssay::CompoundTargetDecoyPair > pairCompoundWithAnnotatedTDSpectraPairs(const std::vector< SiriusMSFile::CompoundInfo > &v_cmpinfo, const std::vector< SiriusFragmentAnnotation::SiriusTargetDecoySpectra > &annotated_spectra)
Pair compound information (SiriusMSFile) with the annotated target and decoy spectrum from SIRIUS/Pas...
static std::vector< MetaboTargetedAssay > extractMetaboTargetedAssay(const MSExperiment &spectra, const FeatureMapping::FeatureToMs2Indices &feature_ms2_index, const double &precursor_rt_tol, const double &precursor_mz_distance, const double &cosine_sim_threshold, const double &transition_threshold, const double &min_fragment_mz, const double &max_fragment_mz, const bool &method_consensus_spectrum, const bool &exclude_ms2_precursor, const unsigned int &file_counter)
Extract a vector of MetaboTargetedAssays without using fragment annotation.
static std::vector< MetaboTargetedAssay > extractMetaboTargetedAssayFragmentAnnotation(const std::vector< CompoundTargetDecoyPair > &v_cmp_spec, const double &transition_threshold, const double &min_fragment_mz, const double &max_fragment_mz, const bool &use_exact_mass, const bool &exclude_ms2_precursor)
Extract a vector of MetaboTargetedAssays using fragment annotation.
int compound_file
integer of file it belongs to in a list of files
Definition: MetaboTargetedAssay.h:38
String compound_adduct
compound adduct
Definition: MetaboTargetedAssay.h:40
double precursor_int
MetaboTargetedAssay is able to store a precursor, metadata as well as compound information.
Definition: MetaboTargetedAssay.h:33
static void filterBasedOnMolFormAdductOccurrence_(std::vector< MetaboTargetedAssay > &mta)
Filter one ambiguity group with multiple possible identifications to use the one with the highest occ...
double compound_rt
compound retention time
Definition: MetaboTargetedAssay.h:36
static void sortByPrecursorInt(std::vector< MetaboTargetedAssay > &vec_mta)
Sort vector of MetaboTargetedAssay by precursor ion intensity.
double precursor_mz
precursor mass-to-charge
Definition: MetaboTargetedAssay.h:35
static void resolveAmbiguityGroup(std::unordered_map< UInt64, std::vector< MetaboTargetedAssay > > &map_mta_filter, const double &total_occurrence_filter, size_t in_files_size)
Resolve ambiguity groups based on occurrence in samples (e.g. at least in 20% of the samples) and if ...
static std::unordered_map< UInt64, std::vector< MetaboTargetedAssay > > buildAmbiguityGroup(const std::vector< MetaboTargetedAssay > &v_mta, const double &ar_mz_tol, const double &ar_rt_tol, const String &ar_mz_tol_unit_res, size_t in_files_size)
Perform feature linking to build ambiguity groups based on the target and decoy position in the vecto...
TargetDecoyGroup stores the mz, rt and file number in correspondence to the index of a MetaboTargeted...
Definition: MetaboTargetedAssay.h:81
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:28
SiriusTargetDecoySpectra holds the target and/or decoy information for one entry (subdirectory from S...
Definition: SiriusFragmentAnnotation.h:24
Definition: SiriusMSConverter.h:38
A more convenient string class.
Definition: String.h:34
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:296
uint64_t UInt64
Unsigned integer type (64bit)
Definition: Types.h:47
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19