diff --git a/modules/merqury/main.nf b/modules/merqury/main.nf new file mode 100644 index 00000000..4b2d87ce --- /dev/null +++ b/modules/merqury/main.nf @@ -0,0 +1,59 @@ +process MERQURY { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::merqury=1.3" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/merqury:1.3--hdfd78af_1': + 'quay.io/biocontainers/merqury:1.3--hdfd78af_1' }" + + input: + tuple val(meta), path(meryl_db), path(assembly) + + output: + tuple val(meta), path("*_only.bed") , emit: assembly_only_kmers_bed + tuple val(meta), path("*_only.wig") , emit: assembly_only_kmers_wig + tuple val(meta), path("*.completeness.stats"), emit: stats + tuple val(meta), path("*.dist_only.hist") , emit: dist_hist + tuple val(meta), path("*.spectra-cn.fl.png") , emit: spectra_cn_fl_png + tuple val(meta), path("*.spectra-cn.hist") , emit: spectra_cn_hist + tuple val(meta), path("*.spectra-cn.ln.png") , emit: spectra_cn_ln_png + tuple val(meta), path("*.spectra-cn.st.png") , emit: spectra_cn_st_png + tuple val(meta), path("*.spectra-asm.fl.png"), emit: spectra_asm_fl_png + tuple val(meta), path("*.spectra-asm.hist") , emit: spectra_asm_hist + tuple val(meta), path("*.spectra-asm.ln.png"), emit: spectra_asm_ln_png + tuple val(meta), path("*.spectra-asm.st.png"), emit: spectra_asm_st_png + tuple val(meta), path("${prefix}.qv") , emit: assembly_qv + tuple val(meta), path("${prefix}.*.qv") , emit: scaffold_qv + tuple val(meta), path("*.hist.ploidy") , emit: read_ploidy + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + // def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = 1.3 + """ + # Nextflow changes the container --entrypoint to /bin/bash (container default entrypoint: /usr/local/env-execute) + # Check for container variable initialisation script and source it. + if [ -f "/usr/local/env-activate.sh" ]; then + set +u # Otherwise, errors out because of various unbound variables + . "/usr/local/env-activate.sh" + set -u + fi + # limit meryl to use the assigned number of cores. + export OMP_NUM_THREADS=$task.cpus + + merqury.sh \\ + $meryl_db \\ + $assembly \\ + $prefix + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + merqury: $VERSION + END_VERSIONS + """ +} diff --git a/modules/merqury/meta.yml b/modules/merqury/meta.yml new file mode 100644 index 00000000..f9c8d778 --- /dev/null +++ b/modules/merqury/meta.yml @@ -0,0 +1,101 @@ +name: "merqury" +description: k-mer based assembly evaluation. +keywords: + - "k-mer" + - "assembly" + - "evaluation" +tools: + - "merqury": + description: "Evaluate genome assemblies with k-mers and more." + homepage: "None" + documentation: "None" + tool_dev_url: "https://github.com/marbl/merqury" + doi: "10.1186/s13059-020-02134-9" + licence: "['PUBLIC DOMAIN']" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - meryl_db: + type: file + description: "Meryl read database" + - assembly: + type: file + description: FASTA assembly file + +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" + - assembly_only_kmers_bed: + type: file + description: "The positions of the k-mers found only in an assembly for further investigation in .bed" + pattern: "*_only.bed" + - assembly_only_kmers_wig: + type: file + description: "The positions of the k-mers found only in an assembly for further investigation in .wig" + pattern: "*_only.wig" + - stats: + type: file + description: Assembly statistics file + pattern: "*.completeness.stats" + - dist_hist: + type: file + description: Histogram + pattern: "*.dist_only.hist" + - spectra_cn_fl_png: + type: file + description: "Unstacked copy number spectra filled plot in PNG format" + pattern: "*.spectra-cn.fl.png" + - spectra_cn_ln_png: + type: file + description: "Unstacked copy number spectra line plot in PNG format" + pattern: "*.spectra-cn.ln.png" + - spectra_cn_st_png: + type: file + description: "Stacked copy number spectra line plot in PNG format" + pattern: "*.spectra-cn.st.png" + - spectra_cn_hist: + type: file + description: "Copy number spectra histogram" + pattern: "*.spectra-cn.hist" + - spectra_asm_fl_png: + type: file + description: "Unstacked assembly spectra filled plot in PNG format" + pattern: "*.spectra-asm.fl.png" + - spectra_asm_ln_png: + type: file + description: "Unstacked assembly spectra line plot in PNG format" + pattern: "*.spectra-asm.ln.png" + - spectra_asm_st_png: + type: file + description: "Stacked assembly spectra line plot in PNG format" + pattern: "*.spectra-asm.st.png" + - spectra_asm_hist: + type: file + description: "Assembly spectra histogram" + pattern: "*.spectra-asm.hist" + - assembly_qv: + type: file + description: "Assembly consensus quality estimation" + pattern: "*.qv" + - scaffold_qv: + type: file + description: "Scaffold consensus quality estimation" + pattern: "*.qv" + - read_ploidy: + type: file + description: "Ploidy estimate from read k-mer database" + pattern: "*.hist.ploidy" + +authors: + - "@mahesh-panchal" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 2d3281bc..1f8e415f 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1398,6 +1398,10 @@ meningotype: - modules/meningotype/** - tests/modules/meningotype/** +merqury: + - modules/merqury/** + - tests/modules/merqury/** + merquryfk/katcomp: - modules/merquryfk/katcomp/** - tests/modules/merquryfk/katcomp/** diff --git a/tests/modules/merqury/main.nf b/tests/modules/merqury/main.nf new file mode 100644 index 00000000..9a12294b --- /dev/null +++ b/tests/modules/merqury/main.nf @@ -0,0 +1,26 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { MERYL_COUNT } from '../../../modules/meryl/count/main.nf' +include { MERYL_UNIONSUM } from '../../../modules/meryl/unionsum/main.nf' +include { MERQURY } from '../../../modules/merqury/main.nf' + +workflow test_merqury { + + input = [ + [ id:'test', single_end:false ], // meta map + [ + file(params.test_data['homo_sapiens']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_2_fastq_gz'], checkIfExists: true) + ] + ] + assembly = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + ] + + MERYL_COUNT ( input ) + MERYL_UNIONSUM ( MERYL_COUNT.out.meryl_db ) + MERQURY ( MERYL_UNIONSUM.out.meryl_db.join( Channel.value( assembly ) ) ) +} diff --git a/tests/modules/merqury/nextflow.config b/tests/modules/merqury/nextflow.config new file mode 100644 index 00000000..3b8d00ca --- /dev/null +++ b/tests/modules/merqury/nextflow.config @@ -0,0 +1,10 @@ +process { + + withName: 'MERQURY' { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + } + + withName: 'MERYL_COUNT' { + ext.args = 'k=21' + } +} diff --git a/tests/modules/merqury/test.yml b/tests/modules/merqury/test.yml new file mode 100644 index 00000000..ca73d7fb --- /dev/null +++ b/tests/modules/merqury/test.yml @@ -0,0 +1,34 @@ +- name: merqury test_merqury + command: nextflow run ./tests/modules/merqury -entry test_merqury -c ./tests/config/nextflow.config -c ./tests/modules/merqury/nextflow.config + tags: + - merqury + files: + - path: output/merqury/genome_only.bed + md5sum: b611f22cde0e410a2ca07c1eefd042d3 + - path: output/merqury/genome_only.wig + md5sum: 19cf44989af72af597ef80d3489b4882 + - path: output/merqury/test.completeness.stats + - path: output/merqury/test.dist_only.hist + md5sum: e2e6b54b0febef1f0fcf24cd2afd0b7a + - path: output/merqury/test.genome.qv + md5sum: c554315aabcc4207c367805cf3090da3 + - path: output/merqury/test.genome.spectra-cn.fl.png + md5sum: 3265701cbb1ddaed6d5cb6b4560564fd + - path: output/merqury/test.genome.spectra-cn.hist + md5sum: 6140a138ba47cb2b97814c93f80b2575 + - path: output/merqury/test.genome.spectra-cn.ln.png + md5sum: 6386b604a8f0fbc43a1e3473ad9a779e + - path: output/merqury/test.genome.spectra-cn.st.png + md5sum: d5af80c91d23b182589b0ec131047f00 + - path: output/merqury/test.qv + md5sum: 6e04952bc182221c8b9e242dc3298808 + - path: output/merqury/test.spectra-asm.fl.png + md5sum: 60920481d988018a4f36a9be5b10c4ec + - path: output/merqury/test.spectra-asm.hist + md5sum: 541c9d1f87ab5c44df5e9e0acc440f8d + - path: output/merqury/test.spectra-asm.ln.png + md5sum: 54790dd54b5d8948d3676d32da1972df + - path: output/merqury/test.spectra-asm.st.png + md5sum: 010e013b5411ab2790e9a93ee70a574a + - path: output/merqury/test.unionsumdb.hist.ploidy + md5sum: f6904468b41a495c7ce255a7a5f3a302