libSBML C++ API  5.20.4
RDFAnnotationParser Class Reference

Detailed Description

MIRIAM-compliant RDF annotation reader/writer.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.

RDFAnnotationParser is a libSBML construct used as part of the libSBML support for annotations conforming to the guidelines specified by MIRIAM ("Minimum Information Requested in the Annotation of biochemical Models", Nature Biotechnology, vol. 23, no. 12, Dec. 2005). Section 6 of the SBML Level 2 and Level 3 specification documents defines a recommended way of encoding MIRIAM information using a subset of RDF (Resource Description Format). The general scheme is as follows. A set of RDF-based annotations attached to a given SBML <annotation> element are read by RDFAnnotationParser and converted into a list of CVTerm objects. There are different versions of the main method, RDFAnnotationParser::parseRDFAnnotation(const XMLNode *annotation, List *CVTerms) and RDFAnnotationParser::parseRDFAnnotation(const XMLNode *annotation), used depending on whether the annotation in question concerns the MIRIAM model history or other MIRIAM resource annotations. A special object class, ModelHistory, is used to make it easier to manipulate model history annotations.

All of the methods on RDFAnnotationParser are static; the class exists only to encapsulate the annotation and CVTerm parsing and manipulation functionality.

Static Public Member Functions

static XMLNodecreateAnnotation ()
 Creates a blank annotation and returns its root XMLNode object. More...
 
static XMLNodecreateCVTerms (const SBase *obj)
 Takes a list of CVTerm objects and creates a the RDF "Description" element. More...
 
static XMLNodecreateRDFAnnotation (unsigned int level=3, unsigned int version=1)
 Creates a blank RDF element suitable for use in SBML annotations. More...
 
static XMLNodecreateRDFDescription (const SBase *obj)
 Takes an SBML object and creates an empty XMLNode corresponding to an RDF "Description" element. More...
 
static XMLNodedeleteRDFAnnotation (const XMLNode *annotation)
 Deletes any SBML MIRIAM RDF annotation found in the given XMLNode tree and returns any remaining annotation content. More...
 
static XMLNodedeleteRDFCVTermAnnotation (const XMLNode *annotation)
 Deletes any SBML MIRIAM RDF 'CVTerm' annotation found in the given XMLNode tree and returns any remaining annotation content. More...
 
static XMLNodedeleteRDFHistoryAnnotation (const XMLNode *annotation)
 Deletes any SBML MIRIAM RDF 'History' annotation found in the given XMLNode tree and returns any remaining annotation content. More...
 
static XMLNodeparseCVTerms (const SBase *obj)
 Takes a list of CVTerm objects and creates a complete SBML annotation around it. More...
 
static XMLNodeparseModelHistory (const SBase *obj)
 Reads the model history and cvTerms stored in obj and creates the XML structure for an SBML annotation representing that metadata if there is a model history stored in obj. More...
 
static XMLNodeparseOnlyModelHistory (const SBase *obj)
 Reads the model history stored in obj and creates the XML structure for an SBML annotation representing that history. More...
 
static ModelHistoryparseRDFAnnotation (const XMLNode *annotation, const char *metaId=NULL, XMLInputStream *stream=NULL, const SBase *parent=NULL)
 Parses an annotation into a ModelHistory class instance. More...
 
static void parseRDFAnnotation (const XMLNode *annotation, List *CVTerms, const char *metaId=NULL, XMLInputStream *stream=NULL)
 Parses an annotation (given as an XMLNode tree) into a list of CVTerm objects. More...
 

Member Function Documentation

◆ createAnnotation()

XMLNode * RDFAnnotationParser::createAnnotation ( )
static

Creates a blank annotation and returns its root XMLNode object.

This creates a completely empty SBML <annotation> element. It is not attached to any SBML element. An example of how this might be used is illustrated in the following code fragment. In this example, suppose that content is an XMLNode object previously created, containing MIRIAM-style annotations, and that sbmlObject is an SBML object derived from SBase (e.g., a Model, or a Species, or a Compartment, etc.). Then:

