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;
680 if (transition_exp_used.hasPeptide(
id))
686 else if (transition_exp_used.hasCompound(
id))
689 if (
c.hasCharge()) {prec_charge =
c.getChargeState();}
A more convenient string class.
Definition: String.h:57
Precursor meta information.
Definition: Precursor.h:57
Product meta information.
Definition: Product.h:48
boost::shared_ptr< ISpectrumAccess > SpectrumAccessPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:89
The representation of a chromatogram.
Definition: MSChromatogram.h:54
void setChromatogramType(ChromatogramType type)
sets the chromatogram type
void setProduct(const Product &product)
sets the products
Peak2D PeakType
Definition: MassTrace.h:47
const InstrumentSettings & getInstrumentSettings() const
returns a const reference to the instrument settings of the current spectrum
const String & getCompoundRef() const
Representation of 1D spectrum settings.
Definition: SpectrumSettings.h:63
void setMZ(double mz)
sets the target m/z
void setSourceFile(const SourceFile &source_file)
sets the source file
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:119
Definition: ChromatogramSettings.h:71
const SourceFile & getSourceFile() const
returns a const reference to the source file
void sortTransitionsByProductMZ()
Lexicographically sorts the transitions by their product m/z.
void setInstrumentSettings(const InstrumentSettings &instrument_settings)
sets the instrument settings of the current spectrum
void setIsolationWindowLowerOffset(double bound)
sets the lower offset from the target m/z
const AcquisitionInfo & getAcquisitionInfo() const
returns a const reference to the acquisition info
std::vector< DataProcessingPtr > & getDataProcessing()
returns a mutable reference to the description of the applied processing
const std::vector< ReactionMonitoringTransition > & getTransitions() const
returns the transition list
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h:170
void setIsolationWindowUpperOffset(double bound)
sets the upper offset from the target m/z
bool hasCharge() const
Whether peptide or compound has set charge state.
Definition: TargetedExperimentHelper.h:314
void setAcquisitionInfo(const AcquisitionInfo &acquisition_info)
sets the acquisition info
double getProductMZ() const
Definition: TransitionExperiment.h:149
std::string sequence
Definition: TransitionExperiment.h:161
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:399
std::vector< DataProcessingPtr > & getDataProcessing()
returns a mutable reference to the description of the applied processing
String id
Definition: TargetedExperimentHelper.h:383
double getPrecursorMZ() const
get the precursor mz (Q1 value)
Definition: ChromatogramSettings.h:73
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
int getChargeState() const
Return the peptide or compound charge state.
Definition: TargetedExperimentHelper.h:320
const String & getPeptideRef() const
String sequence
Definition: TargetedExperimentHelper.h:537
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
const std::vector< Compound > & getCompounds() const
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:64
void setCharge(Int charge)
Mutable access to the charge.
const std::vector< Peptide > & getPeptides() const
static void convertToOpenMSChromatogram(const OpenSwath::ChromatogramPtr cptr, OpenMS::MSChromatogram &chromatogram)
Convert a ChromatogramPtr to an OpenMS Chromatogram.
std::string compound_name
Definition: TransitionExperiment.h:169
const String & getNativeID() const
int charge
Definition: TransitionExperiment.h:160
void setPrecursor(const Precursor &precursor)
sets the precursors
Definition: TransitionExperiment.h:206
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:451
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:56