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)
93 typename ExperimentType::SpectrumType spec;
96 spec.getPrecursors().push_back(it->getPrecursor());
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);
137 template <
typename ExperimentType>
140 typedef typename ExperimentType::SpectrumType SpectrumType;
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)
188 typename ExperimentType::ChromatogramType chrom;
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:197
Product meta information.
Definition: Product.h:49
The representation of a chromatogram.
Definition: MSChromatogram.h:52
Predicate that determines if a spectrum has a certain scan mode.
Definition: RangeUtils.h:206
Peak2D PeakType
Definition: MassTrace.h:49
void setMZ(double mz)
sets the target m/z
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
#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:209
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:51