Exemplo n.º 1
0
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
Exemplo n.º 2
0
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)
    # if a:
    #     print(id1, id2)
    #     print(e1, e2)
    #     print()
    #     print(a)
    #     b = [ssm.get_name(x) for x in a]
    #     print(b)
    #     print('\n\n\n')
    a = [ssm.get_name(x) for x in a]

    return a