|
OpenMS
2.5.0
|
Go to the documentation of this file.
95 template <
typename ExperimentT>
99 double mz_extraction_window,
101 double rt_extraction_window,
107 Size input_size = input.size();
113 int used_filter = getFilterNr_(filter);
114 populatePeptideRTMap_(transition_exp, rt_extraction_window);
122 std::vector<typename ExperimentT::ChromatogramType> chromatograms;
123 prepareSpectra_(settings, chromatograms, transition_exp);
126 startProgress(0, input_size,
"Extracting chromatograms");
127 for (
Size scan_idx = 0; scan_idx < input_size; ++scan_idx)
129 setProgress(scan_idx);
131 if (input[scan_idx].size() == 0)
137 double integrated_intensity = 0;
143 for (
Size k = 0;
k < chromatograms.size(); ++
k)
146 double current_rt = input[scan_idx].getRT();
147 if (outsideExtractionWindow_(transition_exp.
getTransitions()[
k], current_rt, trafo, rt_extraction_window))
155 if (used_filter == 1)
157 extract_value_tophat(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
159 else if (used_filter == 2)
161 extract_value_bartlett(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
166 p.setIntensity(integrated_intensity);
167 chromatograms[
k].push_back(p);
173 output.setChromatograms(chromatograms);
194 std::vector< OpenSwath::ChromatogramPtr >& output,
195 const std::vector<ExtractionCoordinates>& extraction_coordinates,
196 double mz_extraction_window,
201 extraction_coordinates, mz_extraction_window, ppm, -1, filter);
223 std::vector< OpenSwath::ChromatogramPtr >& output,
224 const std::vector<ExtractionCoordinates>& extraction_coordinates,
225 double mz_extraction_window,
227 double im_extraction_window,
231 extraction_coordinates, mz_extraction_window, ppm, im_extraction_window, filter);
255 static void prepare_coordinates(std::vector< OpenSwath::ChromatogramPtr > & output_chromatograms,
256 std::vector< ExtractionCoordinates > & coordinates,
258 const double rt_extraction_window,
259 const bool ms1 =
false,
260 const int ms1_isotopes = 0);
262 static void prepare_coordinates(std::vector< OpenSwath::ChromatogramPtr > & output_chromatograms,
263 std::vector< ExtractionCoordinates > & coordinates,
265 const double rt_extraction_window,
266 const bool ms1 =
false,
267 const int ms1_isotopes = 0);
283 template <
typename TransitionExpT>
285 const std::vector< ChromatogramExtractor::ExtractionCoordinates > & coordinates,
286 TransitionExpT& transition_exp_used,
288 std::vector<OpenMS::MSChromatogram > & output_chromatograms,
290 double im_extraction_width = 0.0)
292 typedef std::map<String, const typename TransitionExpT::Transition* > TransitionMapType;
293 TransitionMapType trans_map;
294 for (
Size i = 0; i < transition_exp_used.getTransitions().size(); i++)
296 trans_map[transition_exp_used.getTransitions()[i].getNativeID()] = &transition_exp_used.getTransitions()[i];
299 for (
Size i = 0; i < chromatograms.size(); i++)
322 if (!transition_group_id.empty())
325 String r = extract_id_(transition_exp_used, transition_group_id, prec_charge);
332 typename TransitionExpT::Transition transition = (*trans_map[coord.
id]);
334 prec.
setMZ(transition.getPrecursorMZ());
343 prod.
setMZ(transition.getProductMZ());
349 if (!transition.getPeptideRef().empty())
352 String r = extract_id_(transition_exp_used, transition.getPeptideRef(), prec_charge);
359 String r = extract_id_(transition_exp_used, transition.getCompoundRef(), prec_charge);
365 if (coord.
ion_mobility >= 0 && im_extraction_width > 0.0)
383 output_chromatograms.push_back(chrom);
388 template <
typename SpectrumT>
392 double& integrated_intensity,
393 const double extract_window,
396 integrated_intensity = 0;
397 if (input.size() == 0)
406 left = mz - mz * extract_window / 2.0 * 1.0e-6;
407 right = mz + mz * extract_window / 2.0 * 1.0e-6;
411 left = mz - extract_window / 2.0;
412 right = mz + extract_window / 2.0;
418 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
427 if (peak_idx >= input.size())
429 walker = input.size() - 1;
433 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
435 integrated_intensity += input[walker].getIntensity();
446 if (walker == 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
448 integrated_intensity += input[walker].getIntensity();
451 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
453 integrated_intensity += input[walker].getIntensity(); walker--;
459 if (walker < input.size() )
463 while (walker < input.size() && input[walker].getMZ() > left && input[walker].getMZ() < right)
465 integrated_intensity += input[walker].getIntensity(); walker++;
470 template <
typename SpectrumT>
474 double& integrated_intensity,
475 const double extract_window,
478 integrated_intensity = 0;
479 if (input.size() == 0)
485 double left, right, half_window_size, weight;
488 half_window_size = mz * extract_window / 2.0 * 1.0e-6;
489 left = mz - mz * extract_window / 2.0 * 1.0e-6;
490 right = mz + mz * extract_window / 2.0 * 1.0e-6;
494 half_window_size = extract_window / 2.0;
495 left = mz - extract_window / 2.0;
496 right = mz + extract_window / 2.0;
502 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
511 if (peak_idx >= input.size())
513 walker = input.size() - 1;
517 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
519 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
520 integrated_intensity += input[walker].getIntensity() * weight;
531 if (walker == 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
533 integrated_intensity += input[walker].getIntensity();
536 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
538 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
539 integrated_intensity += input[walker].getIntensity() * weight; walker--;
545 if (walker < input.size() )
549 while (walker<input.size() && input[walker].getMZ()> left && input[walker].getMZ() < right)
551 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
552 integrated_intensity += input[walker].getIntensity() * weight; walker++;
565 template <
typename TransitionExpT>
566 static String extract_id_(TransitionExpT& transition_exp_used,
const String&
id,
int& prec_charge);
582 template <
class SpectrumSettingsT,
class ChromatogramT>
584 std::vector<ChromatogramT>& chromatograms,
596 if (settings.getPrecursors().size() > 0)
604 for (
Size pep_idx = 0; pep_idx < transition_exp.
getPeptides().size(); pep_idx++)
607 if (pep->
id == pepref)
614 for (
Size comp_idx = 0; comp_idx < transition_exp.
getCompounds().size(); comp_idx++)
617 if (comp->
id == compref)
625 chrom.setPrecursor(prec);
630 chrom.setProduct(prod);
633 chrom.setInstrumentSettings(settings.getInstrumentSettings());
634 chrom.setAcquisitionInfo(settings.getAcquisitionInfo());
635 chrom.setSourceFile(settings.getSourceFile());
637 for (
Size j = 0; j < settings.getDataProcessing().size(); ++j)
639 settings.getDataProcessing()[j]->setMetaValue(
"performed_on_spectra",
"true");
640 chrom.getDataProcessing().push_back(settings.getDataProcessing()[j]);
646 chromatograms.push_back(chrom);
655 double rt_extraction_window);
658 int getFilterNr_(
const String& filter);
662 double rt_extraction_window);
675 prec_charge = comp.
charge;
702 if (
c.hasCharge()) {prec_charge =
c.getChargeState();}
static void return_chromatogram(const std::vector< OpenSwath::ChromatogramPtr > &chromatograms, const std::vector< ChromatogramExtractor::ExtractionCoordinates > &coordinates, TransitionExpT &transition_exp_used, SpectrumSettings settings, std::vector< OpenMS::MSChromatogram > &output_chromatograms, bool ms1, double im_extraction_width=0.0)
This converts the ChromatogramPtr to MSChromatogram and adds meta-information.
Definition: ChromatogramExtractor.h:284
void extractChromatograms(const OpenSwath::SpectrumAccessPtr input, std::vector< OpenSwath::ChromatogramPtr > &output, const std::vector< ExtractionCoordinates > &extraction_coordinates, double mz_extraction_window, bool ppm, double im_extraction_window, const String &filter)
Extract chromatograms at the m/z and RT defined by the ExtractionCoordinates.
Definition: ChromatogramExtractor.h:222
const std::vector< Peptide > & getPeptides() const
Representation of 1D spectrum settings.
Definition: SpectrumSettings.h:63
void setAcquisitionInfo(const AcquisitionInfo &acquisition_info)
sets the acquisition info
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::string id
identifier
Definition: ChromatogramExtractorAlgorithm.h:71
const InstrumentSettings & getInstrumentSettings() const
returns a const reference to the instrument settings of the current spectrum
void setDriftTimeWindowUpperOffset(double drift_time)
sets the upper offset from the target ion mobility
double getPrecursorMZ() const
get the precursor mz (Q1 value)
void extractChromatograms(const ExperimentT &input, ExperimentT &output, OpenMS::TargetedExperiment &transition_exp, double mz_extraction_window, bool ppm, TransformationDescription trafo, double rt_extraction_window, const String &filter)
Extract chromatograms defined by the TargetedExperiment from the input map and write them to the outp...
Definition: ChromatogramExtractor.h:96
int charge
Definition: TransitionExperiment.h:160
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:121
Peak2D PeakType
Definition: MassTrace.h:47
Precursor meta information.
Definition: Precursor.h:57
void setInstrumentSettings(const InstrumentSettings &instrument_settings)
sets the instrument settings of the current spectrum
Definition: ChromatogramExtractorAlgorithm.h:64
Definition: TransitionExperiment.h:207
String id
Definition: TargetedExperimentHelper.h:317
const String & getPeptideRef() const
void setCharge(Int charge)
Mutable access to the charge.
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:61
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:333
const SourceFile & getSourceFile() const
returns a const reference to the source file
void setSourceFile(const SourceFile &source_file)
sets the source file
void setPrecursor(const Precursor &precursor)
sets the precursors
void setProduct(const Product &product)
sets the products
static String computeTransitionGroupId(const String &precursor_id)
Compute transition group id.
Definition: OpenSwathHelper.h:81
String sequence
Definition: TargetedExperimentHelper.h:437
Definition: TransitionExperiment.h:149
const std::vector< Compound > & getCompounds() const
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h:172
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
void setDriftTime(double drift_time)
sets the ion mobility drift time in milliseconds
void setChromatogramType(ChromatogramType type)
sets the chromatogram type
The ChromatogramExtractorAlgorithm extracts chromatograms from a MS data.
Definition: ChromatogramExtractorAlgorithm.h:58
void prepareSpectra_(SpectrumSettingsT &settings, std::vector< ChromatogramT > &chromatograms, OpenMS::TargetedExperiment &transition_exp)
This populates the chromatograms vector with empty chromatograms (but sets their meta-information)
Definition: ChromatogramExtractor.h:583
bool hasCharge() const
Whether peptide or compound has set charge state.
Definition: TargetedExperimentHelper.h:248
std::map< OpenMS::String, double > PeptideRTMap_
Definition: ChromatogramExtractor.h:664
int getChargeState() const
Return the peptide or compound charge state.
Definition: TargetedExperimentHelper.h:254
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
const std::vector< ReactionMonitoringTransition > & getTransitions() const
returns the transition list
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
void extractChromatograms(const OpenSwath::SpectrumAccessPtr input, std::vector< OpenSwath::ChromatogramPtr > &output, const std::vector< ExtractionCoordinates > &extraction_coordinates, double mz_extraction_window, bool ppm, const String &filter)
Extract chromatograms at the m/z and RT defined by the ExtractionCoordinates.
Definition: ChromatogramExtractor.h:193
const Compound & getCompoundByRef(const String &ref) const
The representation of a chromatogram.
Definition: MSChromatogram.h:54
const String & getCompoundRef() const
bool hasCompound(const String &ref) const
const Peptide & getPeptideByRef(const String &ref) const
Product meta information.
Definition: Product.h:48
const LightCompound & getCompoundByRef(const std::string &ref)
Definition: TransitionExperiment.h:255
ChromatogramExtractorAlgorithm::ExtractionCoordinates ExtractionCoordinates
Definition: ChromatogramExtractor.h:73
void extract_value_tophat(const SpectrumT &input, const double mz, Size &peak_idx, double &integrated_intensity, const double extract_window, const bool ppm)
Definition: ChromatogramExtractor.h:389
void extract_value_bartlett(const SpectrumT &input, const double mz, Size &peak_idx, double &integrated_intensity, const double extract_window, const bool ppm)
Definition: ChromatogramExtractor.h:471
boost::shared_ptr< ISpectrumAccess > SpectrumAccessPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:89
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
static void convertToOpenMSChromatogram(const OpenSwath::ChromatogramPtr cptr, OpenMS::MSChromatogram &chromatogram)
Convert a ChromatogramPtr to an OpenMS Chromatogram.
double mz
m/z value around which should be extracted
Definition: ChromatogramExtractorAlgorithm.h:66
A more convenient string class.
Definition: String.h:58
void setIsolationWindowLowerOffset(double bound)
sets the lower offset from the target m/z
double ion_mobility
ion mobility value around which should be extracted
Definition: ChromatogramExtractorAlgorithm.h:67
bool hasPeptide(const String &ref) const
std::string compound_name
Definition: TransitionExperiment.h:170
void setDriftTimeWindowLowerOffset(double drift_time)
sets the lower offset from the target ion mobility
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:56
void sortTransitionsByProductMZ()
Lexicographically sorts the transitions by their product m/z.
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
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
void invert()
Computes an (approximate) inverse of the transformation.
std::vector< DataProcessingPtr > & getDataProcessing()
returns a mutable reference to the description of the applied processing
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:64
double getProductMZ() const
The ChromatogramExtractor extracts chromatograms from a spectra file.
Definition: ChromatogramExtractor.h:67
void setMZ(double mz)
sets the target m/z
Definition: ChromatogramSettings.h:72
void extractChromatograms(const OpenSwath::SpectrumAccessPtr input, std::vector< OpenSwath::ChromatogramPtr > &output, const std::vector< ExtractionCoordinates > &extraction_coordinates, double mz_extraction_window, bool ppm, double im_extraction_window, const String &filter)
Extract chromatograms at the m/z and RT defined by the ExtractionCoordinates.
Definition: ChromatogramSettings.h:74
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:370
const String & getNativeID() const
std::string sequence
Definition: TransitionExperiment.h:161
void setIsolationWindowUpperOffset(double bound)
sets the upper offset from the target m/z