Skip to content

Commit

Permalink
Merge pull request #23 from opentargets/1808-tskir-minor-improvements
Browse files Browse the repository at this point in the history
Minor improvements from issue 1808
  • Loading branch information
DSuveges authored Nov 21, 2022
2 parents 502f5f3 + c4f12e7 commit e78ece6
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.2
v1.0.3
10 changes: 10 additions & 0 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ Install development packages
Installing locally and running the tests
----------------------------------------

.. code-block:: bash
pip install -e .
pytest
Adding a dependency
-------------------
Installation dependencies are stored in the ``setup.py`` file, in the ``install_requires`` section.
Expand Down
16 changes: 15 additions & 1 deletion ontoma/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import csv
import logging
from sys import stderr

import click

Expand All @@ -9,6 +10,10 @@
logger = logging.getLogger(__name__)


def get_version():
return open('../VERSION').read().strip()


@click.command()
@click.option(
'--infile',
Expand Down Expand Up @@ -50,8 +55,17 @@
help=f'EFO release to use. This must be be either “latest”, or match the specific tag name in their GitHub '
f'releases, for example v3.31.0. By default, {EFO_DEFAULT_VERSION!r} is used.'
)
def ontoma(infile, outfile, input_type, cache_dir, columns, efo_release):
@click.option(
'--version',
help='Print version number and exit.',
is_flag=True
)
def ontoma(infile, outfile, input_type, cache_dir, columns, efo_release, version):
"""Maps ontology identifiers and strings to EFO, the ontology used by the Open Targets Platform."""
if version:
stderr.write(f'OnToma version {get_version()}.')
return

if infile.name == '/dev/stdin':
logger.warning('Reading input from STDIN. If this is not what you wanted, re-run with --help to see usage.')

Expand Down
9 changes: 5 additions & 4 deletions ontoma/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ def convert_to_ot_schema(normalised_identifier: str) -> Optional[str]:


URI_MAPPING = {
'NCIT': 'http://purl.obolibrary.org/obo/NCIT_{}',
'ORDO': 'http://www.orpha.net/ORDO/Orphanet_{}',
'CHEBI': 'http://purl.obolibrary.org/obo/CHEBI_{}',
'DOID': 'http://purl.obolibrary.org/obo/DOID_{}',
'EFO': 'http://www.ebi.ac.uk/efo/EFO_{}',
'GO': 'http://purl.obolibrary.org/obo/GO_{}',
'HP': 'http://purl.obolibrary.org/obo/HP_{}',
'EFO': 'http://www.ebi.ac.uk/efo/EFO_{}',
'MONDO': 'http://purl.obolibrary.org/obo/MONDO_{}',
'DOID': 'http://purl.obolibrary.org/obo/DOID_{}',
'MP': 'http://purl.obolibrary.org/obo/MP_{}',
'NCIT': 'http://purl.obolibrary.org/obo/NCIT_{}',
'ORDO': 'http://www.orpha.net/ORDO/Orphanet_{}',
}


Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ def test_file_batch_input(rootdir):
])
assert result.exit_code == 0
output = open('/tmp/ontoma-1.txt').read()
assert 'EFO_0000270' in output
assert 'MONDO_0004979' in output
# assert 'MONDO_0002279' in output # Related synonyms are not processed by this version.
13 changes: 5 additions & 8 deletions tests/test_ontoma.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@
def test_find_term_asthma(ontclient):
assert_result_ot_label(
ontclient.find_term('asthma'),
['EFO_0000270']
['MONDO_0004979']
)


def test_is_included(ontclient):
assert ontclient.filter_identifiers_by_efo_current(['ORDO:354']) == ['ORDO:354']
# FIXME: This represents a term which is in EFO, but perhaps should not be considered by OnToma, because this is
# FIXME: a body part rather than a disease/drug response/etc.
assert ontclient.filter_identifiers_by_efo_current(['UBERON:0000310']) == ['UBERON:0000310']
assert ontclient.filter_identifiers_by_efo_current(['MONDO:0018149']) == ['MONDO:0018149']


def test_suggest_hp_term_not_excluded(ontclient):
assert_result_ot_label(
ontclient.find_term('hypogammaglobulinemia'),
['Orphanet_183669']
['MONDO_0015977']
)


Expand All @@ -29,7 +26,7 @@ def test_catch_ordo(ontclient):
)
assert_result_ot_label(
ontclient.find_term('OMIM:208250', code=True),
{'EFO_0009028', 'MONDO_0008828'}
{'EFO_0009028'}
)


Expand All @@ -42,5 +39,5 @@ def test_query_comma(ontclient):
def test_find_term_alzheimer(ontclient):
assert_result_ot_label(
ontclient.find_term('alzheimer\'s disease'),
['EFO_0000249']
['MONDO_0004975']
)
10 changes: 5 additions & 5 deletions tests/test_phewascat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
def test_find_term_asthma(ontclient):
assert_result_ot_label(
ontclient.find_term('asthma'),
['EFO_0000270']
['MONDO_0004979']
)


def test_efo_direct_match(ontclient):
# The test deliberately expects no results, since a match from “Dementias” to “EFO_0004718” is a fuzzy one and
# cannot be assumed of high quality.
assert not ontclient.find_term('Dementias')
# The test deliberately expects no results, since a match from “Xeroderma Pigmentosa” to “MONDO_0019600” is a fuzzy
# one and cannot be assumed of high quality.
assert not ontclient.find_term('Xeroderma Pigmentosa')


def test_otzooma_mappings_whitespace(ontclient):
Expand All @@ -24,7 +24,7 @@ def test_otzooma_mappings_whitespace(ontclient):
def test_efo_match_with_apostrophe(ontclient):
assert_result_ot_label(
ontclient.find_term('Alzheimer\'s disease'),
['EFO_0000249']
['MONDO_0004975']
)


Expand Down

0 comments on commit e78ece6

Please sign in to comment.