()
| 434 | |
| 435 | |
| 436 | def main() -> int: |
| 437 | args = parse_args() |
| 438 | run_id = args.run_id or slug_timestamp(f"nfcore-{args.pipeline}") |
| 439 | run_dir = (args.outdir or (DEFAULT_RUN_ROOT / args.pipeline / run_id)).expanduser().resolve() |
| 440 | if run_dir.exists(): |
| 441 | raise FileExistsError(f"run directory already exists: {run_dir}") |
| 442 | run_dir.mkdir(parents=True) |
| 443 | (run_dir / "workflow").mkdir(parents=True, exist_ok=True) |
| 444 | (run_dir / "logs").mkdir(parents=True, exist_ok=True) |
| 445 | |
| 446 | input_validation = validate_inputs(args) |
| 447 | resource_plan = write_resource_plan(args, run_dir) |
| 448 | validation = merge_resource_status(input_validation, resource_plan) |
| 449 | tool_status = tool_preflight(["nextflow"], optional=[]) |
| 450 | params = generated_params(args, run_dir) |
| 451 | generated_params_path = run_dir / "workflow" / "params.generated.json" |
| 452 | write_json(generated_params_path, params) |
| 453 | command = build_command(args, run_dir, generated_params_path) |
| 454 | write_json( |
| 455 | run_dir / "workflow" / "nfcore_command.json", |
| 456 | {"command": command, "argv_preview": shlex.split(command)}, |
| 457 | ) |
| 458 | write_command_script(run_dir / "commands.sh", [command]) |
| 459 | write_json(run_dir / "config.json", {**serializable_args(args), "run_dir": str(run_dir)}) |
| 460 | write_json(run_dir / "validation" / "input_validation_summary.json", input_validation) |
| 461 | write_json(run_dir / "validation" / "validation_summary.json", validation) |
| 462 | write_json(run_dir / "validation" / "tool_preflight.json", tool_status) |
| 463 | write_json( |
| 464 | run_dir / "versions" / "software_versions.json", |
| 465 | software_versions({"nextflow": ["nextflow", "-version"]}), |
| 466 | ) |
| 467 | dry_run = { |
| 468 | "ok": validation["ok"] and tool_status["ok"], |
| 469 | "detail": "nf-core inputs, params, and Nextflow runtime validated", |
| 470 | } |
| 471 | write_json(run_dir / "logs" / "validation_dry_run.json", dry_run) |
| 472 | status = "blocked" if not dry_run["ok"] else "validated" |
| 473 | execution = None |
| 474 | if args.execute and dry_run["ok"]: |
| 475 | execution = execute_command(run_dir, command) |
| 476 | write_json(run_dir / "logs" / "nextflow_execute.json", execution) |
| 477 | write_text(run_dir / "logs" / "nextflow_execute.log", str(execution.get("stdout_tail", ""))) |
| 478 | status = "completed" if execution.get("ok") else "failed" |
| 479 | visuals = write_visuals(run_dir, status, validation, resource_plan) |
| 480 | resource_outputs = resource_plan.get("outputs", {}) if resource_plan else {} |
| 481 | write_standard_manifest( |
| 482 | run_dir, |
| 483 | run_id=run_id, |
| 484 | lane=f"nfcore_{args.pipeline}", |
| 485 | workflow=NFCORE_PIPELINES[args.pipeline]["workflow"], |
| 486 | status=status, |
| 487 | execute_requested=args.execute, |
| 488 | validation=validation, |
| 489 | tool_preflight_result=tool_status, |
| 490 | dry_run=dry_run, |
| 491 | execution=execution, |
| 492 | inputs={ |
| 493 | "sample_sheet": str(args.sample_sheet.expanduser().resolve()), |
no test coverage detected