OpenMS
ChromatogramExtractor Class Reference

The ChromatogramExtractor extracts chromatograms (intensity vs retention time) from mass spectrometry data. More...

#include <OpenMS/ANALYSIS/OPENSWATH/ChromatogramExtractor.h>

Inheritance diagram for ChromatogramExtractor:
[legend]
Collaboration diagram for ChromatogramExtractor:
[legend]

Public Types

typedef ChromatogramExtractorAlgorithm::ExtractionCoordinates ExtractionCoordinates
 
- Public Types inherited from ProgressLogger
enum  LogType { CMD , GUI , NONE }
 Possible log types. More...
 

Public Member Functions

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. More...
 
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. More...
 
- Public Member Functions inherited from ProgressLogger
 ProgressLogger ()
 Constructor. More...
 
virtual ~ProgressLogger ()
 Destructor. More...
 
 ProgressLogger (const ProgressLogger &other)
 Copy constructor. More...
 
ProgressLoggeroperator= (const ProgressLogger &other)
 Assignment Operator. More...
 
void setLogType (LogType type) const
 Sets the progress log that should be used. The default type is NONE! More...
 
LogType getLogType () const
 Returns the type of progress log being used. More...
 
void setLogger (ProgressLoggerImpl *logger)
 Sets the logger to be used for progress logging. More...
 
void startProgress (SignedSize begin, SignedSize end, const String &label) const
 Initializes the progress display. More...
 
void setProgress (SignedSize value) const
 Sets the current progress. More...
 
void endProgress (UInt64 bytes_processed=0) const
 
void nextProgress () const
 increment progress by 1 (according to range begin-end) More...
 

Static Public Member Functions

static void prepare_coordinates (std::vector< OpenSwath::ChromatogramPtr > &output_chromatograms, std::vector< ExtractionCoordinates > &coordinates, const OpenMS::TargetedExperiment &transition_exp, const double rt_extraction_window, const bool ms1=false, const int ms1_isotopes=0)
 Prepare the extraction coordinates from a TargetedExperiment. More...
 
static void prepare_coordinates (std::vector< OpenSwath::ChromatogramPtr > &output_chromatograms, std::vector< ExtractionCoordinates > &coordinates, const OpenSwath::LightTargetedExperiment &transition_exp_used, const double rt_extraction_window, const bool ms1=false, const int ms1_isotopes=0)
 
template<typename TransitionExpT >
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. More...
 

Private Member Functions

template<class SpectrumSettingsT , class ChromatogramT >
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) More...
 
bool outsideExtractionWindow_ (const ReactionMonitoringTransition &transition, double current_rt, const TransformationDescription &trafo, double rt_extraction_window)
 
int getFilterNr_ (const String &filter)
 
void populatePeptideRTMap_ (OpenMS::TargetedExperiment &transition_exp, double rt_extraction_window)
 

Static Private Member Functions

template<typename TransitionExpT >
static String extract_id_ (TransitionExpT &transition_exp_used, const String &id, int &prec_charge)
 Extracts id (peptide sequence or compound name) for a compound. More...
 

Private Attributes

std::map< OpenMS::String, double > PeptideRTMap_
 

Additional Inherited Members

- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImplcurrent_logger_
 
- Static Protected Attributes inherited from ProgressLogger
static int recursion_depth_
 

Detailed Description

The ChromatogramExtractor extracts chromatograms (intensity vs retention time) from mass spectrometry data.

This class provides functionality to extract chromatographic traces from mass spectrometry data based on specified coordinates (m/z, retention time, and optionally ion mobility values).

The extractor supports two main interfaces:

  1. Legacy interface: Takes a TargetedExperiment object containing transitions and extracts chromatograms at the m/z values specified in those transitions.
  2. Modern interface: Takes a set of ExtractionCoordinates that specify the exact coordinates for extraction. This provides more flexibility and control over the extraction process. The prepare_coordinates() helper function can generate these coordinates for common MS1 and MS2 extraction scenarios.

