| OpenMS 2.5.0

Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ControlledVocabulary Class Reference
Format

Representation of a controlled vocabulary. More...

`#include <OpenMS/FORMAT/ControlledVocabulary.h>`

## Classes

struct | CVTerm
| Representation of a CV term. More...

## Public Member Functions

| ControlledVocabulary ()
| Constructor. More...
virtual | ~ControlledVocabulary ()
| Destructor. More...
const String & | name () const
| Returns the CV name (set in the load method) More...
void | loadFromOBO (const String &name, const String &filename)
| Loads the CV from an OBO file. More...
bool | exists (const String &id) const
| Returns true if the term is in the CV. Returns false otherwise. More...
bool | hasTermWithName (const String &name) const
| Returns true if a term with the given name is in the CV. Returns false otherwise. More...
const CVTerm & | getTerm (const String &id) const
| Returns a term specified by ID. More...
const CVTerm & | getTermByName (const String &name, const String &desc="") const
| Returns a term specified by name. More...
const Map< String, CVTerm > & | getTerms () const
| returns all the terms stored in the CV More...
void | getAllChildTerms (std::set< String > &terms, const String &parent) const
| Writes all child terms recursively into terms. More...
bool | isChildOf (const String &child, const String &parent) const
| Returns if `child` is a child of `parent`. More...

## Protected Member Functions

bool | checkName_ (const String &id, const String &name, bool ignore_case=true)
| checks if a name corresponds to an id More...

## Protected Attributes

Map< String, CVTerm > | terms_
| Map from ID to CVTerm. More...
Map< String, String > | namesToIds_
| Map from name to id. More...
String | name_
| Name set in the load method. More...

## Friends

std::ostream & | operator<< (std::ostream &os, const ControlledVocabulary &cv)
| Print the contents to a stream. More...

## Detailed Description

Representation of a controlled vocabulary.

This representation only contains the information used for parsing and validation. All other lines are stored in the unparsed member of the CVTerm struct.

## Constructor & Destructor Documentation

## ◆ ControlledVocabulary()

ControlledVocabulary | ( |  | ) |

Constructor.

## ◆ ~ControlledVocabulary()

virtual ~ControlledVocabulary | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## ◆ checkName_()

bool checkName_ | ( | const String & | id,
|  | const String & | name,
|  | bool | ignore_case = `true`
| ) |  |

protected

checks if a name corresponds to an id

If the term is not known, 'true' is returned!

## ◆ exists()

bool exists | ( | const String & | id | ) | const

Returns true if the term is in the CV. Returns false otherwise.

## ◆ getAllChildTerms()

void getAllChildTerms | ( | std::set< String > & | terms,
|  | const String & | parent
| ) |  | const

Writes all child terms recursively into terms.

If parent has child this method writes them recursively into the term object

Exceptions

  Exception::InvalidValue | is thrown if the term is not present

## ◆ getTerm()

const CVTerm& getTerm | ( | const String & | id | ) | const

Returns a term specified by ID.

Exceptions

  Exception::InvalidValue | is thrown if the term is not present

## ◆ getTermByName()

const CVTerm& getTermByName | ( | const String & | name,
|  | const String & | desc = `""`
| ) |  | const

Returns a term specified by name.

Exceptions

  Exception::InvalidValue | is thrown if the term is not present

## ◆ getTerms()

const Map<String, CVTerm>& getTerms | ( |  | ) | const

returns all the terms stored in the CV

## ◆ hasTermWithName()

bool hasTermWithName | ( | const String & | name | ) | const

Returns true if a term with the given name is in the CV. Returns false otherwise.

## ◆ isChildOf()

bool isChildOf | ( | const String & | child,
|  | const String & | parent
| ) |  | const

Returns if `child` is a child of `parent`.

Exceptions

  Exception::InvalidValue | is thrown if one of the terms is not present

## ◆ loadFromOBO()

void loadFromOBO | ( | const String & | name,
|  | const String & | filename
| ) |  |

Loads the CV from an OBO file.

Exceptions

  Exception::FileNotFound | is thrown if the file could not be opened
  Exception::ParseError | is thrown if an error occurs during parsing

## ◆ name()

const String& name | ( |  | ) | const

Returns the CV name (set in the load method)

## Friends And Related Function Documentation

## ◆ operator<<

std::ostream& operator<< | ( | std::ostream & | os,
|  | const ControlledVocabulary & | cv
| ) |  |

friend

Print the contents to a stream.

## Member Data Documentation

## ◆ name_

String name_

protected

Name set in the load method.

## ◆ namesToIds_

Map<String, String> namesToIds_

protected

Map from name to id.

## ◆ terms_

Map<String, CVTerm> terms_

protected

Map from ID to CVTerm.