libSBML Python API  5.18.0
libsbml.ConversionProperties Class Reference
Inheritance diagram for libsbml.ConversionProperties:
[legend]

Detailed Description

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()
2 if config != None:
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:

1 # Assume that the variable 'document' has been set to an SBMLDocument object.
2 status = document.convert(config)
3 if status != LIBSBML_OPERATION_SUCCESS:
4  # Handle error somehow.
5  print('Error: conversion failed due to the following:')
6  document.printErrors()

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()
3  if config != None:
4  config.addOption('stripPackage')
5  config.addOption('package', 'layout')
6  status = document.convert(config)
7  if status != LIBSBML_OPERATION_SUCCESS:
8  # Handle error somehow.
9  print('Error: unable to strip the Layout package.')
10  print('LibSBML returned error: ' + OperationReturnValue_toString(status).strip())
11  else:
12  # Handle error somehow.
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

Public Member Functions

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...
 

Constructor & Destructor Documentation

def libsbml.ConversionProperties.__init__ (   self,
  args 
)

This method has multiple variants; they differ in the arguments they accept.

__init__(SBMLNamespaces targetNS)   ConversionProperties
__init__()   ConversionProperties
__init__(ConversionProperties orig)   ConversionProperties

Each variant is described separately below.


Method variant with the following signature:
ConversionProperties(ConversionProperties orig)

Copy constructor.

Parameters
origthe object to copy.

Method variant with the following signature:
ConversionProperties(SBMLNamespaces targetNS)

Constructor that initializes the conversion properties with a specific SBML target namespace.

Parameters
targetNSthe target namespace to convert to.

Member Function Documentation

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
optionthe option to add.

Method variant with the following signature:
addOption(string key, float value, string description='')

Adds a new ConversionOption object with the given parameters.

Parameters
keythe key for the new option.
valuethe 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
keythe 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
keythe key for the new option.
valuethe 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
keythe key for the new option.
valuethe 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
keythe key for the new option.
valuethe 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
keythe key for the new option.
valuethe integer value of that option.
description(optional) the description for the option.
def libsbml.ConversionProperties.clone (   self)

Creates and returns a deep copy of this ConversionProperties object.

clone()   ConversionProperties
Returns
the (deep) copy of this ConversionProperties object.
def libsbml.ConversionProperties.getBoolValue (   self,
  key 
)

Returns the value of the given option as a Boolean.

getBoolValue(string key)   bool
Parameters
keythe key for the option.
Returns
the boolean value of the option with the given key.
def libsbml.ConversionProperties.getDescription (   self,
  key 
)

Returns the description string for a given option in this properties object.

getDescription(string key)   string
Parameters
keythe key for the option.
Returns
the description text of the option with the given key.
def libsbml.ConversionProperties.getDoubleValue (   self,
  key 
)

Returns the value of the given option as a float.

getDoubleValue(string key)   float
Parameters
keythe key for the option.
Returns
the float value of the option with the given key.
def libsbml.ConversionProperties.getFloatValue (   self,
  key 
)

Returns the value of the given option as a float.

getFloatValue(string key)   float
Parameters
keythe key for the option.
Returns
the float value of the option with the given key.
def libsbml.ConversionProperties.getIntValue (   self,
  key 
)

Returns the value of the given option as an integer.

getIntValue(string key)   int
Parameters
keythe key for the option.
Returns
the int value of the option with the given key.
def libsbml.ConversionProperties.getNumOptions (   self)

Returns the number of options in this Conversion Properties object.

Returns
the number of options in this properties object.
getNumOptions()   int
 
def libsbml.ConversionProperties.getOption (   self,
  args 
)

This method has multiple variants; they differ in the arguments they accept.

getOption(string key)   ConversionOption
getOption(int index)   ConversionOption

Each variant is described separately below.


Method variant with the following signature:
getOption(int index)

Returns the ConversionOption object for the given index.

Parameters
indexthe index for the option.
Returns
the option with the given index.

Method variant with the following signature:
getOption(string key)

Returns the ConversionOption object for a given key.

Parameters
keythe key for the option.
Returns
the option with the given key.
def libsbml.ConversionProperties.getTargetNamespaces (   self)

Returns the current target SBML namespace.

getTargetNamespaces()   SBMLNamespaces
Returns
the SBMLNamepaces object expressing the target namespace.
def libsbml.ConversionProperties.getType (   self,
  key 
)

Returns the type of a given option in this properties object.

getType(string key)   long
Parameters
keythe key for the option.
Returns
the type of the option with the given key.
def libsbml.ConversionProperties.getValue (   self,
  key 
)

Returns the value of the given option as a string.

getValue(string key)   string
Parameters
keythe key for the option.
Returns
the string value of the option with the given key.
def libsbml.ConversionProperties.hasOption (   self,
  key 
)

Returns True if this properties object contains an option with the given key.

hasOption(string key)   bool
Parameters
keythe key of the option to find.
Returns
True if an option with the given key exists in this properties object, False otherwise.
def libsbml.ConversionProperties.hasTargetNamespaces (   self)

Returns True if the target SBML namespace has been set.

hasTargetNamespaces()   bool
Returns
True if the target namespace has been set, False otherwise.
def libsbml.ConversionProperties.removeOption (   self,
  key 
)

Removes the option with the given key from this properties object.

removeOption(string key)   ConversionOption
Parameters
keythe key for the new option to remove.
Returns
the removed option.
def libsbml.ConversionProperties.setBoolValue (   self,
  key,
  value 
)

Sets the value of the given option to a Boolean.

setBoolValue(string key, bool value)
Parameters
keythe key for the option.
valuethe new Boolean value.
def libsbml.ConversionProperties.setDoubleValue (   self,
  key,
  value 
)

Sets the value of the given option to a float.

setDoubleValue(string key, float value)
Parameters
keythe key for the option.
valuethe new float value.
def libsbml.ConversionProperties.setFloatValue (   self,
  key,
  value 
)

Sets the value of the given option to a float.

setFloatValue(string key, float value)
Parameters
keythe key for the option.
valuethe new float value.
def libsbml.ConversionProperties.setIntValue (   self,
  key,
  value 
)

Sets the value of the given option to an integer.

setIntValue(string key, int value)
Parameters
keythe key for the option.
valuethe new integer value.
def libsbml.ConversionProperties.setTargetNamespaces (   self,
  targetNS 
)

Sets the target namespace.

setTargetNamespaces(SBMLNamespaces targetNS)
Parameters
targetNSthe target namespace to use.
def libsbml.ConversionProperties.setValue (   self,
  key,
  value 
)

Sets the value of the given option to a string.

setValue(string key, string value)
Parameters
keythe key for the option.
valuethe new value.