libSBML Python API  5.11.0
libsbml.SBaseRef Class Reference
Inheritance diagram for libsbml.SBaseRef:
[legend]

Detailed Description

comp Base class for references to objects.

The SBaseRef class was introduced by the SBML Level 3 Hierarchical Model Composition package (“comp”) as the principle way by which submodel elements may be referenced. The SBaseRef class is usually found as the base class of a Port, Deletion, ReplacedElement, or ReplacedBy class, but may appear as an child of one of the above classes if the parent object references a Submodel.

An SBaseRef object must reference an element using exactly one of the optional attributes of the class. Subclasses of SBaseRef may define additional optional attributes that are legal ways to reference an element.

SBaseRef objects may reference elements that do not live in the Model parent of the SBaseRef object. However, the SBaseRef class itself does not provide a method of determining which Model or Submodel is being referenced. The subclasses of SBaseRef provide methods for this instead.

Once the Model to which the SBaseRef object is referencing has been established, there are four optional attributes defined in the SBaseRef class that are each methods of referencing an element:

  • 'portRef' (type PortSIdRef): As its name implies, this attribute is used to refer to a port identifier, in the case when the reference being constructed with the SBaseRef is intended to refer to a port on a submodel. The namespace of the PortSIdRef value is the set of identifiers of type PortSId defined in the submodel, not the parent model.
  • 'idRef' (type SIdRef): As its name implies, this attribute is used to refer to a regular identifier (i.e., the value of an 'id' attribute on some other object), in the case when the reference being constructed with the SBaseRef is intended to refer to an object that does not have a port identifier. The namespace of the SIdRef value is the set of identifiers of type SId defined in the submodel, not the parent model.
  • 'unitRef' (type UnitSIdRef): This attribute is used to refer to the identifier of a UnitDefinition object. The namespace of the UnitSIdRef value is the set of unit identifiers defined in the submodel, not the parent model. (Note that even though this attribute is of type UnitSIdRef, the reserved unit identifiers that are defined by SBML Level 3 (see Section 3.1.10 of the core specification) are *not* permitted as values of 'unitRef'. Reserved unit identifiers may not be replaced or deleted.)
  • 'metaIdRef' (type IDREF): This attribute is used to refer to a 'metaid' attribute value on some other object, in the case when the reference being constructed with the SBaseRef is intended to refer to an object that does not have a port identifier. The namespace of the 'metaIdRef' value is the entire document in which the referenced model resides, but must refer to a subelement of the referenced model. Since meta identifiers are optional attributes of SBase, all SBML objects have the potential to have a meta identifier value.

An SBaseRef object may have up to one subcomponent named 'sBaseRef', of type SBaseRef. This permits recursive structures to be constructed so that objects inside submodels can be referenced.

The form of such recursive references must be as follows. The highest-level SBaseRef object of such a chain (which will necessarily be an object of class Port, Deletion, ReplacedElement or ReplacedBy, because they are the only classes derived from the class SBaseRef) must refer to a Submodel object in the containing model. All child SBaseRef objects in the chain must refer to components inside the Model instance to which the Submodel refers.

Public Member Functions

def __init__ (self, args)
 comp Base class for references to objects. More...
 
def clearReferencedElement (self)
 Removes the saved referenced element, if it had been saved earlier. More...
 
def clone (self)
 Creates and returns a deep copy of this SBaseRef object. More...
 
def connectToChild (self)
 
def createSBaseRef (self)
 Creates a new, empty SBaseRef, adds it to this SBaseRef and returns the created SBaseRef. More...
 
def getElementByMetaId (self, metaid)
 Returns the first child element it can find with the given metaid, or itself if it has the given metaid, or None if no such object is found. More...
 
def getElementBySId (self, id)
 Returns the first child element found that has the given id in the model-wide SId namespace, or None if no such object is found. More...
 
def getElementName (self)
 Returns the XML element name of this SBML object. More...
 
def getIdRef (self)
 Returns the value of the 'idRef' attribute of this SBaseRef. More...
 
def getMetaIdRef (self)
 Returns the value of the 'metaIdRef' attribute of this SBaseRef. More...
 
def getNumReferents (self)
 Returns how many elements are being referred to by this SBaseRef. More...
 
def getPortRef (self)
 Returns the value of the 'portRef' attribute of this SBaseRef. More...
 
def getReferencedElement (self)
 Returns the object pointed to by this element. More...
 
def getReferencedElementFrom (self, model)
 Examines the referenced Model for the referenced object, and returns it, if found. More...
 
