mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
Add new module Mapdamage2 (#975)
* Fitst attempt at mapdamage2 * Add new module mapdamage2 * Removed __pycache__/test_versions_yml.cpython-39-pytest-6.2.5.pyc * Modify main.nf and meta.yml * Modify main.nf and meta.yml * Modify main.nf and meta.yml * Modify meta.yml * Update pytest_modules.yml * Apply suggestions from code review Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * edit the meta.yml and main.nf after reviews * Update meta.yml * Update meta.yml Co-authored-by: AIbrahim <AIbrahim@apate.hki-jena.de> Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>
This commit is contained in:
parent
e0ab4ff4ff
commit
6d3d8306e1
6 changed files with 294 additions and 0 deletions
78
modules/mapdamage2/functions.nf
Normal file
78
modules/mapdamage2/functions.nf
Normal file
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// 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()
|
||||
}
|
||||
|
||||
//
|
||||
// Extract name of module from process name using $task.process
|
||||
//
|
||||
def getProcessName(task_process) {
|
||||
return task_process.tokenize(':')[-1]
|
||||
}
|
||||
|
||||
//
|
||||
// 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) {
|
||||
def ioptions = initOptions(args.options)
|
||||
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
|
||||
|
||||
// Do not publish versions.yml unless running from pytest workflow
|
||||
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) {
|
||||
return null
|
||||
}
|
||||
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"
|
||||
}
|
||||
}
|
58
modules/mapdamage2/main.nf
Normal file
58
modules/mapdamage2/main.nf
Normal file
|
@ -0,0 +1,58 @@
|
|||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process MAPDAMAGE2 {
|
||||
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), meta:meta, publish_by_meta:['id']) }
|
||||
|
||||
conda (params.enable_conda ? "bioconda::mapdamage2=2.2.1" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/mapdamage2:2.2.1--pyr40_0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/mapdamage2:2.2.1--pyr40_0"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(bam)
|
||||
path(fasta)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("results_*/Runtime_log.txt") ,emit: runtime_log
|
||||
tuple val(meta), path("results_*/Fragmisincorporation_plot.pdf"), optional: true ,emit: fragmisincorporation_plot
|
||||
tuple val(meta), path("results_*/Length_plot.pdf"), optional: true ,emit: length_plot
|
||||
tuple val(meta), path("results_*/misincorporation.txt"), optional: true ,emit: misincorporation
|
||||
tuple val(meta), path("results_*/lgdistribution.txt"), optional: true ,emit: lgdistribution
|
||||
tuple val(meta), path("results_*/dnacomp.txt"), optional: true ,emit: dnacomp
|
||||
tuple val(meta), path("results_*/Stats_out_MCMC_hist.pdf"), optional: true ,emit: stats_out_mcmc_hist
|
||||
tuple val(meta), path("results_*/Stats_out_MCMC_iter.csv"), optional: true ,emit: stats_out_mcmc_iter
|
||||
tuple val(meta), path("results_*/Stats_out_MCMC_trace.pdf"), optional: true ,emit: stats_out_mcmc_trace
|
||||
tuple val(meta), path("results_*/Stats_out_MCMC_iter_summ_stat.csv"), optional: true ,emit: stats_out_mcmc_iter_summ_stat
|
||||
tuple val(meta), path("results_*/Stats_out_MCMC_post_pred.pdf"), optional: true ,emit: stats_out_mcmc_post_pred
|
||||
tuple val(meta), path("results_*/Stats_out_MCMC_correct_prob.csv"), optional: true ,emit: stats_out_mcmc_correct_prob
|
||||
tuple val(meta), path("results_*/dnacomp_genome.csv"), optional: true ,emit: dnacomp_genome
|
||||
tuple val(meta), path("results_*/rescaled.bam"), optional: true ,emit: rescaled
|
||||
tuple val(meta), path("results_*/5pCtoT_freq.txt"), optional: true ,emit: pctot_freq
|
||||
tuple val(meta), path("results_*/3pGtoA_freq.txt"), optional: true ,emit: pgtoa_freq
|
||||
tuple val(meta), path("results_*/*.fasta"), optional: true ,emit: fasta
|
||||
tuple val(meta), path("*/"), optional: true ,emit: folder
|
||||
path "versions.yml",emit: versions
|
||||
|
||||
script:
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
"""
|
||||
mapDamage \\
|
||||
$options.args \\
|
||||
-i $bam \\
|
||||
-r $fasta
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
${getSoftwareName(task.process)}: \$(echo \$(mapDamage --version))
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
114
modules/mapdamage2/meta.yml
Normal file
114
modules/mapdamage2/meta.yml
Normal file
|
@ -0,0 +1,114 @@
|
|||
name: mapdamage2
|
||||
|
||||
description: Computational framework for tracking and quantifying DNA damage patterns among ancient DNA sequencing reads generated by Next-Generation Sequencing platforms.
|
||||
keywords:
|
||||
- ancient DNA
|
||||
- DNA damage
|
||||
- NGS
|
||||
- damage patterns
|
||||
- bam
|
||||
tools:
|
||||
- mapdamage2:
|
||||
description: Tracking and quantifying damage patterns in ancient DNA sequences
|
||||
homepage: http://ginolhac.github.io/mapDamage/
|
||||
documentation: https://ginolhac.github.io/mapDamage/
|
||||
tool_dev_url: https://github.com/ginolhac/mapDamage
|
||||
doi: "10.1093/bioinformatics/btt193"
|
||||
licence: ['MIT']
|
||||
|
||||
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}"
|
||||
- fasta:
|
||||
type: file
|
||||
description: Fasta file, the reference the input BAM was mapped against
|
||||
pattern: "*.{fasta}"
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: Groovy Map containing sample information e.g. [ id:'test', single_end:false ]
|
||||
- versions:
|
||||
type: file
|
||||
description: File containing software versions
|
||||
pattern: "versions.yml"
|
||||
- runtime_log:
|
||||
type: file
|
||||
description: Log file with a summary of command lines used and timestamps.
|
||||
pattern: "Runtime_log.txt"
|
||||
- fragmisincorporation_plot:
|
||||
type: file
|
||||
description: A pdf file that displays both fragmentation and misincorporation patterns.
|
||||
pattern: "Fragmisincorporation_plot.pdf"
|
||||
- length_plot:
|
||||
type: file
|
||||
description: A pdf file that displays length distribution of singleton reads per strand and cumulative frequencies of C->T at 5'-end and G->A at 3'-end are also displayed per strand.
|
||||
pattern: "Length_plot.pdf"
|
||||
- misincorporation:
|
||||
type: file
|
||||
description: Contains a table with occurrences for each type of mutations and relative positions from the reads ends.
|
||||
pattern: "misincorporation.txt"
|
||||
- pctot_freq:
|
||||
type: file
|
||||
description: Contains frequencies of Cytosine to Thymine mutations per position from the 5'-ends.
|
||||
pattern: "5pCtoT_freq.txt"
|
||||
- pgtoa_freq:
|
||||
type: file
|
||||
description: Contains frequencies of Guanine to Adenine mutations per position from the 3'-ends.
|
||||
pattern: "3pGtoA_freq.txt"
|
||||
- dnacomp:
|
||||
type: file
|
||||
description: Contains a table of the reference genome base composition per position, inside reads and adjacent regions.
|
||||
pattern: "dnacomp.txt"
|
||||
- lgdistribution:
|
||||
type: file
|
||||
description: Contains a table with read length distributions per strand.
|
||||
pattern: "lgdistribution.txt"
|
||||
- stats_out_mcmc_hist:
|
||||
type: file
|
||||
description: A MCMC histogram for the damage parameters and log likelihood.
|
||||
pattern: "Stats_out_MCMC_hist.pdf"
|
||||
- stats_out_mcmc_iter:
|
||||
type: file
|
||||
description: Values for the damage parameters and log likelihood in each MCMC iteration.
|
||||
pattern: "Stats_out_MCMC_iter.csv"
|
||||
- stats_out_mcmc_trace:
|
||||
type: file
|
||||
description: A MCMC trace plot for the damage parameters and log likelihood.
|
||||
pattern: "Stats_out_MCMC_trace.pdf"
|
||||
- stats_out_mcmc_iter_summ_stat:
|
||||
type: file
|
||||
description: Summary statistics for the damage parameters estimated posterior distributions.
|
||||
pattern: "Stats_out_MCMC_iter_summ_stat.csv"
|
||||
- stats_out_mcmc_post_pred:
|
||||
type: file
|
||||
description: Empirical misincorporation frequency and posterior predictive intervals from the fitted model.
|
||||
pattern: "Stats_out_MCMC_post_pred.pdf"
|
||||
- stats_out_mcmc_correct_prob:
|
||||
type: file
|
||||
description: Position specific probability of a C->T and G->A misincorporation is due to damage.
|
||||
pattern: "Stats_out_MCMC_correct_prob.csv"
|
||||
- dnacomp_genome:
|
||||
type: file
|
||||
description: Contains the global reference genome base composition (computed by seqtk).
|
||||
pattern: "dnacomp_genome.csv"
|
||||
- rescaled:
|
||||
type: file
|
||||
description: Rescaled BAM file, where likely post-mortem damaged bases have downscaled quality scores.
|
||||
pattern: "*.{bam}"
|
||||
- fasta:
|
||||
type: file
|
||||
description: Allignments in a FASTA file, only if flagged by -d.
|
||||
pattern: "*.{fasta}"
|
||||
- folder:
|
||||
type: folder
|
||||
description: Folder created when --plot-only, --rescale and --stats-only flags are passed.
|
||||
pattern: "*/"
|
||||
|
||||
authors:
|
||||
- "@darcy220606"
|
|
@ -758,6 +758,10 @@ manta/tumoronly:
|
|||
- modules/manta/tumoronly/**
|
||||
- tests/modules/manta/tumoronly/**
|
||||
|
||||
mapdamage2:
|
||||
- modules/mapdamage2/**
|
||||
- tests/modules/mapdamage2/**
|
||||
|
||||
mash/sketch:
|
||||
- modules/mash/sketch/**
|
||||
- tests/modules/mash/sketch/**
|
||||
|
|
15
tests/modules/mapdamage2/main.nf
Normal file
15
tests/modules/mapdamage2/main.nf
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { MAPDAMAGE2 } from '../../../modules/mapdamage2/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_mapdamage2 {
|
||||
|
||||
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)
|
||||
|
||||
MAPDAMAGE2 ( input, fasta )
|
||||
}
|
25
tests/modules/mapdamage2/test.yml
Normal file
25
tests/modules/mapdamage2/test.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
- name: mapdamage2 test_mapdamage2
|
||||
command: nextflow run tests/modules/mapdamage2 -entry test_mapdamage2 -c tests/config/nextflow.config
|
||||
tags:
|
||||
- mapdamage2
|
||||
files:
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/3pGtoA_freq.txt
|
||||
md5sum: 3b300b8d2842441675cb2b56740801f0
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/5pCtoT_freq.txt
|
||||
md5sum: 4c27465cd02e1fb8bf6fb2b01e98446d
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/Fragmisincorporation_plot.pdf
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/Runtime_log.txt
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/Stats_out_MCMC_correct_prob.csv
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/Stats_out_MCMC_hist.pdf
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/Stats_out_MCMC_iter.csv
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/Stats_out_MCMC_iter_summ_stat.csv
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/Stats_out_MCMC_post_pred.pdf
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/Stats_out_MCMC_trace.pdf
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/dnacomp.txt
|
||||
md5sum: 4244d9fa554bbfeebbcea8eba3ad6466
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/dnacomp_genome.csv
|
||||
md5sum: ea91a3d205717d3c6b3e0b77bb840945
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/lgdistribution.txt
|
||||
md5sum: f86dfc04b1fff4337cc91add6356e3a0
|
||||
- path: output/mapdamage2/results_test.paired_end.sorted/misincorporation.txt
|
||||
md5sum: 1c89b4c96d1f8996c3d0879cad5129a5
|
Loading…
Reference in a new issue