src/pybel/io/graphdati.py
def from_graphdati(j, use_tqdm: bool = True) -> BELGraph:
    """Convert data from the "normal" network format.

    .. warning:: BioDati crashes when requesting the ``full`` network format, so this isn't yet explicitly supported
    """
    root = j['graph']
    graph = BELGraph(
        name=root.get('label'),
        version=root['metadata'].get('gd_rev'),
        authors=root['metadata'].get('gd_creator'),
        description=root.get('gd_description'),
    )
    # Just in case you want to find it again
    graph.graph['biodati_network_id'] = root['metadata']['id']

    parser = BELParser(
        graph=graph,
        namespace_to_pattern=NAMESPACE_TO_PATTERN,  # To be updated manually depending on what William is up to
    )

    it = root['edges']
    if use_tqdm:
        it = tqdm(it, desc='iterating edges')

    for i, edge in enumerate(it):
        relation = edge.get('relation')
        if relation is None:
            logger.warning('no relation for edge: %s', edge)

        if relation in {'actsIn', 'translocates'}:
            continue  # don't need legacy BEL format

        bel_statement = edge.get('label')  # this is actually the BEL statement
        if bel_statement is None:
            logger.debug('No BEL statement for edge %s', edge)
            continue

        # Fill up that sweet, sweet metadata
        metadata_entries = edge['metadata']['nanopub_data']
        for metadata in metadata_entries:
            parser.control_parser.clear()

            citation = metadata['citation_id']  # as CURIE
            citation_db, citation_id = _parse_biodati_citation(citation)
            if citation_db is None:
                continue
            parser.control_parser.citation_db = citation_db
            parser.control_parser.citation_db_id = citation_id

            # FIXME where is the evidence/support/summary text?
            parser.control_parser.evidence = 'No evidence available from BioDai'

            nanopub_id = metadata['nanopub_id']
            parser.control_parser.annotations['biodati_nanopub_id'] = [nanopub_id]

            annotations = metadata['annotations']
            parser.control_parser.annotations.update(_parse_biodati_annotations(annotations))

            # Finally, parse the BEL statement (once to go with each set of metadata)
            # TODO change parser to give back pre-compiled info so this doesn't need to be repeated
            try:
                parser.parseString(bel_statement, line_number=i)
            except pyparsing.ParseException as e:
                logger.warning('parse error for %s: %s', bel_statement, e)

    return graph
Convert data from the "normal" network format.

    .. warning:: BioDati crashes when requesting the ``full`` network format, so this isn't yet explicitly supported
    
Convert data from the "normal" network format.
warning:: BioDati crashes when requesting the ``full`` network format, so this isn't yet explicitly supported
Convert data from the " normal " network format . warning :: BioDati crashes when requesting the ` ` full ` ` network format so this isn ' t yet explicitly supported
def from_graphdati(j, use_tqdm: bool = True) -> BELGraph:
    root = j['graph']
    graph = BELGraph(
        name=root.get('label'),
        version=root['metadata'].get('gd_rev'),
        authors=root['metadata'].get('gd_creator'),
        description=root.get('gd_description'),
    )
    graph.graph['biodati_network_id'] = root['metadata']['id']
    parser = BELParser(
        graph=graph,
        namespace_to_pattern=NAMESPACE_TO_PATTERN,  
    )
    it = root['edges']
    if use_tqdm:
        it = tqdm(it, desc='iterating edges')
    for i, edge in enumerate(it):
        relation = edge.get('relation')
        if relation is None:
            logger.warning('no relation for edge: %s', edge)
        if relation in {'actsIn', 'translocates'}:
            continue  
        bel_statement = edge.get('label')  
        if bel_statement is None:
            logger.debug('No BEL statement for edge %s', edge)
            continue
        metadata_entries = edge['metadata']['nanopub_data']
        for metadata in metadata_entries:
            parser.control_parser.clear()
            citation = metadata['citation_id']  
            citation_db, citation_id = _parse_biodati_citation(citation)
            if citation_db is None:
                continue
            parser.control_parser.citation_db = citation_db
            parser.control_parser.citation_db_id = citation_id
            parser.control_parser.evidence = 'No evidence available from BioDai'
            nanopub_id = metadata['nanopub_id']
            parser.control_parser.annotations['biodati_nanopub_id'] = [nanopub_id]
            annotations = metadata['annotations']
            parser.control_parser.annotations.update(_parse_biodati_annotations(annotations))
            try:
                parser.parseString(bel_statement, line_number=i)
            except pyparsing.ParseException as e:
                logger.warning('parse error for %s: %s', bel_statement, e)
    return graph
def from_graphdati ( j , use_tqdm : bool = True ) -> BELGraph : root = j [ 'graph' ] graph = BELGraph ( name = root . get ( 'label' ) , version = root [ 'metadata' ] . get ( 'gd_rev' ) , authors = root [ 'metadata' ] . get ( 'gd_creator' ) , description = root . get ( 'gd_description' ) , ) graph . graph [ 'biodati_network_id' ] = root [ 'metadata' ] [ 'id' ] parser = BELParser ( graph = graph , namespace_to_pattern = NAMESPACE_TO_PATTERN , ) it = root [ 'edges' ] if use_tqdm : it = tqdm ( it , desc = 'iterating edges' ) for i , edge in enumerate ( it ) : relation = edge . get ( 'relation' ) if relation is None : logger . warning ( 'no relation for edge: %s' , edge ) if relation in { 'actsIn' , 'translocates' } : continue bel_statement = edge . get ( 'label' ) if bel_statement is None : logger . debug ( 'No BEL statement for edge %s' , edge ) continue metadata_entries = edge [ 'metadata' ] [ 'nanopub_data' ] for metadata in metadata_entries : parser . control_parser . clear ( ) citation = metadata [ 'citation_id' ] citation_db , citation_id = _parse_biodati_citation ( citation ) if citation_db is None : continue parser . control_parser . citation_db = citation_db parser . control_parser . citation_db_id = citation_id parser . control_parser . evidence = 'No evidence available from BioDai' nanopub_id = metadata [ 'nanopub_id' ] parser . control_parser . annotations [ 'biodati_nanopub_id' ] = [ nanopub_id ] annotations = metadata [ 'annotations' ] parser . control_parser . annotations . update ( _parse_biodati_annotations ( annotations ) ) try : parser . parseString ( bel_statement , line_number = i ) except pyparsing . ParseException as e : logger . warning ( 'parse error for %s: %s' , bel_statement , e ) return graph
Convert data from the "normal" network format.
Convert data from the " normal " network format .
"""Convert data from the "normal" network format.

    .. warning:: BioDati crashes when requesting the ``full`` network format, so this isn't yet explicitly supported
    """ # Just in case you want to find it again # To be updated manually depending on what William is up to # don't need legacy BEL format # this is actually the BEL statement # Fill up that sweet, sweet metadata # as CURIE # FIXME where is the evidence/support/summary text? # Finally, parse the BEL statement (once to go with each set of metadata) # TODO change parser to give back pre-compiled info so this doesn't need to be repeated
j
use_tqdm
bool