Set of configuration option values for a converter.
This class of objects is defined by libSBML only and has no direct
equivalent in terms of SBML components. It is a class used in
the implementation of extra functionality provided by libSBML.
LibSBML provides a number of converters that can perform transformations on SBML documents. The properties of SBML converters are communicated using objects of class ConversionProperties, and within such objects, individual options are encapsulated using ConversionOption objects. The ConversionProperties class provides numerous methods for setting and getting options.
ConversionProperties objects are also used to determine the target SBML namespace when an SBML converter's behavior depends on the intended Level+Version combination of SBML. In addition, it is conceivable that conversions may be affected by SBML Level 3 packages being used by an SBML document; consequently, the packages in use are also communicated by the values of the SBML namespaces set on a ConversionProperties object.
General information about the use of SBML converters
The use of all the converters follows a similar approach. First, one creates a ConversionProperties object and calls ConversionProperties.addOption() on this object with one argument: a text string that identifies the desired converter. (The text string is specific to each converter; consult the documentation for a given converter to find out how it should be enabled.)
Next, for some converters, the caller can optionally set some converter-specific properties using additional calls to ConversionProperties.addOption(). Many converters provide the ability to configure their behavior to some extent; this is realized through the use of properties that offer different options. The default property values for each converter can be interrogated using the method SBMLConverter.getDefaultProperties() on the converter class in question .
Finally, the caller should invoke the method SBMLDocument.convert() with the ConversionProperties object as an argument.
Example of invoking an SBML converter
The following code fragment illustrates an example using SBMLReactionConverter, which is invoked using the option string 'replaceReactions'
:
1 config = ConversionProperties()
3 config.addOption(
'replaceReactions')
In the case of SBMLReactionConverter, there are no options to affect its behavior, so the next step is simply to invoke the converter on an SBMLDocument object. Continuing the example code:
2 status = document.convert(config)
3 if status != LIBSBML_OPERATION_SUCCESS:
5 print(
'Error: conversion failed due to the following:')
Here is an example of using a converter that offers an option. The following code invokes SBMLStripPackageConverter to remove the SBML Level 3 Layout package from a model. It sets the name of the package to be removed by adding a value for the option named 'package'
defined by that converter:
1 def strip_layout_example(document):
2 config = ConversionProperties()
4 config.addOption(
'stripPackage')
5 config.addOption(
'package',
'layout')
6 status = document.convert(config)
7 if status != LIBSBML_OPERATION_SUCCESS:
9 print(
'Error: unable to strip the Layout package.')
13 print(
'Error: unable to create ConversionProperties object')
Available SBML converters in libSBML
LibSBML provides a number of built-in converters; by convention, their names end in Converter. The following are the built-in converters provided by libSBML 5.18.0:
-
- See also
- ConversionOption
-
SBMLNamespaces
|
def | __init__ (self, args) |
| This method has multiple variants; they differ in the arguments they accept. More...
|
|
def | addOption (self, args) |
| This method has multiple variants; they differ in the arguments they accept. More...
|
|
def | clone (self) |
| Creates and returns a deep copy of this ConversionProperties object. More...
|
|
def | getBoolValue (self, key) |
| Returns the value of the given option as a Boolean. More...
|
|
def | getDescription (self, key) |
| Returns the description string for a given option in this properties object. More...
|
|
def | getDoubleValue (self, key) |
| Returns the value of the given option as a float . More...
|
|
def | getFloatValue (self, key) |
| Returns the value of the given option as a float . More...
|
|
def | getIntValue (self, key) |
| Returns the value of the given option as an integer. More...
|
|
def | getNumOptions (self) |
| Returns the number of options in this Conversion Properties object. More...
|
|
def | getOption (self, args) |
| This method has multiple variants; they differ in the arguments they accept. More...
|
|
def | getTargetNamespaces (self) |
| Returns the current target SBML namespace. More...
|
|
def | getType (self, key) |
| Returns the type of a given option in this properties object. More...
|
|
def | getValue (self, key) |
| Returns the value of the given option as a string. More...
|
|
def | hasOption (self, key) |
| Returns True if this properties object contains an option with the given key. More...
|
|
def | hasTargetNamespaces (self) |
| Returns True if the target SBML namespace has been set. More...
|
|
def | removeOption (self, key) |
| Removes the option with the given key from this properties object. More...
|
|
def | setBoolValue (self, key, value) |
| Sets the value of the given option to a Boolean. More...
|
|
def | setDoubleValue (self, key, value) |
| Sets the value of the given option to a float . More...
|
|
def | setFloatValue (self, key, value) |
| Sets the value of the given option to a float . More...
|
|
def | setIntValue (self, key, value) |
| Sets the value of the given option to an integer. More...
|
|
def | setTargetNamespaces (self, targetNS) |
| Sets the target namespace. More...
|
|
def | setValue (self, key, value) |
| Sets the value of the given option to a string. More...
|
|
def libsbml.ConversionProperties.addOption |
( |
|
self, |
|
|
|
args |
|
) |
| |
This method has multiple variants; they differ in the arguments they accept.
addOption(ConversionOption option)
addOption(string key, string value, long type, string description)
addOption(string key, string value, long type)
addOption(string key, string value)
addOption(string key)
addOption(string key, long value, string description)
addOption(string key, long value)
addOption(string key, bool value, string description)
addOption(string key, bool value)
addOption(string key, float value, string description)
addOption(string key, float value)
addOption(string key, float value, string description)
addOption(string key, float value)
addOption(string key, int value, string description)
addOption(string key, int value)
Each variant is described separately below.
Method variant with the following signature: addOption(ConversionOption option)
Adds a copy of the given option to this properties object.
- Parameters
-
Method variant with the following signature: addOption(string key, float value, string description='')
Adds a new ConversionOption object with the given parameters.
- Parameters
-
key | the key for the new option. |
value | the float value of that option. |
description | (optional) the description for the option. |
Method variant with the following signature: addOption(string key, string value='', long type, string description='')
Adds a new ConversionOption object with the given parameters.
- Parameters
-
key | the key for the new option. |
value | (optional) the value of that option. |
type | (optional) the type of the option (see the documentation for ConversionOption for more information about the types). |
description | (optional) the description for the option. |
Method variant with the following signature: addOption(string key, string value, string description='')
Adds a new ConversionOption object with the given parameters.
- Parameters
-
key | the key for the new option. |
value | the string value of that option. |
description | (optional) the description for the option. |
Method variant with the following signature: addOption(string key, bool value, string description='')
Adds a new ConversionOption object with the given parameters.
- Parameters
-
key | the key for the new option. |
value | the boolean value of that option. |
description | (optional) the description for the option. |
Method variant with the following signature: addOption(string key, float value, string description='')
Adds a new ConversionOption object with the given parameters.
- Parameters
-
key | the key for the new option. |
value | the float value of that option. |
description | (optional) the description for the option. |
Method variant with the following signature: addOption(string key, int value, string description='')
Adds a new ConversionOption object with the given parameters.
- Parameters
-
key | the key for the new option. |
value | the integer value of that option. |
description | (optional) the description for the option. |