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)
67 typename ExperimentType::SpectrumType spec;
70 spec.getPrecursors().push_back(it->getPrecursor());
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());
89 spec.emplace_back(it->getMZ(), pit->getIntensity());
90 exp.addSpectrum(spec);
94 exp.setChromatograms(std::vector<MSChromatogram >());
112 typedef typename ExperimentType::SpectrumType
SpectrumType;
113 std::map<double, std::map<double, std::vector<SpectrumType> > > chroms;
114 std::map<double, MSChromatogram > chroms_xic;
115 for (
typename ExperimentType::ConstIterator it = exp.begin(); it != exp.end(); ++it)
121 if (it->getPrecursors().size() == 1 && it->size() == 1)
123 chroms[it->getPrecursors().begin()->getMZ()][it->begin()->getMZ()].push_back(*it);
129 else if (it->getPrecursors().size() == 1 && it->size() > 0)
131 for (
Size peak_idx = 0; peak_idx < it->size(); peak_idx++)
136 dummy.push_back((*it)[peak_idx]);
139 chroms[it->getPrecursors().begin()->getMZ()][(*it)[peak_idx].getMZ()].push_back(dummy);
143 else if (force_conversion)
147 double mz = p.getMZ();
149 chr_p.
setRT(it->getRT());
151 if (!chroms_xic.contains(mz))
155 chroms_xic[mz].getPrecursor().setMZ(mz);
157 chroms_xic[mz].setInstrumentSettings(it->getInstrumentSettings());
158 chroms_xic[mz].getPrecursor().setMetaValue(
"description",std::string(
"XIC @ " +
StringUtils::toStr(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)
190 typename ExperimentType::ChromatogramType chrom;
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)
202 typename ExperimentType::ChromatogramType::PeakType p;
203 p.setRT(it3->getRT());
204 p.setIntensity(it3->begin()->getIntensity());
208 chrom.setNativeID(
"chromatogram=" + it2->second.begin()->getNativeID());
210 exp.addChromatogram(chrom);