Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ensembl info for MGI genes #1429

Merged
merged 3 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading