()
| 512 | |
| 513 | |
| 514 | def main() -> int: |
| 515 | args = parse_args() |
| 516 | run_dir = (args.outdir or (DEFAULT_RUN_ROOT / args.run_id)).expanduser().resolve() |
| 517 | if run_dir.exists(): |
| 518 | raise FileExistsError(f"run directory already exists: {run_dir}") |
| 519 | run_dir.mkdir(parents=True) |
| 520 | (run_dir / "logs").mkdir(parents=True, exist_ok=True) |
| 521 | |
| 522 | input_validation, rows = validate_inputs(args) |
| 523 | resource_plan = ngs_resource_gate.write_pipeline_resource_plan( |
| 524 | run_dir=run_dir, |
| 525 | pipeline="dna_germline_variants", |
| 526 | genome_build=args.genome_build, |
| 527 | bundle_roots=args.bundle_root, |
| 528 | include_optional=args.include_optional_resources, |
| 529 | include_checksums=args.resource_checksums, |
| 530 | skip=args.skip_resource_plan, |
| 531 | required=args.require_resource_plan, |
| 532 | ) |
| 533 | validation = ngs_resource_gate.merge_resource_status( |
| 534 | input_validation, |
| 535 | resource_plan, |
| 536 | required=args.require_resource_plan, |
| 537 | ) |
| 538 | required_tools = ["samtools", "gatk"] if args.execute else [] |
| 539 | optional_tools = [ |
| 540 | name |
| 541 | for name in ["samtools", "gatk", "bcftools", "deepvariant"] |
| 542 | if name not in required_tools |
| 543 | ] |
| 544 | tool_status = tool_preflight(required_tools, optional=optional_tools) |
| 545 | write_json( |
| 546 | run_dir / "config.json", |
| 547 | { |
| 548 | "reference_fasta": str(args.reference_fasta.expanduser().resolve()), |
| 549 | "known_sites": [str(item.expanduser().resolve()) for item in args.known_sites], |
| 550 | "target_bed": str(args.target_bed.expanduser().resolve()) if args.target_bed else None, |
| 551 | "sample_model": args.sample_model, |
| 552 | "bqsr_mode": args.bqsr_mode, |
| 553 | "emit_gvcf": args.emit_gvcf, |
| 554 | "joint_call": args.joint_call, |
| 555 | }, |
| 556 | ) |
| 557 | write_json(run_dir / "validation" / "input_summary.json", {"samples": rows}) |
| 558 | write_json(run_dir / "validation" / "input_validation_summary.json", input_validation) |
| 559 | write_json(run_dir / "validation" / "validation_summary.json", validation) |
| 560 | write_json(run_dir / "validation" / "tool_preflight.json", tool_status) |
| 561 | write_normalized_samples(run_dir, rows) |
| 562 | write_commands(run_dir, args, rows) |
| 563 | write_json( |
| 564 | run_dir / "versions" / "software_versions.json", |
| 565 | software_versions( |
| 566 | { |
| 567 | "samtools": ["samtools", "--version"], |
| 568 | "gatk": ["gatk", "--version"], |
| 569 | "bcftools": ["bcftools", "--version"], |
| 570 | } |
| 571 | ), |
no test coverage detected