Skip to content

Commit

Permalink
Merge pull request #777 from dfm/snakemake
Browse files Browse the repository at this point in the history
Adding support for Snakemake, #777
  • Loading branch information
AlDanial committed Oct 20, 2023
2 parents 713d067 + 523f733 commit b7e76ec
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Unix/t/00_C.t
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,11 @@ my @Tests = (
'ref' => '../tests/outputs/captcha.cs.yaml',
'args' => '../tests/inputs/captcha.cs',
},
{
'name' => 'Snakemake',
'ref' => '../tests/outputs/Snakefile.yaml',
'args' => '../tests/inputs/Snakefile',
},
{
'name' => 'Smarty',
'ref' => '../tests/outputs/guestbook.tpl.yaml',
Expand Down
11 changes: 11 additions & 0 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -8806,6 +8806,8 @@ sub set_constants { # {{{1
'data.sql' => 'SQL Data' ,
'sss' => 'SugarSS' ,
'st' => 'Smalltalk' ,
'rules' => 'Snakemake' ,
'smk' => 'Snakemake' ,
'styl' => 'Stylus' ,
'i' => 'SWIG' ,
'svelte' => 'Svelte' ,
Expand Down Expand Up @@ -9111,6 +9113,7 @@ sub set_constants { # {{{1
'pom.xml' => 'Maven/XML' ,
'Rakefile' => 'Ruby' ,
'rakefile' => 'Ruby' ,
'Snakefile' => 'Snakemake' ,
'Dockerfile' => 'Dockerfile' ,
'Dockerfile.m4' => 'Dockerfile' ,
'Dockerfile.cmake' => 'Dockerfile' ,
Expand Down Expand Up @@ -10338,6 +10341,12 @@ sub set_constants { # {{{1
[ 'smarty_to_C' ],
[ 'call_regexp_common' , 'C' ],
],
'Snakemake' => [
[ 'remove_matches' , '^\s*#' ],
[ 'docstring_to_C' ],
[ 'call_regexp_common' , 'C' ],
[ 'remove_inline' , '#.*$' ],
],
'Standard ML' => [
[ 'remove_between_general', '(*', '*)' ],
],
Expand Down Expand Up @@ -10762,6 +10771,7 @@ sub set_constants { # {{{1
'kvlang' => '\\\\$' ,
'Kermit' => '\\\\$' ,
'Korn Shell' => '\\\\$' ,
'Snakemake' => '\\\\$' ,
'Starlark' => '\\\\$' ,
'Solidity' => '\\\\$' ,
'Stata' => '///$' ,
Expand Down Expand Up @@ -11263,6 +11273,7 @@ sub set_constants { # {{{1
'PHP' => 3.50,
'Jupyter Notebook' => 4.20,
'Python' => 4.20,
'Snakemake' => 4.20,
'RapydScript' => 4.20,
'Starlark' => 4.20,
'BizTalk Pipeline' => 1.00,
Expand Down
63 changes: 63 additions & 0 deletions tests/inputs/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""
A sample Snakefile for testing line counting
"""

SAMPLES = ["A", "B"]


# This is a
# multiline
# comment
rule all:
input:
"plots/quals.svg"


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"
19 changes: 19 additions & 0 deletions tests/outputs/Snakefile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 1.99
elapsed_seconds : 0.039093017578125
n_files : 1
n_lines : 63
files_per_second : 25.5800156128025
lines_per_second : 1611.54098360656
'Snakemake' :
nFiles: 1
blank: 13
comment: 6
code: 44
SUM:
blank: 13
comment: 6
code: 44
nFiles: 1

0 comments on commit b7e76ec

Please sign in to comment.