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 miRBase client #912

Merged
merged 6 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion indra/databases/mirbase_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def _read():
next(file)
for line in file:
try:
mirbase_id, mirbase_name, db, identifier, name = line.strip().split('\t')
mirbase_id, mirbase_name, db, identifier, name = \
line.strip().split('\t')
except ValueError: # fails on WORMBASE since no names
continue

Expand Down
13 changes: 9 additions & 4 deletions indra/resources/update_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,10 @@ def update_mirbase():
urlretrieve(url, mirbase_gz_path)

mirbase_json_path = os.path.join(path, 'mirbase.tsv')
with gzip.open(mirbase_gz_path, 'rt') as in_file, open(mirbase_json_path, 'w') as out_file:
print('mirbase_id', 'mirbase_name', 'database', 'identifier', 'label', sep='\t', file=out_file)
with gzip.open(mirbase_gz_path, 'rt') as in_file, \
open(mirbase_json_path, 'w') as out_file:
print('mirbase_id', 'mirbase_name', 'database', 'identifier', 'label',
sep='\t', file=out_file)
for line in _process_mirbase_file(in_file):
print(*line, sep='\t', file=out_file)

Expand All @@ -662,11 +664,13 @@ def _process_mirbase_file(lines):
for element in group:
if not element.startswith('DR'):
continue
db, identifier, name = [e.strip() for e in element[len('DR'):].lstrip().split(';')]
db, identifier, name = [e.strip() for e in \
element[len('DR'):].lstrip().split(';')]
yield mirbase_id, mirbase_name, db, identifier, name.rstrip('.')


if __name__ == '__main__':
"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, what's going on here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, commented stuff out for testing and then forgot to uncomment 🤦‍♂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

update_go_id_mappings()
update_cellular_component_hierarchy()
update_famplex()
Expand All @@ -686,5 +690,6 @@ def _process_mirbase_file(lines):
update_ncit_map()
update_lincs_small_molecules()
update_lincs_proteins()
update_mesh_names()
update_mesh_names()a
"""
update_mirbase()
18 changes: 12 additions & 6 deletions indra/tests/test_mirbase_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@


def test_mirbase_id_to_name():
assert 'hsa-mir-19b-2' == mirbase_client.get_mirbase_name_from_mirbase_id('MI0000075')
assert 'hsa-mir-19b-2' == \
mirbase_client.get_mirbase_name_from_mirbase_id('MI0000075')


def test_mirbase_name_to_id():
assert 'MI0000075' == mirbase_client.get_mirbase_id_from_mirbase_name('hsa-mir-19b-2')
assert 'MI0000075' == \
mirbase_client.get_mirbase_id_from_mirbase_name('hsa-mir-19b-2')


def test_mirbase_hgnc_mappings():
assert '31476' == mirbase_client.get_hgnc_id_from_mirbase_id('MI0000060')
assert mirbase_client.get_hgnc_id_from_mirbase_id('MI0000056') is None, 'This one is from C. elegans'
assert mirbase_client.get_hgnc_id_from_mirbase_id('MI0000056') is None, \
'This one is from C. elegans'


def test_hgnc_mirbase_mappings():
assert 'MI0000060' == mirbase_client.get_mirbase_id_from_hgnc_id('31476')
assert mirbase_client.get_mirbase_id_from_hgnc_id('6893') is None, 'HGNC:6893!MAPT is a protein'
assert mirbase_client.get_mirbase_id_from_hgnc_id('6893') is None, \
'HGNC:6893!MAPT is a protein'


def test_hgnc_symbol_mirbase_mappings():
assert 'MI0000075' == mirbase_client.get_mirbase_id_from_hgnc_symbol('MIR19B2')
assert mirbase_client.get_mirbase_id_from_hgnc_symbol('MAPT') is None, 'HGNC:6893!MAPT is a protein'
assert 'MI0000075' == \
mirbase_client.get_mirbase_id_from_hgnc_symbol('MIR19B2')
assert mirbase_client.get_mirbase_id_from_hgnc_symbol('MAPT') is None, \
'HGNC:6893!MAPT is a protein'