New modules: Fgbio callmolecularconsensusreads and sortbam (#352)

* Added fgbio callmolecularconsensusreads and sortbam modules

* Fixed naming issue in meta.yml

* fix: test.yml and config lint

* Revert "fix: test.yml and config lint"

This reverts commit 0453bc3a8dc3dab6997442a4349ee2241adcc380, which caused the sortbam tests to fail.

* style: Fix test names

* style: Remove trailing whitespace

* fixed test.yml

* fix: test data in sortbam

* fix: data format

* fix: test data for callmolecularconsensusreads

* Corrected with updated test data

* Apply suggestions from code review

Applied changes from code review, mainly syntactical changes

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

Co-authored-by: Sruthi Suresh <sps180004@ganymede.utdallas.edu>
Co-authored-by: Edmund Miller <edmund.a.miller@protonmail.com>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
sruthipsuresh 2021-03-28 14:38:50 -05:00 committed by GitHub
parent e50a525715
commit 983ba000c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 335 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.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,38 @@
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process FGBIO_CALLMOLECULARCONSENSUSREADS {
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::fgbio=1.3.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/fgbio:1.3.0--0"
} else {
container "quay.io/biocontainers/fgbio:1.3.0--0"
}
input:
tuple val(meta), path(bam)
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}"
"""
fgbio \\
CallMolecularConsensusReads \\
-i $bam \\
$options.args \\
-o ${prefix}.bam
fgbio --version | sed -e "s/fgbio v//g" > ${software}.version.txt
"""
}

View file

@ -0,0 +1,45 @@
name: fgbio_callmolecularconsensusreads
description: Calls consensus sequences from reads with the same unique molecular tag.
keywords:
- UMIs
- consensus sequence
- bam
- sam
tools:
- fgbio:
description: Tools for working with genomic and high throughput sequencing data.
homepage: https://github.com/fulcrumgenomics/fgbio
documentation: http://fulcrumgenomics.github.io/fgbio/
licence: ['MIT']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false, collapse:false ]
- bam:
type: file
description: |
The input SAM or BAM file.
pattern: "*.{bam,sam}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: |
Output SAM or BAM file to write consensus reads.
pattern: "*.{bam,sam}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@sruthipsuresh"

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

View file

@ -0,0 +1,39 @@
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process FGBIO_SORTBAM {
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::fgbio=1.3.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/fgbio:1.3.0--0"
} else {
container "quay.io/biocontainers/fgbio:1.3.0--0"
}
input:
tuple val(meta), path(bam)
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}"
"""
fgbio \\
SortBam \\
-i $bam \\
$options.args \\
-o ${prefix}.bam
fgbio --version | sed -e "s/fgbio v//g" > ${software}.version.txt
"""
}

View file

@ -0,0 +1,43 @@
name: fgbio_sortbam
description: Sorts a SAM or BAM file. Several sort orders are available, including coordinate, queryname, random, and randomquery.
keywords:
- sort
- bam
- sam
tools:
- fgbio:
description: Tools for working with genomic and high throughput sequencing data.
homepage: https://github.com/fulcrumgenomics/fgbio
documentation: http://fulcrumgenomics.github.io/fgbio/
licence: ['MIT']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false, collapse:false ]
- bam:
type: file
description: |
The input SAM or BAM file to be sorted.
pattern: "*.{bam,sam}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: |
Output SAM or BAM file.
pattern: "*.{bam,sam}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@sruthipsuresh"

View file

@ -178,6 +178,14 @@ fastqc:
- software/fastqc/**
- tests/software/fastqc/**
fgbio_callmolecularconsensusreads:
- software/fgbio/callmolecularconsensusreads/**
- tests/software/fgbio/callmolecularconsensusreads/**
fgbio_sortbam:
- software/fgbio/sortbam/**
- tests/software/fgbio/sortbam/**
flash:
- software/flash/**
- tests/software/flash/**

View file

@ -0,0 +1,13 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { FGBIO_SORTBAM } from '../../../../software/fgbio/sortbam/main.nf' addParams( options: [args: '-s TemplateCoordinate', suffix: '_out'] )
include { FGBIO_CALLMOLECULARCONSENSUSREADS } from '../../../../software/fgbio/callmolecularconsensusreads/main.nf' addParams( options: [args: '-M 1', suffix: '_molreads'] )
workflow test_fgbio_callmolecularconsensusreads {
input = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_single_end_bam'], checkIfExists: true) ]
FGBIO_SORTBAM ( input )
FGBIO_CALLMOLECULARCONSENSUSREADS ( FGBIO_SORTBAM.out.bam )
}

View file

@ -0,0 +1,10 @@
- name: fgbio callmolecularconsensusreads
command: nextflow run tests/software/fgbio/callmolecularconsensusreads -entry test_fgbio_callmolecularconsensusreads -c tests/config/nextflow.config
tags:
- fgbio_callmolecularconsensusreads
- fgbio
files:
- path: output/fgbio/test_molreads.bam
md5sum: 7010bcdc037c36af13dbc370c06c76d3
- path: output/fgbio/test_out.bam
md5sum: d84e28fecc90c0752c543e934f10aa31

View file

@ -0,0 +1,11 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { FGBIO_SORTBAM } from '../../../../software/fgbio/sortbam/main.nf' addParams( options: [:] )
workflow test_fgbio_sortbam {
input = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ]
FGBIO_SORTBAM ( input )
}

View file

@ -0,0 +1,8 @@
- name: fgbio sortbam
command: nextflow run tests/software/fgbio/sortbam -entry test_fgbio_sortbam -c tests/config/nextflow.config
tags:
- fgbio_sortbam
- fgbio
files:
- path: output/fgbio/test.bam
md5sum: 56987f74214cdc72ae840e0007ff4935