diff --git a/pharme.code-workspace b/pharme.code-workspace index b08ff853..ff37c4ae 100644 --- a/pharme.code-workspace +++ b/pharme.code-workspace @@ -35,6 +35,7 @@ "ABCG", "Abilify", "abiraterone", + "amikacin", "anni", "aripiprazole", "atorvastatin", @@ -62,6 +63,7 @@ "Ezallor", "fluorouracil", "fullscreen", + "gentamicin", "haplotype", "haplotypes", "Hasso", @@ -73,6 +75,7 @@ "inhibitable", "irinotecan", "Jantoven", + "kanamycin", "Keycloak", "lookupkey", "lookupkeys", @@ -95,6 +98,7 @@ "oxcarbazepine", "Oxtellar", "pantoprazole", + "paromomycin", "paroxetine", "pazopanib", "Pharmacogenetic", @@ -105,6 +109,7 @@ "PharMe", "phenoconversion", "Plattner", + "plazomicin", "Proprinal", "pubspec", "RGBO", @@ -122,6 +127,7 @@ "subfolders", "tacrolimus", "terbinafine", + "tobramycin", "tramadol", "Trileptal", "Ultrarapid", diff --git a/scripts/README.md b/scripts/README.md index 1ab2443f..6a9aa64b 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -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 @@ -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. diff --git a/scripts/analyze.py b/scripts/analyze.py index d065f283..b29d9072 100644 --- a/scripts/analyze.py +++ b/scripts/analyze.py @@ -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 @@ -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 = { @@ -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): @@ -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, @@ -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( diff --git a/scripts/analyze_functions/checks/fully_annotated_staged.py b/scripts/analyze_functions/checks/fully_annotated_staged.py new file mode 100644 index 00000000..abba352d --- /dev/null +++ b/scripts/analyze_functions/checks/fully_annotated_staged.py @@ -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