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))
maker = EntityMaker(mediawiki_api_url, sparql_endpoint_url, username, password) item_engine = wdi_core.WDItemEngine.wikibase_item_engine_factory( mediawiki_api_url, sparql_endpoint_url) login = wdi_login.WDLogin("testbot", "password", mediawiki_api_url=mediawiki_api_url) else: sparql_endpoint_url = 'https://query.wikidata.org/sparql' item_engine = wdi_core.WDItemEngine login = wd_login cu = wikicurie.CurieUtil() h = wdi_helpers.WikibaseHelper(sparql_endpoint_url=sparql_endpoint_url) for k, v in PROPS.items(): try: PROPS[k] = h.get_pid(v) except Exception: PROPS[k] = None OMIM_QID = h.get_qid("Q241953") EXT_ID_MAP = dict() def retrieve_qid_from_curie(curie): pid, ext_id_value = cu.parse_curie(curie) pid = h.get_pid(pid) if pid not in EXT_ID_MAP: EXT_ID_MAP[pid] = wdi_helpers.id_mapper(pid,
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',