()
| 937 | |
| 938 | |
| 939 | def main() -> int: |
| 940 | args = parse_args() |
| 941 | run_dir = (args.outdir or (DEFAULT_RUN_ROOT / args.run_id)).expanduser().resolve() |
| 942 | if run_dir.exists(): |
| 943 | raise FileExistsError(f"run directory already exists: {run_dir}") |
| 944 | run_dir.mkdir(parents=True) |
| 945 | (run_dir / "logs").mkdir(parents=True, exist_ok=True) |
| 946 | |
| 947 | input_validation, rows = validate_inputs(args) |
| 948 | resource_plan = ngs_resource_gate.write_pipeline_resource_plan( |
| 949 | run_dir=run_dir, |
| 950 | pipeline="dna_variant_calling", |
| 951 | genome_build=args.genome_build, |
| 952 | bundle_roots=args.bundle_root, |
| 953 | include_optional=args.include_optional_resources, |
| 954 | include_checksums=args.resource_checksums, |
| 955 | skip=args.skip_resource_plan, |
| 956 | required=args.require_resource_plan, |
| 957 | ) |
| 958 | validation = ngs_resource_gate.merge_resource_status( |
| 959 | input_validation, |
| 960 | resource_plan, |
| 961 | required=args.require_resource_plan, |
| 962 | ) |
| 963 | tool_status = tool_preflight(["samtools", "bcftools"], optional=[]) |
| 964 | write_json( |
| 965 | run_dir / "config.json", |
| 966 | { |
| 967 | "reference_fasta": str(args.reference_fasta.expanduser().resolve()), |
| 968 | "region": validation.get("region"), |
| 969 | "region_requested": args.region, |
| 970 | "filter_min_qual": args.filter_min_qual, |
| 971 | "filter_min_site_dp": args.filter_min_site_dp, |
| 972 | "callable_min_depth": args.callable_min_depth, |
| 973 | "run_class": validation.get("run_class"), |
| 974 | }, |
| 975 | ) |
| 976 | write_json(run_dir / "validation" / "input_summary.json", {"samples": rows}) |
| 977 | write_json(run_dir / "validation" / "input_validation_summary.json", input_validation) |
| 978 | write_json(run_dir / "validation" / "validation_summary.json", validation) |
| 979 | write_json(run_dir / "validation" / "tool_preflight.json", tool_status) |
| 980 | write_normalized_samples(run_dir, rows) |
| 981 | write_commands(run_dir, args, rows) |
| 982 | write_json( |
| 983 | run_dir / "versions" / "software_versions.json", |
| 984 | software_versions( |
| 985 | {"samtools": ["samtools", "--version"], "bcftools": ["bcftools", "--version"]} |
| 986 | ), |
| 987 | ) |
| 988 | |
| 989 | dry_run = { |
| 990 | "ok": validation["ok"] and tool_status["ok"], |
| 991 | "detail": "input and tool validation completed", |
| 992 | } |
| 993 | write_json(run_dir / "logs" / "validation_dry_run.json", dry_run) |
| 994 | execution = None |
| 995 | status = "blocked" if not dry_run["ok"] else "validated" |
| 996 | if args.execute and dry_run["ok"]: |
no test coverage detected