Skip to content

Commit

Permalink
update constant docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahbeenie committed Mar 12, 2020
1 parent 24f29e4 commit 585fc00
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 15 deletions.
52 changes: 43 additions & 9 deletions src/pathme/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-

"""This module contains all the constants used in PathMe repo."""
"""Constants for PathMe.
This module contains all the string constants used in PathMe.
"""

import os

Expand All @@ -21,17 +24,21 @@ def get_data_dir() -> str:
DATA_DIR = get_data_dir()
DEFAULT_CACHE_CONNECTION = get_connection(MODULE_NAME)

# Databases contained in PathMe
#: KEGG
KEGG = 'kegg'
KEGG_DIR = os.path.join(DATA_DIR, KEGG)
KEGG_BEL = os.path.join(KEGG_DIR, 'bel')
KEGG_FILES = os.path.join(KEGG_DIR, 'xml')
KEGG_CACHE = os.path.join(KEGG_DIR, 'cache')

#: Reactome
REACTOME = 'reactome'
REACTOME_DIR = os.path.join(DATA_DIR, REACTOME)
REACTOME_BEL = os.path.join(REACTOME_DIR, 'bel')
REACTOME_FILES = os.path.join(REACTOME_DIR, 'rdf', 'biopax')

#: WikiPathways
WIKIPATHWAYS = 'wikipathways'
WIKIPATHWAYS_DIR = os.path.join(DATA_DIR, WIKIPATHWAYS)
WIKIPATHWAYS_BEL = os.path.join(WIKIPATHWAYS_DIR, 'bel')
Expand Down Expand Up @@ -68,26 +75,49 @@ def ensure_pathme_folders():
UNKNOWN = 'unknown'

# Other namespaces

#: InterPro
INTERPRO = 'interpro'
#: Pfam
PFAM = 'pfam'
#: BRENDA
BRENDA = 'brenda'
#: ChEMBL
CHEMBL = 'chembl'
#: miRBase
MIRBASE = 'mirbase'

KEGG_ID = 'kegg_id'
KEGG_NAME = 'kegg_name'
KEGG_TYPE = 'kegg_type'
#: HGNC
HGNC = 'HGNC'
#: HGNC Symbol
HGNC_SYMBOL = 'HGNC symbol'
#: ENSEMBL
ENSEMBL = 'ENSEMBL'
#: EXPASY
EXPASY = 'EXPASY'
#: ENTREZ
ENTREZ = 'ENTREZ'
#: UniProt
UNIPROT = 'UniProt'
#: ChEBI
CHEBI = 'ChEBI'
#: ChEBI chemical name
CHEBI_NAME = 'ChEBI name'
#: PubChem
PUBCHEM = 'PubChem'
#: Wikipedia
WIKIPEDIA = 'WIKIPEDIA'

#: KEGG entity identifier
KEGG_ID = 'kegg_id'

#: KEGG entity name
KEGG_NAME = 'kegg_name'

#: KEGG entity type
KEGG_TYPE = 'kegg_type'

#: Protein modification types present in KEGG
KEGG_MODIFICATIONS = {
'phosphorylation': 'Ph',
'glycosylation': 'Glyco',
Expand All @@ -102,18 +132,21 @@ def ensure_pathme_folders():
rna
)

#: KEGG reference Kanehisa, M., & Goto, S. (2000). KEGG: kyoto encyclopedia of genes and genomes. Nucleic acids research, 28(1), 27-30.
KEGG_CITATION = '10592173'
#: Reactome reference Fabregat, A., et al. (2018). The reactome pathway knowledgebase. Nucleic acids research, 46(D1), D649-D655.
REACTOME_CITATION = '29145629'

# FIXME why doesn't this just import the compath_resources package?
KEGG_WIKIPATHWAYS_MAPPINGS = 'https://github.com/ComPath/curation/raw/master/mappings/kegg_wikipathways.xlsx'
KEGG_REACTOME_MAPPINGS = 'https://github.com/ComPath/curation/raw/master/mappings/kegg_reactome.xlsx'
WIKIPATHWAYS_REACTOME_MAPPINGS = 'https://github.com/ComPath/curation/raw/master/mappings/wikipathways_reactome.xlsx'

#: REST API to KEGG
KEGG_KGML_URL = 'http://rest.kegg.jp/get/{}/kgml'

#: Reactome RDF
RDF_REACTOME = 'ftp://ftp.ebi.ac.uk/pub/databases/RDF/reactome/r71/reactome-biopax.tar.bz2'

#: WikiPathways RDF
RDF_WIKIPATHWAYS = 'http://data.wikipathways.org/20190910/rdf/wikipathways-20190910-rdf-wp.zip'

#: Mapping to compare conversion of entities from KEGG XML (i.e. KGML) to BEL
KEGG_STATS_COLUMN_NAMES = {
'nodes': 'BEL Nodes',
'entities': 'XML Entities',
Expand Down Expand Up @@ -159,6 +192,7 @@ def ensure_pathme_folders():
'brite': 'XML Brite Hierarchy',
}

#: Mapping of BEL terms to their definitions
BEL_STATS_COLUMN_NAMES = {
'nodes': 'BEL Nodes',
'edges': 'BEL Edges',
Expand Down
12 changes: 6 additions & 6 deletions src/pathme/kegg/kegg_xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from bio2bel_kegg.constants import API_KEGG_GET
from bio2bel_kegg.parsers.description import parse_description

from pathme.constants import CHEBI, CHEBI_NAME, HGNC, HGNC_SYMBOL, KEGG_CACHE, PUBCHEM, UNIPROT
from pathme.constants import CHEBI, CHEBI_NAME, HGNC, HGNC_SYMBOL, KEGG_CACHE, PUBCHEM, UNIPROT, KEGG_ID, KEGG_TYPE
from pathme.wikipathways.utils import merge_two_dicts

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -124,8 +124,8 @@ def _process_kegg_api_get_entity(entity, type, hgnc_manager, chebi_manager):

node_dict = _post_process_api_query(node_meta_data, hgnc_manager, chebi_manager)

node_dict['kegg_id'] = entity
node_dict['kegg_type'] = type
node_dict[KEGG_ID] = entity
node_dict[KEGG_TYPE] = type

with open(_entity_filepath, 'w') as f:
json.dump(node_dict, f)
Expand Down Expand Up @@ -172,7 +172,7 @@ def get_entity_nodes(tree, hgnc_manager, chebi_manager):

elif kegg_type.startswith('map'):

map_info = {'kegg_id': kegg_ids}
map_info = {KEGG_ID: kegg_ids}

for graphics in entry.iter('graphics'):
map_name = graphics.get('name')
Expand All @@ -184,8 +184,8 @@ def get_entity_nodes(tree, hgnc_manager, chebi_manager):

for ortholog_id in kegg_ids.split(' '):
ortholog_info = {
'kegg_id': ortholog_id,
'kegg_type': kegg_type
KEGG_ID: ortholog_id,
KEGG_TYPE: kegg_type
}

ortholog_dict[entry_id].append(ortholog_info)
Expand Down

0 comments on commit 585fc00

Please sign in to comment.