-
Notifications
You must be signed in to change notification settings - Fork 0
/
Snakefile
74 lines (65 loc) · 1.98 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
SAMPLES = ["SRR2584857_1"]
SUBSET_SAMPLES = ["SRR2584857_1", "SRR2584857_1.sub100k"]
GENOME = ["ecoli-rel606"]
rule make_vcf:
input:
expand("outputs/{sample}.x.{genome}.vcf",
sample=SAMPLES, genome=GENOME)
rule make_subset_vcf:
input:
expand("outputs/{sample}.x.{genome}.vcf",
sample=SUBSET_SAMPLES, genome=GENOME)
rule uncompress_genome:
input: "{genome}.fa.gz"
output: "outputs/{genome}.fa"
shell: """
gunzip -c {input} > {output}
"""
rule map_reads:
input:
reads="{reads}.fastq.gz",
ref="outputs/{genome}.fa"
output: "outputs/{reads}.x.{genome}.sam"
shell: """
minimap2 -ax sr {input.ref} {input.reads} > {output}
"""
rule sam_to_bam:
input: "outputs/{reads}.x.{genome}.sam",
output: "outputs/{reads}.x.{genome}.bam",
shell: """
samtools view -b {input} > {output}
"""
rule sort_bam:
input: "outputs/{reads}.x.{genome}.bam"
output: "outputs/{reads}.x.{genome}.bam.sorted"
shell: """
samtools sort {input} > {output}
"""
rule index_bam:
input: "outputs/{reads}.x.{genome}.bam.sorted"
output: "outputs/{reads}.x.{genome}.bam.sorted.bai"
shell: """
samtools index {input}
"""
rule call_variants:
input:
ref="outputs/{genome}.fa",
bam="outputs/{reads}.x.{genome}.bam.sorted",
bai="outputs/{reads}.x.{genome}.bam.sorted.bai",
output:
pileup="outputs/{reads}.x.{genome}.pileup",
bcf="outputs/{reads}.x.{genome}.bcf",
vcf="outputs/{reads}.x.{genome}.vcf",
shell: """
bcftools mpileup -Ou -f {input.ref} {input.bam} > {output.pileup}
bcftools call -mv -Ob {output.pileup} -o {output.bcf}
bcftools view {output.bcf} > {output.vcf}
"""
rule subset_sample_100k:
input:
"{sample}.fastq.gz",
output:
"{sample}.sub100k.fastq.gz",
shell: """
gunzip -c {input} | head -400000 | gzip -c > {output} || true
"""