2.1. wc_lang package

2.1.2. Submodules

2.1.3. wc_lang.__main__ module

Command line programs for manipulating model definitions

Author:Jonathan Karr <karr@mssm.edu>
Date:2016-12-07
Copyright:2016, Karr Lab
License:MIT
class wc_lang.__main__.App(label=None, **kw)[source]

Bases: cement.core.foundation.CementApp

Command line application

class Meta[source]

Bases: object

base_controller = 'base'[source]
handlers = [<class 'wc_lang.__main__.BaseController'>, <class 'wc_lang.__main__.ValidateController'>, <class 'wc_lang.__main__.DifferenceController'>, <class 'wc_lang.__main__.TransformController'>, <class 'wc_lang.__main__.NormalizeController'>, <class 'wc_lang.__main__.ConvertController'>, <class 'wc_lang.__main__.CreateTemplateController'>, <class 'wc_lang.__main__.UpdateWcLangVersionController'>][source]
label = 'wc_lang'[source]
class wc_lang.__main__.BaseController(*args, **kw)[source]

Bases: cement.core.controller.CementBaseController

Base controller for command line application

class Meta[source]

Bases: object

description = 'Command line utilities for managing whole-cell model definitions'[source]
label = 'base'[source]
get_version()[source]

Get version

class wc_lang.__main__.ConvertController(*args, **kw)[source]

Bases: cement.core.controller.CementBaseController

Convert model definition among Excel (.xlsx), comma separated (.csv), and tab separated formats (.tsv)

class Meta[source]

Bases: object

arguments = [(['source'], {'type': <class 'str'>, 'help': 'Path to model definition'}), (['destination'], {'type': <class 'str'>, 'help': 'Path to save model in converted format'})][source]
description = 'Convert model definition among Excel (.xlsx), comma separated (.csv), and tab separated formats (.tsv)'[source]
label = 'convert'[source]
stacked_on = 'base'[source]
stacked_type = 'nested'[source]
default()[source]
class wc_lang.__main__.CreateTemplateController(*args, **kw)[source]

Bases: cement.core.controller.CementBaseController

Create file with model template (i.e. create file with row and column labels)

class Meta[source]

Bases: object

arguments = [(['path'], {'type': <class 'str'>, 'help': 'Path to save model template'})][source]
description = 'Create file with model template: blank file(s) with row and column labels'[source]
label = 'create-template'[source]
stacked_on = 'base'[source]
stacked_type = 'nested'[source]
default()[source]
class wc_lang.__main__.DifferenceController(*args, **kw)[source]

Bases: cement.core.controller.CementBaseController

Display difference between two model definitions

class Meta[source]

Bases: object

arguments = [(['path_1'], {'type': <class 'str'>, 'help': 'Path to first model definition'}), (['path_2'], {'type': <class 'str'>, 'help': 'Path to second model definition'}), (['--compare-files'], {'dest': 'compare_files', 'default': False, 'action': 'store_true', 'help': 'If true, compare models; otherwise compare files directly'})][source]
description = 'Get difference between two model definitions'[source]
label = 'difference'[source]
stacked_on = 'base'[source]
stacked_type = 'nested'[source]
default()[source]
class wc_lang.__main__.NormalizeController(*args, **kw)[source]

Bases: cement.core.controller.CementBaseController

Normalize model definition

class Meta[source]

Bases: object

arguments = [(['source'], {'type': <class 'str'>, 'help': 'Path to model definition'}), (['--destination'], {'default': '', 'type': <class 'str'>, 'help': 'Path to save normalized model definition'})][source]
description = 'Normalize model definition'[source]
label = 'normalize'[source]
stacked_on = 'base'[source]
stacked_type = 'nested'[source]
default()[source]
class wc_lang.__main__.TransformController(*args, **kw)[source]

Bases: cement.core.controller.CementBaseController

Apply one, or more, transforms to a model and save the result

class Meta[source]

Bases: object

arguments = [(['source'], {'type': <class 'str'>, 'help': 'Path to model definition'}), (['destination'], {'type': <class 'str'>, 'help': 'Path to save transformed model definition'}), (['--transform'], {'dest': 'transforms', 'action': 'append', 'help': 'Model transform:\n MergeAlgorithmicallyLikeSubmodels: Merge groups of algorithmically-like submodels into individual submodels\n SplitReversibleReactions: Split reversible reactions into separate forward and backward reactions'})][source]
description = 'Apply one, or more, transforms to a model and save the result'[source]
label = 'transform'[source]
stacked_on = 'base'[source]
stacked_type = 'nested'[source]
default()[source]
class wc_lang.__main__.UpdateWcLangVersionController(*args, **kw)[source]

Bases: cement.core.controller.CementBaseController

Update wc_lang_version of model

class Meta[source]

Bases: object

arguments = [(['path'], {'type': <class 'str'>, 'help': 'Path to model'})][source]
description = 'Update wc_lang_version of model'[source]
label = 'update-wc-lang-version'[source]
stacked_on = 'base'[source]
stacked_type = 'nested'[source]
default()[source]
class wc_lang.__main__.ValidateController(*args, **kw)[source]

Bases: cement.core.controller.CementBaseController

Validate model definition and display errors

class Meta[source]

Bases: object

arguments = [(['path'], {'type': <class 'str'>, 'help': 'Path to model definition'})][source]
description = 'Validate model definition and display errors'[source]
label = 'validate'[source]
stacked_on = 'base'[source]
stacked_type = 'nested'[source]
default()[source]
wc_lang.__main__.main()[source]

2.1.4. wc_lang.core module

Data model to represent biochemical models.

This module defines classes that represent the schema of a biochemical model:

These are all instances of BaseModel, an alias for obj_model.core.Model. A biochemical model may contain a list of instances of each of these classes, interlinked by object references. For example, a Reaction will reference its constituent ReactionParticipant instances, and the RateLaw that describes the reaction’s rate.

This module also defines numerous classes that serve as attributes of these classes.

Author:Jonathan Karr <karr@mssm.edu>
Author:Arthur Goldberg <Arthur.Goldberg@mssm.edu>
Date:2016-11-10
Copyright:2016-2017, Karr Lab
License:MIT
class wc_lang.core.BiomassComponent(**kwargs)[source]

Bases: obj_model.core.Model

A biomass reaction contains a list of BiomassComponent instances. Distinct BiomassComponents enable separate comments and references for each one.

id[source]

str – unique identifier per BiomassComponent

name[source]

str – name

biomass_reaction[source]

BiomassReaction – the biomass reaction that uses the biomass component

coefficient[source]

float – the specie’s reaction coefficient

species_type[source]

SpeciesType – the specie type

comments[source]

str – comments

references[source]

