bionetgen.modelapi package

Submodules

bionetgen.modelapi.blocks module

class bionetgen.modelapi.blocks.ActionBlock[source]

Bases: ModelBlock

Action block object, subclass of ModelBlock.This is the one object that doesn’t need a begin/end block tag to be in the model.

Attributes

_action_listlist[str]

list of supported action names

Methods

add_action(name, action_type=None, action_args={})

adds an action by making a new Action object and passing the args/kwargs to its initialization.

clear_actions()

add_action(action_type, action_args) None[source]

adds action, needs type as string and args as list of tuples (which preserve order) of (argument, value) pairs

add_item(item_tpl) None[source]

Adds an item to the block from the item tuple given. Exact mechanism is slightly different for each block.

clear_actions() None[source]
gen_string() str[source]

Generates the string for the block from the object.

class bionetgen.modelapi.blocks.CompartmentBlock[source]

Bases: ModelBlock

Compartment block object, subclass of ModelBlock.

Methods

add_compartment(name, dim, size, outside=None)

adds a compartment by making a new Compartment object and passing the args/kwargs to its initialization.

add_compartment(*args, **kwargs) None[source]
class bionetgen.modelapi.blocks.EnergyPatternBlock[source]

Bases: ModelBlock

Energy pattern block object, subclass of ModelBlock.

Methods

add_energy_pattern(id, pattern, expression)

adds an energy pattern by making a new EnergyPattern object and passing the args/kwargs to its initialization.

add_energy_pattern(*args, **kwargs) None[source]
class bionetgen.modelapi.blocks.FunctionBlock[source]

Bases: ModelBlock

Function block object, subclass of ModelBlock.

Methods

add_function(name, name, expr, args=None)

adds a function by making a new Function object and passing the args/kwargs to its initialization.

add_function(*args, **kwargs) None[source]
class bionetgen.modelapi.blocks.ModelBlock[source]

Bases: object

Base block object that will be used for each block in the model.

These objects will implement the following python internal functions to make them feel more natural in a python environment:

__str__, __repr__, __len__, __getitem__, __setitem__, __delitem__, __iter__, __contains__

Attributes

namestr

Name of the block which will be used to write the BNGL text

comment(str, str)

comment at the begin {block} or end {block} statements, tuple

itemsOrderedDict

all the model objects in the block

_changesOrderedDict

a dictionary to keep track of all the changes done in a block after it is originally created

_recompilebool

a tag that tells a potential future simulator if the model needs to be recompiled. TODO: has to be computed from _changes property upon get request.

Methods

reset_compilation_tags()

resets _recompile and _changes tags for the block

add_item((name,value))

sets self.item[name] = value to add a particular model object into a block

add_items(item_list)

loops over every element in the list and uses add_item on it

gen_string()

for every block this method generates the BNGL string of the block. it has to be overwritten for each block.

add_item(item_tpl) None[source]

Adds an item to the block from the item tuple given. Exact mechanism is slightly different for each block.

add_items(item_list) None[source]

Calls add_item for each tuple for a list of tuples.

gen_string() str[source]

Generates the string for the block from the object.

reset_compilation_tags() None[source]

Resets the change history for this block.

class bionetgen.modelapi.blocks.MoleculeTypeBlock[source]

Bases: ModelBlock

Molecule type block, subclass of ModelBlock.

Methods

add_molecule_type(name, name, components)

adds a molecule type by making a new MoleculeType object and passing the args/kwargs to its initialization.

add_molecule_type(name, components) None[source]
class bionetgen.modelapi.blocks.ObservableBlock[source]

Bases: ModelBlock

Observable block object, subclass of ModelBlock.

Methods

add_observable(name, otype, patterns=[])

adds an observable by making a new Observable object and passing the args/kwargs to its initialization.

add_observable(*args, **kwargs) None[source]
class bionetgen.modelapi.blocks.ParameterBlock[source]

Bases: ModelBlock

Parameter block object, subclass of ModelBlock.

Methods

add_parameter(name, value, expr=None)

