PyBEL graphs (indra.assemblers.pybel.assembler)

class indra.assemblers.pybel.assembler.PybelAssembler(stmts=None, name=None, description=None, version=None, authors=None, contact=None, license=None, copyright=None, disclaimer=None, annotations_to_include=None)[source]

Assembles a PyBEL graph from a set of INDRA Statements.

PyBEL tools can subsequently be used to export the PyBEL graph into BEL script files, SIF files, and other related output formats.

  • stmts (list[indra.statement.Statement]) – The list of Statements to assemble.

  • name (str) – Name of the assembled PyBEL network.

  • description (str) – Description of the assembled PyBEL network.

  • version (str) – Version of the assembled PyBEL network.

  • authors (str) – Author(s) of the network.

  • contact (str) – Contact information (email) of the responsible author.

  • license (str) – License information for the network.

  • copyright (str) – Copyright information for the network.

  • disclaimer (str) – Any disclaimers for the network.

  • annotations_to_include (Optional[list[str]]) – A list of evidence annotation keys that should be added to the assembled PyBEL graph. Default: None


>>> from indra.statements import *
>>> map2k1 = Agent('MAP2K1', db_refs={'HGNC': '6840'})
>>> mapk1 = Agent('MAPK1', db_refs={'HGNC': '6871'})
>>> stmt = Phosphorylation(map2k1, mapk1, 'T', '185')
>>> pba = PybelAssembler([stmt])
>>> belgraph = pba.make_model()
>>> sorted(node.as_bel() for node in belgraph)
['p(HGNC:6840 ! MAP2K1)', 'p(HGNC:6871 ! MAPK1)', 'p(HGNC:6871 ! MAPK1, pmod(go:0006468 ! "protein phosphorylation", Thr, 185))']
>>> len(belgraph)
>>> belgraph.number_of_edges()
save_model(path, output_format=None)[source]

Save the pybel.BELGraph using one of the outputs from pybel

  • path (str) – The path to output to

  • output_format (Optional[str]) – Output format as cx, pickle, json or defaults to bel


Send the model to the PyBEL database

This function wraps pybel.to_database().


manager (Optional[pybel.manager.Manager]) – A PyBEL database manager. If none, first checks the PyBEL configuration for PYBEL_CONNECTION then checks the environment variable PYBEL_REMOTE_HOST. Finally, defaults to using SQLite database in PyBEL data directory (automatically configured by PyBEL)


network – The SQLAlchemy model representing the network that was uploaded. Returns None if upload fails.

Return type


to_web(host=None, user=None, password=None)[source]

Send the model to BEL Commons by wrapping pybel.to_web()

The parameters host, user, and password all check the PyBEL configuration, which is located at ~/.config/pybel/config.json by default

  • host (Optional[str]) – The host name to use. If none, first checks the PyBEL configuration entry PYBEL_REMOTE_HOST, then the environment variable PYBEL_REMOTE_HOST. Finally, defaults to

  • user (Optional[str]) – The username (email) to use. If none, first checks the PyBEL configuration entry PYBEL_REMOTE_USER, then the environment variable PYBEL_REMOTE_USER.

  • password (Optional[str]) – The password to use. If none, first checks the PyBEL configuration entry PYBEL_REMOTE_PASSWORD, then the environment variable PYBEL_REMOTE_PASSWORD.


response – The response from the BEL Commons network upload endpoint.

Return type


indra.assemblers.pybel.assembler.get_causal_edge(stmt, activates)[source]

Returns the causal, polar edge with the correct “contact”.