int success; // Status code variable.
XMLNode *RDF = createRDFAnnotation(); // Create XML structure.
success = RDF->addChild(...content...); // Put some content into it.
... // Check return code value.
XMLNode *ann = createAnnotation(); // Create <annotation>.
success = ann->addChild(RDF); // Put the annotation into it.
... // Check return code value.
success = sbmlObject->setAnnotation(ann); // Set object's annotation.
... // Check return code value.
static XMLNode * createAnnotation()
Creates a blank annotation and returns its root XMLNode object.
Definition: RDFAnnotationParser.cpp:420
static XMLNode * createRDFAnnotation(unsigned int level=3, unsigned int version=1)
Creates a blank RDF element suitable for use in SBML annotations.
Definition: RDFAnnotationParser.cpp:428
Definition: XMLNode.h:178
int addChild(const XMLNode &node)
Adds a copy of node as a child of this XMLNode.
Definition: XMLNode.cpp:243

The SBML specification contains more information about the format of annotations. We urge readers to consult Section 6 of the SBML Level 2 (Versions 2–4) and SBML Level 3 specification documents.

Returns
a pointer to an XMLNode for the annotation.
See also
createRDFAnnotation()

◆ createCVTerms()

XMLNode * RDFAnnotationParser::createCVTerms ( const SBase obj)
static

Takes a list of CVTerm objects and creates a the RDF "Description" element.

This essentially takes the given SBML object, reads out the CVTerm objects attached to it, creates an RDF "Description" element to hold the terms, and adds each term with appropriate qualifiers.

Parameters
objthe SBML object to start from.
Returns
the XMLNode tree corresponding to the Description element of an RDF annotation.

◆ createRDFAnnotation()

XMLNode * RDFAnnotationParser::createRDFAnnotation ( unsigned int  level = 3,
unsigned int  version = 1 
)
static

Creates a blank RDF element suitable for use in SBML annotations.

The annotation created by this method has namespace declarations for all the relevant XML namespaces used in RDF annotations and also has an empty RDF element. The result is the following XML:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns:dcterms="http://purl.org/dc/terms/"
         xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#"
         xmlns:bqbiol="http://biomodels.net/biology-qualifiers/"
         xmlns:bqmodel="http://biomodels.net/model-qualifiers/" >

</rdf:RDF>

Note that this does not create the containing SBML <annotation> element; the method createAnnotation() is available for creating the container.

Returns
a pointer to an XMLNode.
See also
createAnnotation()

◆ createRDFDescription()

XMLNode * RDFAnnotationParser::createRDFDescription ( const SBase obj)
static

Takes an SBML object and creates an empty XMLNode corresponding to an RDF "Description" element.

This method is a handy way of creating RDF description objects linked by the appropriate "metaid" field to the given object, for insertion into RDF annotations in a model. The method retrieves the "metaid" attribute from the object passed in as argument, then creates an empty element having the following form (where metaid the value of the "metaid" attribute of the argument):

<rdf:Description rdf:about="#metaid" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
...
</rdf:Description>

Note that this method does not create a complete annotation or even an RDF element; it only creates the "Description" portion. Callers will need to use other methods such as createRDFAnnotation() to create the rest of the structure for an annotation.

Parameters
objthe object to which the "Description" refers.
Returns
a new XMLNode containing the "rdf:Description" element with its "about" attribute value set to the object meta identifier.
See also
createRDFAnnotation()

◆ deleteRDFAnnotation()

XMLNode * RDFAnnotationParser::deleteRDFAnnotation ( const XMLNode annotation)
static

Deletes any SBML MIRIAM RDF annotation found in the given XMLNode tree and returns any remaining annotation content.

The name of the XMLNode given as parameter annotation must be "annotation", or else this method returns NULL. The method will walk down the XML structure looking for elements that are in the RDF XML namespace, and remove them if they conform to the syntax of a History or CVTerm element.

Parameters
annotationthe XMLNode tree within which the RDF annotation is to be found and deleted.
Returns
the XMLNode structure that is left after RDF annotations are deleted.

