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)[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.
Parameters: - 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.
Examples
>>> 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) # doctest:+IGNORE_UNICODE ['p(HGNC:6840 ! MAP2K1)', 'p(HGNC:6871 ! MAPK1)', 'p(HGNC:6871 ! MAPK1, pmod(Ph, Thr, 185))'] >>> len(belgraph) 3 >>> belgraph.number_of_edges() 2
-
save_model(path, output_format=None)[source]¶ Save the
pybel.BELGraphusing one of the outputs frompybelParameters: - path (str) – The path to output to
- output_format (Optional[str]) – Output format as
cx,pickle,jsonor defaults tobel
-
to_database(manager=None)[source]¶ Send the model to the PyBEL database
This function wraps
pybel.to_database().Parameters: manager (Optional[pybel.manager.Manager]) – A PyBEL database manager. If none, first checks the PyBEL configuration for PYBEL_CONNECTIONthen checks the environment variablePYBEL_REMOTE_HOST. Finally, defaults to using SQLite database in PyBEL data directory (automatically configured by PyBEL)Returns: network – The SQLAlchemy model representing the network that was uploaded. Returns None if upload fails. Return type: Optional[pybel.manager.models.Network]
-
to_web(host=None, user=None, password=None)[source]¶ Send the model to BEL Commons by wrapping
pybel.to_web()The parameters
host,user, andpasswordall check the PyBEL configuration, which is located at~/.config/pybel/config.jsonby defaultParameters: - host (Optional[str]) – The host name to use. If none, first checks the PyBEL
configuration entry
PYBEL_REMOTE_HOST, then the environment variablePYBEL_REMOTE_HOST. Finally, defaults to https://bel-commons.scai.fraunhofer.de. - user (Optional[str]) – The username (email) to use. If none, first checks the
PyBEL configuration entry
PYBEL_REMOTE_USER, then the environment variablePYBEL_REMOTE_USER. - password (Optional[str]) – The password to use. If none, first checks the PyBEL configuration
entry
PYBEL_REMOTE_PASSWORD, then the environment variablePYBEL_REMOTE_PASSWORD.
Returns: response – The response from the BEL Commons network upload endpoint.
Return type: requests.Response
- host (Optional[str]) – The host name to use. If none, first checks the PyBEL
configuration entry
- stmts (list[