OpenMS
Loading...
Searching...
No Matches
MRMFeaturePickerFile Class Reference

Loads MRM component and component-group parameter sets from a comma-separated file. More...

#include <OpenMS/FORMAT/MRMFeaturePickerFile.h>

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

Public Member Functions

 MRMFeaturePickerFile ()=default
 Default constructor.
 
 ~MRMFeaturePickerFile () override=default
 Destructor.
 
void load (const std::string &filename, std::vector< MRMFeaturePicker::ComponentParams > &cp_list, std::vector< MRMFeaturePicker::ComponentGroupParams > &cgp_list)
 Read filename and populate cp_list / cgp_list.
 
- Public Member Functions inherited from CsvFile
 CsvFile ()
 Default constructor.
 
 ~CsvFile () override
 destructor
 
 CsvFile (const std::string &filename, char is=',', bool ie=false, Int first_n=-1)
 Constructor with filename.
 
void load (const std::string &filename, char is=',', bool ie=false, Int first_n=-1)
 Loads data from a text file.
 
void store (const std::string &filename)
 Stores the buffer's content into a file.
 
void addRow (const StringList &list)
 Add a row to the buffer.
 
void clear ()
 Clears the buffer.
 
bool getRow (Size row, StringList &list) const
 writes all items from a row to list
 
std::vector< std::string >::size_type rowCount () const
 Returns the number of rows that were loaded from the file.
 

Protected Member Functions

bool extractParamsFromLine_ (const StringList &line, const std::map< std::string, Size > &headers, MRMFeaturePicker::ComponentParams &cp, MRMFeaturePicker::ComponentGroupParams &cgp) const
 Extract the ComponentParams and ComponentGroupParams entries from a single parsed CSV line.
 
void setCastValue_ (const std::string &key, const std::string &value, Param &params) const
 Insert value into params under key, converting the string to the type expected for that parameter name.
 

Detailed Description

Loads MRM component and component-group parameter sets from a comma-separated file.

Produces parallel ComponentParams and ComponentGroupParams vectors (see MRMFeaturePicker) for use by MRMFeaturePicker.

File format
Two required columns: "component_name" and "component_group_name". Any additional column is interpreted by its header name:
  • "TransitionGroupPicker:PeakPickerChromatogram:&lt;param&gt;" feeds the per-component parameter set (ComponentParams::params).
  • "TransitionGroupPicker:&lt;param&gt;" (without the PeakPickerChromatogram prefix) feeds the per-component-group parameter set (ComponentGroupParams::params).
  • Any other column is ignored. Cells whose value is empty are not written into the parameter set. Lines whose component_name or component_group_name cell is empty are skipped entirely.

A reduced example (fewer columns are shown here):

‍component_name,component_group_name,TransitionGroupPicker:stop_after_feature,TransitionGroupPicker:PeakPickerChromatogram:sgolay_frame_length arg-L.arg-L_1.Heavy,arg-L,2,15 arg-L.arg-L_1.Light,arg-L,2,17 orn.orn_1.Heavy,orn,3,21 orn.orn_1.Light,orn,3,13

Constructor & Destructor Documentation

◆ MRMFeaturePickerFile()

MRMFeaturePickerFile ( )
default

Default constructor.

◆ ~MRMFeaturePickerFile()

~MRMFeaturePickerFile ( )
overridedefault

Destructor.

Member Function Documentation

◆ extractParamsFromLine_()

bool extractParamsFromLine_ ( const StringList line,
const std::map< std::string, Size > &  headers,
MRMFeaturePicker::ComponentParams cp,
MRMFeaturePicker::ComponentGroupParams cgp 
) const
protected

Extract the ComponentParams and ComponentGroupParams entries from a single parsed CSV line.

Reads component_name and component_group_name from line via headers; if either is empty, the call returns false and cp / cgp are left in an unspecified state. Otherwise every column whose header matches one of the TransitionGroupPicker: prefixes feeds the corresponding parameter set as described in the class brief.

Parameters
[in]lineTokens of the input line, indexed by headers.
[in]headersMapping from header name to column index in line.
[out]cpReceives the per-component parameters.
[out]cgpReceives the per-component-group parameters (component_group_name plus any matching values).
Returns
true on a fully-populated pair; false when either required name cell was empty.

◆ load()

void load ( const std::string &  filename,
std::vector< MRMFeaturePicker::ComponentParams > &  cp_list,
std::vector< MRMFeaturePicker::ComponentGroupParams > &  cgp_list 
)

Read filename and populate cp_list / cgp_list.

Both output vectors are cleared at the start of the call. The file is parsed as comma-separated; the first non-empty line is treated as the header. For every subsequent line with non-empty component_name and component_group_name cells one ComponentParams entry is appended to cp_list. A ComponentGroupParams entry is appended to cgp_list only the first time a given component_group_name is encountered; subsequent rows with the same group name extend cp_list but do not produce a new cgp_list entry.

Note
If the file contains zero or one line, no header validation is performed and the output vectors stay empty.
Parameters
[in]filenamePath to the .csv input file.
[out]cp_listReceives the per-row component parameters.
[out]cgp_listReceives one entry per unique component_group_name.
Exceptions
Exception::MissingInformationWhen the required component_name and/or component_group_name columns are absent.
Exception::FileNotFoundWhen filename cannot be opened.

◆ setCastValue_()

void setCastValue_ ( const std::string &  key,
const std::string &  value,
Param params 
) const
protected

Insert value into params under key, converting the string to the type expected for that parameter name.

Empty values are dropped without modifying params. The target type is selected by looking key up in a hard-coded table:

  • "gauss_width", "peak_width", "signal_to_noise", "sn_win_len", "stop_after_intensity_ratio", "min_peak_width", "recalculate_peaks_max_z", "minimal_quality", "resample_boundary" -> double.
  • "use_gauss", "write_sn_log_messages", "remove_overlapping_peaks", "recalculate_peaks", "use_precursors", "compute_peak_quality", "compute_peak_shape_metrics" -> bool (case-insensitive "true" maps to "true", everything else to "false").
  • "sgolay_frame_length", "sgolay_polynomial_order", "sn_bin_count" -> UInt (via double rounding).
  • "stop_after_feature" -> Int.
  • Anything else -> stored as a String.
Parameters
[in]keyParameter name (the column header with any TransitionGroupPicker: prefix already stripped).
[in]valueValue to convert.
[in,out]paramsParameter container to update.