◆ deleteRDFCVTermAnnotation()

XMLNode * RDFAnnotationParser::deleteRDFCVTermAnnotation ( const XMLNode annotation)
static

Deletes any SBML MIRIAM RDF 'CVTerm' annotation found in the given XMLNode tree and returns any remaining annotation content.

The name of the XMLNode given as parameter annotation must be "annotation", or else this method returns NULL. The method will walk down the XML structure looking for elements that are in the RDF XML namespace, and remove any that conform to the syntax of a CVTerm element.

Parameters
annotationthe XMLNode tree within which the RDF annotation is to be found and deleted.
Returns
the XMLNode structure that is left after RDF annotations are deleted.

◆ deleteRDFHistoryAnnotation()

XMLNode * RDFAnnotationParser::deleteRDFHistoryAnnotation ( const XMLNode annotation)
static

Deletes any SBML MIRIAM RDF 'History' annotation found in the given XMLNode tree and returns any remaining annotation content.

The name of the XMLNode given as parameter annotation must be "annotation", or else this method returns NULL. The method will walk down the XML structure looking for elements that are in the RDF XML namespace, and remove any that conform to the syntax of a History element.

Parameters
annotationthe XMLNode tree within which the RDF annotation is to be found and deleted.
Returns
the XMLNode structure that is left after RDF annotations are deleted.

◆ parseCVTerms()

XMLNode * RDFAnnotationParser::parseCVTerms ( const SBase obj)
static

Takes a list of CVTerm objects and creates a complete SBML annotation around it.

This essentially takes the given SBML object, reads out the CVTerm objects attached to it, calls createRDFAnnotation() to create an RDF annotation to hold the terms, and finally callscreateAnnotation() to wrap the result as an SBML <annotation> element.

Parameters
objthe SBML object to start from.
Returns
the XMLNode tree corresponding to the annotation.

◆ parseModelHistory()

XMLNode * RDFAnnotationParser::parseModelHistory ( const SBase obj)
static

Reads the model history and cvTerms stored in obj and creates the XML structure for an SBML annotation representing that metadata if there is a model history stored in obj.

Parameters
objany SBase object.
Returns
the XMLNode corresponding to an annotation containing MIRIAM-compliant model history and CV term information in RDF format.
Note
If the object does not have a history element stored then NULL is returned even if CVTerms are present.

◆ parseOnlyModelHistory()

XMLNode * RDFAnnotationParser::parseOnlyModelHistory ( const SBase obj)
static

Reads the model history stored in obj and creates the XML structure for an SBML annotation representing that history.

Parameters
objany SBase object.
Returns
the XMLNode corresponding to an annotation containing MIRIAM-compliant model history information in RDF format.

◆ parseRDFAnnotation() [1/2]

ModelHistory * RDFAnnotationParser::parseRDFAnnotation ( const XMLNode annotation,
const char *  metaId = NULL,
XMLInputStream stream = NULL,
const SBase parent = NULL 
)
static

Parses an annotation into a ModelHistory class instance.

This is used to take an annotation that has been read into an SBML model, identify the RDF elements representing model history information, and create a list of corresponding CVTerm objects.

Parameters
annotationXMLNode containing the annotation.
streamoptional XMLInputStream that facilitates error logging.
metaIdoptional metaId, if set only the RDF annotation for this metaId will be returned.
Returns
a pointer to the ModelHistory created.

◆ parseRDFAnnotation() [2/2]

void RDFAnnotationParser::parseRDFAnnotation ( const XMLNode annotation,
List CVTerms,
const char *  metaId = NULL,
XMLInputStream stream = NULL 
)
static

Parses an annotation (given as an XMLNode tree) into a list of CVTerm objects.

This is used to take an annotation that has been read into an SBML model, identify the RDF elements within it, and create a list of corresponding CVTerm (controlled vocabulary term) objects.

Parameters
annotationXMLNode containing the annotation.
CVTermslist of CVTerm objects to be created.
metaIdoptional metaId, if set only the RDF annotation for this metaId will be returned.
streamoptional XMLInputStream that facilitates error logging.