OpenMS  2.7.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
MSPGenericFile Class Reference

Load MSP text file and save it into an `MSExperiment`. More...

#include <OpenMS/FORMAT/MSPGenericFile.h>

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

Public Member Functions

 MSPGenericFile ()
 Default constructor. More...
 
 MSPGenericFile (const String &filename, MSExperiment &library)
 Constructor with filename and output library. More...
 
 ~MSPGenericFile ()=default
 Destructor. More...
 
void getDefaultParameters (Param &params)
 Get the class' default parameters. More...
 
void load (const String &filename, MSExperiment &library)
 Load the file's data and metadata, and save it into an `MSExperiment`. More...
 
void store (const String &filename, const MSExperiment &library) const
 Save data and metadata into a file. More...
 
- Public Member Functions inherited from DefaultParamHandler
 DefaultParamHandler (const String &name)
 Constructor with name that is displayed in error messages. More...
 
 DefaultParamHandler (const DefaultParamHandler &rhs)
 Copy constructor. More...
 
virtual ~DefaultParamHandler ()
 Destructor. More...
 
virtual DefaultParamHandleroperator= (const DefaultParamHandler &rhs)
 Assignment operator. More...
 
virtual bool operator== (const DefaultParamHandler &rhs) const
 Equality operator. More...
 
void setParameters (const Param &param)
 Sets the parameters. More...
 
const ParamgetParameters () const
 Non-mutable access to the parameters. More...
 
const ParamgetDefaults () const
 Non-mutable access to the default parameters. More...
 
const StringgetName () const
 Non-mutable access to the name. More...
 
void setName (const String &name)
 Mutable access to the name. More...
 
const std::vector< String > & getSubsections () const
 Non-mutable access to the registered subsections. More...
 

Private Member Functions

void updateMembers_ ()
 Overrides `DefaultParamHandler`'s method. More...
 
void addSpectrumToLibrary (MSSpectrum &spectrum, MSExperiment &library)
 

Private Attributes

std::set< Stringloaded_spectra_names_
 To keep track of which spectra have already been loaded and avoid duplicates. More...
 
std::vector< Stringsynonyms_
 
String synonyms_separator_
 The separator to be used in "Synon" metaValue. More...
 

Friends

class MSPGenericFile_friend
 To test private and protected methods. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DefaultParamHandler
static void writeParametersToMetaValues (const Param &write_this, MetaInfoInterface &write_here, const String &prefix="")
 Writes all parameters to meta values. More...
 
- Protected Member Functions inherited from DefaultParamHandler
void defaultsToParam_ ()
 Updates the parameters after the defaults have been set in the constructor. More...
 
- Protected Attributes inherited from DefaultParamHandler
Param param_
 Container for current parameters. More...
 
Param defaults_
 Container for default parameters. This member should be filled in the constructor of derived classes! More...
 
std::vector< Stringsubsections_
 Container for registered subsections. This member should be filled in the constructor of derived classes! More...
 
String error_name_
 Name that is displayed in error messages during the parameter checking. More...
 
bool check_defaults_
 If this member is set to false no checking if parameters in done;. More...
 
bool warn_empty_defaults_
 If this member is set to false no warning is emitted when defaults are empty;. More...
 

Detailed Description

Load MSP text file and save it into an `MSExperiment`.

This class is specialized for metabolites data. The required fields are: Name, Num Peaks, and the peaks data

Points (meaning x and y info) may be separated by a space or a colon. Peaks may be separated by a space or a semicolon.

An example of the expected format: > Name: foo > Num Peaks: 11 > 35 310; 36 1230; 37 27; 38 303; 47 5240; > 66 203; 67 68; 68 77; 82 63; 83 240; > 136 350;

Another supported format: > Name: bar > Num Peaks: 11 > 35:310 36:1230 37:27 38:303 47:5240 > 66:203 67:68 68:77 82:63 83:240 > 136:350

Constructor & Destructor Documentation

◆ MSPGenericFile() [1/2]

Default constructor.

◆ MSPGenericFile() [2/2]

MSPGenericFile ( const String filename,
MSExperiment library 
)

Constructor with filename and output library.

◆ ~MSPGenericFile()

~MSPGenericFile ( )
default

Destructor.

Member Function Documentation

◆ addSpectrumToLibrary()

void addSpectrumToLibrary ( MSSpectrum spectrum,
MSExperiment library 
)
private

Validate and add a spectrum to a spectral library

The spectrum is added to the library if all following criteria are met:

  • Name field is present and not empty
  • The number of peaks parsed matches the value of Num Peaks
  • A spectrum of the same name has not already been added
Exceptions
MissingInformationIf the spectrum doesn't have a name or Num Peaks info is missing
ParseErrorIf Num Peaks' value doesn't match with the number of raw peaks parsed
Parameters
[in/out]spectrum The spectrum to be added
[out]libraryThe spectrum is added into this `MSExperiment` library

Referenced by MSPGenericFile_friend::addSpectrumToLibrary().

◆ getDefaultParameters()

void getDefaultParameters ( Param params)

Get the class' default parameters.

◆ load()

void load ( const String filename,
MSExperiment library 
)

Load the file's data and metadata, and save it into an `MSExperiment`.

Parameters
[in]filenamePath to the MSP input file
[out]libraryThe variable into which the extracted information will be saved
Exceptions
FileNotFoundIf the file could not be found

◆ store()

void store ( const String filename,
const MSExperiment library 
) const

Save data and metadata into a file.

Parameters
[in]filenamePath to the MSP input file
[out]libraryThe variable from which extracted information will be saved
Exceptions
FileNotWritableIf the file is not writable

◆ updateMembers_()

void updateMembers_ ( )
privatevirtual

Overrides `DefaultParamHandler`'s method.

Reimplemented from DefaultParamHandler.

Friends And Related Function Documentation

◆ MSPGenericFile_friend

friend class MSPGenericFile_friend
friend

To test private and protected methods.

Member Data Documentation

◆ loaded_spectra_names_

std::set<String> loaded_spectra_names_
private

To keep track of which spectra have already been loaded and avoid duplicates.

◆ synonyms_

std::vector<String> synonyms_
private

◆ synonyms_separator_

String synonyms_separator_
private

The separator to be used in "Synon" metaValue.