Skip to content

Commit

Permalink
edit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
klaricch committed Feb 6, 2025
1 parent c74eaf1 commit 388e2b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 16 additions & 1 deletion gnomad/assessment/validity_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,21 @@ def check_raw_and_adj_callstats(
),
}

# Check that nhomalt <= AC / 2.
check_field_nhomalt = f"{nhomalt_metric}{delimiter}{group}"
check_field_AC = f"AC{delimiter}{group}"

field_check_expr[f"{check_field_nhomalt} <= {check_field_AC} / 2"] = {
"expr": t.info[check_field_nhomalt] > (t.info[check_field_AC] / 2),
"agg_func": hl.agg.count_where,
"display_fields": hl.struct(
**{
check_field_nhomalt: t.info[check_field_nhomalt],
check_field_AC: t.info[check_field_AC],
}
),
}

# Check AF missing if AN is missing and defined if AN is defined and > 0.
check_field = f"AF{delimiter}{group}"
an_field = f"AN{delimiter}{group}"
Expand Down Expand Up @@ -682,7 +697,7 @@ def check_raw_and_adj_callstats(
),
}

# Check overall gnomad's raw subfields >= adj
# Check overall gnomad's raw subfields >= adj.
for subfield in ["AC", "AN", nhomalt_metric]:
check_field_left = f"{subfield}{delimiter}raw"
check_field_right = f"{subfield}{delimiter}adj"
Expand Down
4 changes: 3 additions & 1 deletion tests/assessment/test_validity_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def ht_for_check_raw_and_adj_callstats() -> hl.Table:
"AF_adj": -0.01,
"AN_raw": 1000,
"AN_adj": 1100,
"nhomalt_raw": 1,
"nhomalt_raw": -3,
"nhomalt_adj": 2,
},
"filters": {"LowQual"},
Expand Down Expand Up @@ -615,6 +615,7 @@ def test_check_raw_and_adj_callstats(
"PASSED AC_adj defined when AN defined and missing when AN missing check",
"PASSED AF_adj defined when AN defined (and > 0) and missing when AN missing check",
"PASSED AC_raw >= AC_adj check",
"PASSED nhomalt_raw <= AC_raw / 2 check",
# Expected FAILURES.
"Found 1 sites that fail nhomalt_raw defined when AN defined and missing when AN missing check:",
"Found 1 sites that fail AF_raw defined when AN defined (and > 0) and missing when AN missing check:",
Expand All @@ -627,6 +628,7 @@ def test_check_raw_and_adj_callstats(
"Found 1 sites that fail AF_adj >= 0 check:",
"Found 1 sites that fail AN_raw >= AN_adj check:",
"Found 1 sites that fail nhomalt_raw >= nhomalt_adj check:",
"Found 1 sites that fail nhomalt_adj <= AC_adj / 2 check:",
]

for msg in expected_logs:
Expand Down

0 comments on commit 388e2b7

Please sign in to comment.