From 79cf6ae0bf95760dc66cad7cf536b755d0880dfc Mon Sep 17 00:00:00 2001 From: Kirill Tsukanov Date: Wed, 26 Oct 2022 15:41:57 +0100 Subject: [PATCH 1/5] Add --version flag to print version and exit --- ontoma/cli.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ontoma/cli.py b/ontoma/cli.py index 3f8603f..72d0f22 100644 --- a/ontoma/cli.py +++ b/ontoma/cli.py @@ -1,5 +1,6 @@ import csv import logging +from sys import stderr import click @@ -9,6 +10,10 @@ logger = logging.getLogger(__name__) +def get_version(): + return open('../VERSION').read().strip() + + @click.command() @click.option( '--infile', @@ -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.') From e0790c71f0ebd7e926368b51ddc38a9ba6d8cc8f Mon Sep 17 00:00:00 2001 From: Kirill Tsukanov Date: Wed, 26 Oct 2022 15:42:15 +0100 Subject: [PATCH 2/5] Sort URI_MAPPING and add entry for CHEBI --- ontoma/ontology.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ontoma/ontology.py b/ontoma/ontology.py index 7ca21b4..0536147 100644 --- a/ontoma/ontology.py +++ b/ontoma/ontology.py @@ -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_{}', } From eb232e2906df68b00b16e1d38d86cd04e111ba52 Mon Sep 17 00:00:00 2001 From: Kirill Tsukanov Date: Thu, 17 Nov 2022 14:33:55 +0000 Subject: [PATCH 3/5] Bump VERSION to v1.0.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 570c796..e946d6b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v1.0.2 +v1.0.3 From 88eb3a3b0d560ee00afce3f6aef623530801afd7 Mon Sep 17 00:00:00 2001 From: Kirill Tsukanov Date: Thu, 17 Nov 2022 14:58:40 +0000 Subject: [PATCH 4/5] Amend documentation for local install and tests --- docs/development.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/development.rst b/docs/development.rst index 4601b6b..e1c979f 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -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. From c4f12e7b406f83e27288f9a8796a3a338d9ea808 Mon Sep 17 00:00:00 2001 From: Kirill Tsukanov Date: Thu, 17 Nov 2022 15:10:22 +0000 Subject: [PATCH 5/5] Amend tests to reflect changes in EFO --- tests/test_cli.py | 2 +- tests/test_ontoma.py | 13 +++++-------- tests/test_phewascat.py | 10 +++++----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 871823a..e52becb 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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. diff --git a/tests/test_ontoma.py b/tests/test_ontoma.py index b19e6a9..7ff3b57 100644 --- a/tests/test_ontoma.py +++ b/tests/test_ontoma.py @@ -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'] ) @@ -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'} ) @@ -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'] ) diff --git a/tests/test_phewascat.py b/tests/test_phewascat.py index c6bdc51..bf10ba8 100644 --- a/tests/test_phewascat.py +++ b/tests/test_phewascat.py @@ -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): @@ -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'] )