Key features:

  • Supports both MS1 and MS2 level extractions
  • Configurable extraction window sizes in m/z dimension (absolute or ppm)
  • Multiple filter types available (Bartlett, tophat) for signal processing
  • Handles ion mobility data when available
  • Optimized for SWATH/DIA (Data Independent Acquisition) experiments
  • Progress logging capabilities through ProgressLogger base class

For MS2 extractions, the input data is expected to come from a SWATH/DIA experiment where precursor ions are fragmented in wide isolation windows, allowing for extraction of fragment ion chromatograms.

See also
ChromatogramExtractorAlgorithm For the underlying extraction algorithm implementation
ExtractionCoordinates For the coordinate specification format

Member Typedef Documentation

◆ ExtractionCoordinates

Member Function Documentation

◆ extract_id_()

static String extract_id_ ( TransitionExpT &  transition_exp_used,
const String id,
int &  prec_charge 
)
staticprivate

Extracts id (peptide sequence or compound name) for a compound.

Parameters
transition_exp_usedThe transition experiment used as input (is constant) and either of type LightTargetedExperiment or TargetedExperiment
idThe identifier of the compound or peptide
prec_chargeThe charge state of the precursor

◆ extractChromatograms() [1/2]

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 
)
inline

Extract chromatograms at the m/z and RT defined by the ExtractionCoordinates.

Parameters
inputThe input spectra from which to extract chromatograms
outputThe output vector in which to store the chromatograms (needs to be of the same length as the extraction coordinates, use prepare_coordinates)
extraction_coordinatesThe extraction coordinates (m/z, RT, ion mobility)
mz_extraction_windowExtracts a window of this size in m/z dimension (e.g. a window of 50 ppm means an extraction of 25 ppm on either side)
ppmWhether mz windows in in ppm
filterWhich filter to use (bartlett or tophat)

References ChromatogramExtractorAlgorithm::extractChromatograms().

◆ extractChromatograms() [2/2]

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 
)
inline

Extract chromatograms at the m/z and RT defined by the ExtractionCoordinates.

Parameters
inputThe input spectra from which to extract chromatograms
outputThe output vector in which to store the chromatograms (needs to be of the same length as the extraction coordinates, use prepare_coordinates)
extraction_coordinatesThe extraction coordinates (m/z, RT, ion mobility)
mz_extraction_windowExtracts a window of this size in m/z dimension (e.g. a window of 50 ppm means an extraction of 25 ppm on either side)
ppmWhether mz windows in in ppm
im_extraction_windowExtracts a window of this size in ion mobility
filterWhich filter to use (bartlett or tophat)
Note
: whenever possible, please use this ChromatogramExtractorAlgorithm implementation

References ChromatogramExtractorAlgorithm::extractChromatograms().

◆ getFilterNr_()

int getFilterNr_ ( const String filter)
private
Note
: TODO deprecate this function (use ChromatogramExtractorAlgorithm instead)

◆ outsideExtractionWindow_()

bool outsideExtractionWindow_ ( const ReactionMonitoringTransition transition,
double  current_rt,
const TransformationDescription trafo,
double  rt_extraction_window 
)
private
Note
: TODO deprecate this function (use ChromatogramExtractorAlgorithm instead)

◆ populatePeptideRTMap_()

void populatePeptideRTMap_ ( OpenMS::TargetedExperiment transition_exp,
double  rt_extraction_window 
)
private
Note
: TODO deprecate this function (use ChromatogramExtractorAlgorithm instead)

◆ prepare_coordinates() [1/2]

static void prepare_coordinates ( std::vector< OpenSwath::ChromatogramPtr > &  output_chromatograms,
std::vector< ExtractionCoordinates > &  coordinates,
const OpenMS::TargetedExperiment transition_exp,
const double  rt_extraction_window,
const bool  ms1 = false,
const int  ms1_isotopes = 0 
)
static

