mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Add Racon module to nf-core/modules (#949)
* add racon * add racon * add racon * add racon module * add racon module * edit racon module * edit racon module * edit racon module * edit racon module Co-authored-by: Daniel Straub <42973691+d4straub@users.noreply.github.com> Co-authored-by: Chris Cheshire <chris.j.cheshire@gmail.com>
This commit is contained in:
parent
2959b4ba07
commit
977d96ed0b
8 changed files with 206 additions and 2 deletions
78
modules/racon/functions.nf
Normal file
78
modules/racon/functions.nf
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
//
|
||||||
|
// 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()
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extract name of module from process name using $task.process
|
||||||
|
//
|
||||||
|
def getProcessName(task_process) {
|
||||||
|
return task_process.tokenize(':')[-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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_meta = args.publish_by_meta ?: []
|
||||||
|
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) {
|
||||||
|
def ioptions = initOptions(args.options)
|
||||||
|
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
|
||||||
|
|
||||||
|
// Do not publish versions.yml unless running from pytest workflow
|
||||||
|
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (ioptions.publish_by_meta) {
|
||||||
|
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta
|
||||||
|
for (key in key_list) {
|
||||||
|
if (args.meta && key instanceof String) {
|
||||||
|
def path = key
|
||||||
|
if (args.meta.containsKey(key)) {
|
||||||
|
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key]
|
||||||
|
}
|
||||||
|
path = path instanceof String ? path : ''
|
||||||
|
path_list.add(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
45
modules/racon/main.nf
Normal file
45
modules/racon/main.nf
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process RACON {
|
||||||
|
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), meta:meta, publish_by_meta:['id']) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::racon=1.4.20" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/racon:1.4.20--h9a82719_1"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/racon:1.4.20--h9a82719_1"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(reads), path(assembly), path(paf)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path('*_assembly_consensus.fasta.gz') , emit: improved_assembly
|
||||||
|
path "versions.yml" , emit: versions
|
||||||
|
|
||||||
|
script:
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
"""
|
||||||
|
racon -t "${task.cpus}" \\
|
||||||
|
"${reads}" \\
|
||||||
|
"${paf}" \\
|
||||||
|
$options.args \\
|
||||||
|
"${assembly}" > \\
|
||||||
|
${prefix}_assembly_consensus.fasta
|
||||||
|
|
||||||
|
gzip -n ${prefix}_assembly_consensus.fasta
|
||||||
|
|
||||||
|
cat <<-END_VERSIONS > versions.yml
|
||||||
|
${getProcessName(task.process)}:
|
||||||
|
${getSoftwareName(task.process)}: \$( racon --version 2>&1 | sed 's/^.*v//' )
|
||||||
|
END_VERSIONS
|
||||||
|
"""
|
||||||
|
}
|
52
modules/racon/meta.yml
Normal file
52
modules/racon/meta.yml
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
name: racon
|
||||||
|
description: Consensus module for raw de novo DNA assembly of long uncorrected reads
|
||||||
|
keywords:
|
||||||
|
- assembly
|
||||||
|
- pacbio
|
||||||
|
- nanopore
|
||||||
|
- polish
|
||||||
|
tools:
|
||||||
|
- racon:
|
||||||
|
description: Ultrafast consensus module for raw de novo genome assembly of long uncorrected reads.
|
||||||
|
homepage: https://github.com/lbcb-sci/racon
|
||||||
|
documentation: https://github.com/lbcb-sci/racon
|
||||||
|
tool_dev_url: https://github.com/lbcb-sci/racon
|
||||||
|
doi: https://doi.org/10.1101/gr.214270.116
|
||||||
|
licence: ['MIT']
|
||||||
|
|
||||||
|
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. Racon expects single end reads
|
||||||
|
pattern: "*.{fastq,fastq.gz,fq,fq.gz}"
|
||||||
|
- assembly:
|
||||||
|
type: file
|
||||||
|
description: Genome assembly to be improved
|
||||||
|
pattern: "*.{fasta,fa}"
|
||||||
|
- paf:
|
||||||
|
type: file
|
||||||
|
description: Alignment in PAF format
|
||||||
|
pattern: "*.paf"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- versions:
|
||||||
|
type: file
|
||||||
|
description: File containing software versions
|
||||||
|
pattern: "versions.yml"
|
||||||
|
- improved_assembly:
|
||||||
|
type: file
|
||||||
|
description: Improved genome assembly
|
||||||
|
pattern: "*_assembly_consensus.fasta.gz"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@avantonder"
|
|
@ -923,6 +923,10 @@ quast:
|
||||||
- modules/quast/**
|
- modules/quast/**
|
||||||
- tests/modules/quast/**
|
- tests/modules/quast/**
|
||||||
|
|
||||||
|
racon:
|
||||||
|
- modules/racon/**
|
||||||
|
- tests/modules/racon/**
|
||||||
|
|
||||||
rapidnj:
|
rapidnj:
|
||||||
- modules/rapidnj/**
|
- modules/rapidnj/**
|
||||||
- tests/modules/rapidnj/**
|
- tests/modules/rapidnj/**
|
||||||
|
|
|
@ -11,6 +11,7 @@ params {
|
||||||
genome_gff3 = "${test_data_dir}/genomics/sarscov2/genome/genome.gff3"
|
genome_gff3 = "${test_data_dir}/genomics/sarscov2/genome/genome.gff3"
|
||||||
genome_gff3_gz = "${test_data_dir}/genomics/sarscov2/genome/genome.gff3.gz"
|
genome_gff3_gz = "${test_data_dir}/genomics/sarscov2/genome/genome.gff3.gz"
|
||||||
genome_gtf = "${test_data_dir}/genomics/sarscov2/genome/genome.gtf"
|
genome_gtf = "${test_data_dir}/genomics/sarscov2/genome/genome.gtf"
|
||||||
|
genome_paf = "${test_data_dir}/genomics/sarscov2/genome/genome.paf"
|
||||||
genome_sizes = "${test_data_dir}/genomics/sarscov2/genome/genome.sizes"
|
genome_sizes = "${test_data_dir}/genomics/sarscov2/genome/genome.sizes"
|
||||||
transcriptome_fasta = "${test_data_dir}/genomics/sarscov2/genome/transcriptome.fasta"
|
transcriptome_fasta = "${test_data_dir}/genomics/sarscov2/genome/transcriptome.fasta"
|
||||||
transcriptome_paf = "${test_data_dir}/genomics/sarscov2/genome/transcriptome.paf"
|
transcriptome_paf = "${test_data_dir}/genomics/sarscov2/genome/transcriptome.paf"
|
||||||
|
@ -243,6 +244,7 @@ params {
|
||||||
'bacteroides_fragilis'{
|
'bacteroides_fragilis'{
|
||||||
'genome' {
|
'genome' {
|
||||||
genome_fna_gz = "${test_data_dir}/genomics/bacteroides_fragilis/genome/genome.fna.gz"
|
genome_fna_gz = "${test_data_dir}/genomics/bacteroides_fragilis/genome/genome.fna.gz"
|
||||||
|
genome_paf = "${test_data_dir}/genomics/bacteroides_fragilis/genome/genome.paf"
|
||||||
}
|
}
|
||||||
'illumina' {
|
'illumina' {
|
||||||
test1_contigs_fa_gz = "${test_data_dir}/genomics/bacteroides_fragilis/illumina/fasta/test1.contigs.fa.gz"
|
test1_contigs_fa_gz = "${test_data_dir}/genomics/bacteroides_fragilis/illumina/fasta/test1.contigs.fa.gz"
|
||||||
|
@ -253,6 +255,7 @@ params {
|
||||||
}
|
}
|
||||||
'nanopore' {
|
'nanopore' {
|
||||||
test_fastq_gz = "${test_data_dir}/genomics/bacteroides_fragilis/nanopore/fastq/test.fastq.gz"
|
test_fastq_gz = "${test_data_dir}/genomics/bacteroides_fragilis/nanopore/fastq/test.fastq.gz"
|
||||||
|
overlap_paf = "${test_data_dir}/genomics/bacteroides_fragilis/nanopore/overlap.paf"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
15
tests/modules/racon/main.nf
Normal file
15
tests/modules/racon/main.nf
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { RACON } from '../../../modules/racon/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_racon {
|
||||||
|
input = [ [ id:'test', single_end:true ], // meta map
|
||||||
|
file(params.test_data['bacteroides_fragilis']['nanopore']['test_fastq_gz'], checkIfExists: true),
|
||||||
|
file(params.test_data['bacteroides_fragilis']['genome']['genome_fna_gz'], checkIfExists: true),
|
||||||
|
file(params.test_data['bacteroides_fragilis']['genome']['genome_paf'], checkIfExists: true)
|
||||||
|
]
|
||||||
|
|
||||||
|
RACON ( input )
|
||||||
|
}
|
7
tests/modules/racon/test.yml
Normal file
7
tests/modules/racon/test.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
- name: racon test_racon
|
||||||
|
command: nextflow run tests/modules/racon -entry test_racon -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- racon
|
||||||
|
files:
|
||||||
|
- path: output/racon/test_assembly_consensus.fasta.gz
|
||||||
|
md5sum: 96a0ba94c6154f6f37b5a76a0207eb6f
|
Loading…
Reference in a new issue