def getSBaseRef (self, args)
 Get the child sBaseRef of this sBaseRef. More...
 
def getTypeCode (self)
 Returns the libSBML type code of this object instance. More...
 
def getUnitRef (self)
 Returns the value of the 'unitRef' attribute of this SBaseRef. More...
 
def hasRequiredAttributes (self)
 Returns true if getNumReferents() is exactly 1. More...
 
def isSetIdRef (self)
 Predicate returning True or False depending on whether this SBaseRef's 'idRef' attribute has been set. More...
 
def isSetMetaIdRef (self)
 Predicate returning True or False depending on whether this SBaseRef's 'metaIdRef' attribute has been set. More...
 
def isSetPortRef (self)
 Predicate returning True or False depending on whether this SBaseRef's 'portRef' attribute has been set. More...
 
def isSetSBaseRef (self)
 Predicate for testing whether the sBaseRef for this SBaseRef is set. More...
 
def isSetUnitRef (self)
 Predicate returning True or False depending on whether this SBaseRef's 'unitRef' attribute has been set. More...
 
def performDeletion (self)
 DEPRECATED FUNCTION: DO NOT USE. More...
 
def removeFromParentAndDelete (self)
 Finds this SBaseRef's parent, which can either be a List or can be another SBaseRef, and tells it to remove this. More...
 
def renameSIdRefs (self, oldid, newid)
 Replaces all uses of a given SIdRef type attribute value with another value. More...
 
def saveReferencedElement (self)
 Finds and stores the referenced object by finding the Model it needs to point to, calling 'saveReferencedElement' on its parent (which will also be a SBaseRef or one of its subclasses), and the storing the result. More...
 
def setIdRef (self, id)
 Sets the value of the 'idRef' attribute of this SBaseRef. More...
 
def setMetaIdRef (self, id)
 Sets the value of the 'metaIdRef' attribute of this SBaseRef. More...
 
def setPortRef (self, id)
 Sets the value of the 'portRef' attribute of this SBaseRef. More...
 
def setSBaseRef (self, sBaseRef)
 Sets the sBaseRef definition of this SBaseRef to a copy of the given SBaseRef object instance. More...
 
def setUnitRef (self, id)
 Sets the value of the 'unitRef' attribute of this SBaseRef. More...
 
def unsetIdRef (self)
 Unsets the value of the 'idRef' attribute of this SBaseRef. More...
 
def unsetMetaIdRef (self)
 Unsets the value of the 'metaIdRef' attribute of this SBaseRef. More...
 
def unsetPortRef (self)
 Unsets the value of the 'portRef' attribute of this SBaseRef. More...
 
def unsetSBaseRef (self)
 Unsets the child SBaseRef of this SBaseRef. More...
 
def unsetUnitRef (self)
 Unsets the value of the 'unitRef' attribute of this SBaseRef. More...
 

Member Function Documentation

def libsbml.SBaseRef.clearReferencedElement (   self)

Removes the saved referenced element, if it had been saved earlier.

clearReferencedElement()
def libsbml.SBaseRef.clone (   self)

Creates and returns a deep copy of this SBaseRef object.

clone()   SBaseRef
Returns
a (deep) copy of this SBaseRef object
def libsbml.SBaseRef.connectToChild (   self)
connectToChild()
def libsbml.SBaseRef.createSBaseRef (   self)

Creates a new, empty SBaseRef, adds it to this SBaseRef and returns the created SBaseRef.

createSBaseRef()   SBaseRef
Returns
the newly created SBaseRef object instance.
def libsbml.SBaseRef.getElementByMetaId (   self,
  metaid 
)

Returns the first child element it can find with the given metaid, or itself if it has the given metaid, or None if no such object is found.

getElementByMetaId(string metaid)   SBase
Parameters
metaidstring representing the metaid of objects to find
Returns
a pointer to the SBase element with the given metaid.
def libsbml.SBaseRef.getElementBySId (   self,
  id 
)

Returns the first child element found that has the given id in the model-wide SId namespace, or None if no such object is found.

getElementBySId(string id)   SBase
Parameters
idstring representing the id of objects to find
Returns
a pointer to the SBase element with the given id.
def libsbml.SBaseRef.getElementName (   self)

Returns the XML element name of this SBML object.

getElementName()   string
Returns
the name of this element, as a text string.
def libsbml.SBaseRef.getIdRef (   self)

Returns the value of the 'idRef' attribute of this SBaseRef.

getIdRef()   string
Returns
the value of the 'idRef' attribute of this SBaseRef.
def libsbml.SBaseRef.getMetaIdRef (   self)

