OpenMS
MRMFeaturePickerFile Class Reference

_MRMFeaturePickerFile_ loads components and components groups parameters from a .csv file. More...

#include <OpenMS/FORMAT/MRMFeaturePickerFile.h>

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

Public Member Functions

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

Protected Member Functions

bool extractParamsFromLine_ (const StringList &line, const std::map< String, Size > &headers, MRMFeaturePicker::ComponentParams &cp, MRMFeaturePicker::ComponentGroupParams &cgp) const
 Extracts the information from a `StringList` and saves it into the correct data structures. More...
 
void setCastValue_ (const String &key, const String &value, Param &params) const
 Helper method which takes care of converting the given value to the desired type, based on the header (here `key`) information. More...
 

Detailed Description

_MRMFeaturePickerFile_ loads components and components groups parameters from a .csv file.

The structures defined in [MRMFeaturePicker](MRMFeaturePicker) are used.

It is required that columns `component_name` and `component_group_name` are present. Lines whose `component_name`'s or `component_group_name`'s value is an empty string, will be skipped. The class supports the absence of information within other columns.

A reduced example of the expected format (fewer columns are shown here): > component_name,component_group_name,TransitionGroupPicker:stop_after_feature,TransitionGroupPicker:PeakPickerMRM: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

Constructor.

◆ ~MRMFeaturePickerFile()

~MRMFeaturePickerFile ( )
overridedefault

Destructor.

Member Function Documentation

◆ extractParamsFromLine_()

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

Extracts the information from a `StringList` and saves it into the correct data structures.

Parameters
[in]lineThe line parsed from the input file
[in]headersA mapping from a given header to its value's position
[out]cpThe extracted component parameters
[out]cgpThe extracted component group parameters
Returns
Returns `false` if `component_name` or `component_group_name` are empty strings. Otherwise, it returns `true`.

◆ load()

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

Loads the file's data and saves it into vectors of `ComponentParams` and `ComponentGroupParams`.

The file is expected to contain at least two columns: `component_name` and `component_group_name`. Otherwise, an exception is thrown.

If a component group (identified by its name) is found multiple times, only the first one is saved.

Parameters
[in]filenamePath to the .csv input file
[out]cp_listComponent params are saved in this list
[out]cgp_listComponent Group params are saved in this list
Exceptions
Exception::MissingInformationIf the required columns are not found.
Exception::FileNotFoundIf input file is not found.

◆ setCastValue_()

void setCastValue_ ( const String key,
const String value,
Param params 
) const
protected

Helper method which takes care of converting the given value to the desired type, based on the header (here `key`) information.

Parameters
[in]keyThe header name with which the correct conversion is chosen
[in]valueThe value to be converted
[in,out]paramsThe object where the new value is saved