adds a parameter by making a new Parameter object and passing the args/kwargs to its initialization.

add_parameter(*args, **kwargs) None[source]
class bionetgen.modelapi.blocks.PopulationMapBlock[source]

Bases: ModelBlock

Population map block object, subclass of ModelBlock.

Methods

add_population_map(id, struct_species, pop_species, rate)

adds a population map by making a new PopulationMap object and passing the args/kwargs to its initialization

add_population_map(*args, **kwargs) None[source]
class bionetgen.modelapi.blocks.RuleBlock[source]

Bases: ModelBlock

Rule block object, subclass of ModelBlock.

Methods

add_rule(name, name, reactants=[], products=[], rate_constants=())

adds a rule by making a new Rule object and passing the args/kwargs to its initialization.

consolidate_rulesNone

XML loading makes it so that reversible rules are split into two unidirectional rules. This find them and combines them into a single rule to correctly represent the original model rule.

add_rule(*args, **kwargs) None[source]
consolidate_rules() None[source]

Generated XML only has unidirectional rules and uses “_reverse_” tag to make bidirectional rules for NFSim. Take all the “_reverse_” tagged rules and convert them to bidirectional rules

class bionetgen.modelapi.blocks.SpeciesBlock[source]

Bases: ModelBlock

Species block object, subclass of ModelBlock.

Methods

add_species(name, pattern=Pattern(), count=0)

adds a species by making a new Species object and passing the args/kwargs to its initialization.

add_species(*args, **kwargs) None[source]

bionetgen.modelapi.bngfile module

class bionetgen.modelapi.bngfile.BNGFile(path, BNGPATH='/home/docs/checkouts/readthedocs.org/user_builds/pybionetgen/checkouts/latest/bionetgen/bng-linux', generate_network=False, suppress=True)[source]

Bases: object

File object designed to deal with .bngl file manipulations.

Usage: BNGFile(bngl_path)

BNGFile(bngl_path, BNGPATH)

Attributes

pathstr

path to the file the object needs to deal with

_action_listlist[str]

list of acceptible actions

BNGPATHstr

optional path to bng folder that contains BNG2.pl

bngexecstr

path to BNG2.pl

Methods

generate_xml(xml_file, model_file=None)bool

takes the given BNGL file and generates a BNG-XML from it

strip_actions(model_path, folder)str

deletes actions from a given BNGL file

write_xml(open_file, xml_type=”bngxml”, bngl_str=None)bool

given a bngl file or a string, writes an SBML or BNG-XML from it

generate_xml(xml_file, model_file=None) bool[source]

generates an BNG-XML file from a given model file. Defaults to self.path if model_file is not given

strip_actions(model_path, folder) str[source]

Strips actions from a BNGL file and makes a copy into the given folder

write_xml(open_file, xml_type='bngxml', bngl_str=None) bool[source]

write new BNG-XML or SBML of file by calling BNG2.pl again or can take BNGL string in as well.

bionetgen.modelapi.bngparser module

class bionetgen.modelapi.bngparser.BNGParser(path, BNGPATH='/home/docs/checkouts/readthedocs.org/user_builds/pybionetgen/checkouts/latest/bionetgen/bng-linux', parse_actions=True, generate_network=False, suppress=True)[source]

Bases: object

Parser object that deals with reading in the BNGL file and setting up the model object

Usage: BNGParser(bngl_path)

BNGParser(bngl_path, BNGPATH)

Attributes

bngfileBNGFile

BNGFile object that’s responsible for .bngl file manipulations

to_parse_actionsbool

whether to parse the actions in a BNGL file or not

alistActionList

action list object that is used to deal with all things related to actions

Methods

parse_model(model_obj)

parses the BNGL model at the given path and adds everything to a given model object

parse_xml(xml_str)

parses given xml string and adds everything to a given model object

parse_actions(model_obj)[source]

Uses ActionList object to parse actions and turn them into action objects and fill up the ActionsBlock with them.

parse_model(model_obj) None[source]

Will determine the parser route eventually and call the right parser

