def assemble_pybel(stmts, out_file_prefix): """Return a PyBEL Assembler""" stmts = ac.filter_belief(stmts, 0.95) stmts = ac.filter_top_level(stmts) pba = PybelAssembler(stmts, name='INDRA/REACH Korkut Model', description='Automatically assembled model of ' 'cancer signaling.', version='0.0.10') pba.make_model() pybel.to_bel_path(pba.model, out_file_prefix + '.bel') with open(out_file_prefix, 'wt') as f: pybel.to_json_file(pba.model, f) url = 'https://pybel.scai.fraunhofer.de/api/receive' headers = {'content-type': 'application/json'} requests.post(url, json=pybel.to_json(pba.model), headers=headers)
def from_indra_statements(statements, name=None, version=None, description=None): """Imports a model from :mod:`indra`. :param list[indra.statements.Statement] statements: A list of statements :param str name: The name for the BEL graph :param str version: The version of the BEL graph :param str description: The description of the BEL graph :rtype: pybel.BELGraph """ from indra.assemblers import PybelAssembler pba = PybelAssembler( stmts=statements, name=name, version=version, description=description ) graph = pba.make_model() return graph
ActiveForm(elk1_p, 'transcription', True), IncreaseAmount(elk1_tscript, fos), Conversion(hk1, [glu], [g6p]), Complex([egfr, grb2, sos1]), Autophosphorylation(p38_tab1, 'Y', '100'), Transphosphorylation(egfr_dimer, 'Y', '1173'), ] ev = Evidence('assertion', 'assertion', 'assertion', 'assertion') for stmt in stmts: stmt.evidence = [ev] model_description = 'Test of INDRA Statement assembly into PyBEL.' print("Assembling to PyBEL...") pba = PybelAssembler(stmts, name='INDRA_PyBEL_test', description=model_description, version='0.0.22') belgraph = pba.make_model() # Write to BEL file pybel.to_bel_path(belgraph, 'simple_pybel.bel') # Upload to PyBEL web with open('pybel_model.json', 'wt') as f: pybel.to_json_file(pba.model, f) url = 'https://pybel.scai.fraunhofer.de/api/receive' headers = {'content-type': 'application/json'} requests.post(url, json=pybel.to_json(pba.model), headers=headers)
Complex([egfr, grb2, sos1]), ActiveForm(sos1_bound, 'gef', True), Autophosphorylation(p38_tab1, 'Y', '100'), Transphosphorylation(egfr_dimer, 'Y', '1173'), ] ev = Evidence('assertion', 'assertion', 'assertion', 'assertion') for stmt in stmts: stmt.evidence = [ev] model_description = 'Test of INDRA Statement assembly into PyBEL.' print("Assembling to PyBEL...") pba = PybelAssembler( stmts, name='INDRA_PyBEL_test', description=model_description, authors='John Bachman', ) belgraph = pba.make_model() # Write to BEL file #pybel.to_bel_path(belgraph, 'simple_pybel.bel') # Upload to PyBEL web #with open('pybel_model.json', 'wt') as f: # pybel.to_json_file(pba.model, f) #url = 'https://pybel.scai.fraunhofer.de/api/receive' #headers = {'content-type': 'application/json'} #requests.post(url, json=pybel.to_json(pba.model), headers=headers) # Put in local database
prize_outpath = "../work/pybel_prize.tsv" interactome_path = "../work/big_pybel_interactome2.tsv" site_file = "../work/gsea_sites.rnk" # Load the statements linking kinases/regulators to phospho sites # in the data stmts = ac.load_statements(stmts) # Employ filters to reduce network size stmts = ac.filter_grounded_only(stmts) stmts = ac.filter_human_only(stmts) stmts = ac.filter_genes_only(stmts) # In this data, statements of these two types will not act on # a short enough timescale to play a meaningful role stmts = ac.filter_by_type(stmts, DecreaseAmount, invert=True) stmts = ac.filter_by_type(stmts, IncreaseAmount, invert=True) stmts = ac.filter_by_type(stmts, Complex, invert=True) stmts = ac.filter_enzyme_kinase(stmts) # Assemble a pybel graph from statements pba = PybelAssembler(stmts) pb_graph = make_model(pba) signed_graph = to_signed_nodes(pb_graph) gn_dict = get_gene_node_dict(signed_graph) # Next we have to load the data file and assign values to site_data = read_site_file(site_file) dump_steiner_files(signed_graph, site_data, prize_outpath, interactome_path)
def stmts_to_pybel_graph(stmts): pba = PybelAssembler(stmts, name='INDRA/REACH Fallahi Eval Model', description='Automatically assembled model.', version='0.0.1') pba.make_model() return pba.to_signed_graph()
parser.add_argument("--grounded", action="store_true") parser.add_argument("--human", action="store_true") parser.add_argument("--gene", action="store_true") parser.add_argument("--stmts") parser.add_argument("--prize_outpath") parser.add_argument("--interactome_outpath") parser.add_argument("--site_file") args = parser.parse_args() stmts = args.stmts # Load the statements linking kinases/regulators to phospho sites in the data stmts = ac.load_statements(stmts) if args.grounded: stmts = ac.filter_grounded_only(stmts) if args.human: stmts = ac.filter_human_only(stmts) if args.gene: stmts = ac.filter_genes_only(stmts) # Assemble a PyBEL graph from the stmts pba = PybelAssembler(stmts) pb_graph = pba.make_model() signed_graph = to_signed_nodes(pb_graph) gn_dict = get_gene_node_dict(signed_graph) # Next we have to load the data file and assign values to site_data = read_site_file(args.site_file) dump_steiner_files(signed_graph, site_data, args.prize_outpath, args.interactome_outpath)