damageprofiler (#545)

* Add damageprofiler module

* Fix tests

* Bump container hopefully with font fix

* Following code review
This commit is contained in:
James A. Fellows Yates 2021-06-30 09:46:24 +02:00 committed by GitHub
parent af4b8814b8
commit 394273f173
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 220 additions and 0 deletions

View file

@ -0,0 +1,68 @@
//
// 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,44 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process DAMAGEPROFILER {
tag "$meta.id"
label 'process_low'
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::damageprofiler=1.1" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/damageprofiler:1.1--hdfd78af_2"
} else {
container "quay.io/biocontainers/damageprofiler:1.1--hdfd78af_2"
}
input:
tuple val(meta), path(bam)
path fasta
path fai
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}"
"""
damageprofiler \\
-i $bam \\
-r $fasta \\
-o $prefix/ \\
$options.args
echo \$(damageprofiler -v) | sed 's/^DamageProfiler v//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,53 @@
name: damageprofiler
description: A Java based tool to determine damage patterns on ancient DNA as a replacement for mapDamage
keywords:
- damage
- deamination
- miscoding lesions
- C to T
- ancient DNA
- aDNA
- palaeogenomics
- archaeogenomics
- palaeogenetics
- archaeogenetics
tools:
- damageprofiler:
description: A Java based tool to determine damage patterns on ancient DNA as a replacement for mapDamage
homepage: https://github.com/Integrative-Transcriptomics/DamageProfiler
documentation: https://damageprofiler.readthedocs.io/
tool_dev_url: https://github.com/Integrative-Transcriptomics/DamageProfiler
doi: "10.1093/bioinformatics/btab190"
licence: ['GPL v3']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"
- fasta:
type: file
description: FASTA reference file
pattern: "*.{fasta,fna,fa}"
- fai:
type: file
description: FASTA index file from samtools faidx
pattern: "*.{fai}"
output:
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
- results:
type: dir
description: DamageProfiler results directory
pattern: "*/*"
authors:
- "@jfy133"

View file

@ -190,6 +190,10 @@ cutadapt:
- software/cutadapt/** - software/cutadapt/**
- tests/software/cutadapt/** - tests/software/cutadapt/**
damageprofiler:
- software/damageprofiler/**
- tests/software/damageprofiler/**
deeptools/computematrix: deeptools/computematrix:
- software/deeptools/computematrix/** - software/deeptools/computematrix/**
- tests/software/deeptools/computematrix/** - tests/software/deeptools/computematrix/**

View file

@ -0,0 +1,15 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { DAMAGEPROFILER } from '../../../software/damageprofiler/main.nf' addParams( options: [:] )
workflow test_damageprofiler {
input = [ [ id:'test', single_end:false ], // meta map
[ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ] ]
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
fai = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
DAMAGEPROFILER ( input, fasta, fai )
}

View file

@ -0,0 +1,36 @@
- name: damageprofiler
command: nextflow run ./tests/software/damageprofiler -entry test_damageprofiler -c tests/config/nextflow.config -dump-channels
tags:
- damageprofiler
files:
- path: output/damageprofiler/test/3p_freq_misincorporations.txt
md5sum: da4cac90c78899a7cb6d72d415392b49
- path: output/damageprofiler/test/3pGtoA_freq.txt
md5sum: 8dab75d51a4b943b501d0995169c767f
- path: output/damageprofiler/test/5pCtoT_freq.txt
md5sum: fcc48ee5f72edff930d627c8bfdd8a5b
- path: output/damageprofiler/test/5p_freq_misincorporations.txt
md5sum: 54665474f5ef17dcc268567e5eaa7d86
- path: output/damageprofiler/test/DamagePlot_five_prime.svg
- path: output/damageprofiler/test/DamagePlot.pdf
- path: output/damageprofiler/test/DamagePlot_three_prime.svg
- path: output/damageprofiler/test/DamageProfiler.log
contains:
- "FINISHED SUCCESSFULLY"
- path: output/damageprofiler/test/dmgprof.json
md5sum: 98499024c7e937896e481f2d3cfbdd3e
- path: output/damageprofiler/test/DNA_comp_genome.txt
md5sum: f91e70760d91a1193a27e360aaddf2fd
- path: output/damageprofiler/test/DNA_composition_sample.txt
md5sum: 1257eb3eb42484647bfba2151f9ef04f
- path: output/damageprofiler/test/edit_distance.pdf
- path: output/damageprofiler/test/edit_distance.svg
- path: output/damageprofiler/test/editDistance.txt
md5sum: af2d2f4a99058ec56eae88ec27779e38
- path: output/damageprofiler/test/Length_plot_combined_data.svg
- path: output/damageprofiler/test/Length_plot_forward_reverse_separated.svg
- path: output/damageprofiler/test/Length_plot.pdf
- path: output/damageprofiler/test/lgdistribution.txt
md5sum: c5d029bf3a92b613310ee23f47d94981
- path: output/damageprofiler/test/misincorporation.txt
md5sum: 3aa6dd749010a492d92a815a83c196a8