diff --git a/modules/nf-core/priorcons/integrate_consensus/environment.yml b/modules/nf-core/priorcons/integrate_consensus/environment.yml new file mode 100644 index 00000000000..fdb7dc003aa --- /dev/null +++ b/modules/nf-core/priorcons/integrate_consensus/environment.yml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - conda-forge + - bioconda +dependencies: + - bioconda::priorcons=0.1.0 diff --git a/modules/nf-core/priorcons/integrate_consensus/main.nf b/modules/nf-core/priorcons/integrate_consensus/main.nf new file mode 100644 index 00000000000..961109c950e --- /dev/null +++ b/modules/nf-core/priorcons/integrate_consensus/main.nf @@ -0,0 +1,73 @@ + +process PRIORCONS_INTEGRATE_CONSENSUS { + tag "$meta.id" + label 'process_low' + + // Activate conda env + conda "${moduleDir}/environment.yml" + + //container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + //'https://depot.galaxyproject.org/singularity/priorcons:0.1.0--pyhdfd78af_0' : + //'quay.io/biocontainers/priorcons:0.1.0--pyhdfd78af_0' }" + + input: + tuple val(meta), path(input_aln), val(ref_id), path(prior_parquet) + + output: + tuple val(meta), path("${meta.id}_output"), emit: results + 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}" + + """ + priorcons integrate-consensus \\ + --input $input_aln \\ + --ref $ref_id \\ + --prior $prior_parquet \\ + --output_dir ${prefix}_output \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + priorcons: \$(priorcons --version 2>&1 | head -n1 || echo "v0.1.0") + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + mkdir -p ${prefix}_output + + # Create stub out files + echo ">${prefix}_integrated_consensus" > ${prefix}_output/${prefix}-INTEGRATED.fasta + echo "ATCGATCGATCG" >> ${prefix}_output/${prefix}-INTEGRATED.fasta + + # Create windows_trace.csv stub + cat <<-EOF > ${prefix}_output/windows_trace.csv + window_start,window_end,score,selected_sequence + 1,100,0.95,mapping_consensus + 101,200,0.87,abacas_consensus + EOF + + # Create qc.json stub + cat <<-EOF > ${prefix}_output/qc.json + { + "total_windows": 150, + "mapping_selected": 95, + "abacas_selected": 55, + "average_score": 0.91 + } + EOF + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + priorcons: "v0.1.0" + END_VERSIONS + """ +} \ No newline at end of file diff --git a/modules/nf-core/priorcons/integrate_consensus/meta.yml b/modules/nf-core/priorcons/integrate_consensus/meta.yml new file mode 100644 index 00000000000..807c209659f --- /dev/null +++ b/modules/nf-core/priorcons/integrate_consensus/meta.yml @@ -0,0 +1,55 @@ +name: PRIORCONS_INTEGRATE_CONSENSUS +description: Integrate consensus sequences using the PriorCons tool with prior + probabilities for improved consensus calling +keywords: + - consensus + - integration + - priorcons + - sequencing + - viral + - genomics +authors: + - "@GERMAN00VP" + +tools: + - priorcons: + description: "Tool for integrating consensus sequences using prior probabilities" + homepage: "https://github.com/GERMAN00VP/PriorCons" + documentation: "https://github.com/GERMAN00VP/PriorCons" + doi: "no DOI available" + licence: ["APL-1.0"] + identifier: "" + +input: + - - meta: + type: map + description: "Groovy Map containing sample information, e.g. [ id:'sample1', + single_end:false ]" + - input_aln: + type: file + description: "Input alignment file containing reference, mapping consensus, + and ABACAS consensus sequences (exactly in that order)" + pattern: "*.{aln,fasta,fa}" + ontologies: [] + - ref_id: + type: string + description: "Reference identifier for the consensus sequence" + - prior_parquet: + type: file + description: "Prior probabilities table in Parquet format" + pattern: "*.parquet" + + ontologies: [] +output: + results: + - - meta: + type: map + description: "Groovy Map containing sample information" + - ${meta.id}_output: + type: directory + description: "Output directory containing integrated consensus and QC files" + versions: + - versions.yml: + type: file + description: "File containing software versions" + ontologies: [] diff --git a/modules/nf-core/priorcons/integrate_consensus/tests/main.nf.test b/modules/nf-core/priorcons/integrate_consensus/tests/main.nf.test new file mode 100644 index 00000000000..68aab29a6f7 --- /dev/null +++ b/modules/nf-core/priorcons/integrate_consensus/tests/main.nf.test @@ -0,0 +1,60 @@ +// nf-core modules test priorcons +nextflow_process { + + name "Test Process PRIORCONS_INTEGRATE_CONSENSUS" + script "../main.nf" + process "PRIORCONS_INTEGRATE_CONSENSUS" + + tag "modules" + tag "modules_nfcore" + tag "priorcons" + tag "priorcons/integrate_consensus" + + test("rsv - alignment and priors") { + + when { + process { + """ + input[0] = [ + [ id:'test_sample' ], + file("https://raw.githubusercontent.com/GERMAN00VP/PriorCons/refs/heads/main/rsv_files/test_aln.aln", checkIfExists: true), + "RSV_BD", + file("https://raw.githubusercontent.com/GERMAN00VP/PriorCons/refs/heads/main/rsv_files/RSV_priors/RSVBD_win100_ovlp50_priors.parquet", checkIfExists: true) + ] + """ + } + } + + then { + assert process.success + assertAll( + { assert snapshot(process.out).match() } + ) + } + } + + test("rsv - alignment and priors - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test_sample' ], + file("https://raw.githubusercontent.com/GERMAN00VP/PriorCons/refs/heads/main/rsv_files/test_aln.aln", checkIfExists: true), + "RSV_BD", + file("https://raw.githubusercontent.com/GERMAN00VP/PriorCons/refs/heads/main/rsv_files/RSV_priors/RSVBD_win100_ovlp50_priors.parquet", checkIfExists: true) + ] + """ + } + } + + then { + assert process.success + assertAll( + { assert snapshot(process.out).match() } + ) + } + } +} \ No newline at end of file diff --git a/modules/nf-core/priorcons/integrate_consensus/tests/main.nf.test.snap b/modules/nf-core/priorcons/integrate_consensus/tests/main.nf.test.snap new file mode 100644 index 00000000000..fbadfa41230 --- /dev/null +++ b/modules/nf-core/priorcons/integrate_consensus/tests/main.nf.test.snap @@ -0,0 +1,84 @@ +{ + "rsv - alignment and priors - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test_sample" + }, + [ + "qc.json:md5,71a1cb3e5374a26598ac9007827dd93d", + "test_sample-INTEGRATED.fasta:md5,36171c110b33501cc6e914c833701a5b", + "windows_trace.csv:md5,f30c5600c891536a8267fd842ccc6bb7" + ] + ] + ], + "1": [ + "versions.yml:md5,a071d22d6ee41cb1c1f6ef405449cf88" + ], + "results": [ + [ + { + "id": "test_sample" + }, + [ + "qc.json:md5,71a1cb3e5374a26598ac9007827dd93d", + "test_sample-INTEGRATED.fasta:md5,36171c110b33501cc6e914c833701a5b", + "windows_trace.csv:md5,f30c5600c891536a8267fd842ccc6bb7" + ] + ] + ], + "versions": [ + "versions.yml:md5,a071d22d6ee41cb1c1f6ef405449cf88" + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.0" + }, + "timestamp": "2025-10-29T14:34:35.32780199" + }, + "rsv - alignment and priors": { + "content": [ + { + "0": [ + [ + { + "id": "test_sample" + }, + [ + "qc.json:md5,4b4e02ba2ea95927346978c8e70c64bb", + "test_aln-INTEGRATED.fasta:md5,bf934389f1e443d6d629c40388a54ebc", + "windows_trace.csv:md5,313ba6650eededbe120b6efb9e31daa6" + ] + ] + ], + "1": [ + "versions.yml:md5,00491161097c256612e9ba72d13a183f" + ], + "results": [ + [ + { + "id": "test_sample" + }, + [ + "qc.json:md5,4b4e02ba2ea95927346978c8e70c64bb", + "test_aln-INTEGRATED.fasta:md5,bf934389f1e443d6d629c40388a54ebc", + "windows_trace.csv:md5,313ba6650eededbe120b6efb9e31daa6" + ] + ] + ], + "versions": [ + "versions.yml:md5,00491161097c256612e9ba72d13a183f" + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.0" + }, + "timestamp": "2025-10-29T14:31:17.242646235" + } +} \ No newline at end of file