In [9]:
text = """The government promotes improved cultivar to boost agricultural
production for ensuring food security. However, the policy to seriously
cut down the use of inorganic fertilizer and phase out the fertilizer
subsidy results in deteriorating biophysical conditions, low use of inorganic
fertilizer, less water, significantly reduced farm sizes which lead to low
benefit from the improved cultivar."""
In [18]:
from indra.sources import eidos
eidos_processor = eidos.process_text(text, out_format='json_ld')
In [19]:
statements = eidos_processor.statements
In [20]:
import indra.tools.assemble_corpus as ac
statements = ac.run_preassembly(statements)
In [21]:
statements
Out[21]:
In [22]:
from indra.assemblers.cag import CAGAssembler
ca = CAGAssembler(statements)
ca.make_model()
Out[22]:
In [23]:
from IPython.core.display import Javascript
Javascript(ca.generate_jupyter_js())
Out[23]:
In [24]:
from indra.assemblers.graph import GraphAssembler
ga = GraphAssembler(statements)
ga.make_model()
ga.save_pdf('model_graph.pdf')
In [25]:
from IPython.display import IFrame
IFrame("model_graph.pdf", width=600, height=500)
Out[25]:
In [26]:
from indra.assemblers.pysb import PysbAssembler
from pysb.simulator import ScipyOdeSimulator; import numpy; import matplotlib.pyplot as plt; plt.ion()
In [27]:
pa = PysbAssembler()
pa.add_statements(statements)
model = pa.make_model()
In [28]:
import numpy
ts = numpy.linspace(0, 50000)
sim = ScipyOdeSimulator(model, ts)
In [29]:
res = sim.run()
In [30]:
plt.figure(figsize=(7,3))
plt.xlim(0, 50000)
plt.ylim(0, 100000)
plt.xlabel('Time')
plt.ylabel('Relative amount (a.u.)')
plt.xticks([])
plt.yticks([])
for i, cp in enumerate(model.species):
if str(cp) == 'benefit()':
plt.plot(ts, res.all['__s%d' % i], label=str(cp))
plt.legend()
Out[30]:
In [31]:
from indra.assemblers.figaro import FigaroAssembler
In [32]:
fa = FigaroAssembler(statements, readout='benefit')
In [33]:
fa.make_model()
In [34]:
print(fa.print_model('IndraModel.scala'))