diff --git a/modules/merquryfk/katcomp/main.nf b/modules/merquryfk/katcomp/main.nf new file mode 100644 index 00000000..cba98edf --- /dev/null +++ b/modules/merquryfk/katcomp/main.nf @@ -0,0 +1,45 @@ +process MERQURYFK_KATCOMP { + tag "$meta.id" + label 'process_medium' + + if (params.enable_conda) { + error "Conda environments cannot be used when using the FastK tool. Please use docker or singularity containers." + } + container 'ghcr.io/nbisweden/fastk_genescopefk_merquryfk:1.0' + + input: + tuple val(meta), path(fastk1_hist), path(fastk1_ktab), path(fastk2_hist), path(fastk2_ktab) + + output: + tuple val(meta), path("*.fi.png"), emit: filled_png , optional: true + tuple val(meta), path("*.ln.png"), emit: line_png , optional: true + tuple val(meta), path("*.st.png"), emit: stacked_png, optional: true + tuple val(meta), path("*.fi.pdf"), emit: filled_pdf , optional: true + tuple val(meta), path("*.ln.pdf"), emit: line_pdf , optional: true + tuple val(meta), path("*.st.pdf"), emit: stacked_pdf, optional: true + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def FASTK_VERSION = 'f18a4e6d2207539f7b84461daebc54530a9559b0' + def MERQURY_VERSION = '8f3ab706e4cf4d7b7d1dfe5739859e3ebd26c494' + """ + KatComp \\ + $args \\ + -T$task.cpus \\ + ${fastk1_ktab.find{ it.toString().endsWith(".ktab") }} \\ + ${fastk2_ktab.find{ it.toString().endsWith(".ktab") }} \\ + $prefix + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + fastk: $FASTK_VERSION + merquryfk: $MERQURY_VERSION + r: \$( R --version | sed '1!d; s/.*version //; s/ .*//' ) + END_VERSIONS + """ +} diff --git a/modules/merquryfk/katcomp/meta.yml b/modules/merquryfk/katcomp/meta.yml new file mode 100644 index 00000000..8518ea55 --- /dev/null +++ b/modules/merquryfk/katcomp/meta.yml @@ -0,0 +1,75 @@ +name: "merquryfk_katcomp" +description: A reimplemenation of Kat Comp to work with FastK databases +keywords: + - fastk + - k-mer + - compare +tools: + - "merquryfk": + description: "FastK based version of Merqury" + homepage: "https://github.com/thegenemyers/MERQURY.FK" + documentation: "" + tool_dev_url: "https://github.com/thegenemyers/MERQURY.FK" + doi: "" + licence: "https://github.com/thegenemyers/MERQURY.FK/blob/main/LICENSE" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - fastk1_hist: + type: file + description: A histogram files from the program FastK + pattern: "*.hist" + - fastk1_ktab: + type: file + description: Histogram ktab files from the program FastK (option -t) + pattern: "*.ktab*" + - fastk2_hist: + type: file + description: A histogram files from the program FastK + pattern: "*.hist" + - fastk2_ktab: + type: file + description: Histogram ktab files from the program FastK (option -t) + pattern: "*.ktab*" + +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" + - filled_png: + type: file + description: Comparison of Kmers between sample 1 and 2 in filled PNG format. + pattern: "*.fi.png" + - line_png: + type: file + description: Comparison of Kmers between sample 1 and 2 in line PNG format. + pattern: "*.ln.png" + - stacked_png: + type: file + description: Comparison of Kmers between sample 1 and 2 in stacked PNG format. + pattern: "*.st.png" + - filled_pdf: + type: file + description: Comparison of Kmers between sample 1 and 2 in filled PDF format. + pattern: "*.fi.pdf" + - line_pdf: + type: file + description: Comparison of Kmers between sample 1 and 2 in line PDF format. + pattern: "*.ln.pdf" + - stacked_pdf: + type: file + description: Comparison of Kmers between sample 1 and 2 in stacked PDF format. + pattern: "*.st.pdf" + +authors: + - "@mahesh-panchal" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index f4d32f8c..6bd5b230 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1342,6 +1342,10 @@ meningotype: - modules/meningotype/** - tests/modules/meningotype/** +merquryfk/katcomp: + - modules/merquryfk/katcomp/** + - tests/modules/merquryfk/katcomp/** + merquryfk/merquryfk: - modules/merquryfk/merquryfk/** - tests/modules/merquryfk/merquryfk/** diff --git a/tests/modules/merquryfk/katcomp/main.nf b/tests/modules/merquryfk/katcomp/main.nf new file mode 100644 index 00000000..74d9a3ea --- /dev/null +++ b/tests/modules/merquryfk/katcomp/main.nf @@ -0,0 +1,41 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { FASTK_FASTK as FASTK1 } from '../../../../modules/fastk/fastk/main.nf' +include { FASTK_FASTK as FASTK2 } from '../../../../modules/fastk/fastk/main.nf' +include { MERQURYFK_KATCOMP } from '../../../../modules/merquryfk/katcomp/main.nf' + +workflow test_merquryfk_katcomp_png { + + input = [ + [ id:'test', single_end:true ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_1_fastq_gz'], checkIfExists: true) + ] + + FASTK1 ( input ) + FASTK2 ( input ) + MERQURYFK_KATCOMP ( + FASTK1.out.hist + .join( FASTK1.out.ktab ) + .join( FASTK2.out.hist ) + .join( FASTK2.out.ktab ) + ) +} + +workflow test_merquryfk_katcomp_pdf { + + input = [ + [ id:'test', single_end:true ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_1_fastq_gz'], checkIfExists: true) + ] + + FASTK1 ( input ) + FASTK2 ( input ) + MERQURYFK_KATCOMP ( + FASTK1.out.hist + .join( FASTK1.out.ktab ) + .join( FASTK2.out.hist ) + .join( FASTK2.out.ktab ) + ) +} diff --git a/tests/modules/merquryfk/katcomp/nextflow.config b/tests/modules/merquryfk/katcomp/nextflow.config new file mode 100644 index 00000000..02629e80 --- /dev/null +++ b/tests/modules/merquryfk/katcomp/nextflow.config @@ -0,0 +1,19 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: 'FASTK.*' { + ext.args = '-t' + publishDir = [ enabled: false ] + } + withName: 'FASTK1' { + ext.prefix = { "${meta.id}_sampleA" } + } + withName: 'FASTK2' { + ext.prefix = { "${meta.id}_sampleB" } + } + withName: 'test_merquryfk_katcomp_pdf:MERQURYFK_KATCOMP' { + ext.args = '-pdf' + } + +} diff --git a/tests/modules/merquryfk/katcomp/test.yml b/tests/modules/merquryfk/katcomp/test.yml new file mode 100644 index 00000000..18a35462 --- /dev/null +++ b/tests/modules/merquryfk/katcomp/test.yml @@ -0,0 +1,22 @@ +- name: merquryfk katcomp test_merquryfk_katcomp_png + command: nextflow run ./tests/modules/merquryfk/katcomp -entry test_merquryfk_katcomp_png -c ./tests/config/nextflow.config -c ./tests/modules/merquryfk/katcomp/nextflow.config + tags: + - merquryfk + - merquryfk/katcomp + files: + - path: output/merquryfk/test.fi.png + md5sum: 83b30d2f6103190887e66d3690c63d55 + - path: output/merquryfk/test.ln.png + md5sum: 6d223a9b91937b1f984e3415fd1580bb + - path: output/merquryfk/test.st.png + md5sum: 00a851c8f1c7f2f5b8bb57c6f07b161c + +- name: merquryfk katcomp test_merquryfk_katcomp_pdf + command: nextflow run ./tests/modules/merquryfk/katcomp -entry test_merquryfk_katcomp_pdf -c ./tests/config/nextflow.config -c ./tests/modules/merquryfk/katcomp/nextflow.config + tags: + - merquryfk + - merquryfk/katcomp + files: + - path: output/merquryfk/test.fi.pdf + - path: output/merquryfk/test.ln.pdf + - path: output/merquryfk/test.st.pdf