summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Foreman-Mackey <dfm@dfm.io>2024-05-02 12:26:17 -0400
committerGitHub <noreply@github.com>2024-05-02 18:26:17 +0200
commit5542fa3ba3198e158bb47ce8687d1c7b62b1b507 (patch)
tree3151703a4e8b754b160cf08990e27a999ee4442c
parent155a960a42e6d000d46f94d55407ceb3aff57c5b (diff)
Adding support for Snakemake (#1045)
-rw-r--r--languages.json7
-rw-r--r--tests/data/Snakefile67
2 files changed, 74 insertions, 0 deletions
diff --git a/languages.json b/languages.json
index 58b24c8..e41f361 100644
--- a/languages.json
+++ b/languages.json
@@ -1403,6 +1403,13 @@
"multi_line_comments": [["\\\"", "\\\""]],
"extensions": ["cs.st", "pck.st"]
},
+ "Snakemake": {
+ "line_comment": ["#"],
+ "doc_quotes": [["\\\"\\\"\\\"", "\\\"\\\"\\\""], ["'''", "'''"]],
+ "quotes": [["\\\"", "\\\""], ["'", "'"]],
+ "extensions": ["smk", "rules"],
+ "filenames": ["snakefile"]
+ },
"Solidity": {
"name": "Solidity",
"line_comment": ["//"],
diff --git a/tests/data/Snakefile b/tests/data/Snakefile
new file mode 100644
index 0000000..2ca6f52
--- /dev/null
+++ b/tests/data/Snakefile
@@ -0,0 +1,67 @@
+# 67 lines 50 code 4 comments 13 blanks
+"""
+A sample Snakefile for testing line counting
+"""
+
+SAMPLES = ["A", "B"]
+
+
+# This is a
+# multiline
+# comment
+rule all:
+ input:
+ "plots/quals.svg"
+
+
+'''Sometimes even some
+comments in single quote
+fences.'''
+rule bwa_map:
+ input:
+ "data/genome.fa", # Inline comments are also supported
+ "data/samples/{sample}.fastq"
+ output:
+ "mapped_reads/{sample}.bam"
+ shell:
+ "bwa mem {input} | samtools view -Sb - > {output}"
+
+
+rule samtools_sort:
+ input:
+ "mapped_reads/{sample}.bam"
+ output:
+ "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=SAMPLES),
+ bai=expand("sorted_reads/{sample}.bam.bai", sample=SAMPLES)
+ output:
+ "calls/all.vcf"
+ shell:
+ "bcftools mpileup -f {input.fa} {input.bam} | "
+ "bcftools call -mv - > {output}"
+
+
+rule plot_quals:
+ input:
+ "calls/all.vcf"
+ output:
+ "plots/quals.svg"
+ script:
+ "scripts/plot-quals.py"