-
Notifications
You must be signed in to change notification settings - Fork 719
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
Add snakemake module #3682
Merged
Merged
Add snakemake module #3682
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ed6e743
snakemake: Add module
adamrtalbot ddbf1d1
snakemake: Updates to testing and modules.
adamrtalbot 5dd6f6a
Add Snakemake nf-test
adamrtalbot 7ecc420
Add tag to snakemake nf-test
adamrtalbot 396a917
Bump snakemake version
adamrtalbot 4033bd6
Update snakemake nf-test with snap
adamrtalbot c024266
Select only relevant output channel in snakemake nf-test
adamrtalbot 10d348b
Prettier on nf_test_modules.yml
adamrtalbot 89250c6
Merge branch 'master' into snakemake_module
adamrtalbot c728fa7
Apply suggestions from code review
adamrtalbot 730174f
Apply suggestions from code review
adamrtalbot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
process SNAKEMAKE { | ||
tag "$meta.id" | ||
label 'process_low' | ||
|
||
// You will have to add all modules to this Conda definition and | ||
// replace the container definition for one that suits your needs | ||
conda "bioconda::snakemake=7.31.0" | ||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://depot.galaxyproject.org/singularity/snakemake:7.31.0--hdfd78af_1' : | ||
'biocontainers/snakemake:7.31.0--hdfd78af_1' }" | ||
|
||
input: | ||
tuple val(meta), path(inputs) | ||
tuple val(meta2), path(snakefile) | ||
|
||
output: | ||
tuple val(meta), path("**[!.snakemake]"), optional: true , emit: outputs | ||
tuple val(meta), path(".snakemake", type: 'dir', hidden: true), emit: snakemake_dir | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def args = task.ext.args ?: '' | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
def cores = task.cpus ? "--cores ${task.cpus}" : "--cores all" | ||
""" | ||
snakemake \\ | ||
$args \\ | ||
$cores \\ | ||
--snakefile $snakefile | ||
|
||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
snakemake: \$(snakemake --version) | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def args = task.ext.args ?: '' | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
def cores = task.cpus ? "--cores ${task.cpus}" : "--cores all" | ||
""" | ||
snakemake \\ | ||
$args \\ | ||
--snakefile $snakefile \\ | ||
$cores \\ | ||
--dry-run | ||
|
||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
snakemake: \$(snakemake --version) | ||
END_VERSIONS | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/yaml-schema.json | ||
name: "snakemake" | ||
description: The Snakemake workflow management system is a tool to create reproducible and scalable data analyses. This module runs a simple Snakemake pipeline based on input snakefile. Expect many limitations." | ||
keywords: | ||
- snakemake | ||
- workflow | ||
- workflow_mode | ||
tools: | ||
- "snakemake": | ||
description: "A popular workflow management system aiming at full in-silico reproducibility." | ||
homepage: "https://snakemake.readthedocs.io/en/stable/" | ||
documentation: "https://snakemake.readthedocs.io/en/stable/" | ||
tool_dev_url: "https://github.com/snakemake/snakemake" | ||
doi: "10.1093/bioinformatics/bty350" | ||
licence: "['MIT']" | ||
|
||
input: | ||
# Only when we have meta | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false ] | ||
- bam: | ||
type: file | ||
description: Any input file required by Snakemake | ||
pattern: "*" | ||
- meta2: | ||
type: map | ||
description: | | ||
Meta information for Snakefile | ||
e.g. [ id: 'snakefile' ] | ||
- snakefile: | ||
type: file | ||
description: | | ||
Snakefile to use with Snakemake. This is required for proper execution of Snakemake. | ||
|
||
output: | ||
#Only when we have meta | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false ] | ||
- outputs: | ||
type: file | ||
description: | | ||
Any file generated by Snakemake, excluding the inputs, hidden files and Snakemake log directory (.snakemake). This is set to optional because Snakemake can be used to run arbitrary commands, and we cannot know what files will be generated. | ||
- snakemake_dir: | ||
type: directory | ||
description: | | ||
Snakemake log directory (.snakemake). Can be used to capture logs of Snakemake execution. | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
|
||
authors: | ||
- "@adamrtalbot" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
fastqc: | ||
- modules/nf-core/fastqc/** | ||
- tests/modules/nf-core/fastqc/** | ||
|
||
snakemake: | ||
- modules/nf-core/snakemake/** | ||
- tests/modules/nf-core/snakemake/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
rule all: | ||
input: "hello.txt" | ||
|
||
rule hello_world: | ||
output: "hello.txt" | ||
shell: "echo Hello World > hello.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env nextflow | ||
|
||
nextflow.enable.dsl = 2 | ||
|
||
include { SNAKEMAKE } from '../../../../modules/nf-core/snakemake/main.nf' | ||
|
||
workflow test_snakemake { | ||
|
||
input = [ | ||
[ id: 'input'], | ||
[] | ||
] | ||
|
||
// This generates a Snakefile for use with Snakemake. | ||
// In real use, you should probably access this via a | ||
// a file stored within the repository. | ||
Channel.of(''' | ||
rule all: | ||
input: "hello.txt" | ||
|
||
rule hello_world: | ||
output: "hello.txt" | ||
shell: "echo Hello World > hello.txt" | ||
|
||
''' | ||
) | ||
.collectFile(name: 'Snakefile') | ||
.map { file -> | ||
[ | ||
[id: 'Snakefile'], | ||
file | ||
]} | ||
.set{ snakefile } | ||
|
||
SNAKEMAKE ( input, snakefile) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
nextflow_process { | ||
|
||
name "Test Process SNAKEMAKE" | ||
script "modules/nf-core/snakemake/main.nf" | ||
process "SNAKEMAKE" | ||
tag "snakemake" | ||
|
||
test("Should run without failures") { | ||
|
||
when { | ||
process { | ||
""" | ||
// Input file | ||
input[0] = [ | ||
[ id: 'input'], | ||
[] | ||
] | ||
// Snakefile | ||
Channel.of(''' | ||
rule all: | ||
input: "hello.txt" | ||
|
||
rule hello_world: | ||
output: "hello.txt" | ||
shell: "echo Hello World > hello.txt" | ||
|
||
''' | ||
) | ||
.collectFile(name: 'Snakefile') | ||
.map { file -> | ||
[ | ||
[id: 'Snakefile'], | ||
file | ||
]} | ||
.set{ snakefile } | ||
|
||
input[1] = snakefile | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assert process.success | ||
assert snapshot(process.out.ouputs).match() | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"Should run without failures": { | ||
"content": null, | ||
"timestamp": "2023-07-31T09:50:07+0000" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
process { | ||
|
||
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
- name: snakemake test_snakemake | ||
command: nextflow run ./tests/modules/nf-core/snakemake -entry test_snakemake -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/snakemake/nextflow.config | ||
tags: | ||
- snakemake | ||
files: | ||
- path: output/snakemake/.snakemake/ | ||
- path: output/snakemake/hello.txt | ||
md5sum: e59ff97941044f85df5297e1c302d260 | ||
- path: output/snakemake/versions.yml | ||
|
||
- name: snakemake test_snakemake_stub | ||
command: nextflow run ./tests/modules/nf-core/snakemake -entry test_snakemake -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/snakemake/nextflow.config -stub | ||
tags: | ||
- snakemake | ||
files: | ||
- path: output/snakemake/.snakemake/ | ||
- path: output/snakemake/versions.yml |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamrtalbot you didn't fix it before you merged!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no! I thought I had. Hotfix coming in...