35 #ifndef OPENMS_KERNEL_CHROMATOGRAMTOOLS_H 36 #define OPENMS_KERNEL_CHROMATOGRAMTOOLS_H 85 template <
typename ExperimentType>
88 for (std::vector<MSChromatogram >::const_iterator it = exp.getChromatograms().begin(); it != exp.getChromatograms().end(); ++it)
91 for (
typename ExperimentType::ChromatogramType::const_iterator pit = it->begin(); pit != it->end(); ++pit)
97 spec.getProducts().push_back(it->getProduct());
98 spec.setRT(pit->getRT());
100 spec.setInstrumentSettings(it->getInstrumentSettings());
101 spec.setAcquisitionInfo(it->getAcquisitionInfo());
102 spec.setSourceFile(it->getSourceFile());
116 peak.
setMZ(it->getMZ());
117 peak.setIntensity(pit->getIntensity());
118 spec.push_back(peak);
119 exp.addSpectrum(spec);
123 exp.setChromatograms(std::vector<MSChromatogram >());
137 template <
typename ExperimentType>
142 for (
typename ExperimentType::ConstIterator it = exp.begin(); it != exp.end(); ++it)
148 if (it->getPrecursors().size() == 1 && it->size() == 1)
150 chroms[it->getPrecursors().begin()->getMZ()][it->begin()->getMZ()].push_back(*it);
156 else if (it->getPrecursors().size() == 1 && it->size() > 0)
158 for (
Size peak_idx = 0; peak_idx < it->size(); peak_idx++)
161 SpectrumType dummy = *it;
163 dummy.push_back((*it)[peak_idx]);
164 chroms[it->getPrecursors().begin()->getMZ()][(*it)[peak_idx].getMZ()].push_back(dummy);
169 LOG_WARN <<
"ChromatogramTools: need exactly one precursor (given " << it->getPrecursors().size() <<
170 ") and one or more product ions (" << it->size() <<
"), skipping conversion of this spectrum to chromatogram." << std::endl;
183 for (; it1 != chroms.end(); ++it1)
186 for (; it2 != it1->second.end(); ++it2)
189 chrom.
setPrecursor(*it2->second.begin()->getPrecursors().begin());
191 prod.
setMZ(it2->first);
192 chrom.setProduct(prod);
193 chrom.setInstrumentSettings(it2->second.begin()->getInstrumentSettings());
194 chrom.setAcquisitionInfo(it2->second.begin()->getAcquisitionInfo());
195 chrom.setSourceFile(it2->second.begin()->getSourceFile());
197 typename std::vector<SpectrumType>::const_iterator it3 = it2->second.begin();
198 for (; it3 != it2->second.end(); ++it3)
201 p.
setRT(it3->getRT());
202 p.setIntensity(it3->begin()->getIntensity());
206 chrom.setNativeID(
"chromatogram=" + it2->second.begin()->getNativeID());
208 exp.addChromatogram(chrom);
222 #endif // OPENMS_KERNEL_CHROMATOGRAMTOOLS_H
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: Peak2D.h:203
Product meta information.
Definition: Product.h:49
Predicate that determines if a spectrum has a certain scan mode.
Definition: RangeUtils.h:207
Peak2D PeakType
Definition: MassTrace.h:48
void setMZ(double mz)
sets the target m/z
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
MSChromatogram ChromatogramType
Definition: MzDataHandler.h:63
Selected reaction monitoring scan Synonyms: 'Multiple reaction monitoring scan', 'SRM scan', 'MRM scan'.
Definition: InstrumentSettings.h:60
#define LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged...
Definition: LogStream.h:451
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:215
Selected ion monitoring scan Synonyms: 'Multiple ion monitoring scan', 'SIM scan', 'MIM scan'.
Definition: InstrumentSettings.h:59
void clear(bool clear_meta_data)
Clears all data and meta data.
Definition: ChromatogramSettings.h:74
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
Definition: ChromatogramSettings.h:73
void setPrecursor(const Precursor &precursor)
sets the precursors
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:51
MSSpectrum SpectrumType
Definition: MzDataHandler.h:62