check_s3_decode.py pairs each Series 3 event file with its _XML.XML report (deduped by basename -- Sent/ mirrors the root), checks each in a process pool, and writes results.jsonl.gz and run.json to a run folder outside the repo. A missing report or any failure is one row for that event; the run goes on. Partial runs by serial, year, type, field prefix or random sample. Timing: --sample 2000 --jobs 4 took 35 s on tmi-dev (~20 min projected for all 70,042). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
"""
|
|
The decode checker's runner and reports (decode checker, Tasks 5-7).
|
|
|
|
Runs on the fixture folder, which holds the binaries and their XML reports
|
|
side by side.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import gzip
|
|
import importlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
run = importlib.import_module("scratch.check_s3_decode")
|
|
|
|
FIX = Path(__file__).parent / "fixtures/decode-checker-10-29-26"
|
|
|
|
|
|
def test_find_pairs_dedupes_and_pairs(tmp_path):
|
|
(tmp_path / "Sent").mkdir()
|
|
for n in ("R352HIUI.F40W", "Sent/R352HIUI.F40W", "UM11719_20240404193109.IDFH"):
|
|
(tmp_path / n).write_bytes(b"x")
|
|
pairs = run.find_pairs(tmp_path, FIX)
|
|
assert [p[0] for p in pairs] == ["R352HIUI.F40W"]
|
|
assert pairs[0][2].name == "R352HIUI_F40W_XML.XML"
|
|
|
|
|
|
def test_check_event_rows_and_attrs():
|
|
out = run.check_event("M007HVWF.K30W", str(FIX / "M007HVWF.K30W"), str(FIX / "M007HVWF_K30W_XML.XML"))
|
|
assert out["attrs"]["range"] == "1.250" and out["attrs"]["model"] == "MiniMate Plus"
|
|
assert any(r[0] == "TranPPV" and r[1] == "mismatch" for r in out["results"])
|
|
|
|
|
|
def test_bad_input_is_one_error_row(tmp_path):
|
|
bad = tmp_path / "R352HIUI.F40W"
|
|
bad.write_bytes(b"not a blastware file")
|
|
out = run.check_event(bad.name, str(bad), str(FIX / "R352HIUI_F40W_XML.XML"))
|
|
assert out["results"] == [["event", "error", None, None, out["results"][0][4], None]]
|
|
|
|
|
|
def test_missing_reference_is_one_no_reference_row():
|
|
out = run.check_event("R352HIUI.F40W", str(FIX / "R352HIUI.F40W"), None)
|
|
assert [r[:2] for r in out["results"]] == [["event", "no_reference"]]
|
|
|
|
|
|
def test_cli_writes_results(tmp_path):
|
|
assert run.main([str(FIX), str(FIX), "--out", str(tmp_path / "run"), "--jobs", "1"]) == 0
|
|
lines = gzip.open(tmp_path / "run/results.jsonl.gz", "rt").read().splitlines()
|
|
assert len(lines) == 7
|
|
assert json.loads((tmp_path / "run/run.json").read_text())["events"] == 7
|
|
|
|
|
|
def test_field_filter_keeps_only_matching_rows(tmp_path):
|
|
assert run.main([str(FIX), str(FIX), "--out", str(tmp_path / "run"), "--jobs", "1",
|
|
"--field", "samples."]) == 0
|
|
for line in gzip.open(tmp_path / "run/results.jsonl.gz", "rt"):
|
|
assert all(r[0].startswith("samples.") for r in json.loads(line)["results"])
|