forked from nf-core/modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new module: samtools/consensus (nf-core#6064)
* Add new module: samtools/consensus * Update modules/nf-core/samtools/consensus/main.nf Co-authored-by: Simon Pearce <[email protected]> * add thread option * Add more test modes to the test * Update modules/nf-core/samtools/consensus/main.nf Co-authored-by: Simon Pearce <[email protected]> * Update modules/nf-core/samtools/consensus/main.nf Co-authored-by: Simon Pearce <[email protected]> * Update modules/nf-core/samtools/consensus/main.nf Co-authored-by: Simon Pearce <[email protected]> * Update modules/nf-core/samtools/consensus/main.nf Co-authored-by: Simon Pearce <[email protected]> * update snapshot of the test --------- Co-authored-by: Simon Pearce <[email protected]>
- Loading branch information
1 parent
416e4b8
commit 4133cae
Showing
8 changed files
with
431 additions
and
0 deletions.
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,9 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
name: "samtools_consensus" | ||
channels: | ||
- conda-forge | ||
- bioconda | ||
- defaults | ||
dependencies: | ||
- "bioconda::samtools=1.20" |
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 @@ | ||
process SAMTOOLS_CONSENSUS { | ||
tag "$meta.id" | ||
label 'process_low' | ||
|
||
conda "${moduleDir}/environment.yml" | ||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://depot.galaxyproject.org/singularity/samtools:1.20--h50ea8bc_1': | ||
'biocontainers/samtools:1.20--h50ea8bc_1' }" | ||
|
||
input: | ||
tuple val(meta), path(input) | ||
|
||
output: | ||
tuple val(meta), path("*.fasta") , emit: fasta , optional: true | ||
tuple val(meta), path("*.fastq") , emit: fastq , optional: true | ||
tuple val(meta), path("*.pileup"), emit: pileup, optional: true | ||
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 extension = args.contains("-f fastq") ? "fastq" : | ||
args.contains("-f pileup") ? "pileup" : | ||
args.contains("-f fasta") ? "fasta" : | ||
"fasta" | ||
|
||
""" | ||
samtools \\ | ||
consensus \\ | ||
$args \\ | ||
-@ $task.cpus \\ | ||
-o ${prefix}.${extension} \\ | ||
$input | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
samtools: \$(samtools --version |& sed '1!d ; s/samtools //') | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def args = task.ext.args ?: '' | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
def extension = args.contains("-f fastq") ? "fastq" : | ||
args.contains("-f pileup") ? "pileup" : | ||
args.contains("-f fasta") ? "fasta" : | ||
"fasta" | ||
|
||
""" | ||
touch ${prefix}.${extension} | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
samtools: \$(samtools --version |& sed '1!d ; s/samtools //') | ||
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,54 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json | ||
name: "samtools_consensus" | ||
description: Produces a consensus FASTA/FASTQ/PILEUP | ||
keywords: | ||
- consensus | ||
- bam | ||
- fastq | ||
- fasta | ||
- pileup | ||
tools: | ||
- samtools: | ||
description: | | ||
SAMtools is a set of utilities for interacting with and post-processing | ||
short DNA sequence read alignments in the SAM, BAM and CRAM formats, written by Heng Li. | ||
These files are generated as output by short read aligners like BWA. | ||
homepage: http://www.htslib.org/ | ||
documentation: http://www.htslib.org/doc/samtools.html | ||
tool_dev_url: "https://github.com/samtools/samtools" | ||
doi: "10.1093/bioinformatics/btp352" | ||
licence: ["MIT"] | ||
|
||
input: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'sample1', single_end:false ]` | ||
- input: | ||
type: file | ||
description: Sorted BAM/CRAM/SAM file | ||
pattern: "*.{bam,cram,sam}" | ||
|
||
output: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'sample1', single_end:false ]` | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
- output: | ||
type: file | ||
description: Consensus sequences | ||
pattern: "*.{fasta,fastq,pileup}" | ||
|
||
authors: | ||
- "@LilyAnderssonLee" | ||
maintainers: | ||
- "@LilyAnderssonLee" |
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 { | ||
withName: SAMTOOLS_CONSENSUS { | ||
ext.args2 = '-f fastq' | ||
} | ||
} |
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,106 @@ | ||
nextflow_process { | ||
|
||
name "Test Process SAMTOOLS_CONSENSUS" | ||
script "../main.nf" | ||
process "SAMTOOLS_CONSENSUS" | ||
|
||
tag "modules" | ||
tag "modules_nfcore" | ||
tag "samtools" | ||
tag "samtools/consensus" | ||
|
||
test("sarscov2 - bam - fasta") { | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] = Channel.of([ | ||
[id: 'test', single_end: false], // meta map | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true) | ||
]) | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot(process.out).match() } | ||
) | ||
} | ||
|
||
} | ||
test("sarscov2 - bam - fastq") { | ||
|
||
config "./fastq.config" | ||
when { | ||
process { | ||
""" | ||
input[0] = Channel.of([ | ||
[id: 'test', single_end: false], // meta map | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true) | ||
]) | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot(process.out).match() } | ||
) | ||
} | ||
|
||
} | ||
test("sarscov2 - bam - pileup") { | ||
|
||
config "./pileup.config" | ||
when { | ||
process { | ||
""" | ||
input[0] = Channel.of([ | ||
[id: 'test', single_end: false], // meta map | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true) | ||
]) | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot(process.out).match() } | ||
) | ||
} | ||
|
||
} | ||
|
||
test("sarscov2 - bam - stub") { | ||
|
||
options "-stub" | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] = Channel.of([ | ||
[id: 'test', single_end: false], // meta map | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true) | ||
]) | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot(process.out).match() } | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.