mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Add new module: cmseq/polymut (#918)
* add pydamage module * remove TODOs * split module by subcommands * update version parsing * remove forgotten TODOs * update module names * remove old holistic module * Update modules/pydamage/analyze/main.nf Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * add keywords * update resource requirement * Update modules/pydamage/filter/main.nf Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update modules/pydamage/filter/meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * merge from upstream * update pydamage from upstream * add freebayes * update pydamage test from upstream * fix meta.yml * update functions.nf * update test.yml * update version parsing * update version parsing * fix indentation * Update modules/freebayes/main.nf Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update modules/freebayes/main.nf Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update modules/freebayes/main.nf Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * add optional inputs * Update modules/freebayes/main.nf Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * add bed test * add metabat2 module * only freebayes * remove metabat2 * update md5sum because of vcf including date of the day * add keyword * rescue conflicted files * attempt to fix ECLint * add pytest workflow for metabat * remove - * Update modules/metabat2/jgisummarizebamcontigdepths/meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update modules/metabat2/metabat2/meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update modules/metabat2/metabat2/meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update modules/metabat2/jgisummarizebamcontigdepths/meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * add optional inputs/outpus * remove trailing whitespace * first cmseq commit * compressing and removing not reproducible md5sums * save intermediate work * follow symlinks while decompressing * add cmseq/polymut * add polymut * add extra test with optional input file * remove metabat2 * Update modules/cmseq/polymut/main.nf Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update modules/cmseq/polymut/meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update modules/cmseq/polymut/meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * fix file extension * Update modules/cmseq/polymut/meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * add test without bam index * split tests in workflows * answer PR review * report version from variable Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
6bb4a6a7ee
commit
b399f22af2
6 changed files with 253 additions and 0 deletions
78
modules/cmseq/polymut/functions.nf
Normal file
78
modules/cmseq/polymut/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"
|
||||||
|
}
|
||||||
|
}
|
46
modules/cmseq/polymut/main.nf
Normal file
46
modules/cmseq/polymut/main.nf
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
def VERSION = '1.0.4'
|
||||||
|
|
||||||
|
process CMSEQ_POLYMUT {
|
||||||
|
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::cmseq=1.0.4" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/cmseq:1.0.4--pyhb7b1952_0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/cmseq:1.0.4--pyhb7b1952_0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(bam), path(bai), path(gff), path(fasta)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("*.txt"), emit: polymut
|
||||||
|
path "versions.yml" , emit: versions
|
||||||
|
|
||||||
|
script:
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
def fasta_refid = fasta ? "-c $fasta" : ""
|
||||||
|
def sortindex = bai ? "" : "--sortindex"
|
||||||
|
"""
|
||||||
|
polymut.py \\
|
||||||
|
$options.args \\
|
||||||
|
$sortindex \\
|
||||||
|
$fasta_refid \\
|
||||||
|
--gff_file $gff \\
|
||||||
|
$bam > ${prefix}.txt
|
||||||
|
|
||||||
|
cat <<-END_VERSIONS > versions.yml
|
||||||
|
${getProcessName(task.process)}:
|
||||||
|
${getSoftwareName(task.process)}: \$( echo $VERSION )
|
||||||
|
END_VERSIONS
|
||||||
|
"""
|
||||||
|
}
|
61
modules/cmseq/polymut/meta.yml
Normal file
61
modules/cmseq/polymut/meta.yml
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
name: cmseq_polymut
|
||||||
|
description: Calculates polymorphic site rates over protein coding genes
|
||||||
|
keywords:
|
||||||
|
- polymut
|
||||||
|
- polymorphic
|
||||||
|
- mags
|
||||||
|
- assembly
|
||||||
|
- polymorphic sites
|
||||||
|
- estimation
|
||||||
|
- protein coding genes
|
||||||
|
- cmseq
|
||||||
|
- bam
|
||||||
|
- coverage
|
||||||
|
tools:
|
||||||
|
- cmseq:
|
||||||
|
description: Set of utilities on sequences and BAM files
|
||||||
|
homepage: https://github.com/SegataLab/cmseq
|
||||||
|
documentation: https://github.com/SegataLab/cmseq
|
||||||
|
tool_dev_url: https://github.com/SegataLab/cmseq
|
||||||
|
licence: ['MIT License']
|
||||||
|
|
||||||
|
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"
|
||||||
|
- bai:
|
||||||
|
type: file
|
||||||
|
description: BAM index file
|
||||||
|
pattern: "*.bai"
|
||||||
|
- gff:
|
||||||
|
type: file
|
||||||
|
description: GFF file used to extract protein-coding genes
|
||||||
|
pattern: "*.gff"
|
||||||
|
- fasta:
|
||||||
|
type: file
|
||||||
|
description: Optional fasta file to run on a subset of references in the BAM file.
|
||||||
|
pattern: .{fa,fasta,fas,fna}
|
||||||
|
|
||||||
|
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"
|
||||||
|
- polymut:
|
||||||
|
type: file
|
||||||
|
description: Polymut report in `.txt` format.
|
||||||
|
pattern: "*.txt"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@maxibor"
|
|
@ -274,6 +274,10 @@ chromap/index:
|
||||||
- modules/chromap/index/**
|
- modules/chromap/index/**
|
||||||
- tests/modules/chromap/index/**
|
- tests/modules/chromap/index/**
|
||||||
|
|
||||||
|
cmseq/polymut:
|
||||||
|
- modules/cmseq/polymut/**
|
||||||
|
- tests/modules/cmseq/polymut/**
|
||||||
|
|
||||||
cnvkit:
|
cnvkit:
|
||||||
- modules/cnvkit/**
|
- modules/cnvkit/**
|
||||||
- tests/modules/cnvkit/**
|
- tests/modules/cnvkit/**
|
||||||
|
|
38
tests/modules/cmseq/polymut/main.nf
Normal file
38
tests/modules/cmseq/polymut/main.nf
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { CMSEQ_POLYMUT } from '../../../../modules/cmseq/polymut/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_cmseq_polymut_1 {
|
||||||
|
|
||||||
|
input_1 = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
|
||||||
|
[],
|
||||||
|
file(params.test_data['sarscov2']['genome']['genome_gff3'], checkIfExists: true),
|
||||||
|
[] ]
|
||||||
|
|
||||||
|
CMSEQ_POLYMUT( input_1 )
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_cmseq_polymut_2 {
|
||||||
|
input_2 = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
|
||||||
|
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
|
||||||
|
file(params.test_data['sarscov2']['genome']['genome_gff3'], checkIfExists: true),
|
||||||
|
[] ]
|
||||||
|
|
||||||
|
CMSEQ_POLYMUT( input_2 )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_cmseq_polymut_3 {
|
||||||
|
input_3 = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
|
||||||
|
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
|
||||||
|
file(params.test_data['sarscov2']['genome']['genome_gff3'], checkIfExists: true),
|
||||||
|
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true), ]
|
||||||
|
|
||||||
|
CMSEQ_POLYMUT( input_3 )
|
||||||
|
}
|
||||||
|
|
26
tests/modules/cmseq/polymut/test.yml
Normal file
26
tests/modules/cmseq/polymut/test.yml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
- name: cmseq polymut test_cmseq_polymut_1
|
||||||
|
command: nextflow run tests/modules/cmseq/polymut -entry test_cmseq_polymut_1 -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- cmseq/polymut
|
||||||
|
- cmseq
|
||||||
|
files:
|
||||||
|
- path: output/cmseq/test.txt
|
||||||
|
md5sum: fd325c1724ee23d132a9115c64494efc
|
||||||
|
|
||||||
|
- name: cmseq polymut test_cmseq_polymut_2
|
||||||
|
command: nextflow run tests/modules/cmseq/polymut -entry test_cmseq_polymut_2 -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- cmseq/polymut
|
||||||
|
- cmseq
|
||||||
|
files:
|
||||||
|
- path: output/cmseq/test.txt
|
||||||
|
md5sum: fd325c1724ee23d132a9115c64494efc
|
||||||
|
|
||||||
|
- name: cmseq polymut test_cmseq_polymut_3
|
||||||
|
command: nextflow run tests/modules/cmseq/polymut -entry test_cmseq_polymut_3 -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- cmseq/polymut
|
||||||
|
- cmseq
|
||||||
|
files:
|
||||||
|
- path: output/cmseq/test.txt
|
||||||
|
md5sum: fd325c1724ee23d132a9115c64494efc
|
Loading…
Reference in a new issue