forked from Parsoa/SVDSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Snakefile
87 lines (77 loc) · 2.15 KB
/
Snakefile
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
78
79
80
81
82
83
84
85
86
87
configfile: "config.yaml"
from os.path import join as pjoin
REF = config["fa"]
BAM = config["bam"]
ODIR = config["out"] # os.getcwd()
THREADS = config["threads"]
SVDSS_BIN = config["bin"]
rule run:
input:
pjoin(ODIR, "svdss.vcf")
rule pp_index:
input:
fa = REF
output:
fmd = REF + ".fmd"
threads: 1
benchmark: pjoin(ODIR, "benchmark", "pp-index.txt")
shell:
"""
{SVDSS_BIN} index --fastq {input.fa} --index {output.fmd}
"""
rule pp_reconstruct:
input:
fa = REF,
bam = BAM
output:
bam = pjoin(ODIR, "smoothed.selective.bam")
params:
wd = pjoin(ODIR)
threads: THREADS
shell:
"""
{SVDSS_BIN} smooth --reference {input.fa} --bam {input.bam} --workdir {params.wd} --threads {threads}
"""
rule pp_sortreconstruct:
input:
bam = pjoin(ODIR, "smoothed.selective.bam")
output:
bam = pjoin(ODIR, "smoothed.selective.sorted.bam")
params:
sam = pjoin(ODIR, "reconstructed.sam"),
tmpd = pjoin(ODIR)
threads: 1
shell:
"""
samtools sort -T {output.bam}.sort-tmp {input.bam} > {output.bam}
samtools index {output.bam}
"""
rule pp_search:
input:
fmd = REF + ".fmd",
bam = pjoin(ODIR, "smoothed.selective.sorted.bam")
output:
sfs = pjoin(ODIR, "solution_batch_0.assembled.sfs")
params:
wd = pjoin(ODIR)
threads: THREADS
shell:
"""
{SVDSS_BIN} search --index {input.fmd} --bam {input.bam} --threads {threads} --workdir {params.wd} --assemble
"""
rule pp_call:
input:
fa = REF,
bam = pjoin(ODIR, "smoothed.selective.sorted.bam"),
sfs = pjoin(ODIR, "solution_batch_0.assembled.sfs")
output:
vcf = pjoin(ODIR, "svdss.vcf")
params:
wd = pjoin(ODIR)
threads: THREADS
shell:
"""
n=$(ls {params.wd}/solution_batch_*.assembled.sfs | wc -l)
{SVDSS_BIN} call --reference {input.fa} --bam {input.bam} --threads {threads} --workdir {params.wd} --batches ${{n}}
bcftools sort {params.wd}/svs_poa.vcf > {output.vcf}
"""