Skip to content

Commit

Permalink
Merge pull request #69 from cancervariants/issue-60
Browse files Browse the repository at this point in the history
Add previous symbols to extensions
  • Loading branch information
korikuzma authored Aug 9, 2021
2 parents 33ab615 + efd641a commit a935f11
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
7 changes: 5 additions & 2 deletions gene/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion gene/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion gene/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.14"
__version__ = "0.1.15"
39 changes: 39 additions & 0 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"]:
Expand All @@ -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):
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit a935f11

Please sign in to comment.