Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create independent Snakemake language #6270

Merged
merged 16 commits into from
Mar 8, 2023
17 changes: 15 additions & 2 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5292,7 +5292,6 @@ Python:
- ".pyt"
- ".pyw"
- ".rpy"
- ".smk"
- ".spec"
- ".tac"
- ".wsgi"
Expand All @@ -5302,7 +5301,6 @@ Python:
- DEPS
- SConscript
- SConstruct
- Snakefile
- wscript
interpreters:
- python
Expand Down Expand Up @@ -6411,6 +6409,21 @@ Smithy:
extensions:
- ".smithy"
language_id: 1027892786
Snakemake:
type: programming
group: Python
tm_scope: source.python
ace_mode: python
codemirror_mode: python
codemirror_mime_type: text/x-python
color: "#33c68a"
extensions:
- ".smk"
- ".snakefile"
filenames:
- Snakefile
SilasK marked this conversation as resolved.
Show resolved Hide resolved
aliases:
- snakefile
SilasK marked this conversation as resolved.
Show resolved Hide resolved
Solidity:
type: programming
color: "#AA6746"
Expand Down
70 changes: 70 additions & 0 deletions samples/Snakemake/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
configfile: "config.yaml"


rule all:
input:
"plots/quals.svg"


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=r"@RG\tID:{sample}\tSM:{sample}"
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:
protected("sorted_reads/{sample}.bam")
shell:
"samtools sort -T sorted_reads/{wildcards.sample} "
"-O bam {input} > {output}"


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


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"
params:
rate=config["prior_mutation_rate"]
log:
"logs/bcftools_call/all.log"
shell:
"(bcftools mpileup -f {input.fa} {input.bam} | "
"bcftools call -mv -P {params.rate} - > {output}) 2> {log}"


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