def get_common_ancestors(id1, id2): e1 = ssm.get_id(id1.replace(":", "_")) e2 = ssm.get_id(id2.replace(":", "_")) #print(id1, id2, e1, e2) a = ssm.common_ancestors(e1, e2) a = [ssm.get_name(x) for x in a] return a
def get_common_ancestors(id1, id2): """ :param id1: :param id2: :return: """ if id1.startswith('CHEBI'): ssm.semantic_base('bin/DiShIn/chebi.db') if id1.startswith('HP'): ssm.semantic_base('bin/DiShIn/hp.db') if id1.startswith('GO'): ssm.semantic_base('bin/DiShIn/go.db') if id1.startswith('DOID'): ssm.semantic_base('bin/DiShIn/doid.db') e1 = ssm.get_id(id1.replace(':', '_')) if id2.startswith('CHEBI'): ssm.semantic_base('bin/DiShIn/chebi.db') if id2.startswith('HP'): ssm.semantic_base('bin/DiShIn/hp.db') if id2.startswith('GO'): ssm.semantic_base('bin/DiShIn/go.db') if id2.startswith('DOID'): ssm.semantic_base('bin/DiShIn/doid.db') e2 = ssm.get_id(id2.replace(':', '_')) a = ssm.common_ancestors(e1, e2) a = [ssm.get_name(x) for x in a] return a
def get_path_to_root(id1): global chebi_cache if id1 in chebi_cache: #logging.info("using chebi cache") return chebi_cache[id1] else: e1 = ssm.get_id(id1.replace(":", "_")) a = ssm.common_ancestors(e1, e1) a = [ssm.get_name(x) for x in a] chebi_cache[id1] = a return a
def get_common_ancestors(id1, id2): global chebi_cache if (id1, id2) in chebi_cache: #logging.info("using chebi cache") return chebi_cache[(id1, id2)] else: e1 = ssm.get_id(id1.replace(":", "_")) e2 = ssm.get_id(id2.replace(":", "_")) #print(id1, id2, e1, e2) a = ssm.common_ancestors(e1, e2) a = [ssm.get_name(x) for x in a] chebi_cache[(id1, id2)] = a return a
def get_path_to_root(entity_id): """ :param entity_id: :return: """ if entity_id.startswith('CHEBI'): ssm.semantic_base('bin/DiShIn/chebi.db') if entity_id.startswith('HP'): ssm.semantic_base('bin/DiShIn/hp.db') if entity_id.startswith('GO'): ssm.semantic_base('bin/DiShIn/go.db') if entity_id.startswith('DOID'): ssm.semantic_base('bin/DiShIn/doid.db') e1 = ssm.get_id(entity_id.replace(':', '_')) a = ssm.common_ancestors(e1, e1) a = [ssm.get_name(x) for x in a] return a
def get_path_to_root(id1): e1 = ssm.get_id(id1.replace(":", "_")) a = ssm.common_ancestors(e1, e1) a = [ssm.get_name(x) for x in a] return a
import os import xml.etree.ElementTree as ET from chebi_ssm import get_best_chebi_id import sys sys.path.append("./") from DiShIn import ssm ssm.semantic_base("DiShIn/chebi.db") chebi_ids = list(ssm.connection.execute("SELECT id FROM entry")) with open("chebi_pop", 'w') as f: for cid in chebi_ids: name = ssm.get_name(cid[0]).replace("_", ':') if name.startswith("CHEBI"): ic = ssm.information_content_extrinsic(cid[0]) #ic = ssm.information_content_intrinsic(cid[0]) if ic != 0: ic = 1 / ic f.write("url:{}\t{}\n".format(name.replace("CHEBI", "http"), ic))