Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cluster-submission flag
Browse files Browse the repository at this point in the history
sets local threads of Aviary recover to 1 to allow parallel submission
AroneyS committed May 3, 2024
1 parent 058355c commit f03cd17
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions binchicken/binchicken.py
Original file line number Diff line number Diff line change
@@ -476,6 +476,7 @@ def coassemble(args):
"aviary_speed": args.aviary_speed,
"assembly_strategy": args.assembly_strategy,
"run_aviary": args.run_aviary,
"cluster_submission": args.cluster_submission,
"aviary_gtdbtk": args.aviary_gtdbtk_db,
"aviary_checkm2": args.aviary_checkm2_db,
"aviary_assemble_threads": args.aviary_assemble_cores,
@@ -1133,6 +1134,7 @@ def add_evaluation_options(argument_group):

def add_aviary_options(argument_group):
argument_group.add_argument("--run-aviary", action="store_true", help="Run Aviary commands for all identified coassemblies (unless specific coassemblies are chosen with --coassemblies) [default: do not]")
argument_group.add_argument("--cluster-submission", action="store_true", help="Flag that cluster submission will occur through `--snakemake-profile`. This sets the local threads of Aviary recover to 1, allowing parallel job submission [default: do not]")
default_aviary_speed = FAST_AVIARY_MODE
argument_group.add_argument("--aviary-speed", help=f"Run Aviary recover in 'fast' or 'comprehensive' mode. Fast mode skips slow binners and refinement steps. [default: {default_aviary_speed}]",
default=default_aviary_speed, choices=[FAST_AVIARY_MODE, COMPREHENSIVE_AVIARY_MODE])
@@ -1378,6 +1380,8 @@ def coassemble_argument_verification(args, iterate=False):
raise Exception("Max recovery samples (--max-recovery-samples) must be greater than or equal to number of coassembly samples (--num-coassembly-samples)")
if args.run_aviary and not (args.aviary_gtdbtk_db and args.aviary_checkm2_db):
raise Exception("Run Aviary (--run-aviary) requires paths to GTDB-Tk and CheckM2 databases to be provided (--aviary-gtdbtk-db or GTDBTK_DATA_PATH and --aviary-checkm2-db or CHECKM2DB)")
if args.cluster_submission and not args.snakemake_profile:
logging.warning("The arg `--cluster-submission` is only a flag and cannot activate cluster submission alone. Please see `--snakemake-profile` for cluster submission.")
if (args.sample_query or args.sample_query_list or args.sample_query_dir) and args.taxa_of_interest and args.assemble_unmapped:
raise Exception("Unmapping is incompatible with the combination of sample query and taxa of interest")

@@ -1407,6 +1411,8 @@ def coassemble_output_argument_verification(args, evaluate=False):
coassemble_output_argument_verification(args)
if args.run_aviary and not (args.aviary_gtdbtk_db and args.aviary_checkm2_db):
raise Exception("Run Aviary (--run-aviary) requires paths to GTDB-Tk and CheckM2 databases to be provided (--aviary-gtdbtk-db and --aviary-checkm2-db)")
if args.cluster_submission and not args.snakemake_profile:
logging.warning("The arg `--cluster-submission` is only a flag and cannot activate cluster submission alone. Please see `--snakemake-profile` for cluster submission.")
update(args)

elif args.subparser_name == "iterate":
1 change: 1 addition & 0 deletions binchicken/config/template_coassemble.yaml
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ unmapping_max_alignment: 1
aviary_speed: "fast"
assembly_strategy: "dynamic"
run_aviary: false
cluster_submission: false
aviary_gtdbtk: ""
aviary_checkm2: ""
aviary_assemble_memory: 1
9 changes: 5 additions & 4 deletions binchicken/workflow/coassemble.smk
Original file line number Diff line number Diff line change
@@ -747,9 +747,10 @@ rule aviary_recover:
snakemake_profile = f"--snakemake-profile {config['snakemake_profile']}" if config["snakemake_profile"] else "",
cluster_retries = f"--cluster-retries {config['cluster_retries']}" if config["cluster_retries"] else "",
tmpdir = f"TMPDIR={config['tmpdir']}" if config["tmpdir"] else "",
threads = int(config["aviary_recover_threads"])
localrule: True
threads:
int(config["aviary_recover_threads"])
1 if config["cluster_submission"] else int(config["aviary_recover_threads"])
resources:
mem_mb = int(config["aviary_recover_memory"])*1000,
mem_gb = int(config["aviary_recover_memory"]),
@@ -771,12 +772,12 @@ rule aviary_recover:
"-2 {params.reads_2} "
"--output {params.output} "
"{params.fast} "
"-n {threads} "
"-t {threads} "
"-n {params.threads} "
"-t {params.threads} "
"-m {resources.mem_gb} "
"--skip-qc "
"{params.snakemake_profile} "
"{params.cluster_retries} "
"{params.retries} "
"{params.dryrun} "
"&> {log} "
"&& touch {output} "
1 change: 1 addition & 0 deletions test/test_manual.py
Original file line number Diff line number Diff line change
@@ -102,6 +102,7 @@ def test_update_aviary_run_real(self):
f"--snakemake-profile mqsub "
f"--local-cores 5 "
f"--cluster-retries 1 "
f"--cluster-submission "
)
subprocess.run(cmd, shell=True, check=True)

0 comments on commit f03cd17

Please sign in to comment.