()
| 730 | |
| 731 | |
| 732 | def main() -> int: |
| 733 | args = parse_args() |
| 734 | run_dir = (args.outdir or (DEFAULT_RUN_ROOT / args.run_id)).expanduser().resolve() |
| 735 | if run_dir.exists(): |
| 736 | raise FileExistsError(f"run directory already exists: {run_dir}") |
| 737 | run_dir.mkdir(parents=True) |
| 738 | (run_dir / "logs").mkdir(parents=True, exist_ok=True) |
| 739 | |
| 740 | input_validation, pairs = validate_inputs(args) |
| 741 | resource_plan = ngs_resource_gate.write_pipeline_resource_plan( |
| 742 | run_dir=run_dir, |
| 743 | pipeline="dna_somatic_variants", |
| 744 | genome_build=args.genome_build, |
| 745 | bundle_roots=args.bundle_root, |
| 746 | include_optional=args.include_optional_resources, |
| 747 | include_checksums=args.resource_checksums, |
| 748 | skip=args.skip_resource_plan, |
| 749 | required=args.require_resource_plan, |
| 750 | ) |
| 751 | validation = ngs_resource_gate.merge_resource_status( |
| 752 | input_validation, resource_plan, required=args.require_resource_plan |
| 753 | ) |
| 754 | required_tools = ["gatk", "samtools", "bcftools"] if args.execute else [] |
| 755 | optional_tools = [ |
| 756 | name for name in ["gatk", "samtools", "bcftools"] if name not in required_tools |
| 757 | ] |
| 758 | tool_status = tool_preflight(required_tools, optional=optional_tools) |
| 759 | plan = mutect2_plan(args, pairs) |
| 760 | write_json(run_dir / "config.json", {**serializable_args(args), "run_dir": str(run_dir)}) |
| 761 | write_json(run_dir / "validation" / "input_validation_summary.json", input_validation) |
| 762 | write_json(run_dir / "validation" / "validation_summary.json", validation) |
| 763 | write_json(run_dir / "validation" / "tool_preflight.json", tool_status) |
| 764 | write_json( |
| 765 | run_dir / "versions" / "software_versions.json", |
| 766 | software_versions( |
| 767 | { |
| 768 | "gatk": ["gatk", "--version"], |
| 769 | "samtools": ["samtools", "--version"], |
| 770 | "bcftools": ["bcftools", "--version"], |
| 771 | } |
| 772 | ), |
| 773 | ) |
| 774 | write_outputs(run_dir, validation, pairs, plan, args) |
| 775 | dry_run = { |
| 776 | "ok": validation["ok"] and (tool_status["ok"] if args.execute else True), |
| 777 | "detail": "input, pairing, resource, and tool validation completed", |
| 778 | } |
| 779 | write_json(run_dir / "logs" / "validation_dry_run.json", dry_run) |
| 780 | status = "blocked" if not dry_run["ok"] else "validated" |
| 781 | execution = None |
| 782 | if args.execute and dry_run["ok"]: |
| 783 | execution = execute_plan(run_dir, plan) |
| 784 | status = "completed" if execution.get("ok") else "failed" |
| 785 | summarize_somatic_artifacts(run_dir, validation, pairs, args) |
| 786 | visuals = write_visuals(run_dir, status, validation, resource_plan) |
| 787 | resource_outputs = ngs_resource_gate.resource_output_paths(resource_plan) |
| 788 | write_standard_manifest( |
| 789 | run_dir, |
no test coverage detected