add gatk4/fastqtosam #198 (#311)

* Inital nf-core create

* remove TODO comments, input and output files defined

* add get version in script

* added flow control for single/paired end data

* added script main commands

* removed completed TODO messages

* removed completed TODO messages

* added software info

* added input reads description

* added output description

* added description and keywords

* added single end test

* added paired end test

* fixed sample name flag

* fixed reverse read variable

* added test yaml

* update for pytest_software

* order in pytest_software was different

* replaced functions.nf with copy from another module

* simplify read command line

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

Co-authored-by: Nicholas TODA <nicholas.toda@mnhn.fr>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
Nicholas Toda 2021-03-22 19:26:02 +01:00 committed by GitHub
parent 0a4fa5050a
commit 53109d53c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 193 additions and 0 deletions

View file

@ -0,0 +1,59 @@
/*
* -----------------------------------------------------
* 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.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"
}
}
}

View file

@ -0,0 +1,40 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process GATK4_FASTQTOSAM {
tag "$meta.id"
label 'process_medium'
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::gatk4=4.2.0.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/gatk4:4.2.0.0--0"
} else {
container "quay.io/biocontainers/gatk4:4.2.0.0--0"
}
input:
tuple val(meta), path(reads)
output:
tuple val(meta), path("*.bam"), emit: bam
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def read_files = meta.single_end ? "-F1 $reads" : "-F1 ${reads[0]} -F2 ${reads[1]}"
"""
gatk FastqToSam \\
$read_files \\
-O ${prefix}.bam \\
-SM $prefix \\
$options.args
gatk --version | grep Picard | sed "s/Picard Version: //g" > ${software}.version.txt
"""
}

View file

@ -0,0 +1,47 @@
name: gatk4_fastqtosam
description: Converts FastQ file to BAM format
keywords:
- bam
- fastq
- convert
tools:
- gatk4:
description: Genome Analysis Toolkit (GATK4)
Developed in the Data Sciences Platform at the Broad Institute, the toolkit offers a wide variety of tools
with a primary focus on variant discovery and genotyping. Its powerful processing engine
and high-performance computing features make it capable of taking on projects of any size.
homepage: https://gatk.broadinstitute.org/hc/en-us
documentation: https://gatk.broadinstitute.org/hc/en-us/categories/360002369672s
tool_dev_url: https://github.com/broadinstitute/gatk
doi: "10.1158/1538-7445.AM2017-3590"
licence: ['BSD-3-clause']
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.
pattern: "*.fastq.gz"
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}"
- bam:
type: file
description: Converted BAM file
pattern: "*.bam"
authors:
- "@ntoda03"

View file

@ -178,6 +178,10 @@ gatk4_createsequencedictionary:
- software/gatk4/createsequencedictionary/**
- tests/software/gatk4/createsequencedictionary/**
gatk4_fastqtosam:
- software/gatk4/fastqtosam/**
- tests/software/gatk4/fastqtosam/**
gatk4_mergebamalignment:
- software/gatk4/mergebamalignment/**
- tests/software/gatk4/mergebamalignment/**

View file

@ -0,0 +1,24 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { GATK4_FASTQTOSAM } from '../../../../software/gatk4/fastqtosam/main.nf' addParams( options: [:] )
workflow test_gatk4_fastqtosam_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) ]
GATK4_FASTQTOSAM ( input )
}
workflow test_gatk4_fastqtosam_paired_end {
def input = []
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) ]
GATK4_FASTQTOSAM ( input )
}

View file

@ -0,0 +1,19 @@
- name: gatk4 fastqtosam test_gatk4_fastqtosam_single_end
command: nextflow run tests/software/gatk4/fastqtosam -entry test_gatk4_fastqtosam_single_end -c tests/config/nextflow.config
tags:
- gatk4_fastqtosam_single_end
- gatk4_fastqtosam
- gatk4
files:
- path: output/gatk4/test.bam
md5sum: 4967100b2e4912c0e4ce0976d946bafb
- name: gatk4 fastqtosam test_gatk4_fastqtosam_paired_end
command: nextflow run tests/software/gatk4/fastqtosam -entry test_gatk4_fastqtosam_paired_end -c tests/config/nextflow.config
tags:
- gatk4_fastqtosam_paired_end
- gatk4_fastqtosam
- gatk4
files:
- path: output/gatk4/test.bam
md5sum: 4967100b2e4912c0e4ce0976d946bafb