Author: Charles Tapley Hoyt
Estimated Run Time: 5 seconds
This notebook shows how the PyBEL-INDRA integration can be used to turn a BEL graph into natural language. Special thanks to John Bachman and Ben Gyori for all of their efforts in making this possible.
To view the interactive Javascript output in this notebook, open in the Jupyter NBViewer.
In [1]:
import sys
import time
import indra
import indra.util.get_version
import ndex2
import pybel
from indra.assemblers.english_assembler import EnglishAssembler
from indra.sources.bel.bel_api import process_pybel_graph
from pybel.examples import sialic_acid_graph
from pybel_tools.visualization import to_jupyter
In [2]:
print(sys.version)
In [3]:
print(time.asctime())
In [4]:
pybel.utils.get_version()
Out[4]:
In [5]:
indra.util.get_version.get_version()
Out[5]:
The Sialic Acid graph is used as an example.
In [6]:
to_jupyter(sialic_acid_graph)
Out[6]:
The PyBEL BELGraph instance is converted to INDRA statments with the function process_pybel_graph. It returns an instance of PybelProcessor, which stores the INDRA statments.
In [7]:
pbp = process_pybel_graph(sialic_acid_graph)
A list of INDRA statements is extracted from the BEL graph and stored in the field PybelProcessor.statements. Note that INDRA is built to consider mechanistic information, and therefore excludes most associative relationships.
In [8]:
stmts = pbp.statements
stmts
Out[8]:
The list of INDRA statements is converted to plain english using the EnglishAssembler.
In [9]:
asm = EnglishAssembler(stmts)
print(asm.make_model(), sep='\n')
While knowledge assembly is indeed difficult and precarious, the true scientific task is to use them to generate mechanistic hypotheses. By far, the most common way is for a scientist to use their intution and choose an explanatory subgraph or pathway. This notebook has demonstrated that after this has been done, the results can be serialized to english prose in a precise manner.