libSBML Python API
5.11.0
|
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.
The SBasePlugin class is libSBML's base class for extensions of core SBML component objects. SBasePlugin defines basic virtual methods for reading/writing/checking additional attributes and/or subobjects; these methods should be overridden by subclasses to implement the necessary features of an extended SBML object.
Perhaps the easiest way to explain and motivate the role of SBasePlugin is through an example. The SBML Layout package specifies the existence of an element, <listOfLayouts>
, contained inside an SBML <model>
element. In terms of libSBML components, this means a new ListOfLayouts class of objects must be defined, and this object placed in an extended class of Model (because Model in plain/core SBML does not allow the inclusion of a ListOfLayouts subobject). This extended class of Model is LayoutModelPlugin, and it is derived from SBasePlugin.
The specification for a SBML Level 3 package will define the attributes and subojects that make up the package constructs. Those constructs that modify existing SBML components such as Model, Reaction, etc., will be the ones that need to be extended using SBasePlugin.
For example, the Layout package makes additions to Model, SpeciesReference, and the <sbml>
element (which is represented in libSBML by SBMLDocument). This means that the Layout package extension in libSBML needs to define extended versions of Model, SpeciesReference and SBMLDocument. Elements other than the SBML document need to be implemented using SBasePlugin; the document component must be implemented using SBMLDocumentPlugin instead.
A new class definition that subclasses SBasePlugin needs to be created for each SBML component to be extended by the package. For instance, the Layout package needs LayoutModelPlugin and LayoutSpeciesReferencePlugin. (As mentioned above, the Layout class also needs LayoutSBMLDocumentPlugin, but this one is implemented using SBMLDocumentPlugin instead of SBasePlugin.) Below, we describe in detail the different parts of an SBasePlugin subclass definition.
Data attributes on each extended class in an SBML package will have one of the data types string
, double
, int
, or bool
. Subelements/subobjects will normally be derived from the ListOf class or from SBase.
The additional data members must be properly initialized in the class constructor, and must be properly copied in the copy constructor and assignment operator. For example, the following data member is defined in the GroupsModelPlugin
class (in the file GroupsModelPlugin.h
):
The derived class must override the constructor, copy constructor, assignment operator (operator=
) and clone()
methods from SBasePlugin.
If the extended component is defined by the SBML Level 3 package to have attributes, then the extended class definition needs to override the following internal methods on SBasePlugin and provide appropriate implementations:
addExpectedAttributes(ExpectedAttributes& attributes)
: This method should add the attributes that are expected to be found on this kind of extended component in an SBML file or data stream.readAttributes(XMLAttributes attributes, ExpectedAttributes& expectedAttributes)
: This method should read the attributes expected to be found on this kind of extended component in an SBML file or data stream.hasRequiredAttributes()
: This method should return True
if all of the required attribute for this extended component are present on instance of the object.writeAttributes(XMLOutputStream stream)
: This method should write out the attributes of an extended component. The implementation should use the different kinds of writeAttribute
methods defined by XMLOutputStream to achieve this.If the extended component is defined by the Level 3 package to have subcomponents (i.e., full XML elements rather than mere attributes), then the extended class definition needs to override the following internal SBasePlugin methods and provide appropriate implementations:
createObject(XMLInputStream stream)
: Subclasses must override this method to create, store, and then return an SBML object corresponding to the next XMLToken in the XMLInputStream. To do this, implementations can use methods like peek()
on XMLInputStream to test if the next object in the stream is something expected for the package. For example, LayoutModelPlugin uses peek()
to examine the next element in the input stream, then tests that element against the Layout namespace and the element name 'listOfLayouts'
to see if it's the single subcomponent (ListOfLayouts) permitted on a Model object using the Layout package. If it is, it returns the appropriate object.connectToParent(SBase sbase)
: This creates a parent-child relationship between a given extended component and its subcomponent(s).setSBMLDocument(SBMLDocument d)
: This method should set the parent SBMLDocument object on the subcomponent object instances, so that the subcomponent instances know which SBMLDocument contains them.enablePackageInternal(string& pkgURI, string& pkgPrefix, bool flag)
: This method should enable or disable the subcomponent based on whether a given XML namespace is active.writeElements(XMLOutputStream stream)
: This method must be overridden to provide an implementation that will write out the expected subcomponents/subelements to the XML output stream.readOtherXML(SBase parentObject, XMLInputStream stream)
: This function should be overridden if elements of annotation, notes, MathML content, etc., need to be directly parsed from the given XMLInputStream object.hasRequiredElements()
: This method should return True
if a given object contains all the required subcomponents defined by the specification for that SBML Level 3 package.If the package needs to add additional xmlns
attributes to declare additional XML namespace URIs, the extended class should override the following method:
writeXMLNS(XMLOutputStream stream)
: This method should write out any additional XML namespaces that might be needed by a package implementation.Extended component implementations can add whatever additional utility methods are useful for their implementation.
Public Member Functions | |
def | clone (self) |
Creates and returns a deep copy of this SBasePlugin object. More... | |
def | getElementByMetaId (self, metaid) |
Return the first child object found with a given meta identifier. More... | |
def | getElementBySId (self, id) |
Return the first child object found with a given identifier. More... | |
def | getElementNamespace (self) |
Base class for extending SBML objects in packages. More... | |
def | getLevel (self) |
Returns the SBML Level of the package extension of this plugin object. More... | |
def | getListOfAllElements |
Returns an SBaseList of all child SBase objects, including those nested to an arbitrary depth. More... | |
def | getPackageName (self) |
Returns the short-form name of the package to which this plugin object belongs. More... | |
def | getPackageVersion (self) |
Returns the package version of the package extension of this plugin object. More... | |
def | getParentSBMLObject (self, args) |
Returns the parent object to which this plugin object is connected. More... | |
def | getPrefix (self) |
Returns the XML namespace prefix of the package to which this plugin object belongs. More... | |
def | getSBMLDocument (self, args) |
Returns the SBMLDocument object containing this object instance. More... | |
def | getURI (self) |
Returns the XML namespace URI for the package to which this object belongs. More... | |
def | getVersion (self) |
Returns the Version within the SBML Level of the package extension of this plugin object. More... | |
def | setElementNamespace (self, uri) |
Sets the XML namespace to which this object belongs. More... | |
def libsbml.SBasePlugin.clone | ( | self | ) |
Creates and returns a deep copy of this SBasePlugin object.
clone() SBasePlugin
def libsbml.SBasePlugin.getElementByMetaId | ( | self, | |
metaid | |||
) |
Return the first child object found with a given meta identifier.
getElementByMetaId(string metaid) SBase
This method searches all the subobjects under this one, compares their meta identifiers to metaid
, and returns the first one that machines.
metaid | string, the metaid of the object to find. |
metaid
. def libsbml.SBasePlugin.getElementBySId | ( | self, | |
id | |||
) |
Return the first child object found with a given identifier.
getElementBySId(string id) SBase
This method searches all the subobjects under this one, compares their identifiers to id
, and returns the first one that machines.
Normally, SId
type identifier values are unique across a model in SBML. However, in some circumstances they may not be, such as if a model is invalid because of multiple objects having the same identifier.
id | string representing the identifier of the object to find |
id
. def libsbml.SBasePlugin.getLevel | ( | self | ) |
Returns the SBML Level of the package extension of this plugin object.
getLevel() long
def libsbml.SBasePlugin.getListOfAllElements | ( | self, | |
filter = None |
|||
) |
Returns an SBaseList of all child SBase objects, including those nested to an arbitrary depth.
getListOfAllElements(ElementFilter filter=None) SBaseList getListOfAllElements() SBaseList
def libsbml.SBasePlugin.getPackageName | ( | self | ) |
Returns the short-form name of the package to which this plugin object belongs.
getPackageName() string
def libsbml.SBasePlugin.getPackageVersion | ( | self | ) |
Returns the package version of the package extension of this plugin object.
getPackageVersion() long
def libsbml.SBasePlugin.getParentSBMLObject | ( | self, | |
args | |||
) |
Returns the parent object to which this plugin object is connected.
getParentSBMLObject() SBase
def libsbml.SBasePlugin.getPrefix | ( | self | ) |
Returns the XML namespace prefix of the package to which this plugin object belongs.
getPrefix() string
def libsbml.SBasePlugin.getSBMLDocument | ( | self, | |
args | |||
) |
Returns the SBMLDocument object containing this object instance.
getSBMLDocument() SBMLDocument
This method allows the caller to obtain the SBMLDocument for the current object.
def libsbml.SBasePlugin.getURI | ( | self | ) |
Returns the XML namespace URI for the package to which this object belongs.
getURI() string
'http://www.sbml.org/sbml/level3/version1/core'
. Individual SBML Level 3 packages define their own XML namespaces; for example, all elements belonging to the SBML Level 3 Layout Version 1 package must be placed in the XML namespace 'http://www.sbml.org/sbml/level3/version1/layout/version1/'
.This method first looks into the SBMLNamespaces object possessed by the parent SBMLDocument object of the current object. If this cannot be found, this method returns the result of getElementNamespace().
def libsbml.SBasePlugin.getVersion | ( | self | ) |
Returns the Version within the SBML Level of the package extension of this plugin object.
getVersion() long
def libsbml.SBasePlugin.setElementNamespace | ( | self, | |
uri | |||
) |
Sets the XML namespace to which this object belongs.
setElementNamespace(string uri) int
'http://www.sbml.org/sbml/level3/version1/core'
. Individual SBML Level 3 packages define their own XML namespaces; for example, all elements belonging to the SBML Level 3 Layout Version 1 package must be placed in the XML namespace 'http://www.sbml.org/sbml/level3/version1/layout/version1/'
.uri | the URI to assign to this object. |