Ejemplo n.º 1
0
def main(force: bool, user: str, password: str):
    """Download and dump the INDRA 'rona graph."""
    if not os.path.exists(GROUNDED_PATH) and not force:
        if not os.path.exists(RAW_PATH) and not force:
            click.echo('Getting EMMAA graph')
            graph = pybel.from_emmaa('covid19')
            pybel.dump(graph, RAW_PATH)
        else:
            click.echo('Loading EMMAA graph from path')
            graph = pybel.load(RAW_PATH)

        graph = pybel.grounding.ground(graph)
        graph.summarize()

        pybel.dump(graph, GROUNDED_PATH)
    else:
        graph = pybel.load(GROUNDED_PATH)

    res = pybel.to_bel_commons(
        graph=graph,
        host='https://bel.labs.coronawhy.org',
        user=user,
        password=password,
    )
    click.secho(json.dumps(res.json(), indent=2))
Ejemplo n.º 2
0
def main():
    """Convert the Selventa graph to Hipathia."""
    if not os.path.exists(PATH):
        urlretrieve(URL, PATH)
    if not os.path.exists(GROUNDED_PATH):
        graph = pybel.load(PATH)
        graph = pybel.grounding.ground(graph)
        pybel.dump(graph, GROUNDED_PATH)
    else:
        graph = pybel.load(GROUNDED_PATH)
    pybel.to_hipathia(graph, HERE)
Ejemplo n.º 3
0
 def test_io(self):
     with tempfile.TemporaryDirectory() as directory:
         path = os.path.join(directory, 'ampk.bel.nodelink.json')
         pybel.dump(pybel.examples.ampk_graph, path)
         self.assertTrue(os.path.exists(path))
         new_graph = pybel.load(path)
         self.assertIsNotNone(new_graph)
Ejemplo n.º 4
0
def main():
    """Convert the AD graph to Hipathia."""
    graph = pybel.load(PATH)
    graph = pybel.grounding.ground(graph)

    graphs = get_subgraphs_by_annotation(graph, annotation='Subgraph')
    for name, graph in graphs.items():
        graph.name = name
        pybel.to_hipathia(graph, OUTPUT)
Ejemplo n.º 5
0
def get_graph(graph_name: str, force: bool = False) -> pybel.BELGraph:
    """Get the Selventa large corpus as a BEL Graph."""
    url = f'https://github.com/cthoyt/selventa-knowledge/raw/master/selventa_knowledge/{graph_name}.bel'
    cache_path = module.join(name=f'{graph_name}.bel.pickle')
    if cache_path.exists() and not force:
        return pybel.load(cache_path)
    path = module.ensure(url=url, force=force)
    graph = pybel.from_bel_script(path, citation_clearing=False)
    pybel.dump(graph, path.as_posix())
    return graph
Ejemplo n.º 6
0
 def test_identifiable(self):
     """Test a BEL example for identifiability."""
     bel_graph = pybel.load(BEL_EXAMPLE)
     nxmg = bel_to_nxmg(bel_graph)
     self.assertTrue(
         is_identifiable(
             nxmg,
             P(
                 Variable('Severe Acute Respiratory Syndrome')
                 @ Variable('angiotensin II')),
         ))