Skip to content

Commit

Permalink
feat(#639): add single lookup with fallback check
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Oct 11, 2024
1 parent e453548 commit 85e4b42
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ and optionally correct what can be corrected easily in
| ----- | ----------- | ------------- | ----------------------------- |
| `brand_whitespace` | Drug brand names should not have leading or trailing white space. |||
| `single_any_fallback` | If any fallback guidelines `*` are present, only one guideline should be present (otherwise other guidelines are ignored) |||
| `fallback_single_lookup` | If fallback guidelines `*` or `~` are present, only one lookup value per gene should be present (otherwise other lookup values are ignored) |||

### Guideline annotation checks

Expand Down
3 changes: 2 additions & 1 deletion scripts/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from analyze_functions.checks.brand_name_whitespace import check_brand_name_whitespace
from analyze_functions.checks.metabolization_before_consequence import check_metabolization_before_consequence
from analyze_functions.checks.single_any_fallback_guideline import check_single_any_fallback_guideline
from analyze_functions.checks.fallback_guidelines import check_single_any_fallback_guideline, check_single_lookup_fallback_guideline
from analyze_functions.checks.warning_levels import check_green_warning_level, \
check_none_warning_level, check_red_warning_level, \
check_yellow_warning_level
Expand All @@ -20,6 +20,7 @@
DRUG_CHECKS = {
'brand_whitespace': check_brand_name_whitespace,
'single_any_fallback': check_single_any_fallback_guideline,
'fallback_single_lookup': check_single_lookup_fallback_guideline,
}

DRUG_CORRECTIONS = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
from common.get_data import get_guideline_by_id

def check_single_lookup_fallback_guideline(args):
drug = args['item']
data = args['data']
guidelines = list(map(
lambda guideline_id: get_guideline_by_id(data, guideline_id),
drug['guidelines'],
))
check_applies = True
for guideline in guidelines:
for gene in guideline['lookupkey'].keys():
for lookupValue in guideline['lookupkey'][gene]:
is_special = lookupValue == '*' or lookupValue == '~'
check_applies = check_applies and \
(not is_special or len( guideline['lookupkey'][gene]) == 1)
return check_applies

def check_single_any_fallback_guideline(args):
drug = args['item']
data = args['data']
Expand All @@ -12,12 +28,6 @@ def check_single_any_fallback_guideline(args):
for gene in guideline['lookupkey'].keys():
for lookupValue in guideline['lookupkey'][gene]:
is_any_fallback = lookupValue == '*'
if is_any_fallback and len(guideline['lookupkey'][gene]) != 1:
print(gene)
print(guideline['lookupkey'])
print(
'[WARNING] Multiple lookupkeys with present "any '
'fallback", all other than * are ignored'
)

has_any_fallback = has_any_fallback or is_any_fallback
return not has_any_fallback or len(guidelines) == 1

0 comments on commit 85e4b42

Please sign in to comment.