Exemplo n.º 1
0
def upload_cbn_dir(dir_path, manager):
    """Uploads CBN data to edge store

    :param str dir_path: Directory full of CBN JGIF files
    :param pybel.Manager manager:
    """
    t = time.time()

    for jfg_path in os.listdir(dir_path):
        if not jfg_path.endswith('.jgf'):
            continue

        path = os.path.join(dir_path, jfg_path)

        log.info('opening %s', path)

        with open(path) as f:
            cbn_jgif_dict = json.load(f)

        graph = pybel.from_cbn_jgif(cbn_jgif_dict)

        out_path = os.path.join(dir_path, jfg_path.replace('.jgf', '.bel'))
        with open(out_path, 'w') as o:
            pybel.to_bel(graph, o)

        strip_annotations(graph)
        enrich_pubmed_citations(manager=manager, graph=graph)
        pybel.to_database(graph, manager=manager)

        log.info('')

    log.info('done in %.2f', time.time() - t)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
def main(file):
    """Provide BEL Statements from BEL graph."""
    df = get_equivalences_df()
    graph = build_equivalences_graph(df)
    pybel.to_bel(graph, file)
Exemplo n.º 5
0
def main():
    """Provide BEL Statements from BEL graph."""
    df = get_relations_df()
    graph = build_relations_graph(df)
    with open("famplex.bel", "w") as file:
        to_bel(graph, file)
Exemplo n.º 6
0
 def to_bel_file(self, file):
     graph = self.to_bel_graph()
     pybel.to_bel(graph, file=file)