OpenMS
MRMFeatureQCFile Class Reference

File adapter for MRMFeatureQC files. More...

#include <OpenMS/FORMAT/MRMFeatureQCFile.h>

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

Public Member Functions

 MRMFeatureQCFile ()=default
 Default constructor. More...
 
 ~MRMFeatureQCFile () override=default
 Destructor. More...
 
void load (const String &filename, MRMFeatureQC &mrmfqc, const bool is_component_group) const
 Loads an MRMFeatureQC file. More...
 
void store (const String &filename, const MRMFeatureQC &mrmfqc, const bool is_component_group)
 
- 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 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...
 

Protected Member Functions

void pushValuesFromLine_ (const StringList &line, const std::map< String, Size > &headers, std::vector< MRMFeatureQC::ComponentQCs > &c_qcs) const
 Save values from a line to a `ComponentQCs`. More...
 
void pushValuesFromLine_ (const StringList &line, const std::map< String, Size > &headers, std::vector< MRMFeatureQC::ComponentGroupQCs > &cg_qcs) const
 Save values from a line to a `ComponentGroupQCs`. More...
 
void setPairValue_ (const String &key, const String &value, const String &boundary, std::map< String, std::pair< double, double >> &meta_values_qc) const
 Set one of the values in a pair. More...
 
Int getCastValue_ (const std::map< String, Size > &headers, const StringList &line, const String &header, const Int default_value) const
 Extracts a column's value from a line. More...
 
double getCastValue_ (const std::map< String, Size > &headers, const StringList &line, const String &header, const double default_value) const
 Extracts a column's value from a line. More...
 
String getCastValue_ (const std::map< String, Size > &headers, const StringList &line, const String &header, const String &default_value) const
 Extracts a column's value from a line. More...
 

Additional Inherited Members

- Public Types inherited from ProgressLogger
enum  LogType { CMD , GUI , NONE }
 Possible log types. More...
 
- Static Protected Member Functions inherited from ProgressLogger
static String logTypeToFactoryName_ (LogType type)
 Return the name of the factory product used for this log type. More...
 
- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImplcurrent_logger_
 
- Static Protected Attributes inherited from ProgressLogger
static int recursion_depth_
 
- Private 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...
 

Detailed Description

File adapter for MRMFeatureQC files.

Loads and stores .csv or .tsv files describing an MRMFeatureQC.

Constructor & Destructor Documentation

◆ MRMFeatureQCFile()

MRMFeatureQCFile ( )
default

Default constructor.

◆ ~MRMFeatureQCFile()

~MRMFeatureQCFile ( )
overridedefault

Destructor.

Member Function Documentation

◆ getCastValue_() [1/3]

double getCastValue_ ( const std::map< String, Size > &  headers,
const StringList line,
const String header,
const double  default_value 
) const
protected

Extracts a column's value from a line.

The method looks for the value found within `line[headers[header]]`. If the information is present and its value is valid, it will be converted to `double` and returned. Otherwise, `default_value` (provided by the user) is returned.

Parameters
[in]headersThe mapping from columns' name to positions' indices
[in]lineA list of strings containing a single row's values
[in]headerThe desired value's column name
[in]default_valueA default value to return in case the information is not found or invalid
Returns
The found information (if found and valid) converted to `double`. Otherwise `default_value`.

◆ getCastValue_() [2/3]

Int getCastValue_ ( const std::map< String, Size > &  headers,
const StringList line,
const String header,
const Int  default_value 
) const
protected

Extracts a column's value from a line.

The method looks for the value found within `line[headers[header]]`. If the information is present and its value is valid, it will be converted to `Int` and returned. Otherwise, `default_value` (provided by the user) is returned.

Parameters
[in]headersThe mapping from columns' name to positions' indices
[in]lineA list of strings containing a single row's values
[in]headerThe desired value's column name
[in]default_valueA default value to return in case the information is not found or invalid
Returns
The found information (if found and valid) converted to `Int`. Otherwise `default_value`.

◆ getCastValue_() [3/3]

String getCastValue_ ( const std::map< String, Size > &  headers,
const StringList line,
const String header,
const String default_value 
) const
protected

Extracts a column's value from a line.

The method looks for the value found within `line[headers[header]]`. If the information is present and its value is valid, it will be converted to `String` and returned. Otherwise, `default_value` (provided by the user) is returned.

Parameters
[in]headersThe mapping from columns' name to positions' indices
[in]lineA list of strings containing a single row's values
[in]headerThe desired value's column name
[in]default_valueA default value to return in case the information is not found or invalid
Returns
The found information (if found and valid) converted to `String`. Otherwise `default_value`.

◆ load()

void load ( const String filename,
MRMFeatureQC mrmfqc,
const bool  is_component_group 
) const

Loads an MRMFeatureQC file.

Exceptions
Exception::FileNotFoundis thrown if the file could not be opened
Exception::ParseErroris thrown if an error occurs during parsing
Parameters
[in]filenameThe path to the input file
[in,out]mrmfqcThe output class which will contain the criteria
[in]is_component_grouptrue if the user intends to load ComponentGroupQCs data, false otherwise

◆ pushValuesFromLine_() [1/2]

void pushValuesFromLine_ ( const StringList line,
const std::map< String, Size > &  headers,
std::vector< MRMFeatureQC::ComponentGroupQCs > &  cg_qcs 
) const
protected

Save values from a line to a `ComponentGroupQCs`.

Note
Lines missing the `component_group_name` value will be skipped.
Parameters
[in]lineA line containing the values from a row in the input file
[in]headersA mapping from headers names to position indices
[out]cg_qcsThe output will be saved in a new element of this vector

◆ pushValuesFromLine_() [2/2]

void pushValuesFromLine_ ( const StringList line,
const std::map< String, Size > &  headers,
std::vector< MRMFeatureQC::ComponentQCs > &  c_qcs 
) const
protected

Save values from a line to a `ComponentQCs`.

Note
Lines missing the `component_name` value will be skipped.
Parameters
[in]lineA line containing the values from a row in the input file
[in]headersA mapping from headers names to position indices
[out]c_qcsThe output will be saved in a new element of this vector

◆ setPairValue_()

void setPairValue_ ( const String key,
const String value,
const String boundary,
std::map< String, std::pair< double, double >> &  meta_values_qc 
) const
protected

Set one of the values in a pair.

The method is given in input a map from Strings to pairs. Assuming the key is present within the map, its mapped value will be updated with the given `value`, in the correct `boundary` position. If the key is not found, a new pair will be created and both its values set (in this case, a default value of 0.0 is given to the other pair's element).

Parameters
[in]keyThe metavalue name
[in]valueThe mapped pair
[in]boundary"l" for lower bound or "u" for upper bound
[out]meta_values_qcThe map containing the metavalues and pairs

◆ store()

void store ( const String filename,
const MRMFeatureQC mrmfqc,
const bool  is_component_group 
)