In [1]:
%pylab inline
import json
from indra.sources import trips
from indra.statements import draw_stmt_graph, stmts_to_json
In [2]:
text = 'Active ATM phosphorylates itself. Active ATM phosphorylates another ATM molecule.'
tp = trips.process_text(text)
In [3]:
tp.statements
Out[3]:
The first Statement, obtained by reading "Active ATM phosphorylates itself", represents the Autophosphorylation of ATM with ATM being in an active state. Here activity
stands for generic molecular activity and True
indicates an active as opposed to an inactive state.
The second Statement, obtained from "Active ATM phosphorylates another ATM molecule" is a Phosphorylation with the enzyme ATM being in an active state phosphorylating another ATM as a substrate.
Next, we can use the draw_stmt_graph
function to display the Statements produced by reading and INDRA input processing as a graph. The root of each tree is the type of the Statement, in this case Autophosphorylation. The arguments of the Statement branch off from the root. In this case the enzyme argument of Autophosphorylation is an Agent with name ATM. Its database references can be inspected under the db_refs
property.
In [4]:
pylab.rcParams['figure.figsize'] = (12, 8)
draw_stmt_graph(tp.statements[1:])
INDRA Statements can be serialized into JSON format. This is a human-readable and editable form of INDRA Statements which is independent of Python and can therefore be used as a platform-independent data exchange format for Statements. The function stmts_to_json
in the indra.statements
module takes a list of Statements and returns a JSON as a dictionary. Below we pretty-print this JSON as a string with indentations.
In [5]:
statements_json = stmts_to_json(tp.statements)
print(json.dumps(statements_json, indent=1))
In [6]:
from indra.assemblers.pysb import PysbAssembler
pa = PysbAssembler()
pa.add_statements([tp.statements[0]])
model1 = pa.make_model()
We can examine the properties of the PySB model object before exporting it. As seen below, the model has a single Monomer and Rule, and two Parameters.
In [7]:
model1
Out[7]:
We can look at the ATM Monomer and its sites. ATM has an activity
site which can be either active
of inactive
. It also has a phospho
site with u
and p
states.
In [8]:
model1.monomers['ATM']
Out[8]:
The rule representing ATM autophosphorylation can be inspected below. The rule is parameterized by the forward rate kf_a_autophos_1
.
In [9]:
model1.rules[0]
Out[9]:
We now assemble a model for the second Statement.
In [10]:
pa = PysbAssembler()
pa.add_statements([tp.statements[1]])
model2 = pa.make_model()
In [11]:
model2
Out[11]:
In [12]:
model2.monomers['ATM']
Out[12]:
In [13]:
model2.rules[0]
Out[13]:
As we see, the rule assembled for this model contains two distinct ATMs on each side, one acting as the kinase and the other as the substrate.
Finally, models assembled by INDRA carry automatically propagated annotations. Below, the grounding of ATM in the UniProt, HGNC and NCIT databases is annotated; the semantic role of monomers in each rule are also annotated, and finally, the unique ID of the INDRA Statement that a rule was derived from is annotated.
In [14]:
model1.annotations
Out[14]:
In [15]:
model2.annotations
Out[15]: