diff --git a/gene/query.py b/gene/query.py index 258ea28c..11997f02 100644 --- a/gene/query.py +++ b/gene/query.py @@ -419,11 +419,14 @@ def add_gene_descriptor(self, response, record, match_type, extension_and_record_labels = [ ("symbol_status", "symbol_status"), ("approved_name", "label"), - ("chromsome_location", "locations"), - ("associated_with", "associated_with") + ("chromosome_location", "locations"), + ("associated_with", "associated_with"), + ("previous_symbols", "previous_symbols") ] for ext_label, record_label in extension_and_record_labels: if record_label in record and record[record_label]: + if ext_label == 'chromosome_location': + record[record_label] = record[record_label][0] extensions.append(Extension( name=ext_label, value=record[record_label] diff --git a/gene/schemas.py b/gene/schemas.py index 34e01a5f..d62208e5 100644 --- a/gene/schemas.py +++ b/gene/schemas.py @@ -236,7 +236,7 @@ class Extension(BaseModel): type = "Extension" name: StrictStr - value: Union[StrictStr, List[Dict], List[StrictStr]] + value: Union[StrictStr, List[Dict], List[StrictStr], Dict] class Config: """Configure model example""" diff --git a/gene/version.py b/gene/version.py index fb69db9c..f3b45743 100644 --- a/gene/version.py +++ b/gene/version.py @@ -1 +1 @@ -__version__ = "0.1.14" +__version__ = "0.1.15" diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py index e478f6a8..3a9187f4 100644 --- a/tests/unit/test_query.py +++ b/tests/unit/test_query.py @@ -47,6 +47,14 @@ def normalized_ache(): "ACEE" ], "extensions": [ + { + "name": "previous_symbols", + "value": [ + "ACEE", + "YT" + ], + "type": "Extension" + }, { "name": "approved_name", "value": "acetylcholinesterase (Cartwright blood group)", @@ -193,6 +201,15 @@ def normalized_abl1(): "ABL" ], "extensions": [ + { + "name": "previous_symbols", + "value": [ + "LOC116063", + "LOC112779", + "ABL" + ], + "type": "Extension" + }, { "name": "approved_name", "value": "ABL proto-oncogene 1, non-receptor tyrosine kinase", @@ -368,6 +385,7 @@ def compare_gene_descriptor(test, actual): if extensions_present: assert len(actual["extensions"]) == len(test["extensions"]), \ "len of extensions" + n_ext_correct = 0 for test_ext in test["extensions"]: for actual_ext in actual["extensions"]: if actual_ext["name"] == test_ext["name"]: @@ -379,6 +397,9 @@ def compare_gene_descriptor(test, actual): else: assert actual_ext["value"] == test_ext["value"] assert actual_ext["type"] == test_ext["type"] + n_ext_correct += 1 + assert n_ext_correct == len(test['extensions']), \ + "number of correct extensions" def test_search_query(query_handler, num_sources): @@ -504,6 +525,12 @@ def test_ache_query(query_handler, num_sources, normalized_ache): compare_normalize_resp(resp, q, MatchType.PREV_SYMBOL, cpy_normalized_ache, expected_source_meta=expected_source_meta) + q = "ACEE" + resp = query_handler.normalize(q) + cpy_normalized_ache["id"] = "normalize.gene:ACEE" + compare_normalize_resp(resp, q, MatchType.PREV_SYMBOL, cpy_normalized_ache, + expected_source_meta=expected_source_meta) + q = "omim:100740" resp = query_handler.normalize(q) cpy_normalized_ache["id"] = "normalize.gene:omim%3A100740" @@ -574,6 +601,12 @@ def test_braf_query(query_handler, num_sources, normalized_braf): compare_normalize_resp(resp, q, MatchType.ALIAS, cpy_normalized_braf, expected_source_meta=expected_source_meta) + q = "b-raf" + resp = query_handler.normalize(q) + cpy_normalized_braf["id"] = "normalize.gene:b-raf" + compare_normalize_resp(resp, q, MatchType.ALIAS, cpy_normalized_braf, + expected_source_meta=expected_source_meta) + q = "omim:164757" resp = query_handler.normalize(q) cpy_normalized_braf["id"] = "normalize.gene:omim%3A164757" @@ -650,6 +683,12 @@ def test_abl1_query(query_handler, num_sources, normalized_abl1): compare_normalize_resp(resp, q, MatchType.PREV_SYMBOL, cpy_normalized_abl1, expected_source_meta=expected_source_meta) + q = "LOC112779" + resp = query_handler.normalize(q) + cpy_normalized_abl1["id"] = "normalize.gene:LOC112779" + compare_normalize_resp(resp, q, MatchType.PREV_SYMBOL, cpy_normalized_abl1, + expected_source_meta=expected_source_meta) + q = "ABL" resp = query_handler.normalize(q) cpy_normalized_abl1["id"] = "normalize.gene:ABL"