Returns the value of the 'metaIdRef' attribute of this SBaseRef.

getMetaIdRef()   string
Returns
the value of the 'metaIdRef' attribute of this SBaseRef.
def libsbml.SBaseRef.getNumReferents (   self)

Returns how many elements are being referred to by this SBaseRef.

getNumReferents()   int

A valid SBaseRef will have exactly one. Possible referents are portRef, idRef, unitRef, and metaIdRef.

Returns
integer value between 0 and 4: the number of different ways this element points to its referent.
def libsbml.SBaseRef.getPortRef (   self)

Returns the value of the 'portRef' attribute of this SBaseRef.

getPortRef()   string
Returns
the value of the 'portRef' attribute of this SBaseRef.
def libsbml.SBaseRef.getReferencedElement (   self)

Returns the object pointed to by this element.

getReferencedElement()   SBase

If that element was previously found and set with 'saveReferencedElement', that element is returned; otherwise, 'saveReferencedElement' is called first, and the found element is returned.

def libsbml.SBaseRef.getReferencedElementFrom (   self,
  model 
)

Examines the referenced Model for the referenced object, and returns it, if found.

getReferencedElementFrom(Model model)   SBase
Parameters
modelthe Model in which to look for the object referenced by this SBaseRef.
Returns
the element in the referenced Model to which this SBaseRef refers. If this object references an object in a Submodel, the returned object will be in the instantiated Model in that Submodel.
def libsbml.SBaseRef.getSBaseRef (   self,
  args 
)

Get the child sBaseRef of this sBaseRef.

getSBaseRef()   SBaseRef
Returns
the SBaseRef child of this SBaseRef, or None if none exists.
def libsbml.SBaseRef.getTypeCode (   self)

Returns the libSBML type code of this object instance.

getTypeCode()   int
LibSBML attaches an identifying code to every kind of SBML object. These are integer constants known as SBML type codes. The names of all the codes begin with the characters SBML_. In the Python language interface for libSBML, the type codes are defined as static integer constants in the interface class libsbml. Note that different Level 3 package plug-ins may use overlapping type codes; to identify the package to which a given object belongs, call the getPackageName() method on the object.
Returns
the SBML type code for this object: SBML_COMP_SBASEREF
Warning
The specific integer values of the possible type codes may be reused by different Level 3 package plug-ins. Thus, to identifiy the correct code, it is necessary to invoke both getTypeCode() and getPackageName().
See also
getElementName()
getPackageName()
def libsbml.SBaseRef.getUnitRef (   self)

Returns the value of the 'unitRef' attribute of this SBaseRef.

getUnitRef()   string
Returns
the value of the 'unitRef' attribute of this SBaseRef.
def libsbml.SBaseRef.hasRequiredAttributes (   self)

Returns true if getNumReferents() is exactly 1.

hasRequiredAttributes()   bool
Returns
boolean: 'true' if the attributes are correctly set; 'false' if not.
def libsbml.SBaseRef.isSetIdRef (   self)

Predicate returning True or False depending on whether this SBaseRef's 'idRef' attribute has been set.

isSetIdRef()   bool
Returns
True if this SBaseRef's 'idRef' attribute has been set, otherwise False is returned.
def libsbml.SBaseRef.isSetMetaIdRef (   self)

Predicate returning True or False depending on whether this SBaseRef's 'metaIdRef' attribute has been set.

isSetMetaIdRef()   bool
Returns
True if this SBaseRef's 'metaIdRef' attribute has been set, otherwise False is returned.
def libsbml.SBaseRef.isSetPortRef (   self)

Predicate returning True or False depending on whether this SBaseRef's 'portRef' attribute has been set.

isSetPortRef()   bool
Returns
True if this SBaseRef's 'portRef' attribute has been set, otherwise False is returned.
def libsbml.SBaseRef.isSetSBaseRef (   self)

Predicate for testing whether the sBaseRef for this SBaseRef is set.

isSetSBaseRef()   bool
Returns
True if the sBaseRef of this SBaseRef is set, False otherwise.
def libsbml.SBaseRef.isSetUnitRef (   self)

Predicate returning True or False depending on whether this SBaseRef's 'unitRef' attribute has been set.

isSetUnitRef()   bool
Returns
True if this SBaseRef's 'unitRef' attribute has been set, otherwise False is returned.
def libsbml.SBaseRef.performDeletion (   self)

DEPRECATED FUNCTION: DO NOT USE.

