diff --git a/bio/samtools/fastq/separate/test/Snakefile b/bio/samtools/fastq/separate/test/Snakefile index eb899a1a95..7c8a38be41 100644 --- a/bio/samtools/fastq/separate/test/Snakefile +++ b/bio/samtools/fastq/separate/test/Snakefile @@ -7,7 +7,7 @@ rule samtools_fastq_separate: log: "{sample}.separate.log", params: - sort="-m 4G", + collate="", fastq="-n", # Remember, this is the number of samtools' additional threads. At least 2 threads have to be requested on cluster sumbission. This value - 2 will be sent to samtools sort -@ argument. threads: 3 diff --git a/bio/samtools/fastq/separate/wrapper.py b/bio/samtools/fastq/separate/wrapper.py index d4f8d1b0ff..581a192099 100644 --- a/bio/samtools/fastq/separate/wrapper.py +++ b/bio/samtools/fastq/separate/wrapper.py @@ -10,37 +10,29 @@ from snakemake.shell import shell from snakemake_wrapper_utils.snakemake import get_mem -params_sort = snakemake.params.get("sort", "") +params_collate = snakemake.params.get("collate", "") params_fastq = snakemake.params.get("fastq", "") log = snakemake.log_fmt_shell(stdout=True, stderr=True) # Samtools takes additional threads through its option -@ -# One thread is used bu Samtools sort +# One thread is used by Samtools collate # One thread is used by Samtools fastq # So snakemake.threads has to take them into account # before allowing additional threads through samtools sort -@ threads = 0 if snakemake.threads <= 2 else snakemake.threads - 2 -mem = get_mem(snakemake, "MiB") -mem = "-m {0:.0f}M".format(mem / threads) if mem and threads else "" - -with tempfile.TemporaryDirectory() as tmpdir: - tmp_prefix = Path(tmpdir) / "samtools_fastq.sort" - - shell( - "(samtools sort -n" - " --threads {threads}" - " {mem}" - " -T {tmp_prefix}" - " {params_sort}" - " {snakemake.input[0]} | " - "samtools fastq" - " {params_fastq}" - " -1 {snakemake.output[0]}" - " -2 {snakemake.output[1]}" - " -0 /dev/null" - " -s /dev/null" - " -F 0x900" - " - " - ") {log}" - ) +shell( + "(samtools collate -u -O" + " --threads {threads}" + " {params_collate}" + " {snakemake.input[0]} | " + "samtools fastq" + " {params_fastq}" + " -1 {snakemake.output[0]}" + " -2 {snakemake.output[1]}" + " -0 /dev/null" + " -s /dev/null" + " -F 0x900" + " - " + ") {log}" +)