OpenMS
Loading...
Searching...
No Matches
MRMFeatureAccessOpenMS.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: Hannes Roest $
6// $Authors: Hannes Roest $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12
17
18#include <memory>
19
20// These classes are minimal implementations of the interfaces defined in ITransition:
21// - IFeature
22// - IMRMFeature
23// - ITransitionGroup
24// - ISignalToNoise
25
26namespace OpenMS
27{
32 class OPENMS_DLLAPI FeatureOpenMS :
34 {
35public:
36
37 explicit FeatureOpenMS(Feature& feature);
38
39 ~FeatureOpenMS() override;
40
41 void getRT(std::vector<double>& rt) const override;
42
43 void getIntensity(std::vector<double>& intens) const override;
44
45 float getIntensity() const override;
46
47 double getRT() const override;
48
49private:
51 };
52
57 class OPENMS_DLLAPI MRMFeatureOpenMS :
59 {
60public:
61
62 explicit MRMFeatureOpenMS(MRMFeature& mrmfeature);
63
65
66 std::shared_ptr<OpenSwath::IFeature> getFeature(std::string nativeID) override;
67
68 std::shared_ptr<OpenSwath::IFeature> getPrecursorFeature(std::string nativeID) override;
69
70 std::vector<std::string> getNativeIDs() const override;
71
72 std::vector<std::string> getPrecursorIDs() const override;
73
74 float getIntensity() const override;
75
76 double getRT() const override;
77
78 double getMetaValue(std::string name) const;
79
80 size_t size() const override;
81
82private:
84 std::map<std::string, std::shared_ptr<FeatureOpenMS> > features_;
85 std::map<std::string, std::shared_ptr<FeatureOpenMS> > precursor_features_;
86 };
87
92 template <typename SpectrumT, typename TransitionT>
95 {
96public:
97
102
104 {
105 }
106
107 std::size_t size() const override
108 {
109 return trgroup_.size();
110 }
111
112 std::vector<std::string> getNativeIDs() const override
113 {
114 std::vector<std::string> result;
115 for (std::size_t i = 0; i < this->size(); i++)
116 {
117 result.push_back(trgroup_.getChromatograms()[i].getNativeID());
118 }
119 return result;
120 }
121
122 void getLibraryIntensities(std::vector<double>& intensities) const override
123 {
124 trgroup_.getLibraryIntensity(intensities);
125 }
126
127private:
129 };
130
135 template <typename ContainerT>
138 {
139public:
140
141 SignalToNoiseOpenMS(ContainerT& chromat,
142 double sn_win_len_, unsigned int sn_bin_count_, bool write_log_messages) :
143 chromatogram_(chromat), sn_()
144 {
145 OpenMS::Param snt_parameters = sn_.getParameters();
146 snt_parameters.setValue("win_len", sn_win_len_);
147 snt_parameters.setValue("bin_count", sn_bin_count_);
148
149 if (write_log_messages)
150 {
151 snt_parameters.setValue("write_log_messages", "true");
152 }
153 else
154 {
155 snt_parameters.setValue("write_log_messages", "false");
156 }
157
158 sn_.setParameters(snt_parameters);
160 }
161
162 double getValueAtRT(double RT) override
163 {
164 if (chromatogram_.empty()) {return -1;}
165
166 // Note that MZBegin does not seem to return the same iterator on
167 // different setups, see https://github.com/OpenMS/OpenMS/issues/1163
168 auto iter = chromatogram_.PosEnd(RT);
169
170 // ensure that iter is valid
171 if (iter == chromatogram_.end())
172 {
173 iter--;
174 }
175
176 auto prev = iter;
177 if (prev != chromatogram_.begin())
178 {
179 prev--;
180 }
181
182 if (std::fabs(prev->getPos() - RT) < std::fabs(iter->getPos() - RT) )
183 {
184 // prev is closer to the apex
185 return sn_.getSignalToNoise((Size) distance(chromatogram_.begin(),prev));
186 }
187 else
188 {
189 // iter is closer to the apex
190 return sn_.getSignalToNoise((Size) distance(chromatogram_.begin(),iter));
191 }
192 }
193
194private:
195
196 const ContainerT& chromatogram_;
198
199 };
200
201}
202
203
const Param & getParameters() const
Non-mutable access to the parameters.
void setParameters(const Param &param)
Sets the parameters.
An implementation of the OpenSWATH Feature Access interface using OpenMS.
Definition MRMFeatureAccessOpenMS.h:34
void getRT(std::vector< double > &rt) const override
~FeatureOpenMS() override
double getRT() const override
float getIntensity() const override
Feature * feature_
Definition MRMFeatureAccessOpenMS.h:50
FeatureOpenMS(Feature &feature)
void getIntensity(std::vector< double > &intens) const override
An LC-MS feature.
Definition Feature.h:46
An implementation of the OpenSWATH MRM Feature Access interface using OpenMS.
Definition MRMFeatureAccessOpenMS.h:59
std::vector< std::string > getNativeIDs() const override
MRMFeatureOpenMS(MRMFeature &mrmfeature)
double getRT() const override
float getIntensity() const override
std::shared_ptr< OpenSwath::IFeature > getFeature(std::string nativeID) override
std::vector< std::string > getPrecursorIDs() const override
std::map< std::string, std::shared_ptr< FeatureOpenMS > > precursor_features_
Definition MRMFeatureAccessOpenMS.h:85
std::map< std::string, std::shared_ptr< FeatureOpenMS > > features_
Definition MRMFeatureAccessOpenMS.h:84
const MRMFeature & mrmfeature_
Definition MRMFeatureAccessOpenMS.h:83
size_t size() const override
double getMetaValue(std::string name) const
std::shared_ptr< OpenSwath::IFeature > getPrecursorFeature(std::string nativeID) override
A multi-chromatogram MRM feature.
Definition MRMFeature.h:26
The representation of a group of transitions in a targeted proteomics experiment.
Definition MRMTransitionGroup.h:42
Size size() const
Definition MRMTransitionGroup.h:99
std::vector< ChromatogramType > & getChromatograms()
Definition MRMTransitionGroup.h:160
void getLibraryIntensity(std::vector< double > &result) const
Definition MRMTransitionGroup.h:319
Management and storage of parameters / INI files.
Definition Param.h:46
void setValue(const std::string &key, const ParamValue &value, const std::string &description="", const std::vector< std::string > &tags=std::vector< std::string >())
Sets a value.
virtual void init(const Container &c)
Set the start and endpoint of the raw data interval, for which signal to noise ratios will be estimat...
Definition SignalToNoiseEstimator.h:75
virtual double getSignalToNoise(const Size index) const
Definition SignalToNoiseEstimator.h:83
An implementation of the OpenSWATH SignalToNoise Access interface using OpenMS.
Definition MRMFeatureAccessOpenMS.h:138
OpenMS::SignalToNoiseEstimatorMedian< ContainerT > sn_
Definition MRMFeatureAccessOpenMS.h:197
SignalToNoiseOpenMS(ContainerT &chromat, double sn_win_len_, unsigned int sn_bin_count_, bool write_log_messages)
Definition MRMFeatureAccessOpenMS.h:141
const ContainerT & chromatogram_
Definition MRMFeatureAccessOpenMS.h:196
double getValueAtRT(double RT) override
Definition MRMFeatureAccessOpenMS.h:162
An implementation of the OpenSWATH Transition Group Access interface using OpenMS.
Definition MRMFeatureAccessOpenMS.h:95
~TransitionGroupOpenMS() override
Definition MRMFeatureAccessOpenMS.h:103
std::vector< std::string > getNativeIDs() const override
Definition MRMFeatureAccessOpenMS.h:112
const MRMTransitionGroup< SpectrumT, TransitionT > & trgroup_
Definition MRMFeatureAccessOpenMS.h:128
TransitionGroupOpenMS(MRMTransitionGroup< SpectrumT, TransitionT > &trgroup)
Definition MRMFeatureAccessOpenMS.h:98
void getLibraryIntensities(std::vector< double > &intensities) const override
Definition MRMFeatureAccessOpenMS.h:122
std::size_t size() const override
Definition MRMFeatureAccessOpenMS.h:107
Definition ITransition.h:21
Definition ITransition.h:31
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
@ RT
RT in seconds.
Definition ITransition.h:53
Definition ITransition.h:45