parse_xml(xml_str, model_obj) None[source]

The main parsing method that parses the contents of a dictionary created from the BNG-XML file using xmltodict library. This method will use XML parser objects to generate each block to attach to the model object

bionetgen.modelapi.model module

class bionetgen.modelapi.model.bngmodel(bngl_model, BNGPATH='/home/docs/checkouts/readthedocs.org/user_builds/pybionetgen/checkouts/latest/bionetgen/bng-linux', generate_network=False, suppress=True)[source]

Bases: object

Main model object and entry point for model API. The goal of this object is to generate and read the BNGXML of a given BNGL model and give the user a pythonic interface to the resulting model object.

Usage: bngmodel(bng_model)

bngmodel(bng_model, BNGPATH)

Attributes

active_blockslist[str]

a list of the blocks that have been parsed in the model

bngparserBNGParser

BNGParser object that’s responsible for .bngl file reading and model setup

model_namestr

name of the model, generally set from the given BNGL file

model_pathstr

path to the model file initially given

recompilebool

a tag to keep track if any changes have been made to the model via the XML API by the user that requires model recompilation

changesdict

a list of changes the user have made to the model

Methods

reset_compilation_tags()

resets compilation tags of each block to keep track of any changes the user makes to the model via the API

add_action(action_type, action_args)

adds the action of action_type with arguments given by the optional keyword argument action_args, which is a dictionary where each element is of the form “ArgumentName”:ArgumentValue

write_model(model_name)

write the model in BNGL format to the path given

setup_simulator(sim_type)

sets up a simulator in bngmodel.simulator where the only current supported type of simulator is libRR for libRoadRunner simulator.

add_block(BlockObject)

adds a given block object (e.g. ParametersBlock) to the model

add_empty_block(block_type)

adds an empty block of type block_type to the model where block_type can be one of: “parameters”, “compartments”, “molecule_types”, “species”, “observables”, “functions”, “energy_patterns”, “population_maps”, “rules”, “reaction_rules”, “actions”.

add_action(action_type, action_args={})[source]

Adds an action to the actions block of the model object. If an actions block doesn’t exist, this will make an empty actions block and append the action to the block.

Arguments

action_type: str

the type of action being added

action_args: dict

a dictionary where the key is the argument type and the value is the value of that argument.

add_actions_block(block=None)[source]

Adds an actions block to the model object.

add_block(block)[source]

Adds the given block object to the model, uses the name of the block object to determine what block it is

add_compartments_block(block=None)[source]

Adds a compartments block to the model object.

add_empty_block(block_name)[source]

Makes an empty block object from a given block name and adds it to the model object.

add_energy_patterns_block(block=None)[source]

Adds an energy patterns block to the model object.

add_functions_block(block=None)[source]

Adds a functions block to the model object.

add_molecule_types_block(block=None)[source]

Adds a molecule types block to the model object.

add_observables_block(block=None)[source]

Adds an observable block to the model object.

add_parameters_block(block=None)[source]

Adds a parameters block to the model object.

add_population_maps_block(block=None)[source]

Adds a population maps block to the model object.

add_rules_block(block=None)[source]

Adds a rules block to the model object.

add_species_block(block=None)[source]

Adds a species block to the model object.

property changes
property recompile
reset_compilation_tags()[source]

This function resets all internal tags used for keeping track of changes done to a model after it’s loaded. Resetting these tags will remove all history of changes.

setup_simulator(sim_type='libRR')[source]

Sets up a simulator attribute that is a generic front-end to all other simulators. At the moment only libroadrunner is supported

write_model(file_name)[source]

write the model to file

bionetgen.modelapi.pattern module

class bionetgen.modelapi.pattern.Component[source]

Bases: object

Component object that describes the state, label and bonding for each component. Molecules can optionally contain components

Attributes

namestr

name of the component

_labelstr

label of the component

_statestr

state of the component, not used for molecule types

_stateslist[str]

list of states for molecule types

_bondslist[Bond]

list of bond objects that describes bonding of the component

