OpenMS  3.0.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-2022.
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 
79  CompoundTargetDecoyPair() = default;
81  compound_info(std::move(info)),
82  target_decoy_spectra(std::move(td_spectra))
83  {}
84  };
85 
90  {
91  public:
94 
95  CompoundSpectrumPair() = default;
97  compound_info(std::move(info)),
98  spectrum(std::move(spectrum))
99  {}
100  };
101 
107  {
108  int target_index = -1;
109  int decoy_index = -1;
110  double target_mz = 0.0;
111  double target_rt = 0.0;
112  double decoy_mz = 0.0;
113  double decoy_rt = 0.0;
114  int target_file_number = 0;
115  int decoy_file_number = 0;
116  };
117 
135  static std::vector<MetaboTargetedAssay> extractMetaboTargetedAssay(const MSExperiment& spectra,
136  const FeatureMapping::FeatureToMs2Indices& feature_ms2_index,
137  const double& precursor_rt_tol,
138  const double& precursor_mz_distance,
139  const double& cosine_sim_threshold,
140  const double& transition_threshold,
141  const double& min_fragment_mz,
142  const double& max_fragment_mz,
143  const bool& method_consensus_spectrum,
144  const bool& exclude_ms2_precursor,
145  const unsigned int& file_counter);
146 
160  static std::vector<MetaboTargetedAssay> extractMetaboTargetedAssayFragmentAnnotation(const std::vector< CompoundTargetDecoyPair >& v_cmp_spec,
161  const double& transition_threshold,
162  const double& min_fragment_mz,
163  const double& max_fragment_mz,
164  const bool& use_exact_mass,
165  const bool& exclude_ms2_precursor,
166  const unsigned int& file_counter);
167 
177  static std::vector< MetaboTargetedAssay::CompoundTargetDecoyPair > pairCompoundWithAnnotatedTDSpectraPairs(const std::vector<SiriusMSFile::CompoundInfo>& v_cmpinfo,
178  const std::vector<SiriusFragmentAnnotation::SiriusTargetDecoySpectra>& annotated_spectra);
179  static std::vector< MetaboTargetedAssay::CompoundSpectrumPair > pairCompoundWithAnnotatedSpectra(const std::vector<SiriusMSFile::CompoundInfo>& v_cmpinfo,
180  const std::vector<MSSpectrum>& annotated_spectra);
181 
193  static std::unordered_map< UInt64, std::vector<MetaboTargetedAssay> > buildAmbiguityGroup(const std::vector<MetaboTargetedAssay>& v_mta,
194  const double& ar_mz_tol,
195  const double& ar_rt_tol,
196  const String& ar_mz_tol_unit_res, size_t in_files_size);
197 
206  static void resolveAmbiguityGroup(std::unordered_map< UInt64, std::vector<MetaboTargetedAssay> >& map_mta_filter,
207  const double& total_occurrence_filter,
208  size_t in_files_size);
209 
210  protected:
211 
213  static constexpr float noise_threshold_constant_ = 1.1;
214 
218  static bool intensityLess_(const Peak1D& a, const Peak1D& b);
219 
223  static int getChargeFromAdduct_(const String& adduct);
224 
233  static void filterBasedOnTotalOccurrence_(std::vector<MetaboTargetedAssay>& mta, double total_occurrence_filter, size_t in_files_size);
234 
240  static void filterBasedOnMolFormAdductOccurrence_(std::vector<MetaboTargetedAssay>& mta);
241 
245  static void sortByPrecursorInt(std::vector<MetaboTargetedAssay>& vec_mta);
246  };
247 
248 } // namespace OpenMS
TargetedExperiment.h
OpenMS::UInt64
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
OpenMS::MetaboTargetedAssay::precursor_mz
double precursor_mz
precursor mass-to-charge
Definition: MetaboTargetedAssay.h:61
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::MetaboTargetedAssay::transition_quality_score
double transition_quality_score
transitions quality score (not yet used)
Definition: MetaboTargetedAssay.h:60
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
OpenMS::MetaboTargetedAssay::compound_rt
double compound_rt
compound retention time
Definition: MetaboTargetedAssay.h:62
OpenMS::MetaboTargetedAssay::CompoundTargetDecoyPair::compound_info
SiriusMSFile::CompoundInfo compound_info
Definition: MetaboTargetedAssay.h:76
OpenMS::MetaboTargetedAssay::potential_rmts
std::vector< ReactionMonitoringTransition > potential_rmts
vector of transitions belonging to the compound
Definition: MetaboTargetedAssay.h:68
OpenMS::MetaboTargetedAssay::CompoundTargetDecoyPair::CompoundTargetDecoyPair
CompoundTargetDecoyPair(SiriusMSFile::CompoundInfo info, SiriusFragmentAnnotation::SiriusTargetDecoySpectra td_spectra)
Definition: MetaboTargetedAssay.h:80
OpenMS::FeatureMapping::FeatureToMs2Indices
Stores preprocessed feature mapping information.
Definition: FeatureMapping.h:58
OpenMS::MetaboTargetedAssay::CompoundSpectrumPair::compound_info
SiriusMSFile::CompoundInfo compound_info
Definition: MetaboTargetedAssay.h:92
ReactionMonitoringTransition.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Exception.h
OpenMS::MetaboTargetedAssay
This class provides methods for the extraction of targeted assays for metabolomics.
Definition: MetaboTargetedAssay.h:53
SiriusMSConverter.h
OpenMS::MetaboTargetedAssay::potential_cmp
TargetedExperiment::Compound potential_cmp
compound information stored in a TargetedExperiment
Definition: MetaboTargetedAssay.h:67
OpenMS::MetaboTargetedAssay::molecular_formula
String molecular_formula
< (putative) molecular formula
Definition: MetaboTargetedAssay.h:63
OpenMS::TargetedExperimentHelper::Compound
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:321
OpenMS::MetaboTargetedAssay::compound_adduct
String compound_adduct
compound adduct
Definition: MetaboTargetedAssay.h:66
OpenMS::MetaboTargetedAssay::CompoundTargetDecoyPair
CompoundTargetDecoyPair stores a pair of CompoundInfo and MSSpectrum (target, decoy)
Definition: MetaboTargetedAssay.h:73
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:53
SiriusFragmentAnnotation.h
OpenMS::MetaboTargetedAssay::TargetDecoyGroup
TargetDecoyGroup stores the mz, rt and file number in correspondence to the index of a MetaboTargeted...
Definition: MetaboTargetedAssay.h:106
OpenMS::MetaboTargetedAssay::CompoundSpectrumPair::spectrum
MSSpectrum spectrum
Definition: MetaboTargetedAssay.h:93
OpenMS::MetaboTargetedAssay::CompoundSpectrumPair::CompoundSpectrumPair
CompoundSpectrumPair(SiriusMSFile::CompoundInfo info, MSSpectrum spectrum)
Definition: MetaboTargetedAssay.h:96
OpenMS::SiriusFragmentAnnotation::SiriusTargetDecoySpectra
SiriusTargetDecoySpectra holds the target and/or decoy information for one entry (subdirectory from S...
Definition: SiriusFragmentAnnotation.h:48
OpenMS::SiriusMSFile::CompoundInfo
Definition: SiriusMSConverter.h:63
OpenMS::MetaboTargetedAssay::precursor_int
double precursor_int
MetaboTargetedAssay is able to store a precursor, metadata as well as compound information.
Definition: MetaboTargetedAssay.h:59
OpenMS::MetaboTargetedAssay::CompoundSpectrumPair
CompoundTargetDecoyPair stores a pair of CompoundInfo and MSSpectrum.
Definition: MetaboTargetedAssay.h:89
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
StandardTypes.h
OpenMS::MetaboTargetedAssay::compound_name
String compound_name
compound name
Definition: MetaboTargetedAssay.h:65
OpenMS::MetaboTargetedAssay::CompoundTargetDecoyPair::target_decoy_spectra
SiriusFragmentAnnotation::SiriusTargetDecoySpectra target_decoy_spectra
Definition: MetaboTargetedAssay.h:77
OpenMS::MetaboTargetedAssay::compound_file
int compound_file
integer of file it belongs to in a list of files
Definition: MetaboTargetedAssay.h:64