org.sbml.jsbml
public class SBMLDocument extends AbstractSBase
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.Boolean> |
checkConsistencyParameters
Contains all the parameter to validate the SBML document
|
private SBMLErrorLog |
listOfErrors
Memorizes all
SBMLError when parsing the file containing this
document. |
private org.apache.log4j.Logger |
logger
logger used to print messages
|
private java.util.Map<java.lang.String,SBase> |
mappingFromMetaId2SBase
Stores all the meta identifiers within this
SBMLDocument to avoid
the creation of multiple identical meta identifiers. |
private Model |
model
Represents the 'model' XML subnode of a SBML file.
|
private java.util.Map<java.lang.String,java.lang.String> |
SBMLDocumentAttributes
Contains all the XML attributes of the sbml XML node.
|
private java.util.Map<java.lang.String,java.lang.String> |
SBMLDocumentNamespaces
Contains all the namespaces of the sbml XML node and their prefixes.
|
private static long |
serialVersionUID
Generated serial version identifier.
|
static java.lang.String |
URI_NAMESPACE_L1
The namespace URI of SBML Level 1 Version 1 and 2.
|
static java.lang.String |
URI_NAMESPACE_L2V1
The namespace URI of SBML Level 2 Version 1.
|
static java.lang.String |
URI_NAMESPACE_L2V2
The namespace URI of SBML Level 2 Version 2.
|
static java.lang.String |
URI_NAMESPACE_L2V3
The namespace URI of SBML Level 2 Version 3.
|
static java.lang.String |
URI_NAMESPACE_L2V4
The namespace URI of SBML Level 2 Version 4.
|
static java.lang.String |
URI_NAMESPACE_L3V1Core
The namespace URI of SBML Level 3 Version 1.
|
lv
listOfListeners, parent
Constructor and Description |
---|
SBMLDocument()
Creates a
SBMLDocument instance. |
SBMLDocument(int level,
int version)
Creates a SBMLDocument instance from a level and version.
|
SBMLDocument(SBMLDocument sb)
Creates a new
SBMLDocument instance from a given SBMLDocument . |
Modifier and Type | Method and Description |
---|---|
void |
addNamespace(java.lang.String namespaceName,
java.lang.String prefix,
java.lang.String URI)
Adds a name space to the SBMLNamespaces of this SBMLDocument.
|
int |
checkConsistency()
Validates the
SBMLDocument using the
SBML.org online validator (http://sbml.org/validator/). |
private void |
checkMetaId(java.lang.String metaId)
Checks if the given meta identifier can be added in this
SBMLDocument
's mappingFromMetaId2SBase . |
SBMLDocument |
clone()
Creates a copy of this object, i.e., e new
SBase with the same properties
like this one and returns a pointer to it. |
private void |
collectMetaIds(java.util.Map<java.lang.String,SBase> metaIds,
SBase sbase,
boolean recursively,
boolean delete)
Collects all meta identifiers of this
AbstractSBase and all of
its sub-elements if recursively is true . |
boolean |
containsMetaId(java.lang.String metaId)
A check to see whether elements have been registered to this
SBMLDocument with the given meta identifier. |
Model |
createModel()
Deprecated.
If not working with SBML Level 2 use
createModel(String) instead. |
Model |
createModel(java.lang.String id)
Creates a new instance of Model from id and the level and version of this
SBMLDocument.
|
boolean |
equals(java.lang.Object o)
|
SBase |
findSBase(java.lang.String metaId)
Looks up the
SBase registered in this SBMLDocument for the
given metaId. |
boolean |
getAllowsChildren() |
javax.swing.tree.TreeNode |
getChildAt(int index) |
int |
getChildCount() |
int |
getDefaultLevel()
The default SBML Level of new SBMLDocument objects.
|
int |
getDefaultVersion()
The default Version of new SBMLDocument objects.
|
java.lang.String |
getElementName() |
SBMLError |
getError(int i) |
SBMLErrorLog |
getErrorLog()
This method returns a collection of all
SBMLError s reflecting
problems in the overall data structure of this SBMLDocument . |
SBMLErrorLog |
getListOfErrors()
This method returns a collection of all
SBMLError s reflecting
problems in the overall data structure of this SBMLDocument . |
Model |
getModel()
Returns the model of this
SBMLDocument . |
int |
getNumErrors() |
java.util.Map<java.lang.String,java.lang.String> |
getSBMLDocumentAttributes() |
java.util.Map<java.lang.String,java.lang.String> |
getSBMLDocumentNamespaces() |
int |
hashCode() |
private void |
initDefaults() |
private boolean |
isSetListOfErrors() |
boolean |
isSetModel() |
java.lang.String |
nextMetaId() |
void |
printErrors() |
void |
printErrors(java.io.PrintStream stream) |
boolean |
readAttribute(java.lang.String attributeName,
java.lang.String prefix,
java.lang.String value)
If the attribute is an id or name attribute, it will set the id or name
of this object with the value of the XML attribute ('value').
|
(package private) boolean |
registerMetaId(SBase sbase,
boolean add)
Saves or removes the given meta identifier in this
SBMLDocument 's
mappingFromMetaId2SBase . |
(package private) void |
registerMetaIds(SBase sbase,
boolean recursively,
boolean delete)
Collects all meta identifiers of this
AbstractSBase and all of
its sub-elements if recursively is true . |
void |
setConsistencyChecks(SBMLValidator.CHECK_CATEGORY category,
boolean apply)
Controls the consistency checks that are performed when
checkConsistency() is called. |
boolean |
setLevelAndVersion(int level,
int version)
Sets the SBML Level and Version of this
SBMLDocument instance,
attempting to convert the model as needed. |
boolean |
setLevelAndVersion(int level,
int version,
boolean strict)
Sets the SBML Level and Version of this
SBMLDocument instance,
attempting to convert the model as needed. |
void |
setModel(Model model)
|
void |
setSBMLDocumentAttributes(java.util.Map<java.lang.String,java.lang.String> sBMLDocumentAttributes)
Sets the SBMLDocumentAttributes.
|
java.lang.String |
toString() |
boolean |
unsetModel()
|
java.util.Map<java.lang.String,java.lang.String> |
writeXMLAttributes() |
addCVTerm, addDeclaredNamespace, addNamespace, appendNotes, appendNotes, checkLevelAndVersionCompatibility, filterCVTerms, filterCVTerms, fireNodeRemovedEvent, getAnnotation, getAnnotationString, getCVTerm, getCVTerms, getDeclaredNamespaces, getHistory, getLevel, getLevelAndVersion, getMetaId, getNamespaces, getNotes, getNotesString, getNumCVTerms, getParent, getParentSBMLObject, getSBMLDocument, getSBOTerm, getSBOTermID, getVersion, hasValidAnnotation, hasValidLevelVersionNamespaceCombination, isSetAnnotation, isSetHistory, isSetLevel, isSetLevelAndVersion, isSetMetaId, isSetNotes, isSetParentSBMLObject, isSetSBOTerm, isSetVersion, isValidLevelAndVersionCombination, notifyChildChange, registerChild, removeNamespace, setAnnotation, setHistory, setLevel, setMetaId, setNotes, setNotes, setParentSBML, setParentSBMLObject, setSBOTerm, setSBOTerm, setThisAsParentSBMLObject, setVersion, unregister, unsetAnnotation, unsetCVTerms, unsetHistory, unsetMetaId, unsetNotes, unsetSBOTerm
addAllChangeListeners, addTreeNodeChangeListener, addTreeNodeChangeListener, children, fireNodeAddedEvent, firePropertyChange, getIndex, getListOfTreeNodeChangeListeners, getNumChildren, getTreeNodeChangeListenerCount, indexOf, isLeaf, isRoot, isSetParent, removeAllTreeNodeChangeListeners, removeTreeNodeChangeListener, removeTreeNodeChangeListener, setParent
finalize, getClass, notify, notifyAll, wait, wait, wait
removeTreeNodeChangeListener
addAllChangeListeners, addTreeNodeChangeListener, addTreeNodeChangeListener, fireNodeAddedEvent, firePropertyChange, getListOfTreeNodeChangeListeners, getTreeNodeChangeListenerCount, isRoot, isSetParent, removeAllTreeNodeChangeListeners, removeTreeNodeChangeListener
private static final long serialVersionUID
public static final transient java.lang.String URI_NAMESPACE_L1
public static final transient java.lang.String URI_NAMESPACE_L2V1
public static final java.lang.String URI_NAMESPACE_L2V2
public static final transient java.lang.String URI_NAMESPACE_L2V3
public static final transient java.lang.String URI_NAMESPACE_L2V4
public static final transient java.lang.String URI_NAMESPACE_L3V1Core
private java.util.Map<java.lang.String,java.lang.Boolean> checkConsistencyParameters
private SBMLErrorLog listOfErrors
SBMLError
when parsing the file containing this
document.private transient org.apache.log4j.Logger logger
private java.util.Map<java.lang.String,SBase> mappingFromMetaId2SBase
SBMLDocument
to avoid
the creation of multiple identical meta identifiers. These identifiers
have to be unique within the document.private Model model
private java.util.Map<java.lang.String,java.lang.String> SBMLDocumentAttributes
private java.util.Map<java.lang.String,java.lang.String> SBMLDocumentNamespaces
public SBMLDocument()
SBMLDocument
instance. By default, the parent SBML object of
this object is itself. The model is null. The SBMLDocumentAttributes and
the SBMLDocumentNamespaces are empty.sb
- public SBMLDocument(int level, int version)
level
- version
- public SBMLDocument(SBMLDocument sb)
SBMLDocument
instance from a given SBMLDocument
.sb
- public void addNamespace(java.lang.String namespaceName, java.lang.String prefix, java.lang.String URI)
namespaceName
- prefix
- URI
- public int checkConsistency()
SBMLDocument
using the
SBML.org online validator (http://sbml.org/validator/).
you can control the consistency checks that are performed when
checkConsistency()
is called with the
#setConsistencyChecks(CHECK_CATEGORY, boolean)
method.
It will fill this SBMLDocument
's listOfErrors
with SBMLError
s for each problem within this whole data
structure. You will then be able to obtain this list by calling
getError(int)
or getListOfErrors()
.
If this method returns a nonzero value (meaning, one or more
consistency checks have failed for SBML document), the failures may be
due to warnings @em or errors. Callers should inspect the severity
flag in the individual SBMLError objects returned by
getError(int)
to determine the nature of the failures.
#setConsistencyChecks(CHECK_CATEGORY, boolean)
private void checkMetaId(java.lang.String metaId)
SBMLDocument
's mappingFromMetaId2SBase
.metaId
- the identifier whose value is to be checked.java.lang.IllegalArgumentException
- if a metaid to add is already present in the list of
registered metaids.public SBMLDocument clone()
SBase
SBase
with the same properties
like this one and returns a pointer to it.clone
in interface SBase
clone
in class AbstractSBase
private void collectMetaIds(java.util.Map<java.lang.String,SBase> metaIds, SBase sbase, boolean recursively, boolean delete)
AbstractSBase
and all of
its sub-elements if recursively is true
.metaIds
- the Map
that gathers the result.sbase
- The SBase
whose meta identifier is to be collected
and from which we maybe have to recursively go through all
of its children.recursively
- if true
, this method will also consider all
sub-elements of this AbstractSBase
.delete
- if true
this method will not check if
the meta identifier can be added to the SBMLDocument
.java.lang.IllegalArgumentException
- However, duplications are not legal and an
IllegalArgumentException
will be thrown in such
cases.public boolean containsMetaId(java.lang.String metaId)
SBMLDocument
with the given meta identifier.metaId
- @Deprecated public Model createModel()
createModel(String)
instead.SBMLDocument
, and returns a
pointer to it.
In SBML Level 2, the use of an identifier on a Model
object is
optional. This method takes an optional argument, sid, for setting the
identifier. If not supplied, the identifier attribute on the Model
instance is not set.Model
instance.public Model createModel(java.lang.String id)
id
- Model
instance.public boolean equals(java.lang.Object o)
SBase
SBase
has exactly the same
properties like this SBase
instance.equals
in interface SBase
equals
in class AbstractSBase
Object
is an instance of
SBase
that has exactly the same properties like this
SBase instance.public SBase findSBase(java.lang.String metaId)
SBase
registered in this SBMLDocument
for the
given metaId.metaId
- public boolean getAllowsChildren()
getAllowsChildren
in interface javax.swing.tree.TreeNode
getAllowsChildren
in class AbstractSBase
public javax.swing.tree.TreeNode getChildAt(int index)
getChildAt
in interface javax.swing.tree.TreeNode
getChildAt
in class AbstractSBase
public int getChildCount()
getChildCount
in interface javax.swing.tree.TreeNode
getChildCount
in class AbstractSBase
public int getDefaultLevel()
public int getDefaultVersion()
public java.lang.String getElementName()
getElementName
in interface SBase
getElementName
in class AbstractSBase
public SBMLError getError(int i)
i
- public SBMLErrorLog getErrorLog()
SBMLError
s reflecting
problems in the overall data structure of this SBMLDocument
.public SBMLErrorLog getListOfErrors()
SBMLError
s reflecting
problems in the overall data structure of this SBMLDocument
.public Model getModel()
SBMLDocument
.getModel
in interface SBase
getModel
in class AbstractSBase
SBMLDocument
. Can be null if it is not set.public int getNumErrors()
public java.util.Map<java.lang.String,java.lang.String> getSBMLDocumentAttributes()
public java.util.Map<java.lang.String,java.lang.String> getSBMLDocumentNamespaces()
public int hashCode()
hashCode
in interface SBase
hashCode
in class AbstractSBase
Object.hashCode()
private void initDefaults()
private boolean isSetListOfErrors()
public boolean isSetModel()
public java.lang.String nextMetaId()
public void printErrors()
public void printErrors(java.io.PrintStream stream)
public boolean readAttribute(java.lang.String attributeName, java.lang.String prefix, java.lang.String value)
SBase
readAttribute
in interface SBase
readAttribute
in class AbstractSBase
attributeName
- : localName of the XML attributeprefix
- : prefix of the XML attributevalue
- : value of the XML attributeboolean registerMetaId(SBase sbase, boolean add)
SBMLDocument
's
mappingFromMetaId2SBase
.sbase
- the element whose meta identifier is to be registered (if it is set).add
- if true
this will add the given meta identifier
to this SBMLDocument
's mappingFromMetaId2SBase
.
Otherwise, the given identifier will be removed from this set.true
, then this method returns
true
if this set did not already contain the specified
element, false
otherwise.true
, this method returns
true
if this set contained the specified element,
false
otherwise.false
if the given
SBase
does not have a defined metaIdjava.lang.IllegalArgumentException
- if a metaid to add is already present in the list of
registered metaids.void registerMetaIds(SBase sbase, boolean recursively, boolean delete)
AbstractSBase
and all of
its sub-elements if recursively is true
. It can also be used
to delete meta identifiers from the given Set
.sbase
- The SBase
whose meta identifier is to be registered
and from which we maybe have to recursively go through all
of its children.recursively
- if true
, this method will also consider all
sub-elements of this AbstractSBase
.delete
- if true
the purpose of this method will be to
delete the meta identifier from the given Set
.
Otherwise, it will try to add it to the set.java.lang.IllegalArgumentException
- However, duplications are not legal and an
IllegalArgumentException
will be thrown in such
cases.public void setConsistencyChecks(SBMLValidator.CHECK_CATEGORY category, boolean apply)
checkConsistency()
is called.
This method works by adding or subtracting consistency checks from the
set of all possible checks that checkConsistency()
knows
how to perform. This method may need to be called multiple times in
order to achieve the desired combination of checks. The first
argument (category
) in a call to this method indicates the category
of consistency/error checks that are to be turned on or off, and the
second argument (apply
, a boolean) indicates whether to turn it on
(value of true
) or off (value of false
).
* The possible categories (values to the argument category
) are the
set of values from the CHECK_CATEGORYH
enumeration.
The following are the possible choices:
GENERAL_CONSISTENCY
:
Correctness and consistency of specific SBML language constructs.
Performing this set of checks is highly recommended. With respect to
the SBML specification, these concern failures in applying the
validation rules numbered 2xxxx in the Level 2 Versions 2, 3
and 4 specifications.
IDENTIFIER_CONSISTENCY
:
Correctness and consistency of identifiers used for model entities.
An example of inconsistency would be using a species identifier in a
reaction rate formula without first having declared the species. With
respect to the SBML specification, these concern failures in applying
the validation rules numbered 103xx in the Level 2
Versions 2, 3 and 4 specifications.
UNITS_CONSISTENCY
:
Consistency of measurement units associated with quantities in a
model. With respect to the SBML specification, these concern failures
in applying the validation rules numbered 105xx in the Level 2
Versions 2, 3 and 4 specifications.
MATHML_CONSISTENCY
:
Syntax of MathML constructs. With respect to the SBML specification,
these concern failures in applying the validation rules numbered 102xx
in the Level 2 Versions 2, 3 and 4 specifications.
SBO_CONSISTENCY
:
Consistency and validity of SBO identifiers (if any) used in the
model. With respect to the SBML specification, these concern failures
in applying the validation rules numbered 107xx in the Level 2
Versions 2, 3 and 4 specifications.
OVERDETERMINED_MODEL
:
Static analysis of whether the system of equations implied by a model
is mathematically overdetermined. With respect to the SBML
specification, this is validation rule #10601 in the SBML Level 2
Versions 2, 3 and 4 specifications.
MODELING_PRACTICE
:
Additional checks for recommended good modeling practice. (These are
tests performed by libSBML and do not have equivalent SBML validation
rules.)
By default, all validation checks are applied to the model in
an SBMLDocument
object unless SBMLDocument#setConsistencyChecks(int, boolean)
is called to
indicate that only a subset should be applied. Further, this default
(i.e., performing all checks) applies separately to each new
SBMLDocument
object created. In other words, each time a model
is read using SBMLReader.readSBML(String)
, SBMLReader.readSBMLFromString(String)
, a new
SBMLDocument
is created and for that document, a call to
checkConsistency()
will default to applying all possible checks.
Calling programs must invoke SBMLDocument#setConsistencyChecks(int, boolean)
for each such new
model if they wish to change the consistency checks applied.
category
- a value drawn from JSBML#JSBML.SBML_VALIDATOR_* indicating the
consistency checking/validation to be turned on or off
apply
- a boolean indicating whether the checks indicated by
category
should be applied or not.
checkConsistency()
public boolean setLevelAndVersion(int level, int version)
Sets the SBML Level and Version of this SBMLDocument
instance,
attempting to convert the model as needed.
This method is equivalent to calling
setLevelAndVersion(level, version, true);
level
- the desired SBML Levelversion
- the desired Version within the SBML LevelsetLevelAndVersion(int, int, boolean)
public boolean setLevelAndVersion(int level, int version, boolean strict)
Sets the SBML Level and Version of this SBMLDocument
instance,
attempting to convert the model as needed.
This method is the principal way in JSBML to convert models between Levels and Versions of SBML. Generally, models can be converted upward without difficulty (e.g., from SBML Level 1 to Level 2, or from an earlier Version of Level 2 to the latest Version of Level 2). Sometimes models can be translated downward as well, if they do not use constructs specific to more advanced Levels of SBML.
Calling this method will not necessarily lead to a successful conversion.
If the conversion fails, it will be logged in the error list associated
with this SBMLDocument
. Callers should consult
getNumErrors()
to find out if the conversion succeeded
without problems. For conversions from Level 2 to Level 1, callers can
also check the Level of the model after calling this method to find out
whether it is Level 1. (If the conversion to Level 1 failed, the Level of
this model will be left unchanged.)
setLevelAndVersion
in class AbstractSBase
level
- the desired SBML Levelversion
- the desired Version within the SBML Levelstrict
- boolean indicating whether to check consistency of both the
source and target model when performing conversion (defaults
to true)public void setModel(Model model)
model
- public void setSBMLDocumentAttributes(java.util.Map<java.lang.String,java.lang.String> sBMLDocumentAttributes)
sBMLDocumentAttributes
- public java.lang.String toString()
toString
in class AbstractSBase
public boolean unsetModel()
true
if calling this method changed the properties
of this element.public java.util.Map<java.lang.String,java.lang.String> writeXMLAttributes()
writeXMLAttributes
in interface SBase
writeXMLAttributes
in class AbstractSBase
Map
containing the XML attributes of this object.