How to create a new bioscrape model?

Creating a bioscrape model is simple, you could use the bioscrape API to write a simple Python script to generate the bioscrape XML, or you could simple write your own bioscrape XML file. This notebook describes both of these methods.

You could also import SBML models into bioscrape, this is demonstrated at the end.

Using bioscrape Python API

We will create a model for the following simple chemical reaction system

$\emptyset \xrightarrow[]{k_1} X \; \; \; \; X \xrightarrow[]{d_1} \emptyset$


In [1]:
from bioscrape.types import Model

species = ['X']
reactions = [(['X'], [], 'massaction', {'k':'d1'}), ([], ['X'], 'massaction', {'k':'k1'})]
k1 = 10.0
d1 = .2
params = [('k1', k1), ('d1', d1)]
initial_condition = {'X':0}
M = Model(species = species, reactions = reactions, parameters = params, 
          initial_condition_dict = initial_condition)

Now write the model to an XML file (the XML file is printed here as well)


In [2]:
M.write_bioscrape_xml('models/txtl_model.xml')
f = open('models/txtl_model.xml')
print("Bioscrape Model XML:\n", f.read())


Bioscrape Model XML:
 <model>
<species name="X" value="0.0" />

<parameter name="d1" value="0.2" />
<parameter name="k1" value="10.0" />

<reaction text= "X -- ">
	<propensity type="massaction" k="d1" species="X" />
	<delay type="none" />
</reaction>
<reaction text= "-- X ">
	<propensity type="massaction" k="k1" species="" />
	<delay type="none" />
</reaction>

</model>

Use bioscrape XML specification language

To directly write the bioscrape XML model, use the following guideline available at this link

https://github.com/ananswam/bioscrape/wiki/BioSCRAPE-XML

Import SBML model into bioscrape


In [3]:
from bioscrape.sbmlutil import import_sbml
from bioscrape.types import Model
M = Model()
M_imported = import_sbml('models/repressilator_sbml.xml', bioscrape_model = M)


C:\ProgramData\Anaconda3\lib\site-packages\bioscrape\sbmlutil.py:184: UserWarning: Compartments, UnitDefintions, Events, and some other SBML model components are not recognized by bioscrape. Refer to the bioscrape wiki for more information.
  warnings.warn('Compartments, UnitDefintions, Events, and some other SBML model components are not recognized by bioscrape. ' +

M_imported is the bioscrape Model object imported from the SBML filename above.


In [4]:
M_imported.get_species_dictionary()


Out[4]:
{'PX': 0.0, 'PY': 0.0, 'PZ': 0.0, 'X': 0.0, 'Y': 20.0, 'Z': 0.0}

In [ ]: