diff --git a/scripts/README.md b/scripts/README.md index 52f93ce5..ad5a924a 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -110,7 +110,8 @@ and optionally correct what can be corrected easily in | `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`) | ❌ | ❌ | -| `should_not_have_normal_risk` | Warns if a guideline uses "normal risk" if not mentioned in external data. | ❌ | ❌ | +| `should_not_have_normal_risk` | Warns if an annotation uses "normal risk" if not mentioned in external data. | ❌ | ❌ | +| `non_metabolizer` | Warns if an annotation uses "break down" or "activate" but is for `NON_METABOLIZERS`. | ❌ | ❌ | \* 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 dcd129ac..eeeecae9 100644 --- a/scripts/analyze.py +++ b/scripts/analyze.py @@ -4,6 +4,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.fallback_guidelines import check_single_any_fallback_guideline, check_single_lookup_fallback_guideline +from analyze_functions.checks.non_metabolizer import check_non_metabolizer from analyze_functions.checks.normal_side_effect_risk import check_normal_side_effect_risk from analyze_functions.checks.warning_levels import check_green_warning_level, \ check_none_warning_level, check_red_warning_level, \ @@ -40,6 +41,7 @@ 'metabolization_before_consequence': check_metabolization_before_consequence, 'annotated_but_not_staged': check_if_fully_annotated_staged, 'should_not_have_normal_risk': check_normal_side_effect_risk, + 'non_metabolizer': check_non_metabolizer, } GUIDELINE_CORRECTIONS = { diff --git a/scripts/analyze_functions/checks/non_metabolizer.py b/scripts/analyze_functions/checks/non_metabolizer.py new file mode 100644 index 00000000..aa6d516e --- /dev/null +++ b/scripts/analyze_functions/checks/non_metabolizer.py @@ -0,0 +1,18 @@ +import analyze_functions.constants as constants + +def check_non_metabolizer(args): + guideline = args['item'] + annotations = args['annotations'] + is_non_metabolizer_guideline = any(map( + lambda gene: gene in constants.NON_METABOLIZERS, + guideline['phenotypes'].keys(), + )) and all(map( + lambda gene: gene in constants.NON_METABOLIZERS or \ + guideline['phenotypes'][gene][0].lower() in constants.MISSING_PHENOTYPES, + guideline['phenotypes'].keys(), + )) + has_metabolizer_text = any(map( + lambda metabolizer_text: metabolizer_text in annotations['implication'], + constants.METABOLIZER_TEXTS, + )) + return not is_non_metabolizer_guideline or not has_metabolizer_text \ No newline at end of file diff --git a/scripts/analyze_functions/constants.py b/scripts/analyze_functions/constants.py index b4fa5dbe..d55acdbc 100644 --- a/scripts/analyze_functions/constants.py +++ b/scripts/analyze_functions/constants.py @@ -7,7 +7,16 @@ 'weak or no evidence for an increased risk', '"normal" risk', ] -IGNORED_PHENOTYPES = ['no result', 'indeterminate', 'normal metabolizer'] +NON_METABOLIZERS = [ + 'G6PD', + 'SLCO1B1', + 'MT-RNR1', + 'HLA-B', + 'HLA-A', +] +METABOLIZER_TEXTS = ['break down', 'activate'] +MISSING_PHENOTYPES = ['no result', 'indeterminate'] +IGNORED_PHENOTYPES = [*MISSING_PHENOTYPES, 'normal metabolizer'] RED_TEXT = 'not be the right medication' NOT_RED_TEXTS = [ 'if more than this dose is needed',