Prepare the extraction coordinates from a TargetedExperiment.

Will fill the coordinates vector with the appropriate extraction coordinates (transitions for MS2 extraction, peptide m/z for MS1 extraction). The output will be sorted by m/z.

Parameters
output_chromatogramsAn empty vector which will be initialized correctly
coordinatesAn empty vector which will be filled with the appropriate extraction coordinates in m/z and rt and sorted by m/z (to be used as input to extractChromatograms)
transition_expThe transition experiment used as input (is constant)
rt_extraction_windowIf non-negative, full RT extraction window, centered on the first RT value (rt_end - rt_start will equal this window size). If negative, rt_end will be set to -1 and rt_start to 0 (i.e. full RT range). If NaN, exactly two RT entries are expected
  • the first is used as rt_start and the second as rt_end.
ms1Whether to extract for MS1 (peptide level) or MS2 (transition level)
ms1_isotopesNumber of isotopes to include in coordinates when in MS1 mode
Exceptions
Exception::IllegalArgumentif RT values are expected (depending on rt_extraction_window) but not provided

◆ prepare_coordinates() [2/2]

static void prepare_coordinates ( std::vector< OpenSwath::ChromatogramPtr > &  output_chromatograms,
std::vector< ExtractionCoordinates > &  coordinates,
const OpenSwath::LightTargetedExperiment transition_exp_used,
const double  rt_extraction_window,
const bool  ms1 = false,
const int  ms1_isotopes = 0 
)
static

◆ prepareSpectra_()

void prepareSpectra_ ( SpectrumSettingsT &  settings,
std::vector< ChromatogramT > &  chromatograms,
OpenMS::TargetedExperiment transition_exp 
)
inlineprivate

◆ return_chromatogram()

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 
)
inlinestatic

This converts the ChromatogramPtr to MSChromatogram and adds meta-information.

It sets 1) the target m/z 2) the isolation window (upper/lower) 3) the peptide sequence 4) the fragment m/z 5) the meta-data, e.g. InstrumentSettings, AcquisitionInfo, sourceFile and DataProcessing 6) the native ID from the transition 7) ion mobility extraction target and window (lower/upper)

References ChromatogramSettings::BASEPEAK_CHROMATOGRAM, OpenSwathHelper::computeTransitionGroupId(), OpenSwathDataAccessHelper::convertToOpenMSChromatogram(), SpectrumSettings::getAcquisitionInfo(), ChromatogramSettings::getDataProcessing(), SpectrumSettings::getDataProcessing(), SpectrumSettings::getInstrumentSettings(), SpectrumSettings::getPrecursors(), SpectrumSettings::getSourceFile(), ChromatogramExtractorAlgorithm::ExtractionCoordinates::id, ChromatogramExtractorAlgorithm::ExtractionCoordinates::ion_mobility, ChromatogramExtractorAlgorithm::ExtractionCoordinates::mz, ChromatogramSettings::SELECTED_REACTION_MONITORING_CHROMATOGRAM, ChromatogramSettings::setAcquisitionInfo(), Precursor::setCharge(), ChromatogramSettings::setChromatogramType(), Precursor::setDriftTime(), Precursor::setDriftTimeWindowLowerOffset(), Precursor::setDriftTimeWindowUpperOffset(), ChromatogramSettings::setInstrumentSettings(), Precursor::setIsolationWindowLowerOffset(), Precursor::setIsolationWindowUpperOffset(), MetaInfoInterface::setMetaValue(), Peak1D::setMZ(), Product::setMZ(), ChromatogramSettings::setNativeID(), ChromatogramSettings::setPrecursor(), ChromatogramSettings::setProduct(), and ChromatogramSettings::setSourceFile().

Member Data Documentation

◆ PeptideRTMap_

std::map<OpenMS::String, double> PeptideRTMap_
private