Skip to content

Commit

Permalink
Wrap to 80 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbachman committed Jul 17, 2019
1 parent 0e5ddd1 commit a1e6aa8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
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__':
"""
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'

0 comments on commit a1e6aa8

Please sign in to comment.