Skip to content

Commit

Permalink
Adding 'interpro' nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarinllao committed Oct 5, 2018
1 parent 531269d commit 1eaa63d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/pathme/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def ensure_pathme_folders():
DEFAULT_CACHE_CONNECTION = get_connection(MODULE_NAME)

KEGG = 'kegg'
INTERPRO = 'interpro'
REACTOME = 'reactome'
WIKIPATHWAYS = 'wikipathways'

Expand Down
6 changes: 3 additions & 3 deletions src/pathme/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def check_multiple(element, element_name):
:param element_name: name to print
:return:
"""
if isinstance(element, Iterable):
if isinstance(element, set) or isinstance(element, list):
log.warning('Multiple {}: {}'.format(element_name, element))
# TODO: print the wikipathways bps that return a set because they are probably wrong.
if len(element) != 0:
return list(element)[0]

log.warning('Empty list/set %s', element)
else:
log.warning('Empty list/set %s', element)

return element

Expand Down
26 changes: 17 additions & 9 deletions src/pathme/wikipathways/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import networkx as nx
from bio2bel_wikipathways import Manager as WikiPathwaysManager

from ..constants import DATA_DIR, ENSEMBL, ENTREZ, EXPASY, HGNC, KEGG, UNIPROT, WIKIPATHWAYS, WIKIPEDIA
from ..constants import DATA_DIR, ENSEMBL, ENTREZ, EXPASY, HGNC, KEGG, UNIPROT, WIKIPATHWAYS, WIKIPEDIA, INTERPRO
from ..utils import get_files_in_folder, check_multiple

WIKIPATHWAYS_DIR = os.path.join(DATA_DIR, WIKIPATHWAYS)
Expand Down Expand Up @@ -86,28 +86,28 @@ def get_valid_gene_identifier(node_ids_dict, hgnc_manager):
# Try to get hgnc symbol
if 'bdb_hgncsymbol' in node_ids_dict:

hgnc_symbol = node_ids_dict['bdb_hgncsymbol']
hgnc_symbol = check_multiple(node_ids_dict['bdb_hgncsymbol'], 'bdb_hgncsymbol')
hgnc_entry = hgnc_manager.get_gene_by_hgnc_symbol(hgnc_symbol)

return _validate_query(hgnc_manager, hgnc_entry, hgnc_symbol, HGNC)

# Try to get ENTREZ id
elif 'bdb_ncbigene' in node_ids_dict:
entrez_id = node_ids_dict['bdb_ncbigene']
entrez_id = check_multiple(node_ids_dict['bdb_ncbigene'], 'bdb_ncbigene')
hgnc_entry = hgnc_manager.get_gene_by_entrez_id(entrez_id)

return _validate_query(hgnc_manager, hgnc_entry, entrez_id, ENTREZ)

# Try to get UniProt id
elif 'bdb_uniprot' in node_ids_dict:
uniprot_id = node_ids_dict['bdb_uniprot']
uniprot_id = check_multiple(node_ids_dict['bdb_uniprot'], 'bdb_uniprot')
hgnc_entry = hgnc_manager.get_gene_by_uniprot_id(uniprot_id)

return _validate_query(hgnc_manager, hgnc_entry, uniprot_id, UNIPROT)

# Try to get ENSEMBL id
elif 'bdb_ensembl' in node_ids_dict:
ensembl_id = node_ids_dict['bdb_ensembl']
ensembl_id = check_multiple(node_ids_dict['bdb_ensembl'], 'bdb_ensembl')
hgnc_entry = hgnc_manager.get_gene_by_uniprot_id(ensembl_id)

return _validate_query(hgnc_manager, hgnc_entry, ensembl_id, ENSEMBL)
Expand Down Expand Up @@ -138,12 +138,20 @@ def get_valid_gene_identifier(node_ids_dict, hgnc_manager):

return WIKIPEDIA, wiki_name, wiki_id

elif KEGG.lower() in node_ids_dict['identifier']:
#TODO: why wikipedia_id? i thought it was a kegg id here
kegg_id = check_multiple(node_ids_dict['identifier'], 'wikipedia_id')
elif KEGG.lower() in node_ids_dict['uri_id']:
kegg_id = check_multiple(node_ids_dict['identifier'], 'kegg_id')
kegg_name = check_multiple(node_ids_dict['name'], 'kegg_name')

log.warning('Adding KEGG node %s ', kegg_id)

return KEGG, kegg_id, kegg_id
return KEGG, kegg_name, kegg_id

elif INTERPRO.lower() in node_ids_dict['uri_id']:
interpro_id = check_multiple(node_ids_dict['identifier'], 'interpro_id')
interpro_name = check_multiple(node_ids_dict['name'], 'interpro_name')
log.warning('Adding INTERPRO node %s ', interpro_id)

return INTERPRO, interpro_name, interpro_id

raise Exception('Unknown identifier for node %s', node_ids_dict)

Expand Down

0 comments on commit 1eaa63d

Please sign in to comment.