59 template <
typename ExperimentType>
62 for (std::vector<MSChromatogram >::const_iterator it = exp.getChromatograms().begin(); it != exp.getChromatograms().end(); ++it)
65 for (
typename ExperimentType::ChromatogramType::const_iterator pit = it->begin(); pit != it->end(); ++pit)
71 spec.getProducts().push_back(it->getProduct());
72 spec.setRT(pit->getRT());
74 spec.setInstrumentSettings(it->getInstrumentSettings());
75 spec.setAcquisitionInfo(it->getAcquisitionInfo());
76 spec.setSourceFile(it->getSourceFile());
90 peak.
setMZ(it->getMZ());
91 peak.setIntensity(pit->getIntensity());
93 exp.addSpectrum(spec);
97 exp.setChromatograms(std::vector<MSChromatogram >());
112 template <
typename ExperimentType>
116 std::map<double, std::map<double, std::vector<SpectrumType> > > chroms;
117 std::map<double, MSChromatogram > chroms_xic;
118 for (
typename ExperimentType::ConstIterator it = exp.begin(); it != exp.end(); ++it)
124 if (it->getPrecursors().size() == 1 && it->size() == 1)
126 chroms[it->getPrecursors().begin()->getMZ()][it->begin()->getMZ()].push_back(*it);
132 else if (it->getPrecursors().size() == 1 && it->size() > 0)
134 for (
Size peak_idx = 0; peak_idx < it->size(); peak_idx++)
139 dummy.push_back((*it)[peak_idx]);
140 chroms[it->getPrecursors().begin()->getMZ()][(*it)[peak_idx].getMZ()].push_back(dummy);
144 else if (force_conversion)
148 double mz = p.getMZ();
150 chr_p.
setRT(it->getRT());
152 if (chroms_xic.find(mz) == chroms_xic.end())
155 chroms_xic[mz].getPrecursor().setMZ(mz);
157 chroms_xic[mz].setInstrumentSettings(it->getInstrumentSettings());
158 chroms_xic[mz].getPrecursor().setMetaValue(
"description",
String(
"XIC @ " +
String(mz)));
159 chroms_xic[mz].setAcquisitionInfo(it->getAcquisitionInfo());
160 chroms_xic[mz].setSourceFile(it->getSourceFile());
162 chroms_xic[mz].push_back(chr_p);
167 OPENMS_LOG_WARN <<
"ChromatogramTools: need exactly one precursor (given " << it->getPrecursors().size() <<
168 ") and one or more product ions (" << it->size() <<
"), skipping conversion of this spectrum to chromatogram. If this is a MS1 chromatogram, please force conversion (e.g. with -convert_to_chromatograms)." << std::endl;
181 for (
auto & chrom: chroms_xic) exp.addChromatogram(chrom.second);
184 typename std::map<double, std::map<double, std::vector<SpectrumType> > >::const_iterator it1 = chroms.begin();
185 for (; it1 != chroms.end(); ++it1)
187 typename std::map<double, std::vector<SpectrumType> >::const_iterator it2 = it1->second.begin();
188 for (; it2 != it1->second.end(); ++it2)
191 chrom.
setPrecursor(*it2->second.begin()->getPrecursors().begin());
193 prod.
setMZ(it2->first);
194 chrom.setProduct(prod);
195 chrom.setInstrumentSettings(it2->second.begin()->getInstrumentSettings());
196 chrom.setAcquisitionInfo(it2->second.begin()->getAcquisitionInfo());
197 chrom.setSourceFile(it2->second.begin()->getSourceFile());
199 typename std::vector<SpectrumType>::const_iterator it3 = it2->second.begin();
200 for (; it3 != it2->second.end(); ++it3)
203 p.
setRT(it3->getRT());
204 p.setIntensity(it3->begin()->getIntensity());
208 chrom.setNativeID(
"chromatogram=" + it2->second.begin()->getNativeID());
210 exp.addChromatogram(chrom);
#define OPENMS_LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged.
Definition: LogStream.h:444
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:28
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:95
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:86
void setPrecursor(const Precursor &precursor)
sets the precursors
@ SELECTED_REACTION_MONITORING_CHROMATOGRAM
Definition: ChromatogramSettings.h:48
@ SELECTED_ION_MONITORING_CHROMATOGRAM
Definition: ChromatogramSettings.h:47
Predicate that determines if a spectrum has a certain scan mode.
Definition: RangeUtils.h:178
@ SRM
Selected reaction monitoring scan Synonyms: 'Multiple reaction monitoring scan',...
Definition: InstrumentSettings.h:33
@ SIM
Selected ion monitoring scan Synonyms: 'Multiple ion monitoring scan', 'SIM scan',...
Definition: InstrumentSettings.h:32
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
void clear(bool clear_meta_data)
Clears all data and meta data.
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: Peak2D.h:178
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:190
Product meta information.
Definition: Product.h:24
void setMZ(double mz)
sets the target m/z
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
MSChromatogram ChromatogramType
Definition: MzDataHandler.h:35
MSSpectrum SpectrumType
Definition: MzDataHandler.h:34
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Peak2D PeakType
Definition: MassTrace.h:21