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 >());
138 template <
typename ExperimentType>
142 std::map<double, std::map<double, std::vector<SpectrumType> > > chroms;
143 std::map<double, MSChromatogram > chroms_xic;
144 for (
typename ExperimentType::ConstIterator it = exp.begin(); it != exp.end(); ++it)
150 if (it->getPrecursors().size() == 1 && it->size() == 1)
152 chroms[it->getPrecursors().begin()->getMZ()][it->begin()->getMZ()].push_back(*it);
158 else if (it->getPrecursors().size() == 1 && it->size() > 0)
160 for (
Size peak_idx = 0; peak_idx < it->size(); peak_idx++)
165 dummy.push_back((*it)[peak_idx]);
166 chroms[it->getPrecursors().begin()->getMZ()][(*it)[peak_idx].getMZ()].push_back(dummy);
170 else if (force_conversion)
174 double mz = p.getMZ();
176 chr_p.
setRT(it->getRT());
178 if (chroms_xic.find(mz) == chroms_xic.end())
181 chroms_xic[mz].getPrecursor().setMZ(mz);
183 chroms_xic[mz].setInstrumentSettings(it->getInstrumentSettings());
184 chroms_xic[mz].getPrecursor().setMetaValue(
"description",
String(
"XIC @ " +
String(mz)));
185 chroms_xic[mz].setAcquisitionInfo(it->getAcquisitionInfo());
186 chroms_xic[mz].setSourceFile(it->getSourceFile());
188 chroms_xic[mz].push_back(chr_p);
193 OPENMS_LOG_WARN <<
"ChromatogramTools: need exactly one precursor (given " << it->getPrecursors().size() <<
194 ") 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;
207 for (
auto & chrom: chroms_xic) exp.addChromatogram(chrom.second);
210 typename std::map<double, std::map<double, std::vector<SpectrumType> > >::const_iterator it1 = chroms.begin();
211 for (; it1 != chroms.end(); ++it1)
213 typename std::map<double, std::vector<SpectrumType> >::const_iterator it2 = it1->second.begin();
214 for (; it2 != it1->second.end(); ++it2)
217 chrom.
setPrecursor(*it2->second.begin()->getPrecursors().begin());
219 prod.
setMZ(it2->first);
220 chrom.setProduct(prod);
221 chrom.setInstrumentSettings(it2->second.begin()->getInstrumentSettings());
222 chrom.setAcquisitionInfo(it2->second.begin()->getAcquisitionInfo());
223 chrom.setSourceFile(it2->second.begin()->getSourceFile());
225 typename std::vector<SpectrumType>::const_iterator it3 = it2->second.begin();
226 for (; it3 != it2->second.end(); ++it3)
229 p.
setRT(it3->getRT());
230 p.setIntensity(it3->begin()->getIntensity());
234 chrom.setNativeID(
"chromatogram=" + it2->second.begin()->getNativeID());
236 exp.addChromatogram(chrom);