OpenMS
Loading...
Searching...
No Matches
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 std::string &filter)
 Extract chromatograms at the m/z and RT defined by the ExtractionCoordinates.
 
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 std::string &filter)
 Extract chromatograms at the m/z and RT defined by the ExtractionCoordinates.
 
- Public Member Functions inherited from ProgressLogger
 ProgressLogger ()
 Constructor.
 
virtual ~ProgressLogger ()
 Destructor.
 
 ProgressLogger (const ProgressLogger &other)
 Copy constructor.
 
ProgressLoggeroperator= (const ProgressLogger &other)
 Assignment Operator.
 
void setLogType (LogType type) const
 Sets the progress log that should be used. The default type is NONE!
 
LogType getLogType () const
 Returns the type of progress log being used.
 
void setLogger (ProgressLoggerImpl *logger)
 Sets the logger to be used for progress logging.
 
void startProgress (SignedSize begin, SignedSize end, const std::string &label) const
 Initializes the progress display.
 
void setProgress (SignedSize value) const
 Sets the current progress.
 
void endProgress (UInt64 bytes_processed=0) const
 
void nextProgress () const
 increment progress by 1 (according to range begin-end)
 

Static Public Member Functions

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)
 Prepare the extraction coordinates from a LightTargetedExperiment.
 
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.
 

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)
 
bool outsideExtractionWindow_ (const ReactionMonitoringTransition &transition, double current_rt, const TransformationDescription &trafo, double rt_extraction_window)
 
int getFilterNr_ (const std::string &filter)
 
void populatePeptideRTMap_ (OpenMS::TargetedExperiment &transition_exp, double rt_extraction_window)
 

Static Private Member Functions

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

Private Attributes

std::map< std::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 primary interface uses a set of ExtractionCoordinates that specify the exact coordinates for extraction. The static prepare_coordinates() helper generates these coordinates from an OpenSwath::LightTargetedExperiment for common MS1 and MS2 extraction scenarios. Callers working with an OpenMS::TargetedExperiment should first convert it to a LightTargetedExperiment via OpenSwathDataAccessHelper::convertTargetedExp().

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_()

template<typename TransitionExpT >
static std::string extract_id_ ( TransitionExpT &  transition_exp_used,
const std::string &  id,
int &  prec_charge 
)
staticprivate

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

Parameters
[in]transition_exp_usedThe transition experiment used as input (LightTargetedExperiment)
[in]idThe identifier of the compound or peptide
[out]prec_chargeThe charge state of the precursor (filled by this function)

◆ 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 std::string &  filter 
)
inline

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

Parameters
[in]inputThe input spectra from which to extract chromatograms
[out]outputThe output vector in which to store the chromatograms (needs to be of the same length as the extraction coordinates, use prepare_coordinates)
[in]extraction_coordinatesThe extraction coordinates (m/z, RT, ion mobility)
[in]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)
[in]ppmWhether mz windows in ppm
[in]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 std::string &  filter 
)
inline

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

Parameters
[in]inputThe input spectra from which to extract chromatograms
[out]outputThe output vector in which to store the chromatograms (needs to be of the same length as the extraction coordinates, use prepare_coordinates)
[in]extraction_coordinatesThe extraction coordinates (m/z, RT, ion mobility)
[in]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)
[in]ppmWhether mz windows in ppm
[in]im_extraction_windowExtracts a window of this size in ion mobility
[in]filterWhich filter to use (bartlett or tophat)
Note
: whenever possible, please use this ChromatogramExtractorAlgorithm implementation

References ChromatogramExtractorAlgorithm::extractChromatograms().

◆ getFilterNr_()

int getFilterNr_ ( const std::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()

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

Prepare the extraction coordinates from a LightTargetedExperiment.

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
[in]output_chromatogramsAn empty vector which will be initialized correctly
[out]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)
[in]transition_exp_usedThe transition experiment used as input
[in]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, the compound's rt_start and rt_end fields are used directly (must be pre-populated, e.g. via OpenSwathDataAccessHelper::convertTargetedExp() from a compound whose rts vector contains exactly two entries).
[in]ms1Whether to extract for MS1 (peptide level) or MS2 (transition level)
[in]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

◆ prepareSpectra_()

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

◆ return_chromatogram()

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

Member Data Documentation

◆ PeptideRTMap_

std::map<std::string, double> PeptideRTMap_
private