-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsbx_spades.rules
77 lines (71 loc) · 2.24 KB
/
sbx_spades.rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# -*- mode: Snakemake -*-
#
# Rules for de novo assembly using aligned reads
from sunbeamlib import samtools
#### 20180410: de novo assembly only mapped reads
rule all_spades:
input:
expand(str(MAPPING_FP/'{genome}'/'spades'/'{sample}'/'done'),
genome=GenomeSegments.keys(), sample=Samples.keys())
rule sort_bam_by_name:
input:
str(MAPPING_FP/'intermediates'/'{genome}'/'{sample}.sam')
output:
str(MAPPING_FP/'{genome}'/'sortbyname'/'{sample}.bam')
threads:
Cfg['sbx_spades']['threads']
conda:
"sbx_spades_env.yml"
shell:
"""
samtools view -@ {threads} -b {Cfg[mapping][samtools_opts]} {input} | \
samtools sort -n -@ {threads} > {output}
"""
rule bam2fastq:
input:
str(MAPPING_FP/'{genome}'/'sortbyname'/'{sample}.bam')
output:
r1 = str(MAPPING_FP/'{genome}'/'reads'/'{sample}_1.fastq'),
r2 = str(MAPPING_FP/'{genome}'/'reads'/'{sample}_2.fastq')
threads:
Cfg['sbx_spades']['threads']
conda:
"sbx_spades_env.yml"
shell:
"""
bedtools bamtofastq -i {input} -fq {output.r1} -fq2 {output.r2}
"""
rule run_spades_paired:
input:
r1 = str(MAPPING_FP/'{genome}'/'reads'/'{sample}_1.fastq'),
r2 = str(MAPPING_FP/'{genome}'/'reads'/'{sample}_2.fastq')
output:
str(MAPPING_FP/'{genome}'/'spades'/'{sample}'/'done')
threads:
Cfg['sbx_spades']['threads']
params:
outdir = str(MAPPING_FP/'{genome}'/'spades'/'{sample}')
conda:
"sbx_spades_env.yml"
shell:
"""
spades.py -1 {input.r1} -2 {input.r2} -o {params.outdir} -t {threads} -m 100 && \
touch {output}
"""
#### The following rule is used with sbx_krakenuniq
rule run_spades_interlaced:
input:
str(CLASSIFY_FP/'krakenhll'/'42789'/'{sample}.fastq'),
output:
str(CLASSIFY_FP/'krakenhll'/'42789'/'spades'/'{sample}'/'done')
threads:
Cfg['sbx_spades']['threads']
params:
outdir = str(CLASSIFY_FP/'krakenhll'/'42789'/'spades'/'{sample}')
conda:
"sbx_spades_env.yml"
shell:
"""
spades.py --12 {input} -o {params.outdir} -t {threads} -m 100 && \
touch {output}
"""