Methods

add_state()

not implemented. will eventually be used to add additional states to an existing component

add_bond()

not implemented. will eventually be used to add additional bonds to an existing component

add_bond()[source]
add_state()[source]
property bonds
property label
property name
print_canonical()[source]

Returns canonical label for the pattern

property state
property states
class bionetgen.modelapi.pattern.Molecule(name='0', components=[], compartment=None, label=None)[source]

Bases: object

Molecule object. A pattern is a list of molecules. This object also handles molecule types where components have a list of possible states.

Attributes

_namestr

name of the molecule

_compartmentstr

compartment of the molecule

_labelstr

label of the molecule

_componentslist[Component]

list of components for this molecule

Methods

add_component(name, state=None, states=[])

add a component object to the list of components with name “name”, current state “state” or a list of states (for molecule types) “states”

add_component(name, state=None, states=[])[source]
property compartment
property components
property label
property name
print_canonical()[source]

Returns canonical label for the pattern

class bionetgen.modelapi.pattern.Pattern(molecules=[], bonds=None, compartment=None, label=None, canonicalize=False)[source]

Bases: object

Pattern object. Fundamentally it’s a list of molecules which are defined later.

Attributes

_bondsBonds

setting a pattern requires you to keep track of all bonds to correctly label them, this object tracks everything

compartmentstr

compartment of the overall pattern (not the same thing as molecule compartment, those have their own)

_labelstr

label of the overall pattern (not the same thing as molecule label, those have their own)

moleculeslist[Molecule]

list of molecule objects that are in the pattern

fixedbool

used for constant species, sets “$” at the beginning of the pattern string

MatchOncebool

used for matchOnce syntax, “{MatchOnce}PatternStr”

relationstr

alongside quantity this is only used for patterns of the form e.g. pattern==5, pattern<=3 etc

quantitystr

alongside relation this is only used for patterns of the form e.g. pattern==5, pattern<=3 etc

nautyGGraph

if canonicalization was done on the pattern this will return a graph object from the library pynauty which is just python bindings to the canonical labelling library nauty.

canonical_certificatestr

if canonicalization was done on the pattern this will return a string that has the canonical labelling for the underlying graph. this doesn’t take into account node names so it can only be used to compare the graph topology

canonical_labelstr

if canonicalization was done on the pattern this will return a canonical label for the entire molecule that’s unique and all isomorphic patterns will have the same label. comparing this label to another molecules canonical label will tell you if they are the same molecule or not.

Methods

canonicalizeNone

