mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-13 05:13:09 +00:00
Add spades module (#277)
* Add spades module * Reorder gatk4 modules alphabetically * Update software/spades/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
313241749c
commit
72e81d6e90
6 changed files with 325 additions and 7 deletions
60
software/spades/functions.nf
Normal file
60
software/spades/functions.nf
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* -----------------------------------------------------
|
||||||
|
* Utility functions used in nf-core DSL2 module files
|
||||||
|
* -----------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extract name of software tool from process name using $task.process
|
||||||
|
*/
|
||||||
|
def getSoftwareName(task_process) {
|
||||||
|
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
|
||||||
|
*/
|
||||||
|
def initOptions(Map args) {
|
||||||
|
def Map options = [:]
|
||||||
|
options.args = args.args ?: ''
|
||||||
|
options.args2 = args.args2 ?: ''
|
||||||
|
options.args3 = args.args3 ?: ''
|
||||||
|
options.publish_by_id = args.publish_by_id ?: false
|
||||||
|
options.publish_dir = args.publish_dir ?: ''
|
||||||
|
options.publish_files = args.publish_files
|
||||||
|
options.suffix = args.suffix ?: ''
|
||||||
|
return options
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tidy up and join elements of a list to return a path string
|
||||||
|
*/
|
||||||
|
def getPathFromList(path_list) {
|
||||||
|
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
|
||||||
|
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
|
||||||
|
return paths.join('/')
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function to save/publish module results
|
||||||
|
*/
|
||||||
|
def saveFiles(Map args) {
|
||||||
|
if (!args.filename.endsWith('.version.txt')) {
|
||||||
|
def ioptions = initOptions(args.options)
|
||||||
|
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
|
||||||
|
if (ioptions.publish_by_id) {
|
||||||
|
path_list.add(args.publish_id)
|
||||||
|
}
|
||||||
|
if (ioptions.publish_files instanceof Map) {
|
||||||
|
for (ext in ioptions.publish_files) {
|
||||||
|
if (args.filename.endsWith(ext.key)) {
|
||||||
|
def ext_list = path_list.collect()
|
||||||
|
ext_list.add(ext.value)
|
||||||
|
return "${getPathFromList(ext_list)}/$args.filename"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ioptions.publish_files == null) {
|
||||||
|
return "${getPathFromList(path_list)}/$args.filename"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
69
software/spades/main.nf
Normal file
69
software/spades/main.nf
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process SPADES {
|
||||||
|
tag "$meta.id"
|
||||||
|
label 'process_high'
|
||||||
|
publishDir "${params.outdir}",
|
||||||
|
mode: params.publish_dir_mode,
|
||||||
|
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::spades=3.15.0" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/spades:3.15.0--h633aebb_0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/spades:3.15.0--h633aebb_0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(reads)
|
||||||
|
path hmm
|
||||||
|
val coronaspades
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path('*.scaffolds.fa') , optional:true, emit: scaffolds
|
||||||
|
tuple val(meta), path('*.contigs.fa') , optional:true, emit: contigs
|
||||||
|
tuple val(meta), path('*.transcripts.fa') , optional:true, emit: transcripts
|
||||||
|
tuple val(meta), path('*.gene_clusters.fa'), optional:true, emit: gene_clusters
|
||||||
|
tuple val(meta), path('*.assembly.gfa') , optional:true, emit: gfa
|
||||||
|
tuple val(meta), path('*.log') , emit: log
|
||||||
|
path '*.version.txt' , emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
def input_reads = meta.single_end ? "-s $reads" : "-1 ${reads[0]} -2 ${reads[1]}"
|
||||||
|
def custom_hmms = params.spades_hmm ? "--custom-hmms $hmm" : ""
|
||||||
|
def command = coronaspades ? "coronaspades.py" : "spades.py"
|
||||||
|
"""
|
||||||
|
$command \\
|
||||||
|
$options.args \\
|
||||||
|
--threads $task.cpus \\
|
||||||
|
$custom_hmms \\
|
||||||
|
$input_reads \\
|
||||||
|
-o ./
|
||||||
|
mv spades.log ${prefix}.spades.log
|
||||||
|
|
||||||
|
if [ -f scaffolds.fasta ]; then
|
||||||
|
mv scaffolds.fasta ${prefix}.scaffolds.fa
|
||||||
|
fi
|
||||||
|
if [ -f contigs.fasta ]; then
|
||||||
|
mv contigs.fasta ${prefix}.contigs.fa
|
||||||
|
fi
|
||||||
|
if [ -f transcripts.fasta ]; then
|
||||||
|
mv transcripts.fasta ${prefix}.transcripts.fa
|
||||||
|
fi
|
||||||
|
if [ -f assembly_graph_with_scaffolds.gfa ]; then
|
||||||
|
mv assembly_graph_with_scaffolds.gfa ${prefix}.assembly.gfa
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f gene_clusters.fasta ]; then
|
||||||
|
mv gene_clusters.fasta ${prefix}.gene_clusters.fa
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo \$(spades.py --version 2>&1) | sed 's/^.*SPAdes genome assembler v//; s/ .*\$//' > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
74
software/spades/meta.yml
Normal file
74
software/spades/meta.yml
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
name: spades
|
||||||
|
description: Assembles a small genome (bacterial, fungal, viral)
|
||||||
|
keywords:
|
||||||
|
- genome
|
||||||
|
- assembly
|
||||||
|
- genome assembler
|
||||||
|
- small genome
|
||||||
|
- de novo assembler
|
||||||
|
tools:
|
||||||
|
- spades:
|
||||||
|
description: SPAdes (St. Petersburg genome assembler) is intended for both standard isolates and single-cell MDA bacteria assemblies.
|
||||||
|
homepage: http://cab.spbu.ru/files/release3.15.0/manual.html
|
||||||
|
documentation: http://cab.spbu.ru/files/release3.15.0/manual.html
|
||||||
|
tool_dev_url: https://github.com/ablab/spades
|
||||||
|
doi: 10.1089/cmb.2012.0021
|
||||||
|
licence: ['GPL v2']
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- reads:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
List of input FastQ files of size 1 and 2 for single-end and paired-end data,
|
||||||
|
respectively.
|
||||||
|
- hmm:
|
||||||
|
type: file
|
||||||
|
description:
|
||||||
|
File or directory with amino acid HMMs for Spades HMM-guided mode.
|
||||||
|
- coronaspades:
|
||||||
|
type: boolean
|
||||||
|
description: |
|
||||||
|
Run coronaspades instead of default spades mode. coronaSPAdes is a special
|
||||||
|
mode of rnaviralSPAdes specifically aimed for SARS-CoV-2 de novo assembly.
|
||||||
|
output:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- scaffolds:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
Fasta file containing scaffolds
|
||||||
|
- contigs:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
Fasta file containing contigs
|
||||||
|
- transcripts:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
Fasta file containing transcripts
|
||||||
|
- gene_clusters:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
Fasta file containing gene_clusters
|
||||||
|
- gfa:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
gfa file containing assembly
|
||||||
|
- log:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
Spades log file
|
||||||
|
- version:
|
||||||
|
type: file
|
||||||
|
description: File containing software version
|
||||||
|
pattern: "*.{version.txt}"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@JoseEspinosa"
|
||||||
|
- "@drpatelh"
|
|
@ -144,6 +144,10 @@ gatk4_createsequencedictionary:
|
||||||
- software/gatk4/createsequencedictionary/**
|
- software/gatk4/createsequencedictionary/**
|
||||||
- tests/software/gatk4/createsequencedictionary/**
|
- tests/software/gatk4/createsequencedictionary/**
|
||||||
|
|
||||||
|
gatk4_mergebamalignment:
|
||||||
|
- software/gatk4/mergebamalignment/**
|
||||||
|
- tests/software/gatk4/mergebamalignment/**
|
||||||
|
|
||||||
gatk4_mergevcfs:
|
gatk4_mergevcfs:
|
||||||
- software/gatk4/mergevcfs/**
|
- software/gatk4/mergevcfs/**
|
||||||
- tests/software/gatk4/mergevcfs/**
|
- tests/software/gatk4/mergevcfs/**
|
||||||
|
@ -160,6 +164,10 @@ gatk4_splitncigarreads:
|
||||||
- software/gatk4/splitncigarreads/**
|
- software/gatk4/splitncigarreads/**
|
||||||
- tests/software/gatk4/splitncigarreads/**
|
- tests/software/gatk4/splitncigarreads/**
|
||||||
|
|
||||||
|
gatk4_variantfiltration:
|
||||||
|
- software/gatk4/variantfiltration/**
|
||||||
|
- tests/software/gatk4/variantfiltration/**
|
||||||
|
|
||||||
gffread:
|
gffread:
|
||||||
- software/gffread/**
|
- software/gffread/**
|
||||||
- tests/software/gffread/**
|
- tests/software/gffread/**
|
||||||
|
@ -289,6 +297,10 @@ seqwish_induce:
|
||||||
- software/seqwish/induce/**
|
- software/seqwish/induce/**
|
||||||
- tests/software/seqwish/induce/**
|
- tests/software/seqwish/induce/**
|
||||||
|
|
||||||
|
spades:
|
||||||
|
- software/spades/**
|
||||||
|
- tests/software/spades/**
|
||||||
|
|
||||||
star_align:
|
star_align:
|
||||||
- software/star/align/**
|
- software/star/align/**
|
||||||
- tests/software/star/align/**
|
- tests/software/star/align/**
|
||||||
|
@ -325,10 +337,3 @@ untar:
|
||||||
- software/untar/**
|
- software/untar/**
|
||||||
- tests/software/untar/**
|
- tests/software/untar/**
|
||||||
|
|
||||||
gatk4_mergebamalignment:
|
|
||||||
- software/gatk4/mergebamalignment/**
|
|
||||||
- tests/software/gatk4/mergebamalignment/**
|
|
||||||
|
|
||||||
gatk4_variantfiltration:
|
|
||||||
- software/gatk4/variantfiltration/**
|
|
||||||
- tests/software/gatk4/variantfiltration/**
|
|
||||||
|
|
52
tests/software/spades/main.nf
Normal file
52
tests/software/spades/main.nf
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { SPADES } from '../../../software/spades/main.nf' addParams( spades_hmm: false ,options: [:] )
|
||||||
|
|
||||||
|
workflow test_spades_single_end {
|
||||||
|
|
||||||
|
def input = []
|
||||||
|
def hmm = []
|
||||||
|
def coronaspades = false
|
||||||
|
input = [ [ id:'test', single_end:true ], // meta map
|
||||||
|
[ file("${launchDir}/tests/data/generic/fastq/test_R1.fastq.gz", checkIfExists: true) ] ]
|
||||||
|
|
||||||
|
SPADES ( input, hmm, coronaspades )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_spades_paired_end {
|
||||||
|
|
||||||
|
def input = []
|
||||||
|
def hmm = []
|
||||||
|
def coronaspades = false
|
||||||
|
input = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
[ file("${launchDir}/tests/data/generic/fastq/test_R1.fastq.gz", checkIfExists: true),
|
||||||
|
file("${launchDir}/tests/data/generic/fastq/test_R2.fastq.gz", checkIfExists: true) ] ]
|
||||||
|
|
||||||
|
SPADES ( input, hmm, coronaspades )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_coronospades_single_end {
|
||||||
|
|
||||||
|
def input = []
|
||||||
|
input = [ [ id:'test', single_end:true ], // meta map
|
||||||
|
[ file("${launchDir}/tests/data/genomics/sarscov2/fastq/test_1.fastq.gz", checkIfExists: true) ] ]
|
||||||
|
def hmm = []
|
||||||
|
def coronaspades = true
|
||||||
|
|
||||||
|
SPADES ( input, hmm, coronaspades )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_coronospades_paired_end {
|
||||||
|
|
||||||
|
def input = []
|
||||||
|
def hmm = []
|
||||||
|
def coronaspades = true
|
||||||
|
input = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
[ file("${launchDir}/tests/data/genomics/sarscov2/fastq/test_1.fastq.gz", checkIfExists: true),
|
||||||
|
file("${launchDir}/tests/data/genomics/sarscov2/fastq/test_2.fastq.gz", checkIfExists: true) ] ]
|
||||||
|
|
||||||
|
SPADES ( input, hmm, coronaspades )
|
||||||
|
}
|
||||||
|
|
58
tests/software/spades/test.yml
Normal file
58
tests/software/spades/test.yml
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
- name: spades single end
|
||||||
|
command: nextflow run ./tests/software/spades -entry test_spades_single_end -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- spades
|
||||||
|
- spades_single_end
|
||||||
|
files:
|
||||||
|
- path: output/spades/test.assembly.gfa
|
||||||
|
md5sum: f15ad4a198324de37c6010dafb3fe781
|
||||||
|
- path: output/spades/test.contigs.fa
|
||||||
|
md5sum: bc21771042b465c26dfc85beedc33d58
|
||||||
|
- path: output/spades/test.scaffolds.fa
|
||||||
|
md5sum: bc21771042b465c26dfc85beedc33d58
|
||||||
|
- path: output/spades/test.spades.log
|
||||||
|
- path: output/spades/warnings.log
|
||||||
|
|
||||||
|
- name: spades paired end
|
||||||
|
command: nextflow run ./tests/software/spades -entry test_spades_paired_end -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- spades
|
||||||
|
- spades_paired_end
|
||||||
|
files:
|
||||||
|
- path: output/spades/test.assembly.gfa
|
||||||
|
md5sum: 5da5b04c6fce549c77a209034a9c1e72
|
||||||
|
- path: output/spades/test.contigs.fa
|
||||||
|
md5sum: 403b612d52edf390f662ab601873f09f
|
||||||
|
- path: output/spades/test.scaffolds.fa
|
||||||
|
md5sum: 49a9cbb29cee4d088e05e62eb4bc77c4
|
||||||
|
- path: output/spades/test.spades.log
|
||||||
|
- path: output/spades/warnings.log
|
||||||
|
|
||||||
|
- name: coronaspades single end
|
||||||
|
command: nextflow run ./tests/software/spades -entry test_coronospades_single_end -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- spades
|
||||||
|
- coronaspades_single_end
|
||||||
|
files:
|
||||||
|
- path: output/spades/test.assembly.gfa
|
||||||
|
md5sum: 46531ec9b845c1a1cb469627688fecb7
|
||||||
|
- path: output/spades/test.contigs.fa
|
||||||
|
md5sum: f2c4a48ebba560aa5c8fde04dbe905fc
|
||||||
|
- path: output/spades/test.scaffolds.fa
|
||||||
|
md5sum: f2c4a48ebba560aa5c8fde04dbe905fc
|
||||||
|
- path: output/spades/test.spades.log
|
||||||
|
|
||||||
|
- name: coronaspades paired end
|
||||||
|
command: nextflow run ./tests/software/spades -entry test_coronospades_single_end -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- spades
|
||||||
|
- coronaspades_paired_end
|
||||||
|
files:
|
||||||
|
- path: output/spades/test.assembly.gfa
|
||||||
|
md5sum: 46531ec9b845c1a1cb469627688fecb7
|
||||||
|
- path: output/spades/test.contigs.fa
|
||||||
|
md5sum: f2c4a48ebba560aa5c8fde04dbe905fc
|
||||||
|
- path: output/spades/test.scaffolds.fa
|
||||||
|
md5sum: f2c4a48ebba560aa5c8fde04dbe905fc
|
||||||
|
- path: output/spades/test.spades.log
|
||||||
|
|
Loading…
Reference in a new issue