def test_thorough_json_file(self): """Test the round-trip through a node-link JSON file.""" sio = StringIO() to_json_file(sialic_acid_graph, sio) sio.seek(0) graph = from_json_file(sio) self.help_test_equal(graph)
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 save_model(self, path, output_format=None): """Save the :class:`pybel.BELGraph` using one of the outputs from :py:mod:`pybel` Parameters ---------- path : str The path to output to output_format : Optional[str] Output format as ``cx``, ``pickle``, ``json`` or defaults to ``bel`` """ if output_format == 'pickle': pybel.to_pickle(self.model, path) else: with open(path, 'w') as fh: if output_format == 'json': pybel.to_json_file(self.model, fh) elif output_format == 'cx': pybel.to_cx_file(self.model, fh) else: # output_format == 'bel': pybel.to_bel(self.model, fh)
def test_thorough_json_file(self): sio = StringIO() to_json_file(self.thorough_graph, sio) sio.seek(0) graph = from_json_file(sio) self.bel_thorough_reconstituted(graph)
def test_thorough_json_file(self): sio = StringIO() to_json_file(sialic_acid_graph, sio) sio.seek(0) graph = from_json_file(sio) self.help_test_equal(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)