Skip to content

Commit

Permalink
Merge pull request #148 from cancervariants/issue-146
Browse files Browse the repository at this point in the history
Issue 146
  • Loading branch information
jsstevenson authored Apr 13, 2021
2 parents 18bc4a8 + 9b24358 commit b9e023b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 14 additions & 0 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,20 @@ def test_query_merged(merge_query_handler, phenobarbital, cisplatin,
assert 'record' not in response
assert response['match_type'] == MatchType.NO_MATCH

test_query = "APRD00818"
response = merge_query_handler.search_groups(test_query)
assert response['query'] == test_query
assert response['warnings'] is None
assert 'record' not in response
assert response['match_type'] == MatchType.NO_MATCH

test_query = "chembl:CHEMBL1200368"
response = merge_query_handler.search_groups(test_query)
assert response['query'] == test_query
assert response['warnings'] is None
assert 'record' not in response
assert response['match_type'] == MatchType.NO_MATCH


def test_merged_meta(merge_query_handler):
"""Test population of source and resource metadata in merged querying."""
Expand Down
10 changes: 5 additions & 5 deletions therapy/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def search_groups(self, query: str) -> Dict:

# check concept ID match
record = self.db.get_record_by_id(query_str, case_sensitive=False)
if record:
if record and record['src_name'].lower() not in PROHIBITED_SOURCES:
merge = self.db.get_record_by_id(record['merge_ref'],
case_sensitive=False,
merge=True)
Expand All @@ -462,10 +462,10 @@ def search_groups(self, query: str) -> Dict:
for match_type in ['label', 'trade_name', 'alias', 'other_id']:
# get matches list for match tier
matching_refs = self.db.get_records_by_type(query_str, match_type)
matching_records = [self.db.get_record_by_id(m['concept_id'],
False)
for m in matching_refs
if m['src_name'] not in PROHIBITED_SOURCES]
matching_records = \
[self.db.get_record_by_id(m['concept_id'], False)
for m in matching_refs
if m['src_name'].lower() not in PROHIBITED_SOURCES]
matching_records.sort(key=self._record_order)

# attempt merge ref resolution until successful
Expand Down

0 comments on commit b9e023b

Please sign in to comment.