Пример #1
0
def main(json_path='doid.json', log_dir="./logs", fast_run=True, write=True):
    login = wdi_login.WDLogin(user=WDUSER, pwd=WDPASS)
    wdi_core.WDItemEngine.setup_logging(log_dir=log_dir, logger_name='WD_logger', log_name=log_name,
                                        header=json.dumps(__metadata__))

    with open(json_path) as f:
        d = json.load(f)
    graphs = {g['id']: g for g in d['graphs']}
    graph = graphs['http://purl.obolibrary.org/obo/doid.owl']
    # get the has phenotype, has_material_basis_in, and transmitted by edges from another graph
    graph['edges'].extend(graphs['http://purl.obolibrary.org/obo/doid/obo/ext.owl']['edges'])
    do = DOGraph(graph, login, fast_run)
    nodes = sorted(do.nodes.values(), key=lambda x: x.doid)
    items = []
    for n, node in tqdm(enumerate(nodes), total=len(nodes)):
        item = node.create(write=write)
        # if n>100:
        #    sys.exit(0)
        if item:
            items.append(item)

    sleep(10 * 60)
    doid_wdid = id_mapper('P699')
    frc = items[0].fast_run_container
    if not frc:
        print("fastrun container not found. not removing deprecated statements")
        return None
    frc.clear()
    for doid in tqdm(doid_wdid.values()):
        remove_deprecated_statements(doid, frc, do.release, list(PROPS.values()), login)

    print("You have to remove these deprecated diseases manually: ")
    print(get_deprecated_nodes(graph))
        WDUSER = os.environ['WDUSER']
        WDPASS = os.environ['WDPASS']
    else:
        raise ValueError(
            "WDUSER and WDPASS must be specified in local.py or as environment variables"
        )

wdi_property_store.wd_properties[PROPS['OMIM ID']]['core_id'] = False
#wdi_property_store.wd_properties[PROPS['MeSH ID']]['core_id'] = False
wdi_property_store.wd_properties[PROPS['Orphanet ID']]['core_id'] = False
wdi_property_store.wd_properties[PROPS['NCI Thesaurus ID']]['core_id'] = False

__metadata__ = {
    'name': 'DOIDBot',
    'tags': ['disease', 'doid'],
    'properties': list(PROPS.values())
}


class DOGraph:
    edge_prop = {
        # 'http://purl.obolibrary.org/obo/IDO_0000664': 'P828',  # has_material_basis_in -> has cause
        'http://purl.obolibrary.org/obo/RO_0001025': 'P276',  # located in
        # 'http://purl.obolibrary.org/obo/RO_0002451': None,  # transmitted by. "pathogen transmission process" (P1060)?
        'is_a': 'P279'
    }

    xref_prop = {
        'ORDO': 'P1550',
        'UMLS_CUI': 'P2892',
        'DOID': 'P699',