94 template <
typename ExperimentT>
98 double mz_extraction_window,
100 double rt_extraction_window,
106 Size input_size = input.size();
112 int used_filter = getFilterNr_(filter);
113 populatePeptideRTMap_(transition_exp, rt_extraction_window);
121 std::vector<typename ExperimentT::ChromatogramType> chromatograms;
122 prepareSpectra_(settings, chromatograms, transition_exp);
125 startProgress(0, input_size,
"Extracting chromatograms");
126 for (
Size scan_idx = 0; scan_idx < input_size; ++scan_idx)
128 setProgress(scan_idx);
130 if (input[scan_idx].size() == 0)
136 double integrated_intensity = 0;
142 for (
Size k = 0;
k < chromatograms.size(); ++
k)
145 double current_rt = input[scan_idx].getRT();
146 if (outsideExtractionWindow_(transition_exp.
getTransitions()[
k], current_rt, trafo, rt_extraction_window))
154 if (used_filter == 1)
156 extract_value_tophat(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
158 else if (used_filter == 2)
160 extract_value_bartlett(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
165 p.setIntensity(integrated_intensity);
166 chromatograms[
k].push_back(p);
172 output.setChromatograms(chromatograms);
193 std::vector< OpenSwath::ChromatogramPtr >& output,
194 const std::vector<ExtractionCoordinates>& extraction_coordinates,
195 double mz_extraction_window,
200 extraction_coordinates, mz_extraction_window, ppm, -1, filter);
222 std::vector< OpenSwath::ChromatogramPtr >& output,
223 const std::vector<ExtractionCoordinates>& extraction_coordinates,
224 double mz_extraction_window,
226 double im_extraction_window,
230 extraction_coordinates, mz_extraction_window, ppm, im_extraction_window, filter);
256 static void prepare_coordinates(std::vector< OpenSwath::ChromatogramPtr > & output_chromatograms,
257 std::vector< ExtractionCoordinates > & coordinates,
259 const double rt_extraction_window,
262 static void prepare_coordinates(std::vector< OpenSwath::ChromatogramPtr > & output_chromatograms,
263 std::vector< ExtractionCoordinates > & coordinates,
265 const double rt_extraction_window,
281 template <
typename TransitionExpT>
283 const std::vector< ChromatogramExtractor::ExtractionCoordinates > & coordinates,
284 TransitionExpT& transition_exp_used,
286 std::vector<OpenMS::MSChromatogram > & output_chromatograms,
289 typedef std::map<String, const typename TransitionExpT::Transition* > TransitionMapType;
290 TransitionMapType trans_map;
291 for (
Size i = 0; i < transition_exp_used.getTransitions().size(); i++)
293 trans_map[transition_exp_used.getTransitions()[i].getNativeID()] = &transition_exp_used.getTransitions()[i];
296 for (
Size i = 0; i < chromatograms.size(); i++)
319 String r = extract_id_(transition_exp_used, coord.
id, prec_charge);
325 typename TransitionExpT::Transition transition = (*trans_map[coord.
id]);
327 prec.
setMZ(transition.getPrecursorMZ());
336 prod.
setMZ(transition.getProductMZ());
342 if (!transition.getPeptideRef().empty())
345 String r = extract_id_(transition_exp_used, transition.getPeptideRef(), prec_charge);
352 String r = extract_id_(transition_exp_used, transition.getCompoundRef(), prec_charge);
369 output_chromatograms.push_back(chrom);
374 template <
typename SpectrumT>
378 double& integrated_intensity,
379 const double extract_window,
382 integrated_intensity = 0;
383 if (input.size() == 0)
392 left = mz - mz * extract_window / 2.0 * 1.0e-6;
393 right = mz + mz * extract_window / 2.0 * 1.0e-6;
397 left = mz - extract_window / 2.0;
398 right = mz + extract_window / 2.0;
404 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
413 if (peak_idx >= input.size())
415 walker = input.size() - 1;
419 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
421 integrated_intensity += input[walker].getIntensity();
432 if (walker == 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
434 integrated_intensity += input[walker].getIntensity();
437 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
439 integrated_intensity += input[walker].getIntensity(); walker--;
445 if (walker < input.size() )
449 while (walker < input.size() && input[walker].getMZ() > left && input[walker].getMZ() < right)
451 integrated_intensity += input[walker].getIntensity(); walker++;
456 template <
typename SpectrumT>
460 double& integrated_intensity,
461 const double extract_window,
464 integrated_intensity = 0;
465 if (input.size() == 0)
471 double left, right, half_window_size, weight;
474 half_window_size = mz * extract_window / 2.0 * 1.0e-6;
475 left = mz - mz * extract_window / 2.0 * 1.0e-6;
476 right = mz + mz * extract_window / 2.0 * 1.0e-6;
480 half_window_size = extract_window / 2.0;
481 left = mz - extract_window / 2.0;
482 right = mz + extract_window / 2.0;
488 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
497 if (peak_idx >= input.size())
499 walker = input.size() - 1;
503 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
505 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
506 integrated_intensity += input[walker].getIntensity() * weight;
517 if (walker == 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
519 integrated_intensity += input[walker].getIntensity();
522 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
524 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
525 integrated_intensity += input[walker].getIntensity() * weight; walker--;
531 if (walker < input.size() )
535 while (walker<input.size() && input[walker].getMZ()> left && input[walker].getMZ() < right)
537 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
538 integrated_intensity += input[walker].getIntensity() * weight; walker++;
552 template <
typename TransitionExpT>
553 static String extract_id_(TransitionExpT& transition_exp_used,
const String&
id,
int& prec_charge);
569 template <
class SpectrumSettingsT,
class ChromatogramT>
571 std::vector<ChromatogramT>& chromatograms,
583 if (settings.getPrecursors().size() > 0)
591 for (
Size pep_idx = 0; pep_idx < transition_exp.
getPeptides().size(); pep_idx++)
594 if (pep->
id == pepref)
601 for (
Size comp_idx = 0; comp_idx < transition_exp.
getCompounds().size(); comp_idx++)
604 if (comp->
id == compref)
612 chrom.setPrecursor(prec);
617 chrom.setProduct(prod);
620 chrom.setInstrumentSettings(settings.getInstrumentSettings());
621 chrom.setAcquisitionInfo(settings.getAcquisitionInfo());
622 chrom.setSourceFile(settings.getSourceFile());
624 for (
Size j = 0; j < settings.getDataProcessing().size(); ++j)
626 settings.getDataProcessing()[j]->setMetaValue(
"performed_on_spectra",
"true");
627 chrom.getDataProcessing().push_back(settings.getDataProcessing()[j]);
633 chromatograms.push_back(chrom);
642 double rt_extraction_window);
645 int getFilterNr_(
const String& filter);
649 double rt_extraction_window);
662 prec_charge = comp.
charge;
689 if (
c.hasCharge()) {prec_charge =
c.getChargeState();}