generated from ngs-docs/2022-ggg-201b-hw1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Snakefile
48 lines (43 loc) · 1.27 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
rule download_genome:
output: "ecoli-rel606.fa.gz"
shell:
"wget https://osf.io/8sm92/download -O {output}"
rule map_reads:
input: ref="ecoli-rel606.fa.gz", reads="{sample}.fastq.gz"
output: "{sample}.x.ecoli-rel606.sam"
shell: """
minimap2 -ax sr {input.ref} {input.reads} > {output}
"""
rule sam_to_bam:
input: "{sample}.x.ecoli-rel606.sam"
output: "{sample}.x.ecoli-rel606.bam"
shell: """
samtools view -b -F 4 {input} > {output}
"""
rule sort_bam:
input: "{sample}.x.ecoli-rel606.bam"
output: "{sample}.x.ecoli-rel606.bam.sorted"
shell: """
samtools sort {input} > {output}
"""
rule gunzip_fa:
input:
"ecoli-rel606.fa.gz"
output:
"ecoli-rel606.fa"
shell: """
gunzip -c {input} > {output}
"""
rule call_variants:
input:
ref="ecoli-rel606.fa",
bamsort="{sample}.x.ecoli-rel606.bam.sorted"
output:
pileup="{sample}.x.ecoli-rel606.pileup",
bcf="{sample}.x.ecoli-rel606.bcf",
vcf="{sample}.x.ecoli-rel606.vcf"
shell: """
bcftools mpileup -Ou -f {input.ref} {input.bamsort} > {output.pileup}
bcftools call -mv -Ob {output.pileup} -o {output.bcf}
bcftools view {output.bcf} > {output.vcf}
"""