Add artic guppyplex (#455)

* Adding artic guppyplex module

* Adding guppyplex tests

* Fix tests

* Correcting typo

* Fix lint

* Fix test

* Missing description

* Missing descriptions

* Update functions to last version as suggested

* Bump newest version of nanoplot
This commit is contained in:
Jose Espinosa-Carrasco 2021-04-27 16:57:34 +02:00 committed by GitHub
parent 789a799e41
commit d63ff4ba1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 199 additions and 4 deletions

View file

@ -0,0 +1,70 @@
/*
* -----------------------------------------------------
* 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_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) {
if (!args.filename.endsWith('.version.txt')) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
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"
}
}
}

View file

@ -0,0 +1,41 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process ARTIC_GUPPYPLEX {
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::artic=1.2.1" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/artic:1.2.1--py_0"
} else {
container "quay.io/biocontainers/artic:1.2.1--py_0"
}
input:
tuple val(meta), path(fastq_dir)
output:
tuple val(meta), path("*.fastq.gz"), emit: fastq
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
artic \\
guppyplex \\
$options.args \\
--directory $fastq_dir \\
--output ${prefix}.fastq
pigz -p $task.cpus *.fastq
echo \$(artic --version 2>&1) | sed 's/^.*artic //; s/ .*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,44 @@
name: artic_guppyplex
description: Aggregates fastq files with demultiplexed reads
keywords:
- artic
- aggregate
- demultiplexed reads
tools:
- artic:
description: ARTIC pipeline - a bioinformatics pipeline for working with virus sequencing data sequenced with nanopore
homepage: https://artic.readthedocs.io/en/latest/
documentation: https://artic.readthedocs.io/en/latest/
tool_dev_url: https://github.com/artic-network/fieldbioinformatics
doi: ""
licence: ['MIT']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- fastq_dir:
type: directory
description: Directory containing the fastq files with demultiplexed reads
pattern: "*"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- fastq:
type: file
description: Aggregated FastQ files
pattern: "*.{fastq.gz}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@joseespinosa"
- "@drpatelh"

View file

@ -11,11 +11,11 @@ process NANOPLOT {
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::nanoplot=1.32.1" : null)
conda (params.enable_conda ? "bioconda::nanoplot=1.36.1" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/nanoplot:1.32.1--py_0"
container "https://depot.galaxyproject.org/singularity/nanoplot:1.36.1--pyhdfd78af_0"
} else {
container "quay.io/biocontainers/nanoplot:1.32.1--py_0"
container "quay.io/biocontainers/nanoplot:1.36.1--pyhdfd78af_0"
}
input:

View file

@ -26,7 +26,7 @@ input:
- summary_txt:
type: file
description: |
List of sequenicng_summary.txt files from running basecalling.
List of sequencing_summary.txt files from running basecalling.
output:
- meta:
type: map

View file

@ -10,6 +10,10 @@ allelecounter:
- software/allelecounter/**
- tests/software/allelecounter/**
artic/guppyplex:
- software/artic/guppyplex/**
- tests/software/artic/guppyplex/**
bandage/image:
- software/bandage/image/**
- tests/software/bandage/image/**

View file

@ -0,0 +1,29 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { ARTIC_GUPPYPLEX } from '../../../../software/artic/guppyplex/main.nf' addParams( options: [:] )
process STAGE_FASTQ_DIR {
input:
tuple val(meta), path(fastq_file)
output:
tuple val(meta), path('fastq'), emit: fastq_dir
script:
"""
mkdir fastq
mv ${fastq_file} fastq
"""
}
workflow test_artic_guppyplex {
input = [ [ id:'test' ],
file(params.test_data['sarscov2']['nanopore']['test_fastq_gz'], checkIfExists: true) ]
STAGE_FASTQ_DIR ( input )
ARTIC_GUPPYPLEX ( STAGE_FASTQ_DIR.out.fastq_dir )
}

View file

@ -0,0 +1,7 @@
- name: artic guppyplex
command: nextflow run tests/software/artic/guppyplex -entry test_artic_guppyplex -c tests/config/nextflow.config
tags:
- artic
- artic/guppyplex
files:
- path: output/artic/test.fastq.gz