mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Prodigal (#333)
* WIP add prodigal * Implement module and add tests * Fix EC lint
This commit is contained in:
parent
ee90e7af77
commit
e33860a2e8
6 changed files with 184 additions and 0 deletions
60
software/prodigal/functions.nf
Normal file
60
software/prodigal/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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
46
software/prodigal/main.nf
Normal file
46
software/prodigal/main.nf
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process PRODIGAL {
|
||||||
|
tag "$meta.id"
|
||||||
|
label 'process_low'
|
||||||
|
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::prodigal=2.6.3" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/prodigal:2.6.3--h516909a_2"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/prodigal:2.6.3--h516909a_2"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(genome)
|
||||||
|
val(output_format)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("${prefix}.${output_format}"), emit: gene_annotations
|
||||||
|
tuple val(meta), path("${prefix}.fna"), emit: nucleotide_fasta
|
||||||
|
tuple val(meta), path("${prefix}.faa"), emit: amino_acid_fasta
|
||||||
|
tuple val(meta), path("${prefix}_all.txt"), emit: all_gene_annotations
|
||||||
|
path "*.version.txt" , emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
"""
|
||||||
|
prodigal -i "${genome}" \\
|
||||||
|
$options.args \\
|
||||||
|
-f $output_format \\
|
||||||
|
-d "${prefix}.fna" \\
|
||||||
|
-o "${prefix}.${output_format}" \\
|
||||||
|
-a "${prefix}.faa" \\
|
||||||
|
-s "${prefix}_all.txt"
|
||||||
|
|
||||||
|
echo \$(prodigal -v 2>&1) | sed -n 's/Prodigal V\\(.*\\):.*/\\1/p' > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
47
software/prodigal/meta.yml
Normal file
47
software/prodigal/meta.yml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
name: prodigal
|
||||||
|
## TODO nf-core: Add a description of the module and list keywords
|
||||||
|
description: write your description here
|
||||||
|
keywords:
|
||||||
|
- sort
|
||||||
|
tools:
|
||||||
|
- prodigal:
|
||||||
|
## TODO nf-core: Add a description and other details for the software below
|
||||||
|
description: Prodigal (Prokaryotic Dynamic Programming Genefinding Algorithm) is a microbial (bacterial and archaeal) gene finding program
|
||||||
|
homepage: {}
|
||||||
|
documentation: {}
|
||||||
|
tool_dev_url: {}
|
||||||
|
doi: ""
|
||||||
|
licence: ['GPL v3']
|
||||||
|
|
||||||
|
## TODO nf-core: Add a description of all of the variables used as input
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
## TODO nf-core: Delete / customise this example input
|
||||||
|
- bam:
|
||||||
|
type: file
|
||||||
|
description: BAM/CRAM/SAM file
|
||||||
|
pattern: "*.{bam,cram,sam}"
|
||||||
|
|
||||||
|
## TODO nf-core: Add a description of all of the variables used as output
|
||||||
|
output:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- version:
|
||||||
|
type: file
|
||||||
|
description: File containing software version
|
||||||
|
pattern: "*.{version.txt}"
|
||||||
|
## TODO nf-core: Delete / customise this example output
|
||||||
|
- bam:
|
||||||
|
type: file
|
||||||
|
description: Sorted BAM/CRAM/SAM file
|
||||||
|
pattern: "*.{bam,cram,sam}"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@grst"
|
|
@ -299,6 +299,10 @@ preseq_lcextrap:
|
||||||
- software/preseq/lcextrap/**
|
- software/preseq/lcextrap/**
|
||||||
- tests/software/preseq/lcextrap/**
|
- tests/software/preseq/lcextrap/**
|
||||||
|
|
||||||
|
prodigal:
|
||||||
|
- software/prodigal/**
|
||||||
|
- tests/software/prodigal/**
|
||||||
|
|
||||||
prokka:
|
prokka:
|
||||||
- software/prokka/**
|
- software/prokka/**
|
||||||
- tests/software/prokka/**
|
- tests/software/prokka/**
|
||||||
|
|
14
tests/software/prodigal/main.nf
Normal file
14
tests/software/prodigal/main.nf
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { PRODIGAL } from '../../../software/prodigal/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_prodigal {
|
||||||
|
|
||||||
|
def input = []
|
||||||
|
input = [ [ id:'test' ], // meta map
|
||||||
|
file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta", checkIfExists: true) ]
|
||||||
|
|
||||||
|
PRODIGAL ( input , "gff")
|
||||||
|
}
|
13
tests/software/prodigal/test.yml
Normal file
13
tests/software/prodigal/test.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
- name: prodigal test_prodigal
|
||||||
|
command: nextflow run tests/software/prodigal -entry test_prodigal -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- prodigal
|
||||||
|
files:
|
||||||
|
- path: output/prodigal/test.fna
|
||||||
|
md5sum: 1bc8a05bcb72a3c324f5e4ffaa716d3b
|
||||||
|
- path: output/prodigal/test.gff
|
||||||
|
md5sum: 612c2724c2891c63350f171f74165757
|
||||||
|
- path: output/prodigal/test.faa
|
||||||
|
md5sum: 7168b854103f3586ccfdb71a44c389f7
|
||||||
|
- path: output/prodigal/test_all.txt
|
||||||
|
md5sum: e6d6c50f0c39e5169f84ae3c90837fa9
|
Loading…
Reference in a new issue