Skip to content

Commit

Permalink
feat(#639): add annotated_but_not_staged check
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Oct 15, 2024
1 parent 85e4b42 commit 704f6b8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
6 changes: 6 additions & 0 deletions pharme.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"ABCG",
"Abilify",
"abiraterone",
"amikacin",
"anni",
"aripiprazole",
"atorvastatin",
Expand Down Expand Up @@ -62,6 +63,7 @@
"Ezallor",
"fluorouracil",
"fullscreen",
"gentamicin",
"haplotype",
"haplotypes",
"Hasso",
Expand All @@ -73,6 +75,7 @@
"inhibitable",
"irinotecan",
"Jantoven",
"kanamycin",
"Keycloak",
"lookupkey",
"lookupkeys",
Expand All @@ -95,6 +98,7 @@
"oxcarbazepine",
"Oxtellar",
"pantoprazole",
"paromomycin",
"paroxetine",
"pazopanib",
"Pharmacogenetic",
Expand All @@ -105,6 +109,7 @@
"PharMe",
"phenoconversion",
"Plattner",
"plazomicin",
"Proprinal",
"pubspec",
"RGBO",
Expand All @@ -122,6 +127,7 @@
"subfolders",
"tacrolimus",
"terbinafine",
"tobramycin",
"tramadol",
"Trileptal",
"Ultrarapid",
Expand Down
2 changes: 2 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,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) |||
| `annotated_but_not_staged` | Warns if a drug is annotated but not staged (ignored drugs in `IGNORE_STAGED_CHECK`) |||

### Guideline annotation checks

Expand All @@ -108,6 +109,7 @@ and optionally correct what can be corrected easily in
| `green_warning` | Green warning level should be applied in all non-red and non-yellow cases and when the recommendation states "at standard dose" or similar formulations. |||
| `none_warning` | None warning level should be applied in all not handled warning level cases. |||
| `metabolization_before_consequence` | Metabolization implications should come before consequences. |||
| `annotated_but_not_staged` | Warns if a guideline is annotated but not staged (ignored drugs in `IGNORE_STAGED_CHECK`) |||

\* Skips guidelines with multiple genes unless all results but one are missing
or indeterminate.
28 changes: 20 additions & 8 deletions scripts/analyze.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys

from analyze_functions.checks.fully_annotated_staged import check_if_fully_annotated_staged
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.fallback_guidelines import check_single_any_fallback_guideline, check_single_lookup_fallback_guideline
Expand All @@ -21,6 +22,7 @@
'brand_whitespace': check_brand_name_whitespace,
'single_any_fallback': check_single_any_fallback_guideline,
'fallback_single_lookup': check_single_lookup_fallback_guideline,
'annotated_but_not_staged': check_if_fully_annotated_staged,
}

DRUG_CORRECTIONS = {
Expand All @@ -35,20 +37,17 @@
'green_warning_level': check_green_warning_level,
'none_warning_level': check_none_warning_level,
'metabolization_before_consequence': check_metabolization_before_consequence,
'annotated_but_not_staged': check_if_fully_annotated_staged,
}

GUIDELINE_CORRECTIONS = {
'has_consult': add_consult,
}

def analyze_annotations(item, annotations, checks, data = None):
def analyze_annotations(checks, check_args):
results = {}
for check_name, check_function in checks.items():
results[check_name] = check_function({
'item': item,
'annotations': annotations,
'data': data,
})
results[check_name] = check_function(check_args)
return results

def correct_inconsistency(data, item, check_name, corrections):
Expand Down Expand Up @@ -112,7 +111,14 @@ def run_analyses():
log_not_annotated(log_content)
else:
drug_result = analyze_annotations(
drug, drug_annotations, DRUG_CHECKS, data)
DRUG_CHECKS,
{
'item': drug,
'annotations': drug_annotations,
'data': data,
'drug_name': drug_name,
},
)
if not all(drug_result.values()):
skipped, failed = handle_failed_checks(data, drug, drug_result,
DRUG_CORRECTIONS, correct_inconsistencies,
Expand All @@ -131,7 +137,13 @@ def run_analyses():
log_not_annotated(log_content)
continue
guideline_result = analyze_annotations(
guideline, guideline_annotations, GUIDELINE_CHECKS)
GUIDELINE_CHECKS,
{
'item': guideline,
'annotations': guideline_annotations,
'drug_name': drug_name,
},
)
if guideline_result == None: continue
if not all(guideline_result.values()):
skipped, failed = handle_failed_checks(
Expand Down
21 changes: 21 additions & 0 deletions scripts/analyze_functions/checks/fully_annotated_staged.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
IGNORE_STAGED_CHECK = [#
'amikacin',
'gentamicin',
'kanamycin',
'paromomycin',
'tobramycin',
'streptomycin',
'plazomicin',
]

def check_if_fully_annotated_staged(args):
if args['drug_name'] in IGNORE_STAGED_CHECK: return None
item = args['item']
isStaged = item['isStaged']
if isStaged: return True
annotations = args['annotations']
isFullyAnnotated = all(map(
lambda annotationKey: annotations[annotationKey] != None,
annotations.keys(),
))
return isFullyAnnotated and isStaged

0 comments on commit 704f6b8

Please sign in to comment.