Skip to content

Commit

Permalink
Merge pull request #1429 from bgyori/mgi_ensembl
Browse files Browse the repository at this point in the history
Add Ensembl info for MGI genes
  • Loading branch information
bgyori authored Dec 17, 2023
2 parents a3e6984 + a873759 commit c6e0feb
Show file tree
Hide file tree
Showing 4 changed files with 88,766 additions and 85,559 deletions.
28 changes: 25 additions & 3 deletions indra/databases/mgi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,32 @@ def get_id_from_name_synonym(name_synonym: str) -> Union[None, str, List[str]]:
return None


def get_ensembl_id(mgi_id: str) -> Union[str, None]:
"""Return the Ensembl ID for an MGI ID.
Parameters
----------
mgi_id :
An MGI ID, without prefix.
Returns
-------
:
The Ensembl ID corresponding to the MGI ID, or None if not available.
"""
if mgi_id and mgi_id.startswith('MGI:'):
mgi_id = mgi_id[4:]
return mgi_id_to_ensembl.get(mgi_id)


def _read_mgi():
fname = get_resource_path('mgi_entries.tsv')
mgi_id_to_name = {}
mgi_name_to_id = {}
mgi_synonyms = {}
mgi_synonyms_reverse = defaultdict(list)
for mgi_id, name, synonyms_str in read_unicode_csv(fname, '\t'):
mgi_id_to_ensembl = {}
for mgi_id, name, synonyms_str, ensembl_id in read_unicode_csv(fname, '\t'):
if name:
mgi_id_to_name[mgi_id] = name
mgi_name_to_id[name] = mgi_id
Expand All @@ -108,9 +127,12 @@ def _read_mgi():
mgi_synonyms[mgi_id] = synonyms
for synonym in synonyms:
mgi_synonyms_reverse[synonym].append(mgi_id)
if ensembl_id:
mgi_id_to_ensembl[mgi_id] = ensembl_id

return mgi_id_to_name, mgi_name_to_id, mgi_synonyms, \
dict(mgi_synonyms_reverse)
dict(mgi_synonyms_reverse), mgi_id_to_ensembl


mgi_id_to_name, mgi_name_to_id, mgi_synonyms, mgi_synonyms_reverse = _read_mgi()
mgi_id_to_name, mgi_name_to_id, mgi_synonyms, mgi_synonyms_reverse, \
mgi_id_to_ensembl = _read_mgi()
Loading

0 comments on commit c6e0feb

Please sign in to comment.