OpenMS  2.8.0
MetaboTargetedAssay.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Oliver Alka $
32 // $Authors: Oliver Alka $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
38 #include <map> //insert
39 
42 #include <OpenMS/ANALYSIS/ID/SiriusMSConverter.h> //SiriusMSFile
43 #include <OpenMS/FORMAT/DATAACCESS/SiriusFragmentAnnotation.h> //SiriusTargetDecoySpectra
44 
46 
47 namespace OpenMS
48 {
53  class OPENMS_DLLAPI MetaboTargetedAssay
54  {
55  public:
59  double precursor_int;
61  double precursor_mz;
62  double compound_rt;
68  std::vector<ReactionMonitoringTransition> potential_rmts;
69 
74  {
75  public:
78 
80  CompoundTargetDecoyPair(SiriusMSFile::CompoundInfo info, SiriusFragmentAnnotation::SiriusTargetDecoySpectra td_spectra) : compound_info(info), target_decoy_spectra(td_spectra) {}
81  };
82 
88  {
89  public:
90  int target_index = -1;
91  int decoy_index = -1;
92  double target_mz = 0.0;
93  double target_rt = 0.0;
94  double decoy_mz = 0.0;
95  double decoy_rt = 0.0;
96  int target_file_number = 0;
97  int decoy_file_number = 0;
98  };
99 
117  static std::vector<MetaboTargetedAssay> extractMetaboTargetedAssay(const MSExperiment& spectra,
118  const FeatureMapping::FeatureToMs2Indices& feature_ms2_index,
119  const double& precursor_rt_tol,
120  const double& precursor_mz_distance,
121  const double& cosine_sim_threshold,
122  const double& transition_threshold,
123  const double& min_fragment_mz,
124  const double& max_fragment_mz,
125  const bool& method_consensus_spectrum,
126  const bool& exclude_ms2_precursor,
127  const unsigned int& file_counter);
128 
142  static std::vector<MetaboTargetedAssay> extractMetaboTargetedAssayFragmentAnnotation(const std::vector< CompoundTargetDecoyPair >& v_cmp_spec,
143  const double& transition_threshold,
144  const double& min_fragment_mz,
145  const double& max_fragment_mz,
146  const bool& use_exact_mass,
147  const bool& exclude_ms2_precursor,
148  const unsigned int& file_counter);
149 
158  static std::vector< MetaboTargetedAssay::CompoundTargetDecoyPair > pairCompoundWithAnnotatedSpectra(const std::vector<SiriusMSFile::CompoundInfo>& v_cmpinfo,
159  const std::vector<SiriusFragmentAnnotation::SiriusTargetDecoySpectra>& annotated_spectra);
171  static std::unordered_map< UInt64, std::vector<MetaboTargetedAssay> > buildAmbiguityGroup(const std::vector<MetaboTargetedAssay>& v_mta,
172  const double& ar_mz_tol,
173  const double& ar_rt_tol,
174  const String& ar_mz_tol_unit_res, size_t in_files_size);
175 
184  static void resolveAmbiguityGroup(std::unordered_map< UInt64, std::vector<MetaboTargetedAssay> >& map_mta_filter,
185  const double& total_occurrence_filter,
186  size_t in_files_size);
187 
188  protected:
189 
191  static constexpr float noise_threshold_constant_ = 1.1;
192 
196  static bool intensityLess_(Peak1D a, Peak1D b);
197 
201  static int getChargeFromAdduct_(const String& adduct);
202 
211  static void filterBasedOnTotalOccurrence_(std::vector<MetaboTargetedAssay>& mta, double total_occurrence_filter, size_t in_files_size);
212 
218  static void filterBasedOnMolFormAdductOccurrence_(std::vector<MetaboTargetedAssay>& mta);
219 
223  static void sortByPrecursorInt(std::vector<MetaboTargetedAssay>& vec_mta);
224  };
225 
226 } // namespace OpenMS
Stores preprocessed feature mapping information.
Definition: FeatureMapping.h:59
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:73
CompoundTargetDecoyPair stores a pair of CompoundInfo and MSSpectrum (target, decoy)
Definition: MetaboTargetedAssay.h:74
SiriusMSFile::CompoundInfo compound_info
Definition: MetaboTargetedAssay.h:76
CompoundTargetDecoyPair(SiriusMSFile::CompoundInfo info, SiriusFragmentAnnotation::SiriusTargetDecoySpectra td_spectra)
Definition: MetaboTargetedAssay.h:80
SiriusFragmentAnnotation::SiriusTargetDecoySpectra target_decoy_spectra
Definition: MetaboTargetedAssay.h:77
This class provides methods for the extraction of targeted assays for metabolomics.
Definition: MetaboTargetedAssay.h:54
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:67
String molecular_formula
< (putative) molecular formula
Definition: MetaboTargetedAssay.h:63
double transition_quality_score
transitions quality score (not yet used)
Definition: MetaboTargetedAssay.h:60
String compound_name
compound name
Definition: MetaboTargetedAssay.h:65
std::vector< ReactionMonitoringTransition > potential_rmts
vector of transitions belonging to the compound
Definition: MetaboTargetedAssay.h:68
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, const unsigned int &file_counter)
Extract a vector of MetaboTargetedAssays using fragment annotation.
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.
int compound_file
integer of file it belongs to in a list of files
Definition: MetaboTargetedAssay.h:64
String compound_adduct
compound adduct
Definition: MetaboTargetedAssay.h:66
static bool intensityLess_(Peak1D a, Peak1D b)
Compare two peaks based on their intensity.
double precursor_int
MetaboTargetedAssay is able to store a precursor, metadata as well as compound information.
Definition: MetaboTargetedAssay.h:59
static void filterBasedOnMolFormAdductOccurrence_(std::vector< MetaboTargetedAssay > &mta)
Filter one ambiguity group with multiple possible identifications to use the one with the highest occ...
static std::vector< MetaboTargetedAssay::CompoundTargetDecoyPair > pairCompoundWithAnnotatedSpectra(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...
double compound_rt
compound retention time
Definition: MetaboTargetedAssay.h:62
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:61
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:88
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
SiriusTargetDecoySpectra holds the target and/or decoy information for one entry (subdirectory from S...
Definition: SiriusFragmentAnnotation.h:49
Definition: SiriusMSConverter.h:64
A more convenient string class.
Definition: String.h:60
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:323
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47