35 #ifndef OPENMS_ANALYSIS_OPENSWATH_CHROMATOGRAMEXTRACTOR_H
36 #define OPENMS_ANALYSIS_OPENSWATH_CHROMATOGRAMEXTRACTOR_H
88 template <
typename ExperimentT>
96 Size input_size = input.size();
102 int used_filter = getFilterNr_(filter);
103 populatePeptideRTMap_(transition_exp, rt_extraction_window);
111 std::vector<typename ExperimentT::ChromatogramType> chromatograms;
112 prepareSpectra_(settings, chromatograms, transition_exp);
115 startProgress(0, input_size,
"Extracting chromatograms");
116 for (
Size scan_idx = 0; scan_idx < input_size; ++scan_idx)
118 setProgress(scan_idx);
120 if (input[scan_idx].size() == 0)
126 double integrated_intensity = 0;
132 for (
Size k = 0;
k < chromatograms.size(); ++
k)
135 double current_rt = input[scan_idx].getRT();
136 if (outsideExtractionWindow_(transition_exp.
getTransitions()[
k], current_rt, trafo, rt_extraction_window))
144 if (used_filter == 1)
146 extract_value_tophat(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
148 else if (used_filter == 2)
150 extract_value_bartlett(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
155 p.setIntensity(integrated_intensity);
156 chromatograms[
k].push_back(p);
162 output.setChromatograms(chromatograms);
172 std::vector< OpenSwath::ChromatogramPtr >& output,
173 std::vector<ExtractionCoordinates> extraction_coordinates,
174 double mz_extraction_window,
bool ppm,
String filter)
177 extraction_coordinates, mz_extraction_window, ppm, filter);
201 void prepare_coordinates(std::vector< OpenSwath::ChromatogramPtr > & output_chromatograms,
202 std::vector< ExtractionCoordinates > & coordinates,
204 const double rt_extraction_window,
205 const bool ms1)
const;
220 template <
typename TransitionExpT>
222 std::vector< ChromatogramExtractor::ExtractionCoordinates > & coordinates,
226 typedef std::map<String, const typename TransitionExpT::Transition* > TransitionMapType;
227 TransitionMapType trans_map;
228 for (
Size i = 0; i < transition_exp_used.getTransitions().size(); i++)
230 trans_map[transition_exp_used.getTransitions()[i].getNativeID()] = &transition_exp_used.getTransitions()[i];
233 for (
Size i = 0; i < chromatograms.size(); i++)
238 typename TransitionExpT::Peptide pep;
239 typename TransitionExpT::Transition transition;
253 pep = transition_exp_used.getPeptideByRef(coord.
id);
259 transition = (*trans_map[coord.
id]);
260 pep = transition_exp_used.getPeptideByRef(transition.getPeptideRef());
262 prec.
setMZ(transition.getPrecursorMZ());
271 prod.
setMZ(transition.getProductMZ());
289 output_chromatograms.push_back(chrom);
294 template <
typename SpectrumT>
296 double& integrated_intensity,
const double& extract_window,
const bool ppm)
298 integrated_intensity = 0;
299 if (input.size() == 0)
308 left = mz - mz * extract_window / 2.0 * 1.0e-6;
309 right = mz + mz * extract_window / 2.0 * 1.0e-6;
313 left = mz - extract_window / 2.0;
314 right = mz + extract_window / 2.0;
320 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
328 if (peak_idx >= input.size())
330 walker = input.size() - 1;
334 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
336 integrated_intensity += input[walker].getIntensity();
345 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
347 integrated_intensity += input[walker].getIntensity(); walker--;
350 if (walker < input.size() )
354 while (walker<input.size() && input[walker].getMZ()> left && input[walker].getMZ() < right)
356 integrated_intensity += input[walker].getIntensity(); walker++;
361 template <
typename SpectrumT>
363 double& integrated_intensity,
const double& extract_window,
const bool ppm)
365 integrated_intensity = 0;
366 if (input.size() == 0)
372 double left, right, half_window_size, weight;
375 half_window_size = mz * extract_window / 2.0 * 1.0e-6;
376 left = mz - mz * extract_window / 2.0 * 1.0e-6;
377 right = mz + mz * extract_window / 2.0 * 1.0e-6;
381 half_window_size = extract_window / 2.0;
382 left = mz - extract_window / 2.0;
383 right = mz + extract_window / 2.0;
389 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
397 if (peak_idx >= input.size())
399 walker = input.size() - 1;
403 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
405 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
406 integrated_intensity += input[walker].getIntensity() * weight;
415 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
417 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
418 integrated_intensity += input[walker].getIntensity() * weight; walker--;
421 if (walker < input.size() )
425 while (walker<input.size() && input[walker].getMZ()> left && input[walker].getMZ() < right)
427 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
428 integrated_intensity += input[walker].getIntensity() * weight; walker++;
448 template <
class SpectrumSettingsT,
class ChromatogramT>
461 if (settings.getPrecursors().size() > 0)
469 for (
Size pep_idx = 0; pep_idx < transition_exp.
getPeptides().size(); pep_idx++)
472 if (pep->
id == pepref)
479 chrom.setPrecursor(prec);
484 chrom.setProduct(prod);
487 chrom.setInstrumentSettings(settings.getInstrumentSettings());
488 chrom.setAcquisitionInfo(settings.getAcquisitionInfo());
489 chrom.setSourceFile(settings.getSourceFile());
491 for (
Size j = 0; j < settings.getDataProcessing().size(); ++j)
495 chrom.getDataProcessing().push_back(dp);
501 chromatograms.push_back(chrom);
511 int getFilterNr_(
String filter);
Description of the applied preprocessing steps.
Definition: DataProcessing.h:51
const std::vector< DataProcessing > & getDataProcessing() const
returns a const reference to the description of the applied processing
A more convenient string class.
Definition: String.h:57
Precursor meta information.
Definition: Precursor.h:56
Product meta information.
Definition: Product.h:49
boost::shared_ptr< ISpectrumAccess > SpectrumAccessPtr
Definition: openswathalgo/include/OpenMS/ANALYSIS/OPENSWATH/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:90
The representation of a chromatogram.
Definition: MSChromatogram.h:52
void setChromatogramType(ChromatogramType type)
sets the chromatogram type
void setProduct(const Product &product)
sets the products
Peak2D PeakType
Definition: MassTrace.h:48
const AcquisitionInfo & getAcquisitionInfo() const
returns a const reference to the acquisition info
Representation of 1D spectrum settings.
Definition: SpectrumSettings.h:64
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:47
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:120
const std::vector< DataProcessing > & getDataProcessing() const
returns a const reference to the description of the applied processing
void sortTransitionsByProductMZ()
Lexicographically sorts the transitions by their product m/z.
const String & getPeptideRef() const
void setInstrumentSettings(const InstrumentSettings &instrument_settings)
sets the instrument settings of the current spectrum
double getPrecursorMZ() const
void setIsolationWindowLowerOffset(double bound)
sets the lower offset from the target m/z
const SourceFile & getSourceFile() const
returns a const reference to the source file
double getProductMZ() const
String id
Definition: TargetedExperimentHelper.h:321
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/ANALYSIS/OPENSWATH/OPENSWATHALGO/DATAACCESS/DataStructures.h:154
void setIsolationWindowUpperOffset(double bound)
sets the upper offset from the target m/z
void setAcquisitionInfo(const AcquisitionInfo &acquisition_info)
sets the acquisition info
String sequence
Definition: TargetedExperimentHelper.h:324
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
This class stores an prediction of an SRM/MRM transition.
Definition: TargetedExperiment.h:53
const String & getNativeID() const
const InstrumentSettings & getInstrumentSettings() const
returns a const reference to the instrument settings of the current spectrum
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
void setPrecursor(const Precursor &precursor)
sets the precursors
const std::vector< Peptide > & getPeptides() const
static void convertToOpenMSChromatogram(OpenMS::MSChromatogram<> &chromatogram, const OpenSwath::ChromatogramPtr cptr)
Convert a ChromatogramPtr to an OpenMS Chromatogram.
Definition: TargetedExperimentHelper.h:211
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:55