69 template <
typename ExperimentT>
73 double mz_extraction_window,
75 double rt_extraction_window,
81 Size input_size = input.size();
87 int used_filter = getFilterNr_(filter);
88 populatePeptideRTMap_(transition_exp, rt_extraction_window);
96 std::vector<typename ExperimentT::ChromatogramType> chromatograms;
97 prepareSpectra_(settings, chromatograms, transition_exp);
100 startProgress(0, input_size,
"Extracting chromatograms");
101 for (
Size scan_idx = 0; scan_idx < input_size; ++scan_idx)
103 setProgress(scan_idx);
105 if (input[scan_idx].size() == 0)
111 double integrated_intensity = 0;
117 for (
Size k = 0;
k < chromatograms.size(); ++
k)
120 double current_rt = input[scan_idx].getRT();
121 if (outsideExtractionWindow_(transition_exp.
getTransitions()[
k], current_rt, trafo, rt_extraction_window))
129 if (used_filter == 1)
131 extract_value_tophat(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
133 else if (used_filter == 2)
135 extract_value_bartlett(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
140 p.setIntensity(integrated_intensity);
141 chromatograms[
k].push_back(p);
147 output.setChromatograms(chromatograms);
168 std::vector< OpenSwath::ChromatogramPtr >& output,
169 const std::vector<ExtractionCoordinates>& extraction_coordinates,
170 double mz_extraction_window,
175 extraction_coordinates, mz_extraction_window, ppm, -1, filter);
197 std::vector< OpenSwath::ChromatogramPtr >& output,
198 const std::vector<ExtractionCoordinates>& extraction_coordinates,
199 double mz_extraction_window,
201 double im_extraction_window,
205 extraction_coordinates, mz_extraction_window, ppm, im_extraction_window, filter);
230 std::vector< ExtractionCoordinates > & coordinates,
232 const double rt_extraction_window,
233 const bool ms1 =
false,
234 const int ms1_isotopes = 0);
237 std::vector< ExtractionCoordinates > & coordinates,
239 const double rt_extraction_window,
240 const bool ms1 =
false,
241 const int ms1_isotopes = 0);
257 template <
typename TransitionExpT>
259 const std::vector< ChromatogramExtractor::ExtractionCoordinates > & coordinates,
260 TransitionExpT& transition_exp_used,
262 std::vector<OpenMS::MSChromatogram > & output_chromatograms,
264 double im_extraction_width = 0.0)
266 typedef std::map<String, const typename TransitionExpT::Transition* > TransitionMapType;
267 TransitionMapType trans_map;
268 for (
Size i = 0; i < transition_exp_used.getTransitions().size(); i++)
270 trans_map[transition_exp_used.getTransitions()[i].getNativeID()] = &transition_exp_used.getTransitions()[i];
273 for (
Size i = 0; i < chromatograms.size(); i++)
296 if (!transition_group_id.empty())
299 String r = extract_id_(transition_exp_used, transition_group_id, prec_charge);
306 typename TransitionExpT::Transition transition = (*trans_map[coord.
id]);
308 prec.
setMZ(transition.getPrecursorMZ());
317 prod.
setMZ(transition.getProductMZ());
323 if (!transition.getPeptideRef().empty())
326 String r = extract_id_(transition_exp_used, transition.getPeptideRef(), prec_charge);
333 String r = extract_id_(transition_exp_used, transition.getCompoundRef(), prec_charge);
339 if (coord.
ion_mobility >= 0 && im_extraction_width > 0.0)
357 output_chromatograms.push_back(chrom);
362 template <
typename SpectrumT>
366 double& integrated_intensity,
367 const double extract_window,
370 integrated_intensity = 0;
371 if (input.size() == 0)
380 left = mz - mz * extract_window / 2.0 * 1.0e-6;
381 right = mz + mz * extract_window / 2.0 * 1.0e-6;
385 left = mz - extract_window / 2.0;
386 right = mz + extract_window / 2.0;
392 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
401 if (peak_idx >= input.size())
403 walker = input.size() - 1;
407 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
409 integrated_intensity += input[walker].getIntensity();
420 if (walker == 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
422 integrated_intensity += input[walker].getIntensity();
425 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
427 integrated_intensity += input[walker].getIntensity(); walker--;
433 if (walker < input.size() )
437 while (walker < input.size() && input[walker].getMZ() > left && input[walker].getMZ() < right)
439 integrated_intensity += input[walker].getIntensity(); walker++;
444 template <
typename SpectrumT>
448 double& integrated_intensity,
449 const double extract_window,
452 integrated_intensity = 0;
453 if (input.size() == 0)
459 double left, right, half_window_size, weight;
462 half_window_size = mz * extract_window / 2.0 * 1.0e-6;
463 left = mz - mz * extract_window / 2.0 * 1.0e-6;
464 right = mz + mz * extract_window / 2.0 * 1.0e-6;
468 half_window_size = extract_window / 2.0;
469 left = mz - extract_window / 2.0;
470 right = mz + extract_window / 2.0;
476 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
485 if (peak_idx >= input.size())
487 walker = input.size() - 1;
491 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
493 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
494 integrated_intensity += input[walker].getIntensity() * weight;
505 if (walker == 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
507 integrated_intensity += input[walker].getIntensity();
510 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
512 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
513 integrated_intensity += input[walker].getIntensity() * weight; walker--;
519 if (walker < input.size() )
523 while (walker<input.size() && input[walker].getMZ()> left && input[walker].getMZ() < right)
525 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
526 integrated_intensity += input[walker].getIntensity() * weight; walker++;
539 template <
typename TransitionExpT>
556 template <
class SpectrumSettingsT,
class ChromatogramT>
558 std::vector<ChromatogramT>& chromatograms,
570 if (settings.getPrecursors().size() > 0)
578 for (
Size pep_idx = 0; pep_idx < transition_exp.
getPeptides().size(); pep_idx++)
581 if (pep->
id == pepref)
588 for (
Size comp_idx = 0; comp_idx < transition_exp.
getCompounds().size(); comp_idx++)
591 if (comp->
id == compref)
599 chrom.setPrecursor(prec);
604 chrom.setProduct(prod);
607 chrom.setInstrumentSettings(settings.getInstrumentSettings());
608 chrom.setAcquisitionInfo(settings.getAcquisitionInfo());
609 chrom.setSourceFile(settings.getSourceFile());
611 for (
Size j = 0; j < settings.getDataProcessing().size(); ++j)
613 settings.getDataProcessing()[j]->setMetaValue(
"performed_on_spectra",
"true");
614 chrom.getDataProcessing().push_back(settings.getDataProcessing()[j]);
620 chromatograms.push_back(chrom);
629 double rt_extraction_window);
636 double rt_extraction_window);
649 prec_charge = comp.
charge;
676 if (
c.hasCharge()) {prec_charge =
c.getChargeState();}
void setPrecursor(const Precursor &precursor)
sets the precursors
void setProduct(const Product &product)
sets the products
void setInstrumentSettings(const InstrumentSettings &instrument_settings)
sets the instrument settings of the current spectrum
@ BASEPEAK_CHROMATOGRAM
Definition: ChromatogramSettings.h:46
@ SELECTED_REACTION_MONITORING_CHROMATOGRAM
Definition: ChromatogramSettings.h:48
void setSourceFile(const SourceFile &source_file)
sets the source file
void setChromatogramType(ChromatogramType type)
sets the chromatogram type
std::vector< DataProcessingPtr > & getDataProcessing()
returns a mutable reference to the description of the applied processing
void setAcquisitionInfo(const AcquisitionInfo &acquisition_info)
sets the acquisition info
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
The representation of a chromatogram.
Definition: MSChromatogram.h:31
static void convertToOpenMSChromatogram(const OpenSwath::ChromatogramPtr &cptr, OpenMS::MSChromatogram &chromatogram)
Convert a ChromatogramPtr to an OpenMS Chromatogram.
static String computeTransitionGroupId(const String &precursor_id)
Compute transition group id.
Definition: OpenSwathHelper.h:56
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:93
Precursor meta information.
Definition: Precursor.h:35
void setIsolationWindowUpperOffset(double bound)
sets the upper offset from the target m/z
void setDriftTime(double drift_time)
sets the ion mobility drift time in milliseconds
void setDriftTimeWindowUpperOffset(double drift_time)
sets the upper offset from the target ion mobility
void setDriftTimeWindowLowerOffset(double drift_time)
sets the lower offset from the target ion mobility
void setIsolationWindowLowerOffset(double bound)
sets the lower offset from the target m/z
void setCharge(Int charge)
Mutable access to the charge.
Product meta information.
Definition: Product.h:24
void setMZ(double mz)
sets the target m/z
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:32
double getPrecursorMZ() const
get the precursor mz (Q1 value)
double getProductMZ() const
const String & getCompoundRef() const
const String & getPeptideRef() const
const String & getNativeID() const
Representation of 1D spectrum settings.
Definition: SpectrumSettings.h:39
const SourceFile & getSourceFile() const
returns a const reference to the source file
const AcquisitionInfo & getAcquisitionInfo() const
returns a const reference to the acquisition info
const InstrumentSettings & getInstrumentSettings() const
returns a const reference to the instrument settings of the current spectrum
std::vector< DataProcessingPtr > & getDataProcessing()
returns a mutable reference to the description of the applied processing
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
A more convenient string class.
Definition: String.h:34
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:297
String id
Definition: TargetedExperimentHelper.h:280
int getChargeState() const
Return the peptide or compound charge state.
Definition: TargetedExperimentHelper.h:217
bool hasCharge() const
Whether peptide or compound has set charge state.
Definition: TargetedExperimentHelper.h:211
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:334
String sequence
Definition: TargetedExperimentHelper.h:394
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:39
const Peptide & getPeptideByRef(const String &ref) const
const std::vector< Peptide > & getPeptides() const
const Compound & getCompoundByRef(const String &ref) const
const std::vector< ReactionMonitoringTransition > & getTransitions() const
returns the transition list
void sortTransitionsByProductMZ()
Lexicographically sorts the transitions by their product m/z.
bool hasCompound(const String &ref) const
bool hasPeptide(const String &ref) const
const std::vector< Compound > & getCompounds() const
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
const double c
Definition: Constants.h:188
const double k
Definition: Constants.h:132
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Peak2D PeakType
Definition: MassTrace.h:21
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h:146
boost::shared_ptr< ISpectrumAccess > SpectrumAccessPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:61
Definition: TransitionExperiment.h:127
std::string sequence
Definition: TransitionExperiment.h:138
std::string compound_name
Definition: TransitionExperiment.h:147
int charge
Definition: TransitionExperiment.h:137
Definition: TransitionExperiment.h:185
const LightCompound & getCompoundByRef(const std::string &ref)
Definition: TransitionExperiment.h:232