This method will generate a canonical label stored in canonical_label attribute. This label can be used to compare patterns to see if they are the same pattern quickly. This method will only run if pynauty is installed. See [nauty documentation](https://users.cecs.anu.edu.au/~bdm/nauty/) for more information

canonicalize()[source]

This method will use pynauty library to generate a canonical label for the pattern. This pattern will be stored in canonical_label attribute.

property compartment
consolidate_molecule_compartments()[source]
property label
print_canonical()[source]

Returns canonical label for the pattern

bionetgen.modelapi.pattern_reader module

class bionetgen.modelapi.pattern_reader.BNGParsers[source]

Bases: object

Container for parsers for the reader

class bionetgen.modelapi.pattern_reader.BNGPatternReader(pattern_str)[source]

Bases: object

Class that generates parsers to read BNG pattern strings and form Pattern objects from them.

Usage: BNGPatternReader(pattern_str)

Arguments

pattern_strstr

The pattern string to read and generate a Pattern object from

Attributes

patternPattern

The Pattern object formed from the parsed string

parsersBNGParsers

Container object that has parsers for various parts of a BNG pattern string

Methods

define_parsersNone

runs other defined parser commands to setup all parsers

define_component_parserNone

defines pyparsing parser for components

define_molecule_parserNone

defines pyparsing parser for molecules

define_pattern_parserNone

defines pyparsing parser for overall patterns

make_patternPattern

forms the actual Pattern object from the pattern string using the defined parsers

define_component_parser()[source]

Defines specific parsers for BNG components

define_molecule_parser()[source]

Defines specific parsers for BNG molecules

define_parsers()[source]
define_pattern_parser()[source]

Defines specific parsers for overall BNG patterns

make_pattern(pattern_str)[source]

Forms the Pattern object from the given string using the parsed defined above.

bionetgen.modelapi.rulemod module

class bionetgen.modelapi.rulemod.RuleMod(mod_type=None)[source]

Bases: object

Rule modifiers class for storage and printing.

property type

bionetgen.modelapi.runner module

bionetgen.modelapi.runner.run(inp, out=None, suppress=False, timeout=None)[source]

Convenience function to run BNG2.pl as a library

Usage: run(path_to_input_file, output_folder)

Arguments

path_to_input_filestr

this has to point to a BNGL file

output_folderstr

(optional) this points to a folder to put the results into. If it doesn’t exist, it will be created.

bionetgen.modelapi.structs module

class bionetgen.modelapi.structs.Action(action_type=None, action_args={})[source]

Bases: ModelObj

Class for all actions in the model, subclass of ModelObj.

In BNGL actions are of the form

action_type({arg1=>value1, arg2=>value2, …})

Attributes

typestr

type of action, e.g. simulate or writeFile

argsdict[arg_name] = arg_value

action arguments as keys and their values as values

gen_string() str[source]
print_line() str[source]
class bionetgen.modelapi.structs.Compartment(name, dim, size, outside=None)[source]

Bases: ModelObj

Class for all compartments in the model, subclass of ModelObj.

In BNGL the compartments are of the form

compartment_name dimensions size

or

compartment_name dimensions size parent_compartment

the second form only applies when one compartment is contained in another compartment.

Attributes

namestr

name of the compartment

dimstr

dimensionality of the compartment

sizestr

size/volume of the compartment

outsidestr

parent compartment, if exists

write_exprbool

boolean that describes if the size is a volume or an expression

gen_string() str[source]
class bionetgen.modelapi.structs.EnergyPattern(name, pattern, expression)[source]

Bases: ModelObj

Class for all energy patterns in the model, subclass of ModelObj.

In BNGL the energy patterns are of the form

EP_pattern EP_expression

Attributes

namestr

id of the energy pattern

patternPattern

Pattern object representing the energy pattern

expressionstr

expression used for energy pattern

gen_string() str[source]
class bionetgen.modelapi.structs.Function(name, expr, args=None)[source]

Bases: ModelObj

Class for all functions in the model, subclass of ModelObj.

In BNGL functions are of the form

function_name function_expression

or

function_name = function_expression

and functions can have arguments

function_name(arg1, arg2, …, argN)

Attributes

namestr

name of the function

exprstr

function expression

argslist

optional list of arguments for the function

gen_string() str[source]
class bionetgen.modelapi.structs.ModelObj[source]

Bases: object

The base class for all items in a model (parameter, observable etc.).

Attributes

commentstr

comment at the end of the line/object

line_labelstr

line label at the beginning of the line/object

Methods

print_line()

generates the actual line string with line label and comments if applicable

gen_string()

generates the BNGL string of the object itself, separate from line attributes

property comment: None
property line_label: str
print_line() str[source]
class bionetgen.modelapi.structs.MoleculeType(name, components)[source]

Bases: ModelObj

Class for all molecule types in the model, subclass of ModelObj.

In BNGL the molecule types are of the form

molecule_type

where all possible states of each component of a molecule is listed, e.g.

A(b, p~0~1, k~ON~OFF~NULL)

Attributes

moleculeMolecule

a molecule type only contains a molecule object which can also handle multiple component states

gen_string() str[source]
class bionetgen.modelapi.structs.Observable(name, otype, patterns=[])[source]

Bases: ModelObj

Class for all observables in the model, subclass of ModelObj.

In BNGL the observables are of the form

observable_type observable_name observable_patterns

where patterns can include multiple patterns separated by commas.

Attributes

namestr

name of the observable

typestr

type of the observable, Molecules or Species

patternslist[Pattern]

list of patterns of the observable

Methods

add_pattern

add a Pattern object into the list of patterns for this observable

add_pattern(pat) None[source]
gen_string() str[source]
class bionetgen.modelapi.structs.Parameter(name, value, expr=None)[source]

Bases: ModelObj

Class for all parameters in the model, subclass of ModelObj.

In BNGL parameters are of the form

parameter_name parameter_value/expression

or

parameter_name = parameter_value/expression

Attributes

namestr

name of the parameter

valuestr

value of the parameter, if loaded from XML this will always exist since NFsim needs the value and not the expression

exprstr

this exists if the parameter is a math expression, not necerssary

write_exprbool

this is a boolean that determines if the generated string has is in expression form or in value form.

gen_string() str[source]
class bionetgen.modelapi.structs.PopulationMap(name, struct_species, pop_species, rate)[source]

Bases: ModelObj

Class for all population maps in the model, subclass of ModelObj.

In BNGL the population maps are of the form

structured_species -> population_species lumping_parameter

Attributes

namestr

id of the population map

struct_speciesPattern

Pattern object representing the species to be mapped

pop_speciesPattern

Pattern object representing the population count

ratestr

lumping parameter used in population mapping

gen_string() str[source]
class bionetgen.modelapi.structs.Rule(name, reactants=[], products=[], rate_constants=(), rule_mod=Rule modifier of type None, operations=[])[source]

Bases: ModelObj

Class for all rules in the model, subclass of ModelObj.

Attributes

namestr

name of the rule, optional

reactantslist[Pattern]

list of patterns for reactants

productslist[Pattern]

list of patterns for products

rule_modRuleMod

modifier (moveConnected, TotalRate, etc.) used by a given rule

operationslist[Operation]

list of operations

Methods

set_rate_constants((k_fwd,k_bck))

sets forward and backwards rate constants, backwards rate constants are optional and if not given, will set the rule to be a unidirectional rule

side_string(list[Pattern])

given a list of patterns, return a string formatted to be on one side of a rule definition

gen_string()[source]
set_rate_constants(rate_cts)[source]
side_string(patterns)[source]
class bionetgen.modelapi.structs.Species(pattern=, count=0)[source]

Bases: ModelObj

Class for all species in the model, subclass of ModelObj.

In BNGL the species/seed species are of the form

species count

where species is a single pattern and count is the starting value for that specific pattern

Attributes

patternPattern

pattern of the seed species

countstr

starting value of the seed species

gen_string() str[source]

bionetgen.modelapi.xmlparsers module

class bionetgen.modelapi.xmlparsers.BondsXML(bonds_xml=None)[source]

Bases: object

Bonds XML parser, derived from XMLObj.

get_bond_id(comp)[source]
get_tpl_from_id(id_str)[source]
resolve_xml(bonds_xml)[source]
set_xml(bonds_xml)[source]
tpls_from_bond(bond)[source]
class bionetgen.modelapi.xmlparsers.CompartmentBlockXML(xml)[source]

Bases: XMLObj

CompartmentBlock XML parser, derived from XMLObj. Creates a CompartmentBlock that contains the compartments parsed.

parse_xml(xml)[source]
class bionetgen.modelapi.xmlparsers.EnergyPatternBlockXML(xml)[source]

Bases: XMLObj

EnergyPatternBlock XML parser, derived from XMLObj. Creates an EnergyPatternBlock that contains the energy patterns parsed.

parse_xml(xml)[source]
class bionetgen.modelapi.xmlparsers.FunctionBlockXML(xml)[source]

Bases: XMLObj

FunctionBlock XML parser, derived from XMLObj. Creates a FunctionBlock that contains the functions parsed.

Methods

get_arguments(xml)

parses the argument list XML and returns a list of argument names

get_arguments(xml) list[source]
parse_xml(xml)[source]
class bionetgen.modelapi.xmlparsers.MoleculeTypeBlockXML(xml)[source]

Bases: XMLObj

MoleculeTypeBlock XML parser, derived from XMLObj. Creates a MoleculeTypeBlock that contains the molecule types parsed.

Methods

add_molecule_type_to_block(block,xml)

parses the XML to create a MoleculeType object and adds it to a given MoleculeTypeBlock object

add_molecule_type_to_block(block, xml)[source]
parse_xml(xml)[source]
class bionetgen.modelapi.xmlparsers.ObservableBlockXML(xml)[source]

Bases: XMLObj

ObservableBlock XML parser, derived from XMLObj. Creates an ObservableBlock that contains the observables parsed.

parse_xml(xml) ObservableBlock[source]
class bionetgen.modelapi.xmlparsers.Operation[source]

Bases: object

To be used for parsing & storing ListOfOperations information.

valid_ops = ['AddBond', 'DeleteBond', 'ChangeCompartment', 'StateChange', 'Add', 'Delete']
class bionetgen.modelapi.xmlparsers.ParameterBlockXML(xml)[source]

Bases: XMLObj

PatternBlock XML parser, derived from XMLObj. Creates a ParameterBlock that contains the parameters parsed.

parse_xml(xml) ParameterBlock[source]
class bionetgen.modelapi.xmlparsers.PatternListXML(xml)[source]

Bases: object

Pattern list XML parser. Takes a list of patterns and parses them using PatternXML and generates a list of patterns.

Attributes

patternslist[Pattern]

list of patterns parsed from the XML dict list

parse_xml(xml) list[source]
class bionetgen.modelapi.xmlparsers.PatternXML(xml)[source]

Bases: XMLObj

Pattern XML parser, derived from XMLObj.

Methods

_process_mol(xml)

processes a molecule XML dictionary and returns a Molecule object

_process_comp(self, xml)

processes a component XML dictionary and returns a list of Compartment objects

parse_xml(xml) Pattern[source]
class bionetgen.modelapi.xmlparsers.PopulationMapBlockXML(xml)[source]

Bases: XMLObj

PopulationMapBlock XML parser, derived from XMLObj. Creates a PopulationMapBlock that contains the population maps parsed.

Methods

resolve_ratelaw(xml)

parses a rate law XML and returns the rate constant

parse_xml(xml)[source]
resolve_ratelaw(xml)[source]
class bionetgen.modelapi.xmlparsers.RuleBlockXML(xml)[source]

Bases: XMLObj

RuleBlock XML parser, derived from XMLObj. Creates a RuleBlock that contains the rules parsed.

Methods

resolve_ratelaw(xml)

parses a rate law XML and returns the rate constant

resolve_rxn_side(xml)

parses either reactants or products XML and returns a list of Pattern objects

get_operations(xml)

creates and populates a list of operations and their arguments

get_rule_mod(xml)

stores rule modifier used by a given rule as a string

get_operations(xml)[source]
get_rule_mod(xml)[source]
parse_xml(xml)[source]
resolve_ratelaw(xml)[source]
resolve_rxn_side(xml)[source]
class bionetgen.modelapi.xmlparsers.SpeciesBlockXML(xml)[source]

Bases: XMLObj

SpeciesBlock XML parser, derived from XMLObj. Creates a SpeciesBlock that contains the species parsed.

parse_xml(xml)[source]
class bionetgen.modelapi.xmlparsers.XMLObj(xml)[source]

Bases: object

Base object that contains XMLs that is the parent of all XML object that will be used for BNGL blocks as we read from BNGXML. This sets up the python internals such as __repr__ and __str__ for the rest of the XML classes.

This base class assumes at least two methods will be defined by each class that inherits this base object which are defined in the methods below.

Attributes

xmllist/OrderedDict

XML loaded via xmltodict to be parsed. Either a list of items or an OrderedDict.

parsed_objobj

appropriate parsed object, one of the Block objects

Methods

resolve_xml(xml)

the method that parses the XML given and is written separately for each subclass of this one

gen_string()

the method to generate the string from the parsed object

gen_string()[source]
parse_xml(xml)[source]

Module contents