Skip to content

Commit

Permalink
feat: 10 with log directives
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeesters committed Apr 24, 2024
1 parent 69d6731 commit ab0f505
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions setup/solutions/10_Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
configfile: "config/config.yaml"

rule all:
input:
"plots/quals.svg",
"calls/all.vcf"


def get_bwa_map_input_fastqs(wildcards):
return config["samples"][wildcards.sample]

rule bwa_map:
input:
"data/genome.fa",
get_bwa_map_input_fastqs
output:
temp("mapped_reads/{sample}.bam")
params:
rg=config["bwa_map"]["rg"]
log: "logs/bwa_mem/{sample}.log"
threads: 8
shell:
"(bwa mem -R '{params.rg}' -t {threads} {input} | "
"samtools view -Sb - > {output}) 2> {log}"


rule samtools_sort:
input:
"mapped_reads/{sample}.bam"
output:
temp("sorted_reads/{sample}.bam")
log: "logs/samtools_sort/{sample}.log"
shell:
"samtools sort -T sorted_reads/{wildcards.sample} "
"-O bam {input} > {output} 2> {log}"


rule samtools_index:
input:
"sorted_reads/{sample}.bam"
output:
"sorted_reads/{sample}.bam.bai"
log: "logs/sorted_reads/{sample}.log
shell:
"samtools index {input} &> {log}"


rule bcftools_call:
input:
fa="data/genome.fa",
bam=expand("sorted_reads/{sample}.bam", sample=config["samples"]),
bai=expand("sorted_reads/{sample}.bam.bai", sample=config["samples"])
output:
"calls/all.vcf"
log: "logs/bcftools.log"
shell:
"(bcftools mpileup -f {input.fa} {input.bam} | "
"bcftools call -mv - > {output}) &> {log}"


rule plot_quals:
input:
"calls/all.vcf"
output:
"plots/quals.svg"
log: "logs/plot-quals.log"
script:
"scripts/plot-quals.py"

0 comments on commit ab0f505

Please # to comment.