93 template <
typename ExperimentT>
101 Size input_size = input.size();
107 int used_filter = getFilterNr_(filter);
108 populatePeptideRTMap_(transition_exp, rt_extraction_window);
116 std::vector<typename ExperimentT::ChromatogramType> chromatograms;
117 prepareSpectra_(settings, chromatograms, transition_exp);
120 startProgress(0, input_size,
"Extracting chromatograms");
121 for (
Size scan_idx = 0; scan_idx < input_size; ++scan_idx)
123 setProgress(scan_idx);
125 if (input[scan_idx].size() == 0)
131 double integrated_intensity = 0;
137 for (
Size k = 0;
k < chromatograms.size(); ++
k)
140 double current_rt = input[scan_idx].getRT();
141 if (outsideExtractionWindow_(transition_exp.
getTransitions()[
k], current_rt, trafo, rt_extraction_window))
149 if (used_filter == 1)
151 extract_value_tophat(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
153 else if (used_filter == 2)
155 extract_value_bartlett(input[scan_idx], mz, peak_idx, integrated_intensity, mz_extraction_window, ppm);
160 p.setIntensity(integrated_intensity);
161 chromatograms[
k].push_back(p);
167 output.setChromatograms(chromatograms);
188 std::vector< OpenSwath::ChromatogramPtr >& output,
189 const std::vector<ExtractionCoordinates>& extraction_coordinates,
190 double mz_extraction_window,
bool ppm,
const String& filter)
193 extraction_coordinates, mz_extraction_window, ppm, -1, filter);
215 std::vector< OpenSwath::ChromatogramPtr >& output,
216 const std::vector<ExtractionCoordinates>& extraction_coordinates,
217 double mz_extraction_window,
bool ppm,
double im_extraction_window,
const String& filter)
220 extraction_coordinates, mz_extraction_window, ppm, im_extraction_window, filter);
246 void prepare_coordinates(std::vector< OpenSwath::ChromatogramPtr > & output_chromatograms,
247 std::vector< ExtractionCoordinates > & coordinates,
249 const double rt_extraction_window,
250 const bool ms1)
const;
265 template <
typename TransitionExpT>
267 std::vector< ChromatogramExtractor::ExtractionCoordinates > & coordinates,
268 TransitionExpT& transition_exp_used,
270 std::vector<OpenMS::MSChromatogram > & output_chromatograms,
273 typedef std::map<String, const typename TransitionExpT::Transition* > TransitionMapType;
274 TransitionMapType trans_map;
275 for (
Size i = 0; i < transition_exp_used.getTransitions().size(); i++)
277 trans_map[transition_exp_used.getTransitions()[i].getNativeID()] = &transition_exp_used.getTransitions()[i];
280 for (
Size i = 0; i < chromatograms.size(); i++)
302 String r = extract_id_(transition_exp_used, coord.
id);
307 typename TransitionExpT::Transition transition = (*trans_map[coord.
id]);
309 prec.
setMZ(transition.getPrecursorMZ());
318 prod.
setMZ(transition.getProductMZ());
324 if (!transition.getPeptideRef().empty())
326 String r = extract_id_(transition_exp_used, transition.getPeptideRef());
331 String r = extract_id_(transition_exp_used, transition.getCompoundRef());
347 output_chromatograms.push_back(chrom);
352 template <
typename SpectrumT>
354 double& integrated_intensity,
const double& extract_window,
const bool ppm)
356 integrated_intensity = 0;
357 if (input.size() == 0)
366 left = mz - mz * extract_window / 2.0 * 1.0e-6;
367 right = mz + mz * extract_window / 2.0 * 1.0e-6;
371 left = mz - extract_window / 2.0;
372 right = mz + extract_window / 2.0;
378 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
387 if (peak_idx >= input.size())
389 walker = input.size() - 1;
393 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
395 integrated_intensity += input[walker].getIntensity();
406 if (walker == 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
408 integrated_intensity += input[walker].getIntensity();
411 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
413 integrated_intensity += input[walker].getIntensity(); walker--;
419 if (walker < input.size() )
423 while (walker < input.size() && input[walker].getMZ() > left && input[walker].getMZ() < right)
425 integrated_intensity += input[walker].getIntensity(); walker++;
430 template <
typename SpectrumT>
432 double& integrated_intensity,
const double& extract_window,
const bool ppm)
434 integrated_intensity = 0;
435 if (input.size() == 0)
441 double left, right, half_window_size, weight;
444 half_window_size = mz * extract_window / 2.0 * 1.0e-6;
445 left = mz - mz * extract_window / 2.0 * 1.0e-6;
446 right = mz + mz * extract_window / 2.0 * 1.0e-6;
450 half_window_size = extract_window / 2.0;
451 left = mz - extract_window / 2.0;
452 right = mz + extract_window / 2.0;
458 while (peak_idx < input.size() && input[peak_idx].getMZ() < mz)
467 if (peak_idx >= input.size())
469 walker = input.size() - 1;
473 if (input[walker].getMZ() > left && input[walker].getMZ() < right)
475 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
476 integrated_intensity += input[walker].getIntensity() * weight;
487 if (walker == 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
489 integrated_intensity += input[walker].getIntensity();
492 while (walker > 0 && input[walker].getMZ() > left && input[walker].getMZ() < right)
494 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
495 integrated_intensity += input[walker].getIntensity() * weight; walker--;
501 if (walker < input.size() )
505 while (walker<input.size() && input[walker].getMZ()> left && input[walker].getMZ() < right)
507 weight = 1 - fabs(input[walker].getMZ() - mz) / half_window_size;
508 integrated_intensity += input[walker].getIntensity() * weight; walker++;
521 template <
typename TransitionExpT>
522 static String extract_id_(TransitionExpT& transition_exp_used,
String id);
538 template <
class SpectrumSettingsT,
class ChromatogramT>
550 if (settings.getPrecursors().size() > 0)
558 for (
Size pep_idx = 0; pep_idx < transition_exp.
getPeptides().size(); pep_idx++)
561 if (pep->
id == pepref)
568 for (
Size comp_idx = 0; comp_idx < transition_exp.
getCompounds().size(); comp_idx++)
571 if (comp->
id == compref)
579 chrom.setPrecursor(prec);
584 chrom.setProduct(prod);
587 chrom.setInstrumentSettings(settings.getInstrumentSettings());
588 chrom.setAcquisitionInfo(settings.getAcquisitionInfo());
589 chrom.setSourceFile(settings.getSourceFile());
591 for (
Size j = 0; j < settings.getDataProcessing().size(); ++j)
593 settings.getDataProcessing()[j]->setMetaValue(
"performed_on_spectra",
"true");
594 chrom.getDataProcessing().push_back(settings.getDataProcessing()[j]);
600 chromatograms.push_back(chrom);
610 int getFilterNr_(
const String& filter);
639 if (transition_exp_used.hasPeptide(
id))
644 else if (transition_exp_used.hasCompound(
id))
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
void setAcquisitionInfo(const AcquisitionInfo &acquisition_info)
sets the acquisition info
double getProductMZ() const
Definition: TransitionExperiment.h:149
std::string sequence
Definition: TransitionExperiment.h:161
Definition: TargetedExperimentHelper.h:383
std::vector< DataProcessingPtr > & getDataProcessing()
returns a mutable reference to the description of the applied processing
String id
Definition: TargetedExperimentHelper.h:373
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
const String & getPeptideRef() const
String sequence
Definition: TargetedExperimentHelper.h:515
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:61
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
void setPrecursor(const Precursor &precursor)
sets the precursors
Definition: TransitionExperiment.h:206
Definition: TargetedExperimentHelper.h:429
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:55