![]() |
OpenMS
|
#include <OpenMS/FORMAT/ControlledVocabulary.h>
Classes | |
| struct | CVTerm |
| Representation of a CV term. More... | |
| struct | FNV1aHasher |
| ensure same hash on all platforms (for reproducibility)- More... | |
Public Member Functions | |
| ControlledVocabulary () | |
| Constructor. | |
| virtual | ~ControlledVocabulary () |
| Destructor. | |
| const std::string & | name () const |
| Returns the CV name (set in the load method) | |
| const std::string & | label () const |
| Returns the CV label (set in the load method) | |
| const std::string & | version () const |
| Returns the CV version (set in the load method) | |
| const std::string & | url () const |
| Returns the CV url (set in the load method) | |
| void | loadFromOBO (const std::string &name, const std::string &filename) |
| Loads the CV from an OBO file. | |
| bool | exists (const std::string &id) const |
| Returns true if the term is in the CV. Returns false otherwise. | |
| bool | hasTermWithName (const std::string &name) const |
| Returns true if a term with the given name is in the CV. Returns false otherwise. | |
| const CVTerm & | getTerm (const std::string &id) const |
| Returns a term specified by ID. | |
| const CVTerm & | getTermByName (const std::string &name, const std::string &desc="") const |
| Returns a term specified by name. | |
| const std::map< std::string, CVTerm > & | getTerms () const |
| returns all the terms stored in the CV | |
| void | getAllChildTerms (std::set< std::string > &terms, const std::string &parent_id) const |
| Writes all child terms recursively into terms. | |
| void | addAllChildTerms (std::set< std::string > &terms, const std::string &parent_id) const |
Writes the parent term and all descendant term IDs into terms. | |
| template<class LAMBDA > | |
| bool | iterateAllChildren (const std::string &parent_id, LAMBDA lbd) const |
| Iterates over all children (incl. subchildren etc) of parent recursively, i.e. the whole subtree. | |
| const ControlledVocabulary::CVTerm * | checkAndGetTermByName (const std::string &name) const |
Searches the existing terms for the given name. | |
| bool | isChildOf (const std::string &child_id, const std::string &parent_id) const |
Returns if child is a child of parent. | |
Static Public Member Functions | |
| static const ControlledVocabulary & | getPSIMSCV () |
| Returns a CV for parsing/storing PSI-MS related data, e.g. mzML, or handle accessions/ids in datastructures. | |
Protected Member Functions | |
| bool | checkName_ (const std::string &id, const std::string &name, bool ignore_case=true) const |
| checks if a name corresponds to an id | |
Protected Attributes | |
| std::map< std::string, CVTerm > | terms_ |
| Map from ID to CVTerm. | |
| std::map< std::string, std::string > | namesToIds_ |
| Map from name to id. | |
| std::string | name_ |
| Name set in the load method. | |
| std::string | label_ |
| CV label. | |
| std::string | version_ |
| CV version. | |
| std::string | url_ |
| CV URL. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const ControlledVocabulary &cv) |
| Print the contents to a stream. | |
@brief Representation of a controlled vocabulary. This representation only contains the information used for parsing and validation. All other lines are stored in the @em unparsed member of the CVTerm struct.
Constructor.
|
virtual |
Destructor.
| void addAllChildTerms | ( | std::set< std::string > & | terms, |
| const std::string & | parent_id | ||
| ) | const |
Writes the parent term and all descendant term IDs into terms.
| [in,out] | terms | Output set extended with parent_id and all descendants |
| [in] | parent_id | The parent term ID |
| Exception::InvalidValue | is thrown if the term is not present |
| const ControlledVocabulary::CVTerm * checkAndGetTermByName | ( | const std::string & | name | ) | const |
Searches the existing terms for the given name.
| [in] | name | The term name to search for |
|
protected |
checks if a name corresponds to an id
If the term is not known, 'true' is returned!
| bool exists | ( | const std::string & | id | ) | const |
Returns true if the term is in the CV. Returns false otherwise.
| void getAllChildTerms | ( | std::set< std::string > & | terms, |
| const std::string & | parent_id | ||
| ) | const |
Writes all child terms recursively into terms.
If parent has child this method writes them recursively into the term object
| [out] | terms | Output set of child term IDs |
| [in] | parent_id | The parent term ID |
| Exception::InvalidValue | is thrown if the term is not present |
|
static |
Returns a CV for parsing/storing PSI-MS related data, e.g. mzML, or handle accessions/ids in datastructures.
The CV will be initialized on first access. Repeated access is therefor cheap.
It consists of the following CVs:
| const CVTerm & getTerm | ( | const std::string & | id | ) | const |
Returns a term specified by ID.
| Exception::InvalidValue | is thrown if the term is not present |
| const CVTerm & getTermByName | ( | const std::string & | name, |
| const std::string & | desc = "" |
||
| ) | const |
Returns a term specified by name.
| Exception::InvalidValue | is thrown if the term is not present |
| const std::map< std::string, CVTerm > & getTerms | ( | ) | const |
returns all the terms stored in the CV
| bool hasTermWithName | ( | const std::string & | name | ) | const |
Returns true if a term with the given name is in the CV. Returns false otherwise.
| bool isChildOf | ( | const std::string & | child_id, |
| const std::string & | parent_id | ||
| ) | const |
Returns if child is a child of parent.
| [in] | child_id | The child term ID |
| [in] | parent_id | The parent term ID |
| Exception::InvalidValue | is thrown if one of the terms is not present |
|
inline |
Iterates over all children (incl. subchildren etc) of parent recursively, i.e. the whole subtree.
| [in] | parent_id | Id of parent (to be passed to getTerm(), to obtain its children). |
| [in] | lbd | Function that gets the child-Ids passed. Must return bool. Used for comparisons and / or to set captured variables. If the lambda returns true, the iteration is exited prematurely. E.g. if you have found your search, you don't need to continue searching. Otherwise, if you want to go through the whole tree (e.g. to fill a vector) you can just return false always to not quit early. |
| const std::string & label | ( | ) | const |
Returns the CV label (set in the load method)
| void loadFromOBO | ( | const std::string & | name, |
| const std::string & | filename | ||
| ) |
Loads the CV from an OBO file.
| [in] | name | The CV name |
| [in] | filename | The OBO file path |
| Exception::FileNotFound | is thrown if the file could not be opened |
| Exception::ParseError | is thrown if an error occurs during parsing |
| const std::string & name | ( | ) | const |
Returns the CV name (set in the load method)
| const std::string & url | ( | ) | const |
Returns the CV url (set in the load method)
| const std::string & version | ( | ) | const |
Returns the CV version (set in the load method)
|
friend |
Print the contents to a stream.
|
protected |
CV label.
|
protected |
Name set in the load method.
|
protected |
Map from name to id.
|
protected |
CV URL.
|
protected |
CV version.