In this tutorial we build a simple model using natural language, and export it into different formats.
First we import INDRA's API to the TRIPS reading system. We then define a block of text which serves as the description of the mechanism to be modeled in the model_text variable. Finally, indra.sources.trips.process_text is called which sends a request to the TRIPS web service, gets a response and processes the extraction knowledge base to obtain a list of INDRA Statements
python
from indra.sources import trips
model_text = 'MAP2K1 phosphorylates MAPK1 and DUSP6 dephosphorylates MAPK1.' tp = trips.process_text(model_text)
At this point tp.statements should contain 2 INDRA Statements: a Phosphorylation Statement and a Dephosphorylation Statement. Note that the evidence sentence for each Statement is propagated:
python
- for st in tp.statements:
print('%s with evidence "%s"' % (st, st.evidence[0].text))
We next use INDRA's PySB Assembler to automatically assemble a rule-based model representing the biochemical mechanisms described in model_text. First a PysbAssembler object is instantiated, then the list of INDRA Statements is added to the assembler. Finally, the assembler's make_model method is called which assembles the model and returns it, while also storing it in pa.model. Notice that we are using policies='two_step' as an argument of make_model. This directs the assemble to use rules in which enzymatic catalysis is modeled as a two-step process in which enzyme and substrate first reversibly bind and the enzyme-substrate complex produces and releases a product irreversibly.
python
from indra.assemblers.pysb import PysbAssembler
pa = PysbAssembler() pa.add_statements(tp.statements) pa.make_model(policies='two_step')
At this point pa.model contains a PySB model object with 3 monomers,
python
- for monomer in pa.model.monomers:
print(monomer)
6 rules,
python
- for rule in pa.model.rules:
print(rule)
and 9 parameters (6 kinetic rate constants and 3 total protein amounts) that are set to nominal but plausible values,
python
- for parameter in pa.model.parameters:
print(parameter)
The model also contains extensive annotations that tie the monomers to database identifiers and also annotate the semantics of each component of each rule.
python
- for annotation in pa.model.annotations:
print(annotation)
From the assembled PySB format it is possible to export the model into other common formats such as SBML, BNGL and Kappa. One can also generate a Matlab or Mathematica script with ODEs corresponding to the model.
pa.export_model('sbml')
pa.export_model('bngl')
One can also pass a file name argument to the export_model function to save the exported model directly into a file:
pa.export_model('sbml', 'example_model.sbml')