list of Reference – references

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'biomass_reaction', 'coefficient', 'species_type', 'comments', 'references')[source]
attributes = {'biomass_reaction': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a79b0>, 'coefficient': <obj_model.core.FloatAttribute object at 0x7fd3351a7908>, 'comments': <obj_model.core.LongStringAttribute object at 0x7fd3351a7978>, 'id': <obj_model.core.SlugAttribute object at 0x7fd3351a7940>, 'name': <obj_model.core.StringAttribute object at 0x7fd3351a7780>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7a20>, 'species_type': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a79e8>}[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.BiomassComponent'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {}[source]
unique_together = (('biomass_reaction', 'species_type'),)[source]
verbose_name = 'Biomass component'[source]
verbose_name_plural = 'Biomass components'[source]
biomass_reaction = <obj_model.core.ManyToOneAttribute object>[source]
coefficient = <obj_model.core.FloatAttribute object>[source]
comments = <obj_model.core.LongStringAttribute object>[source]
id = <obj_model.core.SlugAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
species_type = <obj_model.core.ManyToOneAttribute object>[source]
class wc_lang.core.BiomassReaction(**kwargs)[source]

Bases: obj_model.core.Model

A pseudo-reaction used to estimate a cell’s growth.

id[source]

str – unique identifier

name[source]

str – name

compartment[source]

Compartment – the compartment containing this BiomassReaction’s species

comments[source]

str – comments

references[source]

list of Reference – references

submodels[source]

list of Submodel – submodels that use this biomass reaction

objective_functions[source]

list of ObjectiveFunction – objective functions that use this biomass reaction

biomass_components[source]

list of BiomassComponent – the components of this biomass reaction

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'compartment', 'comments', 'references')[source]
attributes = {'comments': <obj_model.core.LongStringAttribute object at 0x7fd3351a7be0>, 'compartment': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a7ba8>, 'id': <obj_model.core.SlugAttribute object at 0x7fd3351a7b70>, 'name': <obj_model.core.StringAttribute object at 0x7fd3351a7b00>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7c18>}[source]
indexed_attrs_tuples = (('id',),)[source]
inheritance = (<class 'wc_lang.core.BiomassReaction'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {'biomass_components': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a79b0>, 'objective_functions': <obj_model.core.ManyToManyAttribute object at 0x7fd3353034e0>, 'submodels': <obj_model.core.ManyToOneAttribute object at 0x7fd385ef6e80>}[source]
unique_together = ()[source]
verbose_name = 'Biomass reaction'[source]
verbose_name_plural = 'Biomass reactions'[source]
add_to_sbml_doc(sbml_document)[source]

Add a BiomassReaction to a libsbml SBML document.

BiomassReactions are added to the SBML document because they can be used in a dFBA submodel’s objective function. In fact the default objective function is the submodel’s biomass reaction. Since SBML does not define BiomassReaction as a separate class, BiomassReactions are added to the SBML model as SBML reactions. CheckModel ensures that wc_lang BiomassReactions and Reactions have distinct ids.

Parameters:sbml_document (obj) – a libsbml SBMLDocument
Returns:the libsbml reaction that’s created
Return type:libsbml.reaction
Raises:LibSBMLError – if calling libsbml raises an error
comments = <obj_model.core.LongStringAttribute object>[source]
compartment = <obj_model.core.ManyToOneAttribute object>[source]
id = <obj_model.core.SlugAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
class wc_lang.core.Compartment(**kwargs)[source]

Bases: obj_model.core.Model

id[source]

str – unique identifier

name[source]

str – name

model[source]

Model – model

initial_volume[source]

float – initial volume (L)

comments[source]

str – comments

references[source]

list of Reference – references

cross_references[source]

list of CrossReference – cross references

concentrations[source]

list of Concentration – concentrations

reaction_participants[source]

list of ReactionParticipant – reaction participants

biomass_reactions[source]

list of BiomassReaction – biomass reactions defined for this compartment

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'model', 'initial_volume', 'comments', 'references')[source]
attributes = {'comments': <obj_model.core.LongStringAttribute object at 0x7fd335303f98>, 'id': <obj_model.core.SlugAttribute object at 0x7fd335303a20>, 'initial_volume': <obj_model.core.FloatAttribute object at 0x7fd335303f60>, 'model': <obj_model.core.ManyToOneAttribute object at 0x7fd335303780>, 'name': <obj_model.core.StringAttribute object at 0x7fd335303320>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd335303f28>}[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.Compartment'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {'biomass_reactions': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a7ba8>, 'cross_references': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bd30>, 'species': <obj_model.core.ManyToOneAttribute object at 0x7fd385ead5f8>, 'submodels': <obj_model.core.ManyToOneAttribute object at 0x7fd385ef6e10>}[source]
unique_together = ()[source]
verbose_name = 'Compartment'[source]
verbose_name_plural = 'Compartments'[source]
add_to_sbml_doc(sbml_document)[source]

Add this Compartment to a libsbml SBML document.

Parameters:sbml_document (obj) – a libsbml SBMLDocument
Returns:the libsbml compartment that’s created
Return type:libsbml.compartment
Raises:LibSBMLError – if calling libsbml raises an error
comments = <obj_model.core.LongStringAttribute object>[source]
id = <obj_model.core.SlugAttribute object>[source]
initial_volume = <obj_model.core.FloatAttribute object>[source]
model = <obj_model.core.ManyToOneAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
class wc_lang.core.Concentration(**kwargs)[source]

Bases: obj_model.core.Model

Species concentration

species[source]

Species – species

value[source]

float – value (M)

comments[source]

str – comments

references[source]

list of Reference – references

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('species', 'value', 'comments', 'references')[source]
attributes = {'comments': <obj_model.core.LongStringAttribute object at 0x7fd385ead9e8>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd385eada20>, 'species': <wc_lang.core.OneToOneSpeciesAttribute object at 0x7fd385ead7b8>, 'value': <obj_model.core.FloatAttribute object at 0x7fd385ead940>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.Concentration'>,)[source]
ordering = ('species',)[source]
primary_attribute = None[source]
related_attributes = {}[source]
unique_together = (('species',),)[source]
verbose_name = 'Concentration'[source]
verbose_name_plural = 'Concentrations'[source]
comments = <obj_model.core.LongStringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
serialize()[source]

Generate string representation

Returns:value of primary attribute
Return type:str
species = <wc_lang.core.OneToOneSpeciesAttribute object>[source]
value = <obj_model.core.FloatAttribute object>[source]
class wc_lang.core.CrossReference(**kwargs)[source]

Bases: obj_model.core.Model

Cross reference to a database

database[source]

str – database name

id[source]

str – id of database entry

url[source]

str – URL of database entry

model[source]

Model – model

taxon[source]

Taxon – taxon

submodel[source]

Submodel – submodel

species_type[source]

SpeciesType – species type

reaction[source]

Reaction – reaction

reference[source]

Reference – reference

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('database', 'id', 'url', 'model', 'taxon', 'submodel', 'compartment', 'species_type', 'reaction', 'reference')[source]
attributes = {'compartment': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bd30>, 'database': <obj_model.core.StringAttribute object at 0x7fd33519bbe0>, 'id': <obj_model.core.StringAttribute object at 0x7fd33519b7f0>, 'model': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bc50>, 'reaction': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bda0>, 'reference': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bdd8>, 'species_type': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bd68>, 'submodel': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bcf8>, 'taxon': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bcc0>, 'url': <obj_model.core.UrlAttribute object at 0x7fd33519bc18>}[source]
frozen_columns = 2[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.CrossReference'>,)[source]
ordering = ('database', 'id')[source]
primary_attribute = None[source]
related_attributes = {}[source]
unique_together = (('database', 'id'),)[source]
verbose_name = 'Cross reference'[source]
verbose_name_plural = 'Cross references'[source]
compartment = <obj_model.core.ManyToOneAttribute object>[source]
database = <obj_model.core.StringAttribute object>[source]
id = <obj_model.core.StringAttribute object>[source]
model = <obj_model.core.ManyToOneAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
reaction = <obj_model.core.ManyToOneAttribute object>[source]
reference = <obj_model.core.ManyToOneAttribute object>[source]
serialize()[source]

Generate string representation

Returns:value of primary attribute
Return type:str
species_type = <obj_model.core.ManyToOneAttribute object>[source]
submodel = <obj_model.core.ManyToOneAttribute object>[source]
taxon = <obj_model.core.ManyToOneAttribute object>[source]
url = <obj_model.core.UrlAttribute object>[source]
class wc_lang.core.Model(**kwargs)[source]

Bases: obj_model.core.Model

id[source]

str – unique identifier

name[source]

str – name

version[source]

str – version number

wc_lang_version[source]

str – wc_lang version number

comments[source]

str – comments

taxon[source]

Taxon – taxon

submodels[source]

list of Submodel – submodels

compartments[source]

list of Compartment – compartments

species_types[source]

list of SpeciesType – species types

parameters[source]

list of Parameter – parameters

references[source]

list of Reference – references

cross_references[source]

list of CrossReference – cross references

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'version', 'wc_lang_version', 'comments')[source]
attributes = {'comments': <obj_model.core.LongStringAttribute object at 0x7fd3359a4ef0>, 'id': <obj_model.core.SlugAttribute object at 0x7fd3359a4400>, 'name': <obj_model.core.StringAttribute object at 0x7fd3359a4fd0>, 'version': <obj_model.core.RegexAttribute object at 0x7fd3359a4208>, 'wc_lang_version': <obj_model.core.RegexAttribute object at 0x7fd3359a4390>}[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.Model'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {'compartments': <obj_model.core.ManyToOneAttribute object at 0x7fd335303780>, 'cross_references': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bc50>, 'parameters': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a7f28>, 'references': <obj_model.core.ManyToOneAttribute object at 0x7fd33519b390>, 'species_types': <obj_model.core.ManyToOneAttribute object at 0x7fd335303d30>, 'submodels': <obj_model.core.ManyToOneAttribute object at 0x7fd33508ab70>, 'taxon': <obj_model.core.OneToOneAttribute object at 0x7fd394814630>}[source]
tabular_orientation = 2[source]
unique_together = ()[source]
verbose_name = 'Model'[source]
verbose_name_plural = 'Models'[source]
comments = <obj_model.core.LongStringAttribute object>[source]
get_biomass_reactions()[source]

Get all biomass reactions used by submodels

Returns:biomass reactions
Return type:list of BiomassReaction
get_compartments()[source]

Get all compartments

Returns:compartments
Return type:list of Compartment
get_component(type, id)[source]

Find model component of type with id

Parameters:
  • type (str) –
  • id (str) – id of component to find
Returns:

component with id, or None if there is no component with id`=`id

Return type:

BaseModel

get_concentrations()[source]

Get all concentrations from species types

Returns:concentations
Return type:list of Concentration
get_parameters()[source]

Get all parameters from model and submodels

Returns:parameters
Return type:list of Parameter
get_rate_laws()[source]

Get all rate laws from reactions

Returns:rate laws
Return type:list of RateLaw
get_reactions()[source]

Get all reactions from submodels

Returns:reactions
Return type:list of Reaction
get_references()[source]

Get all references from model and children

Returns:references
Return type:list of Reference
get_species()[source]

Get all species from submodels

Returns:species
Return type:list of Species
get_species_types()[source]

Get all species types

Returns:species types
Return type:list of SpeciesType
get_submodels()[source]

Get all submodels

Returns:submodels
Return type:list of Submodel
id = <obj_model.core.SlugAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
version = <obj_model.core.RegexAttribute object>[source]
wc_lang_version = <obj_model.core.RegexAttribute object>[source]
class wc_lang.core.ObjectiveFunction(**kwargs)[source]

Bases: obj_model.core.Model

Objective function

expression[source]

str – input mathematical expression of the objective function

linear[source]

bool – indicates whether objective function is linear function of reaction fluxes

reactions[source]

list of Reaction – if linear, reactions whose fluxes are used in the objective function

reaction_coefficients[source]

list of float – parallel list of coefficients for reactions

biomass_reactions[source]

list of BiomassReaction – if linear, biomass reactions whose fluxes are used in the objective function

biomass_reaction_coefficients[source]

list of float – parallel list of coefficients for reactions in biomass_reactions

submodel[source]

Submodel – the Submodel which uses this ObjectiveFunction

ACTIVE_OBJECTIVE = 'active_objective'[source]
class Meta[source]

Bases: obj_model.core.Meta

valid_functions[source]

tuple of str – tuple of names of functions that can be used in

this `ObjectiveFunction`
attribute_order = ('expression', 'reactions', 'biomass_reactions', 'linear')[source]
attributes = {'biomass_reactions': <obj_model.core.ManyToManyAttribute object at 0x7fd3353034e0>, 'expression': <obj_model.core.LongStringAttribute object at 0x7fd335303550>, 'linear': <obj_model.core.BooleanAttribute object at 0x7fd335303cc0>, 'reactions': <obj_model.core.ManyToManyAttribute object at 0x7fd3353032b0>}[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.ObjectiveFunction'>,)[source]
ordering = ()[source]
primary_attribute = None[source]
related_attributes = {'submodel': <wc_lang.core.ObjectiveFunctionAttribute object at 0x7fd385ef6e48>}[source]
tabular_orientation = 3[source]
unique_together = ()[source]
valid_functions = (<built-in function exp>, <built-in function pow>, <built-in function log>, <built-in function log10>)[source]
verbose_name = 'Objective function'[source]
verbose_name_plural = 'Objective functions'[source]
add_to_sbml_doc(sbml_document)[source]

Add this ObjectiveFunction to a libsbml SBML document in a libsbml.model.ListOfObjectives.

This uses version 2 of the ‘Flux Balance Constraints’ extension. SBML assumes that an ObjectiveFunction is a linear combination of reaction fluxes.

Parameters:sbml_document (obj) – a libsbml SBMLDocument
Returns:the libsbml Objective that’s created
Return type:libsbml.Objective
Raises:LibSBMLError – if calling libsbml raises an error
biomass_reactions = <obj_model.core.ManyToManyAttribute object>[source]
classmethod deserialize(attribute, value, objects)[source]

Deserialize value

Parameters:
  • attribute (Attribute) – attribute
  • value (str) – String representation
  • objects (dict) – dictionary of all Model objects, grouped by model
Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of object, InvalidAttribute or None

expression = <obj_model.core.LongStringAttribute object>[source]
get_products()[source]

Get the species produced by this objective function

Returns:species produced by this objective function
Return type:list of Species
linear = <obj_model.core.BooleanAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
reactions = <obj_model.core.ManyToManyAttribute object>[source]
serialize()[source]

Generate string representation

Returns:value of primary attribute
Return type:str
validate()[source]

Determine whether an ObjectiveFunction is valid

Ensure that self.expression evaluates as valid Python.

Returns:
None if the object is valid,
otherwise return a list of errors in an InvalidObject instance
Return type:InvalidObject or None
class wc_lang.core.ObjectiveFunctionAttribute(related_name='', verbose_name='', verbose_related_name='', help='')[source]

Bases: obj_model.core.OneToOneAttribute

Objective function attribute

deserialize(value, objects)[source]

Deserialize value

Parameters:
  • value (str) – String representation
  • objects (dict) – dictionary of objects, grouped by model
Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of object, InvalidAttribute or None

serialize(value)[source]

Serialize related object

Parameters:value (ObjectiveFunction) – the referenced ObjectiveFunction
Returns:simple Python representation
Return type:str
class wc_lang.core.OneToOneSpeciesAttribute(related_name='', verbose_name='', verbose_related_name='', help='')[source]

Bases: obj_model.core.OneToOneAttribute

Species attribute

deserialize(value, objects)[source]

Deserialize value

Parameters:
  • value (str) – String representation
  • objects (dict) – dictionary of objects, grouped by model
Returns:

tuple of cleaned value

and cleaning error

Return type:

tuple of list of ReactionParticipant, InvalidAttribute or None

serialize(value)[source]

Serialize related object

Parameters:value (Model) – Python representation
Returns:simple Python representation
Return type:str
class wc_lang.core.Parameter(**kwargs)[source]

Bases: obj_model.core.Model

id[source]

str – unique identifier per model/submodel

name[source]

str – name

model[source]

Model – model

submodel[source]

Submodel – submodel

value[source]

float – value

units[source]

str – units of value

comments[source]

str – comments

references[source]

list of Reference – references

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'model', 'submodels', 'value', 'units', 'comments', 'references')[source]
attributes = {'comments': <obj_model.core.LongStringAttribute object at 0x7fd33519b0b8>, 'id': <obj_model.core.SlugAttribute object at 0x7fd3351a7e10>, 'model': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a7f28>, 'name': <obj_model.core.StringAttribute object at 0x7fd3351a7eb8>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd33519b0f0>, 'submodels': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7fd0>, 'units': <obj_model.core.StringAttribute object at 0x7fd33519b080>, 'value': <obj_model.core.FloatAttribute object at 0x7fd33519b048>}[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.Parameter'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {}[source]
unique_together = (('id', 'model', 'submodels'),)[source]
verbose_name = 'Parameter'[source]
verbose_name_plural = 'Parameters'[source]
add_to_sbml_doc(sbml_document)[source]

Add this Parameter to a libsbml SBML document.

Parameters:sbml_document (obj) – a libsbml SBMLDocument
Returns:the libsbml Parameter that’s created
Return type:libsbml.Parameter
Raises:LibSBMLError – if calling libsbml raises an error
comments = <obj_model.core.LongStringAttribute object>[source]
id = <obj_model.core.SlugAttribute object>[source]
model = <obj_model.core.ManyToOneAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
submodels = <obj_model.core.ManyToManyAttribute object>[source]
units = <obj_model.core.StringAttribute object>[source]
value = <obj_model.core.FloatAttribute object>[source]
class wc_lang.core.RateLaw(**kwargs)[source]

Bases: obj_model.core.Model

Rate law

reaction[source]

Reaction – reaction

direction[source]

RateLawDirection – direction

equation[source]

RateLawEquation – equation

k_cat[source]

float – v_max (reactions enz^-1 s^-1)

k_m[source]

float – k_m (M)

comments[source]

str – comments

references[source]

list of Reference – references

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('reaction', 'direction', 'equation', 'k_cat', 'k_m', 'comments', 'references')[source]
attributes = {'comments': <obj_model.core.LongStringAttribute object at 0x7fd3351a7438>, 'direction': <obj_model.core.EnumAttribute object at 0x7fd3351a72e8>, 'equation': <wc_lang.core.RateLawEquationAttribute object at 0x7fd3351a7390>, 'k_cat': <obj_model.core.FloatAttribute object at 0x7fd3351a7400>, 'k_m': <obj_model.core.FloatAttribute object at 0x7fd3351a73c8>, 'reaction': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a7320>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7470>}[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.RateLaw'>,)[source]
ordering = ('reaction', 'direction')[source]
primary_attribute = None[source]
related_attributes = {}[source]
unique_together = (('direction', 'reaction'),)[source]
verbose_name = 'Rate law'[source]
verbose_name_plural = 'Rate laws'[source]
comments = <obj_model.core.LongStringAttribute object>[source]
direction = <obj_model.core.EnumAttribute object>[source]
equation = <wc_lang.core.RateLawEquationAttribute object>[source]
k_cat = <obj_model.core.FloatAttribute object>[source]
k_m = <obj_model.core.FloatAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
reaction = <obj_model.core.ManyToOneAttribute object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
serialize()[source]

Generate string representation

Returns:value of primary attribute
Return type:str
validate()[source]

Determine whether this RateLaw is valid

Returns:
None if the object is valid,
otherwise return a list of errors in an InvalidObject instance
Return type:InvalidObject or None
class wc_lang.core.RateLawDirection[source]

Bases: int, wc_utils.util.enumerate.CaseInsensitiveEnum

Rate law directions

backward = -1[source]
forward = 1[source]
class wc_lang.core.RateLawEquation(**kwargs)[source]

Bases: obj_model.core.Model

Rate law equation

expression[source]

str – mathematical expression of the rate law

transcoded[source]

str – transcoded expression, suitable for evaluating as a Python expression

modifiers[source]

list of Species – species whose concentrations are used in the rate law

rate_law[source]

RateLaw – the RateLaw which uses this RateLawEquation

class Meta[source]

Bases: obj_model.core.Meta

valid_functions[source]

tuple of str – tuple of names of functions that can be used in this RateLawEquation

attribute_order = ('expression', 'modifiers', 'transcoded')[source]
attributes = {'expression': <obj_model.core.LongStringAttribute object at 0x7fd3351a75f8>, 'modifiers': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7668>, 'transcoded': <obj_model.core.LongStringAttribute object at 0x7fd3351a7630>}[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.RateLawEquation'>,)[source]
ordering = ('rate_law',)[source]
primary_attribute = None[source]
related_attributes = {'rate_law': <wc_lang.core.RateLawEquationAttribute object at 0x7fd3351a7390>}[source]
tabular_orientation = 3[source]
unique_together = ()[source]
valid_functions = (<built-in function ceil>, <built-in function floor>, <built-in function exp>, <built-in function pow>, <built-in function log>, <built-in function log10>, <built-in function min>, <built-in function max>)[source]
verbose_name = 'Rate law equation'[source]
verbose_name_plural = 'Rate law equations'[source]
classmethod deserialize(attribute, value, objects)[source]

Deserialize value

Parameters:
  • attribute (Attribute) – attribute
  • value (str) – String representation
  • objects (dict) – dictionary of objects, grouped by model
Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of object, InvalidAttribute or None

expression = <obj_model.core.LongStringAttribute object>[source]
modifiers = <obj_model.core.ManyToManyAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
serialize()[source]

Generate string representation

Returns:value of primary attribute
Return type:str
transcoded = <obj_model.core.LongStringAttribute object>[source]
validate()[source]

Determine whether a RateLawEquation is valid

Returns:
None if the object is valid,
otherwise return a list of errors in an InvalidObject instance
Return type:InvalidObject or None
class wc_lang.core.RateLawEquationAttribute(related_name='', verbose_name='', verbose_related_name='', help='')[source]

Bases: obj_model.core.OneToOneAttribute

Rate law equation

deserialize(value, objects)[source]

Deserialize value

Parameters:
  • value (str) – String representation
  • objects (dict) – dictionary of objects, grouped by model
Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of object, InvalidAttribute or None

serialize(value)[source]

Serialize related object

Parameters:value (RateLawEquation) – the related RateLawEquation
Returns:simple Python representation of the rate law equation
Return type:str
class wc_lang.core.Reaction(**kwargs)[source]

Bases: obj_model.core.Model

id[source]

str – unique identifier

name[source]

str – name

submodel[source]

Submodel – submodel that reaction belongs to

participants[source]

list of ReactionParticipant – participants

reversible[source]

bool – indicates if reaction is thermodynamically reversible

min_flux[source]

float – minimum flux bound for solving an FBA model; negative for reversible reactions

max_flux[source]

float – maximum flux bound for solving an FBA model

comments[source]

str – comments

references[source]

list of Reference – references

cross_references[source]

list of CrossReference – cross references

rate_laws[source]

list of RateLaw – rate laws

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'submodel', 'participants', 'reversible', 'min_flux', 'max_flux', 'comments', 'references')[source]
attributes = {'comments': <obj_model.core.LongStringAttribute object at 0x7fd385eadd68>, 'id': <obj_model.core.SlugAttribute object at 0x7fd385eadba8>, 'max_flux': <obj_model.core.FloatAttribute object at 0x7fd385eadd30>, 'min_flux': <obj_model.core.FloatAttribute object at 0x7fd385eadcf8>, 'name': <obj_model.core.StringAttribute object at 0x7fd385eadb38>, 'participants': <wc_lang.core.ReactionParticipantsAttribute object at 0x7fd385eadc88>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd385eadda0>, 'reversible': <obj_model.core.BooleanAttribute object at 0x7fd385eadcc0>, 'submodel': <obj_model.core.ManyToOneAttribute object at 0x7fd385eadbe0>}[source]
indexed_attrs_tuples = (('id',),)[source]
inheritance = (<class 'wc_lang.core.Reaction'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {'cross_references': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bda0>, 'objective_functions': <obj_model.core.ManyToManyAttribute object at 0x7fd3353032b0>, 'rate_laws': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a7320>}[source]
unique_together = ()[source]
verbose_name = 'Reaction'[source]
verbose_name_plural = 'Reactions'[source]
add_to_sbml_doc(sbml_document)[source]

Add this Reaction to a libsbml SBML document.

Parameters:sbml_document (obj) – a libsbml SBMLDocument
Returns:the libsbml reaction that’s created
Return type:libsbml.reaction
Raises:LibSBMLError – if calling libsbml raises an error
comments = <obj_model.core.LongStringAttribute object>[source]
get_species()[source]

Get species

Returns:list of Species
Return type:list
id = <obj_model.core.SlugAttribute object>[source]
max_flux = <obj_model.core.FloatAttribute object>[source]
min_flux = <obj_model.core.FloatAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
participants = <wc_lang.core.ReactionParticipantsAttribute object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
reversible = <obj_model.core.BooleanAttribute object>[source]
submodel = <obj_model.core.ManyToOneAttribute object>[source]
class wc_lang.core.ReactionParticipant(**kwargs)[source]

Bases: obj_model.core.Model

Species in a reaction

species[source]

Species – species

coefficient[source]

float – coefficient

reaction[source]

Reaction – reaction

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('species', 'coefficient')[source]
attributes = {'coefficient': <obj_model.core.FloatAttribute object at 0x7fd3351a7128>, 'species': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a7080>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.ReactionParticipant'>,)[source]
ordering = ('species',)[source]
primary_attribute = None[source]
related_attributes = {'reactions': <wc_lang.core.ReactionParticipantsAttribute object at 0x7fd385eadc88>}[source]
tabular_orientation = 3[source]
unique_together = (('coefficient', 'species'),)[source]
verbose_name = 'Reaction participant'[source]
verbose_name_plural = 'Reaction participants'[source]
coefficient = <obj_model.core.FloatAttribute object>[source]
classmethod deserialize(attribute, value, objects, compartment=None)[source]

Deserialize value

Parameters:
  • attribute (Attribute) – attribute
  • value (str) – String representation
  • objects (dict) – dictionary of objects, grouped by model
  • compartment (Compartment, optional) – compartment
Returns:

tuple of cleaned value

and cleaning error

Return type:

tuple of list of ReactionParticipant, InvalidAttribute or None

objects = <obj_model.core.Manager object>[source]
serialize(show_compartment=True, show_coefficient_sign=True)[source]

Serialize related object

Parameters:
  • show_compartment (bool, optional) – if true, show compartment
  • show_coefficient_sign (bool, optional) – if true, show coefficient sign
Returns:

simple Python representation

Return type:

str

species = <obj_model.core.ManyToOneAttribute object>[source]
class wc_lang.core.ReactionParticipantsAttribute(related_name='', verbose_name='', verbose_related_name='', help='')[source]

Bases: obj_model.core.ManyToManyAttribute

Reaction participants

deserialize(value, objects)[source]

Deserialize value

Parameters:
  • value (str) – String representation
  • objects (dict) – dictionary of objects, grouped by model
Returns:

tuple of cleaned value

and cleaning error

Return type:

tuple of list of ReactionParticipant, InvalidAttribute or None

deserialize_side(direction, value, objects, global_comp)[source]

Deserialize the LHS or RHS of a reaction equation

Parameters:
  • direction (float) – -1. indicates LHS, +1. indicates RHS
  • value (str) – String representation
  • objects (dict) – dictionary of objects, grouped by model
  • global_comp (Compartment) – global compartment of the reaction
Returns:

Return type:

tuple

serialize(participants)[source]

Serialize related object

Parameters:participants (list of ReactionParticipant) – Python representation of reaction participants
Returns:simple Python representation
Return type:str
class wc_lang.core.Reference(**kwargs)[source]

Bases: obj_model.core.Model

id[source]

str – unique identifier

name[source]

str – name

model[source]

Model – model

title[source]

str – title

author[source]

str – author(s)

editor[source]

str – editor(s)

year[source]

int – year

type[source]

ReferenceType – type

publication[source]

str – publication title

publisher[source]

str – publisher

series[source]

str – series

volume[source]

str – volume

number[source]

str – number

issue[source]

str – issue

edition[source]

str – edition

chapter[source]

str – chapter

pages[source]

str – page range

comments[source]

str – comments

cross_references[source]

list of CrossReference – cross references

taxa[source]

list of Taxon – taxa

submodels[source]

list of Submodel – submodels

compartments[source]

list of Compartment – compartments

species_types[source]

list of SpeciesType – species types

concentrations[source]

list of Concentration – concentrations

reactions[source]

list of Reaction – reactions

rate_laws[source]

list of RateLaw – rate laws

parameters[source]

list of Parameter – parameters

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'model', 'title', 'author', 'editor', 'year', 'type', 'publication', 'publisher', 'series', 'volume', 'number', 'issue', 'edition', 'chapter', 'pages', 'comments')[source]
attributes = {'author': <obj_model.core.StringAttribute object at 0x7fd33519b470>, 'chapter': <obj_model.core.StringAttribute object at 0x7fd33519b6d8>, 'comments': <obj_model.core.LongStringAttribute object at 0x7fd33519b748>, 'edition': <obj_model.core.StringAttribute object at 0x7fd33519b6a0>, 'editor': <obj_model.core.StringAttribute object at 0x7fd33519b4a8>, 'id': <obj_model.core.SlugAttribute object at 0x7fd33519b358>, 'issue': <obj_model.core.StringAttribute object at 0x7fd33519b668>, 'model': <obj_model.core.ManyToOneAttribute object at 0x7fd33519b390>, 'name': <obj_model.core.StringAttribute object at 0x7fd33519b320>, 'number': <obj_model.core.StringAttribute object at 0x7fd33519b630>, 'pages': <obj_model.core.StringAttribute object at 0x7fd33519b710>, 'publication': <obj_model.core.StringAttribute object at 0x7fd33519b550>, 'publisher': <obj_model.core.StringAttribute object at 0x7fd33519b588>, 'series': <obj_model.core.StringAttribute object at 0x7fd33519b5c0>, 'title': <obj_model.core.StringAttribute object at 0x7fd33519b438>, 'type': <obj_model.core.EnumAttribute object at 0x7fd33519b518>, 'volume': <obj_model.core.StringAttribute object at 0x7fd33519b5f8>, 'year': <obj_model.core.PositiveIntegerAttribute object at 0x7fd33519b4e0>}[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.Reference'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {'biomass_components': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7a20>, 'biomass_reactions': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7c18>, 'compartments': <obj_model.core.ManyToManyAttribute object at 0x7fd335303f28>, 'concentrations': <obj_model.core.ManyToManyAttribute object at 0x7fd385eada20>, 'cross_references': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bdd8>, 'parameters': <obj_model.core.ManyToManyAttribute object at 0x7fd33519b0f0>, 'rate_laws': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7470>, 'reactions': <obj_model.core.ManyToManyAttribute object at 0x7fd385eadda0>, 'species_types': <obj_model.core.ManyToManyAttribute object at 0x7fd385ead0b8>, 'submodels': <obj_model.core.ManyToManyAttribute object at 0x7fd3946cc828>, 'taxa': <obj_model.core.ManyToManyAttribute object at 0x7fd394814048>}[source]
unique_together = ()[source]
verbose_name = 'Reference'[source]
verbose_name_plural = 'References'[source]
author = <obj_model.core.StringAttribute object>[source]
chapter = <obj_model.core.StringAttribute object>[source]
comments = <obj_model.core.LongStringAttribute object>[source]
edition = <obj_model.core.StringAttribute object>[source]
editor = <obj_model.core.StringAttribute object>[source]
id = <obj_model.core.SlugAttribute object>[source]
issue = <obj_model.core.StringAttribute object>[source]
model = <obj_model.core.ManyToOneAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
number = <obj_model.core.StringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
pages = <obj_model.core.StringAttribute object>[source]
publication = <obj_model.core.StringAttribute object>[source]
publisher = <obj_model.core.StringAttribute object>[source]
series = <obj_model.core.StringAttribute object>[source]
title = <obj_model.core.StringAttribute object>[source]
type = <obj_model.core.EnumAttribute object>[source]
volume = <obj_model.core.StringAttribute object>[source]
year = <obj_model.core.PositiveIntegerAttribute object>[source]
class wc_lang.core.ReferenceType[source]

Bases: int, wc_utils.util.enumerate.CaseInsensitiveEnum

Reference types

article = 1[source]
book = 2[source]
inbook = 6[source]
incollection = 7[source]
inproceedings = 8[source]
misc = 9[source]
online = 3[source]
proceedings = 4[source]
thesis = 5[source]
class wc_lang.core.Species(tuple of species type, compartment)[source]

Bases: obj_model.core.Model

species_type[source]

SpeciesType – species type

compartment[source]

Compartment – compartment

concentration[source]

Concentration – concentration

reaction_participants[source]

list of Reaction – participations in reactions

rate_law_equations[source]

RateLawEquation – rate law equations

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('species_type', 'compartment')[source]
attributes = {'compartment': <obj_model.core.ManyToOneAttribute object at 0x7fd385ead5f8>, 'species_type': <obj_model.core.ManyToOneAttribute object at 0x7fd385ead518>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.Species'>,)[source]
ordering = ('species_type', 'compartment')[source]
primary_attribute = None[source]
related_attributes = {'concentration': <wc_lang.core.OneToOneSpeciesAttribute object at 0x7fd385ead7b8>, 'rate_law_equations': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7668>, 'reaction_participants': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a7080>}[source]
tabular_orientation = 3[source]
unique_together = (('compartment', 'species_type'),)[source]
verbose_name = 'Species'[source]
verbose_name_plural = 'Species'[source]
add_to_sbml_doc(sbml_document)[source]

Add this Species to a libsbml SBML document.

Parameters:sbml_document (obj) – a libsbml SBMLDocument
Returns:the libsbml species that’s created
Return type:libsbml.species
Raises:LibSBMLError – if calling libsbml raises an error
compartment = <obj_model.core.ManyToOneAttribute object>[source]
classmethod deserialize(attribute, value, objects)[source]

Deserialize value

Parameters:
  • attribute (Attribute) – attribute
  • value (str) – String representation
  • objects (dict) – dictionary of objects, grouped by model
Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of object, InvalidAttribute or None

static gen_id(species_type, compartment)[source]

Generate a Species’ primary identifier

Parameters:
  • species_type (object) – a SpeciesType, or its id
  • compartment (object) – a Compartment, or its id
Returns:

canonical identifier for a specie in a compartment, ‘species_type_id[compartment_id]’

Return type:

str

static get(ids, species_iterator)[source]

Find some Species instances

Parameters:
  • ids (Iterator of str) – an iterator over some species identifiers
  • species_iterator (Iterator) – an iterator over some species
Returns:

each element of the list corresponds to an element

of ids and contains either a Species with id() equal to the element in ids, or None indicating that species_iterator does not contain a matching Species

Return type:

list of Species or None

id()[source]

Provide a Species’ primary identifier

Returns:canonical identifier for a specie in a compartment, ‘specie_id[compartment_id]’
Return type:str
static make_xml_id(species_type_id, compartment_id)[source]

Make a Species id that satisfies the SBML string id syntax.

Replaces the ‘[‘ and ‘]’ in Species.id() with double-underscores ‘__’. See Finney and Hucka, “Systems Biology Markup Language (SBML) Level 2: Structures and Facilities for Model Definitions”, 2003, section 3.4.

Returns:an SBML id
Return type:str
objects = <obj_model.core.Manager object>[source]
serialize()[source]

Provide a Species’ primary identifier

Returns:canonical identifier for a specie in a compartment, ‘specie_id[compartment_id]’
Return type:str
species_type = <obj_model.core.ManyToOneAttribute object>[source]
xml_id()[source]

Make a Species id that satisfies the SBML string id syntax.

Use make_xml_id() to make a SBML id.

Returns:an SBML id
Return type:str
static xml_id_to_id(xml_id)[source]

Convert an xml_id to its species id.

Returns:a species id
Return type:str
class wc_lang.core.SpeciesType(**kwargs)[source]

Bases: obj_model.core.Model

Species type

id[source]

str – unique identifier

name[source]

str – name

model[source]

Model – model

structure[source]

str – structure (InChI for metabolites; sequence for DNA, RNA, proteins)

empirical_formula[source]

str – empirical formula

molecular_weight[source]

float – molecular weight

charge[source]

int – charge

type[source]

SpeciesTypeType – type

comments[source]

str – comments

references[source]

list of Reference – references

cross_references[source]

list of CrossReference – cross references

concentrations[source]

list of Concentration – concentrations

reaction_participants[source]

list of ReactionParticipant – reaction participants

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'model', 'structure', 'empirical_formula', 'molecular_weight', 'charge', 'type', 'comments', 'references')[source]
attributes = {'charge': <obj_model.core.IntegerAttribute object at 0x7fd385ead908>, 'comments': <obj_model.core.LongStringAttribute object at 0x7fd385ead240>, 'empirical_formula': <obj_model.core.RegexAttribute object at 0x7fd335303c18>, 'id': <obj_model.core.SlugAttribute object at 0x7fd335303d68>, 'model': <obj_model.core.ManyToOneAttribute object at 0x7fd335303d30>, 'molecular_weight': <obj_model.core.FloatAttribute object at 0x7fd335303048>, 'name': <obj_model.core.StringAttribute object at 0x7fd335303cf8>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd385ead0b8>, 'structure': <obj_model.core.LongStringAttribute object at 0x7fd335303c50>, 'type': <obj_model.core.EnumAttribute object at 0x7fd385ead128>}[source]
indexed_attrs_tuples = (('id',),)[source]
inheritance = (<class 'wc_lang.core.SpeciesType'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {'biomass_components': <obj_model.core.ManyToOneAttribute object at 0x7fd3351a79e8>, 'cross_references': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bd68>, 'species': <obj_model.core.ManyToOneAttribute object at 0x7fd385ead518>}[source]
unique_together = ()[source]
verbose_name = 'Species type'[source]
verbose_name_plural = 'Species types'[source]
charge = <obj_model.core.IntegerAttribute object>[source]
comments = <obj_model.core.LongStringAttribute object>[source]
empirical_formula = <obj_model.core.RegexAttribute object>[source]
id = <obj_model.core.SlugAttribute object>[source]
is_carbon_containing()[source]

Returns True is species contains at least one carbon atom.

Returns:True is species contains at least one carbon atom.
Return type:bool
model = <obj_model.core.ManyToOneAttribute object>[source]
molecular_weight = <obj_model.core.FloatAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
structure = <obj_model.core.LongStringAttribute object>[source]
type = <obj_model.core.EnumAttribute object>[source]
class wc_lang.core.SpeciesTypeType[source]

Bases: int, wc_utils.util.enumerate.CaseInsensitiveEnum

Types of species types

dna = 3[source]
metabolite = 1[source]
protein = 2[source]
pseudo_species = 5[source]
rna = 4[source]
class wc_lang.core.Submodel(**kwargs)[source]

Bases: obj_model.core.Model

id[source]

str – unique identifier

name[source]

str – name

model[source]

Model – model

algorithm[source]

SubmodelAlgorithm – algorithm

compartment[source]

Compartment – the compartment that contains the submodel’s species

biomass_reaction[source]

BiomassReaction – the growth reaction for a dFBA submodel

objective_function[source]

ObjectiveFunction, optional – objective function for a dFBA submodel; if not initialized, then biomass_reaction is used as the objective function

comments[source]

str – comments

references[source]

list of Reference – references

cross_references[source]

list of CrossReference – cross references

reactions[source]

list of Reaction – reactions

parameters[source]

list of Parameter – parameters

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'model', 'algorithm', 'compartment', 'biomass_reaction', 'objective_function', 'comments', 'references')[source]
attributes = {'algorithm': <obj_model.core.EnumAttribute object at 0x7fd33508acf8>, 'biomass_reaction': <obj_model.core.ManyToOneAttribute object at 0x7fd385ef6e80>, 'comments': <obj_model.core.LongStringAttribute object at 0x7fd3946cc6a0>, 'compartment': <obj_model.core.ManyToOneAttribute object at 0x7fd385ef6e10>, 'id': <obj_model.core.SlugAttribute object at 0x7fd33508ae48>, 'model': <obj_model.core.ManyToOneAttribute object at 0x7fd33508ab70>, 'name': <obj_model.core.StringAttribute object at 0x7fd33508aef0>, 'objective_function': <wc_lang.core.ObjectiveFunctionAttribute object at 0x7fd385ef6e48>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd3946cc828>}[source]
indexed_attrs_tuples = (('id',),)[source]
inheritance = (<class 'wc_lang.core.Submodel'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {'cross_references': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bcf8>, 'parameters': <obj_model.core.ManyToManyAttribute object at 0x7fd3351a7fd0>, 'reactions': <obj_model.core.ManyToOneAttribute object at 0x7fd385eadbe0>}[source]
unique_together = ()[source]
verbose_name = 'Submodel'[source]
verbose_name_plural = 'Submodels'[source]
add_to_sbml_doc(sbml_document)[source]

Add this Submodel to a libsbml SBML document as a libsbml.model.

Parameters:sbml_document (obj) – a libsbml SBMLDocument
Returns:the libsbml model
Return type:libsbml.model
Raises:LibSBMLError – if calling libsbml raises an error
algorithm = <obj_model.core.EnumAttribute object>[source]
biomass_reaction = <obj_model.core.ManyToOneAttribute object>[source]
comments = <obj_model.core.LongStringAttribute object>[source]
compartment = <obj_model.core.ManyToOneAttribute object>[source]
get_ex_species(ex_comp_id='e')[source]

Get extracellular species used by this submodel

Returns:extracellular species used by this submodel
Return type:list of Species
get_species()[source]

Get species in reactions

Returns:species in reactions
Return type:list of Species
id = <obj_model.core.SlugAttribute object>[source]
model = <obj_model.core.ManyToOneAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
objective_function = <wc_lang.core.ObjectiveFunctionAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
class wc_lang.core.SubmodelAlgorithm[source]

Bases: int, wc_utils.util.enumerate.CaseInsensitiveEnum

Submodel algorithms

dfba = 1[source]
ode = 2[source]
ssa = 3[source]
class wc_lang.core.Taxon(**kwargs)[source]

Bases: obj_model.core.Model

Biological taxon (e.g. family, genus, species, strain, etc.)

id[source]

str – unique identifier

name[source]

str – name

model[source]

Model – model

rank[source]

TaxonRank – rank

comments[source]

str – comments

references[source]

list of Reference – references

cross_references[source]

list of CrossReference – cross references

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ('id', 'name', 'model', 'rank', 'comments', 'references')[source]
attributes = {'comments': <obj_model.core.LongStringAttribute object at 0x7fd394814710>, 'id': <obj_model.core.SlugAttribute object at 0x7fd3946b7320>, 'model': <obj_model.core.OneToOneAttribute object at 0x7fd394814630>, 'name': <obj_model.core.StringAttribute object at 0x7fd394814d68>, 'rank': <obj_model.core.EnumAttribute object at 0x7fd3948145f8>, 'references': <obj_model.core.ManyToManyAttribute object at 0x7fd394814048>}[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_lang.core.Taxon'>,)[source]
ordering = ('id',)[source]
primary_attribute = <obj_model.core.SlugAttribute object>[source]
related_attributes = {'cross_references': <obj_model.core.ManyToOneAttribute object at 0x7fd33519bcc0>}[source]
tabular_orientation = 2[source]
unique_together = ()[source]
verbose_name = 'Taxon'[source]
verbose_name_plural = 'Taxons'[source]
comments = <obj_model.core.LongStringAttribute object>[source]
id = <obj_model.core.SlugAttribute object>[source]
model = <obj_model.core.OneToOneAttribute object>[source]
name = <obj_model.core.StringAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
rank = <obj_model.core.EnumAttribute object>[source]
references = <obj_model.core.ManyToManyAttribute object>[source]
class wc_lang.core.TaxonRank[source]

Bases: int, enum.Enum

Taxonomic ranks

classis = 4[source]
domain = 1[source]
family = 6[source]
genus = 8[source]
kingdom = 2[source]
order = 5[source]
phylum = 3[source]
species = 9[source]
tribe = 7[source]
variety = 10[source]
class wc_lang.core.TaxonRankMeta[source]

Bases: wc_utils.util.enumerate.CaseInsensitiveEnumMeta

__getattr__(name)[source]

Get value by name

Parameters:name (str) – attribute name
Returns:taxonomic rank
Return type:TaxonRank
__getitem__(name)[source]

Get value by name

Parameters:name (str) – attribute name
Returns:taxonomic rank
Return type:TaxonRank

2.1.5. wc_lang.io module

Reading and writing models to/from files.

Supported file types:

  • Comma separated values (.csv)
  • Excel (.xlsx)
  • Tab separated values (.tsv)
Author:Jonathan Karr <karr@mssm.edu>
Date:2016-12-05
Copyright:2016, Karr Lab
License:MIT
class wc_lang.io.Reader[source]

Bases: object

Read model from file(s)

run(path)[source]

Read model from file(s)

Parameters:path (str) – path to file(s)
Returns:model
Return type:Model
class wc_lang.io.Writer[source]

Bases: object

Write model to file(s)

model_order = [<class 'wc_lang.core.Model'>, <class 'wc_lang.core.Taxon'>, <class 'wc_lang.core.Submodel'>, <class 'wc_lang.core.ObjectiveFunction'>, <class 'wc_lang.core.Compartment'>, <class 'wc_lang.core.SpeciesType'>, <class 'wc_lang.core.Concentration'>, <class 'wc_lang.core.Reaction'>, <class 'wc_lang.core.RateLaw'>, <class 'wc_lang.core.BiomassComponent'>, <class 'wc_lang.core.BiomassReaction'>, <class 'wc_lang.core.Parameter'>, <class 'wc_lang.core.Reference'>, <class 'wc_lang.core.CrossReference'>][source]
run(path, model=None)[source]

Write model to file(s)

Parameters:
  • path (str) – path to file(s)
  • model (Model) – model
wc_lang.io.convert(source, destination)[source]

Convert among Excel (.xlsx), comma separated (.csv), and tab separated model formats (.tsv)

Read a model from the source files(s) and write it to the destination files(s). A path to a delimiter separated set of models must be represented by a Unix glob pattern (with a *) that matches all delimiter separated files.

Parameters:
  • source (str) – path to source file(s)
  • destination (str) – path to save converted file
wc_lang.io.create_template(path)[source]

Create file with model template, including row and column headings

Parameters:path (str) – path to file(s)

2.1.6. wc_lang.prepare module

Prepare a WC model for further processing, such as export or simulation.

Author:Arthur Goldberg <Arthur.Goldberg@mssm.edu>
Date:2017-10-22
Copyright:2017, Karr Lab
License:MIT
class wc_lang.prepare.AnalyzeModel(model)[source]

Bases: object

Statically analyze a model

AnalyzeModel performs static analysis of WC-lang models which are useful for constructing models.

Current analyses:

  • Identify dead end species and reaction network gaps in dFBA submodels
static digraph_of_rxn_network(submodel)[source]

Create a NetworkX network representing the reaction network in submodel

To leverage the algorithms in NetworkX, map a reaction network onto a NetworkX directed graph. The digraph is bipartite, with Reaction and Species nodes. A reaction is represented a Reaction node, with an edge from each reactant Species node to the Reaction node, and an edge from the Reaction node to each product Species node.

Parameters:submodel (Submodel) – a DFBA submodel
Returns:a NetworkX directed graph representing submodel’s reaction network
Return type:DiGraph
static find_dead_end_species(submodel, inactive_reactions)[source]

Find the dead end species in a reaction network

Given a set of inactive reactions in submodel, determine species that are not consumed by any reaction, or are not produced by any reaction. Costs \(O(n*p)\), where \(n\) is the number of reactions in submodel and \(p\) is the maximum number of participants in a reaction.

Parameters:
  • submodel (Submodel) – a DFBA submodel
  • inactive_reactions (set of Reaction) – the inactive reactions in submodel
Returns:

  • set of Species: the species that are not consumed
  • set of Species: the species that are not produced

Return type:

tuple

static get_inactive_reactions(submodel, dead_end_species)[source]

Find the inactive reactions in a reaction network

Given the dead end species in a reaction network, find the reactions that must eventually become inactive. Reactions that consume species which are not produced must become inactive. And reactions that produce species which are not consumed must become inactive to prevent the copy numbers of those species from growing without bound. Costs \(O(n*p)\), where \(n\) is the number of reactions in submodel and \(p\) is the maximum number of participants in a reaction.

Parameters:
  • submodel (Submodel) – a DFBA submodel
  • dead_end_species (tuple) –
    • set of Species: the Species that are not consumed by any Reaction in submodel
    • set of Species: the Species that are not produced by any Reaction in submodel
Returns:

the inactive reactions in submodel’s reaction network

Return type:

set of Reaction

identify_dfba_submodel_rxn_gaps(submodel)[source]

Identify gaps in a dFBA submodel’s reaction network

Species that are not consumed or not produced indicate gaps in the reaction network. These can be found by a static analysis of the model. Reactions that use species that are not produced or produce species that are not consumed must eventually have zero flux. A reaction network can be reduced to a minimal network of reactions that can all have positive fluxes.

Algorithm:

all_gap_species = get_gap_species([])
delta_gap_species = all_gap_species
while delta_gap_species:
    all_gap_reactions = get_gap_reactions(all_gap_species)
    tmp_gap_species = all_gap_species
    all_gap_species = get_gap_species(all_gap_reactions)
    delta_gap_species = all_gap_species - tmp_gap_species
return (all_gap_species, all_gap_reactions)
Parameters:submodel (Submodel) – a DFBA submodel
Raises:ValueError – if submodel is not a dFBA submodel
Returns:
  • set of Species: Species not in the minimal reaction network
  • set of Reaction: `Reaction`s not in the minimal reaction network
Return type:tuple
static path_bounds_analysis(submodel)[source]

Perform path bounds analysis on submodel

To be adequately constrained, a dFBA metabolic model should have the property that each path from an extracellular species to a component in the objective function contains at least one reaction constrained by a finite flux upper bound.

Analyze the reaction network in submodel and return all paths from extracellular species to objective function components that lack a finite flux upper bound.

Parameters:submodel (Submodel) – a DFBA submodel
Returns:obj:: paths from extracellular species to objective function components that lack a finite flux upper bound. Keys in the dict are the ids of extracellular species; the corresponding values contain the unbounded paths for the extracellular species, as returned by unbounded_paths.
Return type:dict of list of list of
static unbounded_paths(rxn_network, ex_species, obj_fn_species, min_non_finite_ub=1000.0)[source]

Find the unbounded paths from an extracellular species to some objective function species

Return all paths in a reaction network that lack a finite flux upper bound and go from ex_species to an objective function component.

Parameters:
  • rxn_network (DiGraph) – a NetworkX directed graph representing a reaction network,
  • by digraph_of_rxn_network (created) –
  • ex_species (Species) – an extracellular Species that is a node in rxn_network
  • obj_fn_species (list of Species) – objective function Species that are
  • nodes in rxn_network (also) –
  • finite_upper_bound_limit (float, optional) – the maximum value of a finite flux
  • bound (upper) –
  • min_non_finite_ub (float, optional) – flux upper bounds less than min_non_finite_ub
  • considered finite (are) –
Returns:

obj:: a list of the reaction paths from ex_species to objective function components that lack a finite flux upper bound. A path is a list of Species, Reaction, Species, …, Species, starting with ex_species and ending with an objective function component.

Return type:

list of list of

class wc_lang.prepare.CheckModel(model)[source]

Bases: object

Statically check a model

A Model which validates may fail to satisfy global properties that must hold for the Model to be used. CheckModel evaluates these properties.

Currently checked properties:

  • DFBA submodels contain a biomass reaction and an objective function
  • Rate laws transcode and evaluate without error
  • All reactants in each submodel’s reactions are in the submodel’s compartment

Other properties to be checked:

  • The model does not contain dead-end species which are only consumed or produced
  • Reactions are balanced
  • Reactions in dynamic submodels contain fully specified rate laws
  • All Species used in reactions have concentration values
  • Consider the reactions modeled by a submodel – all modifier species used by the rate laws for the reactions participate in at least one reaction in the submodel
  • Ensure that Reaction and BiomassReaction ids don’t overlap; can then simplify ObjectiveFunction.deserialize()

# TODO: implement these, and expand the list of properties

# TODO: fix doc string formatting

check_dfba_submodel(submodel)[source]

Check the inputs to a DFBA submodel

Ensure that:

  • All DFBA reactions have min flux and max flux with appropriate values
  • The DFBA submodel contains a biomass reaction and an objective function
  • All species used in biomass reactions are defined
Parameters:submodel (Submodel) – a DFBA submodel
Returns:if no errors, returns an empty list; otherwise a list of error messages
Return type:list of str
check_dynamic_submodel(submodel)[source]

Check the inputs to a dynamic submodel

Ensure that:

  • All reactions have rate laws for the appropriate directions
Parameters:submodel (Submodel) – a dynamic (SSA or ODE) submodel
Returns:if no errors, returns an empty list; otherwise a list of error messages
Return type:list of str
run()[source]
transcode_and_check_rate_law_equations()[source]

Transcode and evaluate all rate law equations in a model

Ensure that all rate law equations can be transcoded and evaluated.

Returns:if no errors, returns an empty list; otherwise a list of error messages
Return type:list of str
verify_reactant_compartments()[source]

Verify that all reactants in each submodel’s reactions are in the submodel’s compartment

Returns:if no errors, returns an empty list; otherwise a list of error messages
Return type:list of str
class wc_lang.prepare.PrepareModel(model)[source]

Bases: object

Statically prepare a model

Models which validate usually lack data needed to use them. PrepareModel automates the addition of default and statically computed data to a Model.

Currently added data:

  • Missing concentrations
  • Create implicit exchange reactions for dFBA submodels
  • Ensure that dFBA submodels have objective functions
  • Apply default flux bounds to the reactions in dFBA submodels
apply_default_dfba_submodel_flux_bounds(submodel)[source]

Apply default flux bounds to a dFBA submodel’s reactions

The FBA optimizer needs min and max flux bounds for each dFBA submodel reaction. If some reactions lack bounds and default bounds are provided in a config file, then apply the defaults to the reactions. Specifically, min and max default bounds are applied as follows:

reversible reactions:

  • min_flux = -default_max_flux_bound
  • max_flux = default_max_flux_bound

irreversible reactions:

  • min_flux = default_min_flux_bound
  • max_flux = default_max_flux_bound
Parameters:submodel (Submodel) – a dFBA submodel
Raises:ValueError – if submodel is not a dFBA submodel
Returns:
  • obj:int: number of min flux bounds set to the default
  • obj:int: number of max flux bounds set to the default
Return type:tuple
static assign_linear_objective_fn(submodel, reactions, biomass_reactions)[source]

Assign a linear objective function to a submodel

Assign a linear objective function parsed by parse_dfba_submodel_obj_func to a submodel’s attributes.

Parameters:
  • submodel (Submodel) – a dFBA submodel
  • reactions (list of (float, str)) – list of (coeff, id) pairs for reactions
  • biomass_reactions (list of (float, str)) – list of (coeff, id) pairs for biomass reactions
Raises:

ValueError – if submodel is not a dFBA submodel

confirm_dfba_submodel_obj_func(submodel)[source]

Ensure that a dFBA submodel has an objective function

If the submodel definition does not provide an objective function, then use the biomass reaction.

Parameters:

submodel (Submodel) – a dFBA submodel

Raises:
  • ValueError – if submodel is not a dFBA submodel
  • ValueError – if submodel cannot use its biomass reaction ‘{}’ as an objective function
create_dfba_exchange_rxns(submodel, extracellular_compartment_id)[source]

Create exchange reactions for a dFBA submodel’s reaction network.

To represent FBA’s mathematical assumption that it models a closed system, create ‘implicit’ forward exchange reactions that synthesize all extracellular metabolites.

# TODO: To model how other pathways consume metabolites generated by metabolism, create ‘implicit’ reactions which exchange these metabolites between a dFBA metabolism submodel and the other pathway(s)/submodel(s).

Algorithm to synthesize extracellular metabolites:

E = the set of all extracellular metabolites used by the submodel
generate a "-> e" reaction for each e in E in the submodel
Parameters:
  • submodel (Submodel) – a DFBA submodel
  • extracellular_compartment_id (str) – the id of the extracellular compartment
Raises:

ValueError – if submodel is not a dFBA submodel

Returns:

the number of reactions created

Return type:

int

init_concentrations()[source]

Initialize missing concentration values to 0

parse_dfba_submodel_obj_func(submodel)[source]

Parse a dFBA submodel’s objective function into a linear function of reaction fluxes

The SBML FBC only handles objectives that are a linear function of reaction fluxes. This method uses Python’s parser to parse an objective function.

The general form for an objective is \(c_1*id_1 + c_2*id_2 + ... + c_n*id_n\), where \(c_i\) is a numerical coefficient and \(id_i\) is a reaction id. The ids may represent reactions or biomass reactions. Coefficients may also appear after an id, as in \(id_j*c_j\). Coefficients equal to 1.0 are not needed. And negative coefficients are supported.

Parameters:

submodel (Submodel) – a dFBA submodel

Returns:

a pair of lists representing the objective’s linear form

  • obj:list: (coeff, id) pairs for reactions
  • obj:list: (coeff, id) pairs for biomass reactions

Return type:

tuple

Raises:
  • ValueError – if submodel is not a dFBA submodel
  • ValueError – if submodel.objective_function is not a legal python expression, does not have the form above, is not a linear function of reaction ids, uses an unknown reaction id, or uses an id multiple times
run()[source]

Statically prepare a model by executing all Prepare methods.

2.1.7. wc_lang.rate_law_utils module

Static methods which handle rate laws and their expressions

Author:Arthur Goldberg, Arthur.Goldberg@mssm.edu
Date:2017-10-23
Copyright:2016-2017, Karr Lab
License:MIT
class wc_lang.rate_law_utils.RateLawUtils[source]

Bases: object

A set of static rate_law methods

static eval_rate_law(rate_law, concentrations, transcoded_equation=None)[source]

Evaluate a rate law at the given species concentrations

Parameters:
  • rate_law (wc_lang.core.RateLaw) – a RateLaw instance
  • concentrations (dict of species_id -> float) – a dictionary of species concentrations
  • transcoded_equation (str, optional) – the rate law’s transcoded_equation; if not provided, will be taken from rate_law.equation.transcoded
Returns:

the rate law’s rate

Return type:

(float)

Raises:
  • ValueError – if the rate law has a syntax error
  • NameError – if the rate law references a specie whose concentration is not provided in concentrations
  • Exception – if the rate law has other errors, such as a reference to an unknown function
static eval_reaction_rate_laws(reaction, concentrations)[source]

Evaluate a reaction’s rate laws at the given species concentrations

Parameters:
  • reaction (wc_lang.core.Reaction) – a Reaction instance
  • concentrations (dict of species_id -> float) – a dictionary of species concentrations
Returns:

the reaction’s forward and, perhaps, backward rates

Return type:

(list of float)

Raises:
  • ValueError – if the reaction’s rate law has a syntax error
  • NameError – if the rate law references a specie whose concentration is not provided in concentrations
  • Exception – if the rate law has other errors, such as a reference to an unknown function
static transcode(rate_law_equation, species)[source]

Translate a wc_lang.core.RateLawEquation into a python expression that can be evaluated during a simulation.

Parameters:
  • rate_law_equation (wc_lang.core.RateLawEquation) – a rate law equation
  • species (set of wc_lang.core.Species) – the species that use the rate law
Returns:

The python expression, or None if the rate law doesn’t have an equation

Raises:
  • ValueError – If rate_law_equation contains __, which increases its security risk, or
  • if rate_law_equation refers to species not in species
static transcode_rate_laws(model)[source]

Transcode all of model’s rate law expressions into Python expressions

Parameters:model (wc_lang.core.Model) – a wc_lang.core.Model
Raises:ValueError – If a rate law cannot be transcoded

2.1.8. wc_lang.transform module

Transform models.

Author:Jonathan Karr <karr@mssm.edu>
Date:2016-11-10
Copyright:2016, Karr Lab
License:MIT
class wc_lang.transform.MergeAlgorithmicallyLikeSubmodelsTransform[source]

Bases: wc_lang.transform.Transform

Merge groups of algorithmically-like submodels into individual submodels

class Meta[source]

Bases: object

id = 'MergeAlgorithmicallyLikeSubmodels'[source]
label = 'Merge groups of algorithmically-like submodels into individual submodels'[source]
run(model)[source]

Merge groups of algorithmically-like submodels into individual submodels

Parameters:model (Model) – model definition
Returns:same model definition, but with submodels of the same simulation algorithm merged
Return type:Model
class wc_lang.transform.SplitReversibleReactionsTransform[source]

Bases: wc_lang.transform.Transform

Split reversible reactions into separate forward and backward reactions

class Meta[source]

Bases: object

id = 'SplitReversibleReactions'[source]
label = 'Split reversible reactions into separate forward and backward reactions'[source]
run(model)[source]

Split reversible reactions into separate forward and backward reactions

Parameters:model (Model) – model definition
Returns:same model definition, but with reversible reactions split into separate forward and backward reactions
Return type:Model
class wc_lang.transform.Transform[source]

Bases: object

run(model)[source]

Transform a model

Parameters:model (Model) – model
Returns:transformed model
Return type:Model
wc_lang.transform.get_transforms()[source]

Get dictionary of available transform classes

Returns:class: dictionary of available transform classes
Return type:dict of str

2.1.9. wc_lang.util module

Data model to represent models.

Author:Jonathan Karr <karr@mssm.edu>
Date:2016-11-10
Copyright:2016, Karr Lab
License:MIT
wc_lang.util.get_model_size(model)[source]

Get numbers of model components

Parameters:model (wc_lang.core.Model) – model
Returns:dictionary with numbers of each type of model component
Return type:dict
wc_lang.util.get_model_summary(model)[source]

Get textual summary of a model

Parameters:model (wc_lang.core.Model) – model
Returns:textual summary of the model
Return type:str
wc_lang.util.get_models(inline=True)[source]

Get list of models :param inline: if true, return inline models :type inline: bool, optional

Returns:list of models
Return type:list of class
wc_lang.util.get_reaction_string(reaction)[source]

Generate string representation of reaction stoichometry.

Returns:string representation of reaction stoichometry
Return type:str

2.1.10. Module contents