|
10 | 10 | from snakemake.shell import shell
|
11 | 11 | from snakemake_wrapper_utils.snakemake import get_mem
|
12 | 12 |
|
13 |
| -params_sort = snakemake.params.get("sort", "") |
| 13 | +params_collate = snakemake.params.get("collate", "") |
14 | 14 | params_fastq = snakemake.params.get("fastq", "")
|
15 | 15 | log = snakemake.log_fmt_shell(stdout=True, stderr=True)
|
16 | 16 |
|
17 | 17 | # Samtools takes additional threads through its option -@
|
18 |
| -# One thread is used bu Samtools sort |
| 18 | +# One thread is used by Samtools collate |
19 | 19 | # One thread is used by Samtools fastq
|
20 | 20 | # So snakemake.threads has to take them into account
|
21 | 21 | # before allowing additional threads through samtools sort -@
|
22 | 22 | threads = 0 if snakemake.threads <= 2 else snakemake.threads - 2
|
23 | 23 |
|
24 |
| -mem = get_mem(snakemake, "MiB") |
25 |
| -mem = "-m {0:.0f}M".format(mem / threads) if mem and threads else "" |
26 |
| - |
27 |
| -with tempfile.TemporaryDirectory() as tmpdir: |
28 |
| - tmp_prefix = Path(tmpdir) / "samtools_fastq.sort" |
29 |
| - |
30 |
| - shell( |
31 |
| - "(samtools sort -n" |
32 |
| - " --threads {threads}" |
33 |
| - " {mem}" |
34 |
| - " -T {tmp_prefix}" |
35 |
| - " {params_sort}" |
36 |
| - " {snakemake.input[0]} | " |
37 |
| - "samtools fastq" |
38 |
| - " {params_fastq}" |
39 |
| - " -1 {snakemake.output[0]}" |
40 |
| - " -2 {snakemake.output[1]}" |
41 |
| - " -0 /dev/null" |
42 |
| - " -s /dev/null" |
43 |
| - " -F 0x900" |
44 |
| - " - " |
45 |
| - ") {log}" |
46 |
| - ) |
| 24 | +shell( |
| 25 | + "(samtools collate -u -O" |
| 26 | + " --threads {threads}" |
| 27 | + " {params_collate}" |
| 28 | + " {snakemake.input[0]} | " |
| 29 | + "samtools fastq" |
| 30 | + " {params_fastq}" |
| 31 | + " -1 {snakemake.output[0]}" |
| 32 | + " -2 {snakemake.output[1]}" |
| 33 | + " -0 /dev/null" |
| 34 | + " -s /dev/null" |
| 35 | + " -F 0x900" |
| 36 | + " - " |
| 37 | + ") {log}" |
| 38 | +) |
0 commit comments