The class provides simplified access to ontology files in the .obo format. More...
#include <ms_obofile.hpp>
Public Member Functions | |
ms_obofile () | |
Default constructor - not generally useful. | |
ms_obofile (const char *oboFileName) | |
Constructor which loads the obo file from a local file. | |
ms_obofile (const ms_obofile &right) | |
Copying constructor. | |
~ms_obofile () | |
Destructor. | |
void | appendErrors (const ms_errors &src) |
Copies all errors from another instance and appends them at the end of own list. | |
void | clearAllErrors () |
Remove all errors from the current list of errors. | |
void | copyFrom (const ms_errors *right) |
Use this member to make a copy of another instance. | |
void | copyFrom (const ms_obofile *right) |
Copies all data from another instance of the class. | |
void | defaultValues () |
Initialises the object. | |
std::string | findIDFromTagValue (const char *tag, const char *value) const |
Find the ontology term with an exact match to the passed tag/value pair. | |
const ms_errs * | getErrorHandler () const |
Retrive the error object using this function to get access to all errors and error parameters. | |
std::vector< std::string > | getItemFromId (const char *id) const |
Returns the vector of tag, value, comment strings for the specified ontology item. | |
int | getLastError () const |
Return the error description of the last error that occurred. | |
std::string | getLastErrorString () const |
Return the error description of the last error that occurred. | |
int | getNumberOfEntries () const |
Returns the number of entries . | |
bool | isValid () const |
Call this function to determine if there have been any errors. | |
ms_obofile & | operator= (const ms_obofile &right) |
Assignment operator. | |
void | parseLine (const std::string str, std::string &tag, std::string &value, std::string &comment) const |
Retrieves the tag, value and any comments from a line in the obo file. | |
The class provides simplified access to ontology files in the .obo format.
The file format for the ontology files is described in http://www.geneontology.org/GO.format.obo-1_2.shtml .
This class provides limited read only access to OBO files. The aim of the class is to allow scripts using Mascot Parser to easily look up an ID for a given term in a local .obo file.
ms_obofile | ( | ) |
Default constructor - not generally useful.
Create a default empty ontology.
ms_obofile | ( | const char * | oboFileName | ) |
Constructor which loads the obo file from a local file.
Loads ontology from a local file. The file format will be:
[Term] id: PI:00000 name: protein informatics cv def: "Collection of terms for PSI Proteome Informatics standards." [PSI:PI] [Term] . . .
The ID of each term is indexed for fast access.
After loading, use the isValid() function to determine if there were any errors.
oboFileName | is the file name of the local file. |
ms_obofile | ( | const ms_obofile & | src | ) |
Copying constructor.
src | is the original OBO file. |
~ms_obofile | ( | ) |
Destructor.
No need to call this directly. Frees the complete ontology.
|
inherited |
Copies all errors from another instance and appends them at the end of own list.
src | The object to copy the errors across from. See Maintaining object references: two rules of thumb. |
|
inherited |
Remove all errors from the current list of errors.
The list of 'errors' can include fatal errors, warning messages, information messages and different levels of debugging messages.
All messages are accumulated into a list in this object, until clearAllErrors() is called.
See Error Handling.
|
inherited |
Use this member to make a copy of another instance.
right | is the source to initialise from |
void copyFrom | ( | const ms_obofile * | right | ) |
Copies all data from another instance of the class.
right | is the original object to copy to the new one. |
void defaultValues | ( | ) |
Initialises the object.
Reset all values to their defaults.
std::string findIDFromTagValue | ( | const char * | tag, |
const char * | value | ||
) | const |
Find the ontology term with an exact match to the passed tag/value pair.
This function is only useful for retrieving items where you expect the tag value to be unique – for example the "name" field.
tag | is the name of the tag. For example, "name", "is_a", "property_value". |
value | is the value to be found. |
|
inherited |
Retrive the error object using this function to get access to all errors and error parameters.
See Error Handling.
std::vector< std::string > getItemFromId | ( | const char * | id | ) | const |
Returns the vector of tag, value, comment strings for the specified ontology item.
Returns all the lines in the [Term]
for the specified ID.
id | is the ID of the term. For example, "PI:00171". |
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
int getNumberOfEntries | ( | ) | const |
Returns the number of entries .
Each [Term]
section is considered to be a single entry.
|
inherited |
Call this function to determine if there have been any errors.
This will return true unless there have been any fatal errors.
See Error Handling.
ms_obofile & operator= | ( | const ms_obofile & | right | ) |
Assignment operator.
right | is the original object to copy to the new one. |
void parseLine | ( | const std::string | str, |
std::string & | tag, | ||
std::string & | value, | ||
std::string & | comment | ||
) | const |
Retrieves the tag, value and any comments from a line in the obo file.
For example, for the following line, the tag would be "is_a", the value returned would be "PI:00153" and the comment would be "search engine specific score":
is_a: PI:00153 ! search engine specific score
str | is the input string. |
tag | is the name of the tag in the input line. |
value | is the value of the tag in the input line. |
comment | is any comment (after the ! in the input line). |