Deletes the referenced object, plus any other elements that element points to through ReplacedElement or ReplacedBy children.

performDeletion()   int

Instead of calling this function directly, use 'CompModelPlugin::instantiateSubmodels' instead, which deals with all the intricacies of replacements and deletions, and gives you access to the non-flattened hierarchical form of the model.

def libsbml.SBaseRef.removeFromParentAndDelete (   self)

Finds this SBaseRef's parent, which can either be a List or can be another SBaseRef, and tells it to remove this.

removeFromParentAndDelete()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.renameSIdRefs (   self,
  oldid,
  newid 
)

Replaces all uses of a given SIdRef type attribute value with another value.

renameSIdRefs(string oldid, string newid)
In SBML, object identifiers are of a data type called SId. In SBML Level 3, an explicit data type called SIdRef was introduced for attribute values that refer to SId values; in previous Levels of SBML, this data type did not exist and attributes were simply described to as 'referring to an identifier', but the effective data type was the same as SIdRefin Level 3. These and other methods of libSBML refer to the type SIdRef for all Levels of SBML, even if the corresponding SBML specification did not explicitly name the data type.

This method works by looking at all attributes and (if appropriate) mathematical formulas in MathML content, comparing the referenced identifiers to the value of oldid. If any matches are found, the matching values are replaced with newid. The method does not descend into child elements.

Parameters
oldidthe old identifier
newidthe new identifier
def libsbml.SBaseRef.saveReferencedElement (   self)

Finds and stores the referenced object by finding the Model it needs to point to, calling 'saveReferencedElement' on its parent (which will also be a SBaseRef or one of its subclasses), and the storing the result.

saveReferencedElement()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.setIdRef (   self,
  id 
)

Sets the value of the 'idRef' attribute of this SBaseRef.

setIdRef(string id)   int

This method fails if the id is not a valid syntax for an SIdRef (LIBSBML_INVALID_ATTRIBUTE_VALUE), or if the SBaseRef already points to an element of the submodel using a different interface (LIBSBML_OPERATION_FAILED). A sBaseRef must use exactly one method to point to a submodel element.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.setMetaIdRef (   self,
  id 
)

Sets the value of the 'metaIdRef' attribute of this SBaseRef.

setMetaIdRef(string id)   int

This method fails if the id is not a valid syntax for an IDREF (LIBSBML_INVALID_ATTRIBUTE_VALUE), or if the SBaseRef already points to an element of the submodel using a different interface (LIBSBML_OPERATION_FAILED). An sBaseRef must use exactly one method to point to a submodel element.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.setPortRef (   self,
  id 
)

Sets the value of the 'portRef' attribute of this SBaseRef.

setPortRef(string id)   int

Fails if the id is not a valid syntax for a PortSIdRef (LIBSBML_INVALID_ATTRIBUTE_VALUE), or if the SBaseRef already points to an element of the submodel using a different interface (LIBSBML_OPERATION_FAILED). An SBaseRef must use exactly one method to point to a submodel element.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.setSBaseRef (   self,
  sBaseRef 
)

Sets the sBaseRef definition of this SBaseRef to a copy of the given SBaseRef object instance.

setSBaseRef(SBaseRef sBaseRef)   int

This method fails if the added sBaseRef does not match the level/version/package of the parent object or if the added sBaseRef cannot be copied.

Parameters
sBaseRefthe SBaseRef object instance to use.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.setUnitRef (   self,
  id 
)

Sets the value of the 'unitRef' attribute of this SBaseRef.

setUnitRef(string id)   int

This method fails if the id is not a valid syntax for a UnitSIdRef (LIBSBML_INVALID_ATTRIBUTE_VALUE), or if the SBaseRef already points to an element of the submodel using a different interface (LIBSBML_OPERATION_FAILED). A sBaseRef must use exactly one method to point to a submodel element.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.unsetIdRef (   self)

Unsets the value of the 'idRef' attribute of this SBaseRef.

unsetIdRef()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.unsetMetaIdRef (   self)

Unsets the value of the 'metaIdRef' attribute of this SBaseRef.

unsetMetaIdRef()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.unsetPortRef (   self)

Unsets the value of the 'portRef' attribute of this SBaseRef.

unsetPortRef()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.unsetSBaseRef (   self)

Unsets the child SBaseRef of this SBaseRef.

unsetSBaseRef()   int

Deletes the former SBaseRef child, if one existed.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBaseRef.unsetUnitRef (   self)

Unsets the value of the 'unitRef' attribute of this SBaseRef.

unsetUnitRef()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are: