add qualimap/bamqc + test

This commit is contained in:
phue 2021-02-17 17:34:51 +01:00
parent ed573db194
commit b5b259a2d9
6 changed files with 238 additions and 0 deletions

4
.github/filters.yml vendored
View file

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

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,63 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process QUALIMAP_BAMQC {
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::qualimap=2.2.2d" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/qualimap:2.2.2d--1"
} else {
container "quay.io/biocontainers/qualimap:2.2.2d--1"
}
input:
tuple val(meta), path(bam)
path gff
val use_gff
output:
tuple val(meta), path("${prefix}"), emit: results
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def threads = task.cpus
def collect_pairs = meta.single_end ? '' : '--collect-overlap-pairs'
def memory = task.memory.toGiga() + "G"
def regions = use_gff ? "--gff $gff" : ''
def strandedness = 'non-strand-specific'
if (meta.strandedness == 'forward') {
strandedness = 'strand-specific-forward'
} else if (meta.strandedness == 'reverse') {
strandedness = 'strand-specific-reverse'
}
"""
unset DISPLAY
mkdir tmp
export _JAVA_OPTIONS=-Djava.io.tmpdir=./tmp
qualimap \\
--java-mem-size=$memory \\
bamqc \\
$options.args \\
-bam $bam \\
$regions \\
-p $strandedness \\
$collect_pairs \\
-outdir $prefix \\
-nt $threads
echo \$(qualimap 2>&1) | sed 's/^.*QualiMap v.//; s/Built.*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,70 @@
name: qualimap_bamqc
description: Evaluate alignment data
keywords:
- quality control
- qc
- bam
tools:
- qualimap:
description: |
Qualimap 2 is a platform-independent application written in
Java and R that provides both a Graphical User Interface and
a command-line interface to facilitate the quality control of
alignment sequencing data and its derivatives like feature counts.
homepage: http://qualimap.bioinfo.cipf.es/
documentation: http://qualimap.conesalab.org/doc_html/index.html
doi: 10.1093/bioinformatics/bts503
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- publish_dir_mode:
type: string
description: |
Value for the Nextflow `publishDir` mode parameter.
Available: symlink, rellink, link, copy, copyNoFollow, move.
- enable_conda:
type: boolean
description: |
Run the module with Conda using the software specified
via the `conda` directive
- singularity_pull_docker_container:
type: boolean
description: |
Instead of directly downloading Singularity images for use with Singularity,
force the workflow to pull and convert Docker containers instead.
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: BAM file
pattern: "*.{bam}"
- gff:
type: file
description: Feature file with regions of interest
pattern: "*.{gff,gtf,bed}"
- use_gff:
type: boolean
description: Specifies if feature file should be used or not
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- results:
type: dir
description: Qualimap results dir
pattern: "*/*"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@phue"

View file

@ -0,0 +1,16 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { QUALIMAP_BAMQC } from '../../../../software/qualimap/bamqc/main.nf' addParams( options: [:] )
workflow test_qualimap_bamqc {
def input = []
input = [ [ id:'test', single_end:false ], // meta map
file("${launchDir}/tests/data/bam/test.paired_end.sorted.bam", checkIfExists: true) ]
def gff = file("dummy_file.txt")
def use_gff = false
QUALIMAP_BAMQC ( input, gff, use_gff )
}

View file

@ -0,0 +1,26 @@
- name: Run qualimap bamqc test workflow
command: nextflow run ./tests/software/qualimap/bamqc -entry test_qualimap_bamqc -c tests/config/nextflow.config
tags:
- qualimap
- qualimap_bamqc
files:
- path: output/qualimap/test/raw_data_qualimapReport/coverage_across_reference.txt
md5sum: 0e2ae3deae8adbe6c66db4dadb260c76
- path: output/qualimap/test/raw_data_qualimapReport/coverage_histogram.txt
md5sum: 0e9f37aabb761969526f445ed8d3173b
- path: output/qualimap/test/raw_data_qualimapReport/duplication_rate_histogram.txt
md5sum: 2299c92a3049270b9d7b1f521cafbb86
- path: output/qualimap/test/raw_data_qualimapReport/genome_fraction_coverage.txt
md5sum: 89c8c882c9423fafe03b4fc98e2bfb5a
- path: output/qualimap/test/raw_data_qualimapReport/insert_size_across_reference.txt
md5sum: 966230f2bbe796788beac30678597e79
- path: output/qualimap/test/raw_data_qualimapReport/insert_size_histogram.txt
md5sum: b3049afc6c3c57c3b278abd66a66a690
- path: output/qualimap/test/raw_data_qualimapReport/mapped_reads_gc-content_distribution.txt
md5sum: e9e0189463430b5565ea6da1d5976e40
- path: output/qualimap/test/raw_data_qualimapReport/mapped_reads_nucleotide_content.txt
md5sum: fa1566299e1bcd2d65c95b32ae2ca3d1
- path: output/qualimap/test/raw_data_qualimapReport/mapping_quality_across_reference.txt
md5sum: 40b6951739a602da545e38a00b698fde
- path: output/qualimap/test/raw_data_qualimapReport/mapping_quality_histogram.txt
md5sum: c66579f0114a9aedc70820fa609fb1ec