public class RDFAnnotationParser extends Object
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 in SBML. 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(XMLNode annotation, CVTermList CVTerms)
and RDFAnnotationParser.parseRDFAnnotation(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.
Constructor and Description |
---|
RDFAnnotationParser()   |
Modifier and Type | Method and Description |
---|---|
static XMLNode |
createAnnotation()
Creates a blank annotation and returns its root
XMLNode object. |
static XMLNode |
createCVTerms(SBase obj)
Takes a list of
CVTerm objects and creates a the RDF 'Description'
element. |
static XMLNode |
createRDFAnnotation()
Creates a blank RDF element suitable for use in SBML annotations.
|
void |
delete()
Explicitly deletes the underlying native object.
|
static XMLNode |
deleteRDFAnnotation(XMLNode annotation)
Deletes any SBML MIRIAM RDF annotation found in the given
XMLNode
tree and returns
any remaining annotation content. |
static XMLNode |
deleteRDFCVTermAnnotation(XMLNode annotation)
|
static XMLNode |
deleteRDFHistoryAnnotation(XMLNode annotation)
Deletes any SBML MIRIAM RDF 'History' annotation found in the given
XMLNode tree and returns
any remaining annotation content. |
static XMLNode |
parseCVTerms(SBase obj)
Takes a list of
CVTerm objects and creates a complete SBML annotation
around it. |
static XMLNode |
parseModelHistory(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 . |
static XMLNode |
parseOnlyModelHistory(SBase obj)
Reads the model history stored in
obj and creates the
XML structure for an SBML annotation representing that history. |
static ModelHistory |
parseRDFAnnotation(XMLNode annotation)
Parses an annotation into a
ModelHistory class instance. |
static void |
parseRDFAnnotation(XMLNode annotation,
CVTermList CVTerms)   |
static ModelHistory |
parseRDFAnnotation(XMLNode annotation,
String metaId)
Parses an annotation into a
ModelHistory class instance. |
static ModelHistory |
parseRDFAnnotation(XMLNode annotation,
String metaId,
XMLInputStream stream)
Parses an annotation into a
ModelHistory class instance. |
static void |
parseRDFAnnotation(XMLNode annotation,
org.sbml.libsbml.SWIGTYPE_p_List CVTerms,
String metaId)
|
static void |
parseRDFAnnotation(XMLNode annotation,
org.sbml.libsbml.SWIGTYPE_p_List CVTerms,
String metaId,
XMLInputStream stream)
|
public RDFAnnotationParser()
public static XMLNode createAnnotation()
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, used below.XMLNode
RDF = createRDFAnnotation() // Create RDF annotation XML structure. success = RDF.addChild(...content...) // Put some content into it. ... // Check 'success' return code value.XMLNode
ann = createAnnotation() // Create <annotation> container. success = ann.addChild(RDF) // Put the RDF annotation into it. ... // Check 'success' return code value. success = sbmlObject.setAnnotation(ann) // Set object's annotation to what we built. ... // Check 'success' return code value.
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&ndash4) and SBML Level 3 specification documents.
XMLNode
for the annotation
RDFAnnotationParser.createRDFAnnotation()
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_createAnnotation(). They are functionally
identical.
public static XMLNode createCVTerms(SBase obj)
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.
obj
- the SBML object to start from
XMLNode
tree corresponding to the Description element of
an RDF annotation.
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
createRDFDescription(@if java SBase
obj). They are functionally
identical. @endifpublic static XMLNode createRDFAnnotation()
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
RDFAnnotationParser.createAnnotation()
is available for creating the container.
XMLNode
RDFAnnotationParser.createAnnotation()
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_createRDFAnnotation(). They are functionally
identical.
public void delete()
In general, application software will not need to call this method directly. The Java language binding for libSBML is implemented as a language wrapper that provides a Java interface to libSBML's underlying C++/C code. Some of the Java methods return objects that are linked to objects created not by Java code, but by C++ code. The Java objects wrapped around them will be deleted when the garbage collector invokes the corresponding C++ finalize()
methods for the objects. The finalize()
methods in turn call the RDFAnnotationParser.delete()
method on the libSBML object.
This method is exposed in case calling programs want to ensure that the underlying object is freed immediately, and not at some arbitrary time determined by the Java garbage collector. In normal usage, callers do not need to invoke RDFAnnotationParser.delete()
themselves.
public static XMLNode deleteRDFAnnotation(XMLNode annotation)
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.
annotation
- the XMLNode
tree within which the RDF annotation is
to be found and deleted
XMLNode
structure that is left after RDF annotations are
deleted.
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_deleteRDFAnnotation(). They are functionally
identical.public static XMLNode deleteRDFCVTermAnnotation(XMLNode annotation)
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.
annotation
- the XMLNode
tree within which the RDF annotation is
to be found and deleted
XMLNode
structure that is left after RDF annotations are
deleted.
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_deleteRDFAnnotation(). They are functionally
identical.public static XMLNode deleteRDFHistoryAnnotation(XMLNode annotation)
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.
annotation
- the XMLNode
tree within which the RDF annotation is
to be found and deleted
XMLNode
structure that is left after RDF annotations are
deleted.
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_deleteRDFAnnotation(). They are functionally
identical.public static XMLNode parseCVTerms(SBase obj)
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 * RDFAnnotationParser.createRDFAnnotation()
to create an RDF
annotation to hold the terms, and finally calls * RDFAnnotationParser.createAnnotation()
to wrap the result as
an SBML <annotation>
element.
obj
- the SBML object to start from
XMLNode
tree corresponding to the annotation.
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_parseCVTerms(). They are functionally
identical.public static XMLNode parseModelHistory(SBase obj)
obj
and creates the
XML structure for an SBML annotation representing that metadata if
there is a model history stored in obj
.
obj
- any SBase
object
XMLNode
corresponding to an annotation containing
MIRIAM-compliant model history and CV term information in RDF format.
null
is returned even if CVTerms are present.
, Because this is a static method, the non-C++
language interfaces for libSBML will contain two variants. One will
be a static method on the class (i.e., RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_parseModelHistory(@if java Sbase obj). They
are functionally identical. @endif
public static XMLNode parseOnlyModelHistory(SBase obj)
obj
and creates the
XML structure for an SBML annotation representing that history.
obj
- any SBase
object
XMLNode
corresponding to an annotation containing
MIRIAM-compliant model history information in RDF format.
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_parseOnlyModelHistory(). They are functionally
identical.public static ModelHistory parseRDFAnnotation(XMLNode annotation)
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.
annotation
- XMLNode
containing the annotation.stream
- optional XMLInputStream that facilitates error loggingmetaId
- optional metaId, if set only the rdf annotation for this metaId will be returned.
ModelHistory
created.RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_parseRDFAnnotation(). They are functionally
identical.
public static void parseRDFAnnotation(XMLNode annotation, CVTermList CVTerms)
public static ModelHistory parseRDFAnnotation(XMLNode annotation, String metaId)
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.
annotation
- XMLNode
containing the annotation.stream
- optional XMLInputStream that facilitates error loggingmetaId
- optional metaId, if set only the rdf annotation for this metaId will be returned.
ModelHistory
created.RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_parseRDFAnnotation(). They are functionally
identical.
public static ModelHistory parseRDFAnnotation(XMLNode annotation, String metaId, XMLInputStream stream)
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.
annotation
- XMLNode
containing the annotation.stream
- optional XMLInputStream that facilitates error loggingmetaId
- optional metaId, if set only the rdf annotation for this metaId will be returned.
ModelHistory
created.RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_parseRDFAnnotation(). They are functionally
identical.
public static void parseRDFAnnotation(XMLNode annotation, org.sbml.libsbml.SWIGTYPE_p_List CVTerms, String metaId)
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.
annotation
- XMLNode
containing the annotation.
CVTerms
- list of CVTerm
objects to be created.stream
- optional XMLInputStream that facilitates error loggingmetaId
- optional metaId, if set only the rdf annotation for this metaId will be returned.
RDFAnnotationParser.parseRDFAnnotation(XMLNode annotation)
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_parseRDFAnnotation(). They are functionally
identical.
public static void parseRDFAnnotation(XMLNode annotation, org.sbml.libsbml.SWIGTYPE_p_List CVTerms, String metaId, XMLInputStream stream)
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.
annotation
- XMLNode
containing the annotation.
CVTerms
- list of CVTerm
objects to be created.stream
- optional XMLInputStream that facilitates error loggingmetaId
- optional metaId, if set only the rdf annotation for this metaId will be returned.
RDFAnnotationParser.parseRDFAnnotation(XMLNode annotation)
RDFAnnotationParser
), and the
other will be a standalone top-level function with the name
RDFAnnotationParser_parseRDFAnnotation(). They are functionally
identical.