diff --git a/software/msisensor/msi/functions.nf b/software/msisensor/msi/functions.nf new file mode 100644 index 00000000..f177f0c8 --- /dev/null +++ b/software/msisensor/msi/functions.nf @@ -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" + } + } +} diff --git a/software/msisensor/msi/main.nf b/software/msisensor/msi/main.nf new file mode 100644 index 00000000..d89624a7 --- /dev/null +++ b/software/msisensor/msi/main.nf @@ -0,0 +1,45 @@ +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +params.options = [:] +options = initOptions(params.options) + +process MSISENSOR_MSI { + 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), publish_id:meta.id) } + + conda (params.enable_conda ? "bioconda::msisensor=0.5" : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container "https://depot.galaxyproject.org/singularity/msisensor:0.5--hb3646a4_2" + } else { + container "quay.io/biocontainers/msisensor:0.5--hb3646a4_2" + } + + input: + tuple val(meta), path(normal_bam), path(normal_bai), path(tumor_bam), path(tumor_bai), val(metascan), path(homopolymers) + + output: + tuple val(meta), path("${prefix}") , emit: output + tuple val(meta), path("${prefix}_dis") , emit: output_dis + tuple val(meta), path("${prefix}_germline"), emit: output_germline + tuple val(meta), path("${prefix}_somatic") , emit: output_somatic + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" + """ + msisensor \\ + msi \\ + -d $homopolymers \\ + -n $normal_bam \\ + -t $tumor_bam \\ + -o $prefix \\ + $options.args + + echo \$(msisensor 2>&1) | sed -nE 's/Version:\\sv([0-9]\\.[0-9])/\\1/ p' > ${software}.version.txt + """ +} diff --git a/software/msisensor/msi/meta.yml b/software/msisensor/msi/meta.yml new file mode 100644 index 00000000..214f90e6 --- /dev/null +++ b/software/msisensor/msi/meta.yml @@ -0,0 +1,69 @@ +name: msisensor_msi + +description: Evaluate microsattelite instability (MSI) using paired tumor-normal sequencing data +keywords: + - homoploymer,microsatellite +tools: + - msisensor: + description: MSIsensor is a C++ program to detect replication slippage variants at microsatellite regions, and differentiate them as somatic or germline. + homepage: https://github.com/ding-lab/msisensor + documentation: None + tool_dev_url: None + doi: "10.1093/bioinformatics/btt755" + licence: ['MIT'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - normal_bam: + type: file + description: Coordinate sorted BAM/CRAM/SAM file from normal tissue + pattern: "*.{bam,cram,sam}" + - normal_bai: + type: file + description: Index for coordinate sorted BAM/CRAM/SAM file from normal tissue + pattern: "*.{bam,cram,sam}" + - tumor_bam: + type: file + description: Coordinate sorted BAM/CRAM/SAM file from tumor tissue + pattern: "*.{bam,cram,sam}" + - tumor_bai: + type: file + description: Index for coordinate sorted BAM/CRAM/SAM file from tumor tissue + pattern: "*.{bam,cram,sam}" + - homopolymers: + type: file + description: Output file from MSIsensor scan module + pattern: "*.msisensor_scan.tab" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - version: + type: file + description: File containing software version + pattern: "*.{version.txt}" + - txt: + type: file + description: MSIsensor MSI final report file + pattern: "*.output" + - txt: + type: file + description: MSIsensor MSI DIS report file + pattern: "*.output_dis" + - txt: + type: file + description: MSIsensor MSI germline report file + pattern: "*.output_germline" + - txt: + type: file + description: MSIsensor MSI somatic report file + pattern: "*.output_somatic" +authors: + - "@kevbrick" diff --git a/software/msisensor/scan/functions.nf b/software/msisensor/scan/functions.nf new file mode 100644 index 00000000..f177f0c8 --- /dev/null +++ b/software/msisensor/scan/functions.nf @@ -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" + } + } +} diff --git a/software/msisensor/scan/main.nf b/software/msisensor/scan/main.nf new file mode 100644 index 00000000..3030560b --- /dev/null +++ b/software/msisensor/scan/main.nf @@ -0,0 +1,40 @@ +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +params.options = [:] +options = initOptions(params.options) + +process MSISENSOR_SCAN { + 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), publish_id:meta.id) } + + conda (params.enable_conda ? "bioconda::msisensor=0.5" : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container "https://depot.galaxyproject.org/singularity/msisensor:0.5--hb3646a4_2" + } else { + container "quay.io/biocontainers/msisensor:0.5--hb3646a4_2" + } + + input: + tuple val(meta), path(fasta) + + output: + tuple (val(meta), path("*.tab"), emit: txt) + path ("*.version.txt" , emit: version) + + script: + def software = getSoftwareName(task.process) + def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" + """ + msisensor \\ + scan \\ + -d $fasta \\ + -o ${prefix}.msisensor_scan.tab \\ + $options.args + + echo \$(msisensor 2>&1) | sed -nE 's/Version:\\sv([0-9]\\.[0-9])/\\1/ p' > ${software}.version.txt + """ +} diff --git a/software/msisensor/scan/meta.yml b/software/msisensor/scan/meta.yml new file mode 100644 index 00000000..2e4f8f18 --- /dev/null +++ b/software/msisensor/scan/meta.yml @@ -0,0 +1,42 @@ +name: msisensor_scan + +description: Scan a reference genome to get microsatellite & homopolymer information +keywords: + - homoploymer,microsatellite +tools: + - msisensor: + description: MSIsensor is a C++ program to detect replication slippage variants at microsatellite regions, and differentiate them as somatic or germline. + homepage: https://github.com/ding-lab/msisensor + documentation: None + tool_dev_url: None + doi: "10.1093/bioinformatics/btt755" + licence: ['MIT'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - fasta: + type: file + description: FASTA file + pattern: "*.{fa,fasta}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - version: + type: file + description: File containing software version + pattern: "*.{version.txt}" + - txt: + type: file + description: MSIsensor scan output file of homopolymers & minisatellites + pattern: "*.msisensor_scan.txt" + +authors: + - "@kevbrick" diff --git a/tests/config/pytest_software.yml b/tests/config/pytest_software.yml index e48f536b..eb569091 100755 --- a/tests/config/pytest_software.yml +++ b/tests/config/pytest_software.yml @@ -278,6 +278,14 @@ mosdepth: - software/mosdepth/** - tests/software/mosdepth/** +msisensor_scan: + - software/msisensor/scan/** + - tests/software/msisensor/scan/** + +msisensor_msi: + - software/msisensor/msi/** + - tests/software/msisensor/msi/** + multiqc: - software/fastqc/** - software/multiqc/** diff --git a/tests/software/msisensor/msi/main.nf b/tests/software/msisensor/msi/main.nf new file mode 100644 index 00000000..af61fcf9 --- /dev/null +++ b/tests/software/msisensor/msi/main.nf @@ -0,0 +1,31 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { MSISENSOR_SCAN } from '../../../../software/msisensor/scan/main.nf' addParams( options: [:] ) +include { MSISENSOR_MSI } from '../../../../software/msisensor/msi/main.nf' addParams( options: [:] ) + +workflow test_msisensor_msi { + + def scaninput = [] + scaninput = [ [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ] + scan = MSISENSOR_SCAN ( scaninput ) + + // IMPERFECT TEST: + // USING SARS-COV2 DATA AS NORMAL:TUMOR PAIR THIS WILL SUFFICE TO + // TEST MODULE EXECUTION, BUT NOT FUNCTIONALITY. + // FUNCTIONALITY HAS BEEN TESTED MANUALY USING AUTHOR-PROVIDED TEST + // DATA (https://github.com/ding-lab/msisensor/tree/master/test) + def input = [] + + input = Channel.from([ [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_methylated_paired_end_sorted_bam'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_methylated_paired_end_sorted_bam_bai'], checkIfExists: true), + 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) ]) + //scan.txt.view() + input.concat(scan.txt).collect().view() + // BIT CLUMSY: + MSISENSOR_MSI ( input.concat(scan.txt).collect() ) +} diff --git a/tests/software/msisensor/msi/test.yml b/tests/software/msisensor/msi/test.yml new file mode 100644 index 00000000..152bf60a --- /dev/null +++ b/tests/software/msisensor/msi/test.yml @@ -0,0 +1,14 @@ +- name: msisensor msi + command: nextflow run ./tests/software/msisensor/msi -entry test_msisensor_msi -c tests/config/nextflow.config + tags: + - msisensor + - msisensor_msi + files: + - path: output/msisensor/test + md5sum: a3290f7539dbbf83777e8590156c0e28 + - path: output/msisensor/test_dis + md5sum: 060a3fc3701f3b10f6b19da9b21a32b7 + - path: output/msisensor/test_germline + md5sum: d41d8cd98f00b204e9800998ecf8427e + - path: output/msisensor/test_somatic + md5sum: d41d8cd98f00b204e9800998ecf8427e diff --git a/tests/software/msisensor/scan/main.nf b/tests/software/msisensor/scan/main.nf new file mode 100644 index 00000000..bb39ab19 --- /dev/null +++ b/tests/software/msisensor/scan/main.nf @@ -0,0 +1,14 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { MSISENSOR_SCAN } from '../../../../software/msisensor/scan/main.nf' addParams( options: [:] ) + +workflow test_msisensor_scan { + + def input = [] + input = [ [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)] + + MSISENSOR_SCAN ( input ) +} diff --git a/tests/software/msisensor/scan/test.yml b/tests/software/msisensor/scan/test.yml new file mode 100644 index 00000000..7d8f6e5c --- /dev/null +++ b/tests/software/msisensor/scan/test.yml @@ -0,0 +1,8 @@ +- name: msisensor scan + command: nextflow run ./tests/software/msisensor/scan -entry test_msisensor_scan -c tests/config/nextflow.config + tags: + - msisensor + - msisensor_scan + files: + - path: output/msisensor/test.msisensor_scan.tab + md5sum: b7ae85acdcfc1a51e867ab3446d6fb59