add prokka module (#298)

* add prokka module

* adjust test outputs

* fix prokka command

* adjust test outputs

* handle optional input

* update pytest

* update pytest

* adjust test outputs

* adjust test outputs

* switch to lists for optional inputs, add md5sums for non-timestamped outputs

* add optional prodigal training file

* add optional prodigal training info to meta yaml
This commit is contained in:
Robert A. Petit III 2021-03-23 05:51:23 -04:00 committed by GitHub
parent 1fc4aa260d
commit c2aa95cb6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 250 additions and 0 deletions

View 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"
}
}
}

56
software/prokka/main.nf Normal file
View file

@ -0,0 +1,56 @@
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process PROKKA {
tag "$meta.id"
label 'prokka'
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::prokka=1.14.6" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/prokka:1.14.6--pl526_0"
} else {
container "quay.io/biocontainers/prokka:1.14.6--pl526_0"
}
input:
tuple val(meta), path(fasta)
path proteins
path prodigal_tf
output:
tuple val(meta), path("${prefix}/*.gff"), emit: gff
tuple val(meta), path("${prefix}/*.gbk"), emit: gbk
tuple val(meta), path("${prefix}/*.fna"), emit: fna
tuple val(meta), path("${prefix}/*.faa"), emit: faa
tuple val(meta), path("${prefix}/*.ffn"), emit: ffn
tuple val(meta), path("${prefix}/*.sqn"), emit: sqn
tuple val(meta), path("${prefix}/*.fsa"), emit: fsa
tuple val(meta), path("${prefix}/*.tbl"), emit: tbl
tuple val(meta), path("${prefix}/*.err"), emit: err
tuple val(meta), path("${prefix}/*.log"), emit: log
tuple val(meta), path("${prefix}/*.txt"), emit: txt
tuple val(meta), path("${prefix}/*.tsv"), emit: tsv
path "*.version.txt", emit: version
script:
def software = getSoftwareName(task.process)
prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def proteins_opt = proteins ? "--proteins ${proteins[0]}" : ""
def prodigal_opt = prodigal_tf ? "--prodigaltf ${prodigal_tf[0]}" : ""
"""
prokka \\
$options.args \\
--cpus $task.cpus \\
--prefix $prefix \\
$proteins_opt \\
$prodigal_tf \\
$fasta
echo \$(prokka --version 2>&1) | sed 's/^.*prokka //' > ${software}.version.txt
"""
}

91
software/prokka/meta.yml Normal file
View file

@ -0,0 +1,91 @@
name: prokka
description: Whole genome annotation of small genomes (bacterial, archeal, viral)
keywords:
- annotation
- fasta
- prokka
tools:
- prokka:
description: Rapid annotation of prokaryotic genomes
homepage: https://github.com/tseemann/prokka
doi: "10.1093/bioinformatics/btu153"
licence: ['GPL v2']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- fasta:
type: file
description: |
FASTA file to be annotated. Has to contain at least a non-empty string dummy value.
- proteins:
type: file
description: FASTA file of trusted proteins to first annotate from (optional)
- prodigal_tf:
type: file
description: Training file to use for Prodigal (optional)
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}"
- gff:
type: file
description: annotation in GFF3 format, containing both sequences and annotations
pattern: "*.{gff}"
- gbk:
type: file
description: annotation in GenBank format, containing both sequences and annotations
pattern: "*.{gbk}"
- fna:
type: file
description: nucleotide FASTA file of the input contig sequences
pattern: "*.{fna}"
- faa:
type: file
description: protein FASTA file of the translated CDS sequences
pattern: "*.{faa}"
- ffn:
type: file
description: nucleotide FASTA file of all the prediction transcripts (CDS, rRNA, tRNA, tmRNA, misc_RNA)
pattern: "*.{ffn}"
- sqn:
type: file
description: an ASN1 format "Sequin" file for submission to Genbank
pattern: "*.{sqn}"
- fsa:
type: file
description: nucleotide FASTA file of the input contig sequences, used by "tbl2asn" to create the .sqn file
pattern: "*.{fsa}"
- tbl:
type: file
description: feature Table file, used by "tbl2asn" to create the .sqn file
pattern: "*.{tbl}"
- err:
type: file
description: unacceptable annotations - the NCBI discrepancy report.
pattern: "*.{err}"
- log:
type: file
description: contains all the output that Prokka produced during its run
pattern: "*.{log}"
- txt:
type: file
description: statistics relating to the annotated features found
pattern: "*.{txt}"
- tsv:
type: file
description: tab-separated file of all features (locus_tag,ftype,len_bp,gene,EC_number,COG,product)
pattern: "*.{tsv}"
authors:
- "@rpetit3"

View file

@ -283,6 +283,10 @@ preseq_lcextrap:
- software/preseq/lcextrap/** - software/preseq/lcextrap/**
- tests/software/preseq/lcextrap/** - tests/software/preseq/lcextrap/**
prokka:
- software/prokka/**
- tests/software/prokka/**
qualimap_bamqc: qualimap_bamqc:
- software/qualimap/bamqc/** - software/qualimap/bamqc/**
- tests/software/qualimap/bamqc/** - tests/software/qualimap/bamqc/**

View file

@ -0,0 +1,12 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { PROKKA } from '../../../software/prokka/main.nf' addParams( options: [:] )
workflow test_prokka {
def input = []
input = [ [ id:'test', single_end:false ], // meta map
file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta", checkIfExists: true), ]
PROKKA ( input, [], [] )
}

View file

@ -0,0 +1,27 @@
- name: prokka
command: nextflow run ./tests/software/prokka -entry test_prokka -c tests/config/nextflow.config
tags:
- prokka
files:
- path: output/prokka/test/test.err
md5sum: b3daedc646fddd422824e2b3e5e9229d
- path: output/prokka/test/test.faa
md5sum: a4ceda83262b3c222a6b1f508fb9e24b
- path: output/prokka/test/test.ffn
md5sum: 80f474b5367b7ea5ed23791935f65e34
- path: output/prokka/test/test.fna
md5sum: 787307f29a263e5657cc276ebbf7e2b3
- path: output/prokka/test/test.fsa
md5sum: 71bbefcb7f12046bcd3263f58cfd5404
- path: output/prokka/test/test.gff
md5sum: 5dbfb8fcf2db020564c16045976a0933
- path: output/prokka/test/test.tbl
md5sum: d8f816a066ced94b62d9618b13fb8add
- path: output/prokka/test/test.tsv
md5sum: da7c720c3018c5081d6a70b517b7d450
- path: output/prokka/test/test.txt
md5sum: b40e485ffc8eaf1feacf8d79d9751a33
# Contain time stamps
- path: output/prokka/test/test.gbk
- path: output/prokka/test/test.log
- path: output/prokka/test/test.sqn