about summary refs log tree commit diff
path: root/uploader/scripts
diff options
context:
space:
mode:
authorpi coding agent <pi@localhost>2026-11-05 21:06:15 +0000
committerFrederick Muriuki Muriithi <fredmanglis@gmail.com>2026-11-05 16:42:01 -0600
commit1f40a2114848aa35ed37ca26ed48ed26694214d0 (patch)
tree0c6ebac2be9896bc5e61293624c3a25801f7735b /uploader/scripts
parentaec6f7a927f1cf44bc5e7dfe3951ddddf3425872 (diff)
downloadgn-uploader-1f40a2114848aa35ed37ca26ed48ed26694214d0.tar.gz
Add Stage 03 genotype value QC and schedule it from Stage 02
- Store the genotype file path and collector config in the collector job
  metadata so later stages can re-read the file.
- Seed `dot_geno_fields.unk` into the Stage 02 missing-value symbols default.
- Add `uploader.genotypes.qc` with value checks (empty and unknown symbols)
  and a placeholder marker-ordering helper (chromosome, cM, Mb) that warns.
- Add the `uploader.scripts.genotypes.qc` worker that reads the collector job,
  runs the checks and exits non-zero when errors are found.
- On Stage 02 save, schedule the QC job and record its id for idempotency.
Diffstat (limited to 'uploader/scripts')
-rw-r--r--uploader/scripts/genotypes/qc.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/uploader/scripts/genotypes/qc.py b/uploader/scripts/genotypes/qc.py
new file mode 100644
index 0000000..408c883
--- /dev/null
+++ b/uploader/scripts/genotypes/qc.py
@@ -0,0 +1,44 @@
+"""Run quality-control checks on a genotype file for a collector job."""
+import sys
+import json
+import logging
+from argparse import ArgumentParser
+
+from gn_libs import jobs, sqlite3
+
+from uploader.genotypes import qc
+
+logger = logging.getLogger(__name__)
+
+
+def parse_args():
+    """Parse the command-line arguments."""
+    parser = ArgumentParser(
+        prog="genotype-file-qc",
+        description="Run QC on a genotype file for a collector job.")
+    parser.add_argument("jobs_db", help="Path to the jobs SQLite database.")
+    parser.add_argument(
+        "collector_job_id", help="The id of the genotype-file-stats job.")
+    parser.add_argument(
+        "--log-level", default="info",
+        choices=("debug", "info", "warning", "error", "critical"))
+    return parser.parse_args()
+
+
+def main():
+    """Entry point to the genotype file QC."""
+    args = parse_args()
+    logging.basicConfig(level=getattr(logging, args.log_level.upper()))
+    with sqlite3.connection(args.jobs_db) as conn:
+        job = jobs.job(conn, args.collector_job_id, fulldetails=True)
+    metadata = job["metadata"]
+    result = qc.check_file(
+        metadata["file"],
+        json.loads(metadata["config"]),
+        json.loads(metadata.get("stage02") or "{}"))
+    print(json.dumps(result))
+    return 0 if not result["errors"] else 1
+
+
+if __name__ == "__main__":
+    sys.exit(main())