diff --git a/modules/nf-core/hifiadapterfilt/environment.yml b/modules/nf-core/hifiadapterfilt/environment.yml new file mode 100644 index 00000000000..aff605bdc36 --- /dev/null +++ b/modules/nf-core/hifiadapterfilt/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::hifiadapterfilt=3.0.0 diff --git a/modules/nf-core/hifiadapterfilt/main.nf b/modules/nf-core/hifiadapterfilt/main.nf new file mode 100644 index 00000000000..65eb846c1fe --- /dev/null +++ b/modules/nf-core/hifiadapterfilt/main.nf @@ -0,0 +1,63 @@ +process HIFIADAPTERFILT { + tag "$meta.id" + label 'process_medium' + + // WARN: Version information not provided by tool on CLI. Please update version string below when bumping container versions. + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/hifiadapterfilt:3.0.0--hdfd78af_0': + 'quay.io/biocontainers/hifiadapterfilt:3.0.0--hdfd78af_0' }" + + input: + tuple val(meta), path(reads) + + output: + tuple val(meta), path("${prefix}.contaminant.blastout"), emit: blastout + tuple val(meta), path("${prefix}.blocklist") , emit: blocklist + tuple val(meta), path("${prefix}.filt.fastq.gz") , emit: fastq + tuple val(meta), path("${prefix}.stats") , emit: stats + tuple val("${task.process}"), val('hifiadapterfilt'), eval('echo 3.0.0'), topic: versions, emit: versions_hifiadapterfilt + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: "${meta.id}" + def input_ext = "$reads".endsWith('.fastq.gz') ? '.fastq.gz' : + "$reads".endsWith('.fq.gz') ? '.fq.gz' : + "$reads".endsWith('.fastq') ? '.fastq' : + "$reads".endsWith('.fq') ? '.fq' : + "$reads".endsWith('.bam') ? '.bam' : + error("Unsupported input file extension for HiFiAdapterFilt: ${reads}") + def tool_prefix = "hifiadapterfilt_input" + """ + mkdir -p hifiadapterfilt_work + ln -sf "../${reads}" "hifiadapterfilt_work/${tool_prefix}${input_ext}" + + ( + cd hifiadapterfilt_work + hifiadapterfilt.sh \\ + -p all \\ + -t ${task.cpus} \\ + -o .. \\ + ${args} + ) + + if [[ "${tool_prefix}" != "${prefix}" ]]; then + mv ${tool_prefix}.contaminant.blastout ${prefix}.contaminant.blastout + mv ${tool_prefix}.blocklist ${prefix}.blocklist + mv ${tool_prefix}.filt.fastq.gz ${prefix}.filt.fastq.gz + mv ${tool_prefix}.stats ${prefix}.stats + fi + """ + + stub: + prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.contaminant.blastout + touch ${prefix}.blocklist + echo "" | gzip > ${prefix}.filt.fastq.gz + touch ${prefix}.stats + """ +} diff --git a/modules/nf-core/hifiadapterfilt/meta.yml b/modules/nf-core/hifiadapterfilt/meta.yml new file mode 100644 index 00000000000..8e07d856fab --- /dev/null +++ b/modules/nf-core/hifiadapterfilt/meta.yml @@ -0,0 +1,107 @@ +name: hifiadapterfilt +description: Remove remnant PacBio adapter sequences from HiFi reads and convert BAM input to compressed FASTQ +keywords: + - PacBio + - HiFi + - adapter filtering + - long reads + - FASTQ +tools: + - hifiadapterfilt: + description: HiFiAdapterFilt removes CCS reads with remnant PacBio adapter sequences and converts outputs to compressed FASTQ. + homepage: https://github.com/sheinasim-USDA/HiFiAdapterFilt + documentation: https://github.com/sheinasim-USDA/HiFiAdapterFilt + tool_dev_url: https://github.com/sheinasim-USDA/HiFiAdapterFilt + doi: "10.1186/s12864-022-08375-1" + licence: + - "GPL-3.0-or-later" + identifier: biotools:hifiadapterfilt +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:true ] + - reads: + type: file + description: PacBio HiFi reads in BAM, FASTQ, or gzip-compressed FASTQ format + pattern: "*.{bam,fastq,fq,fastq.gz,fq.gz}" + ontologies: + - edam: http://edamontology.org/format_2572 # BAM + - edam: http://edamontology.org/format_1930 # FASTQ + - edam: http://edamontology.org/format_3989 # GZIP format +output: + blastout: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:true ] + - ${prefix}.contaminant.blastout: + type: file + description: Tabular BLAST output containing reads aligned to PacBio adapter sequences + pattern: "*.contaminant.blastout" + ontologies: + - edam: http://edamontology.org/format_3475 # TSV + blocklist: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:true ] + - ${prefix}.blocklist: + type: file + description: List of read headers identified as PacBio adapter-contaminated and removed + pattern: "*.blocklist" + ontologies: + - edam: http://edamontology.org/format_2330 # Textual format + fastq: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:true ] + - ${prefix}.filt.fastq.gz: + type: file + description: Gzipped FASTQ file containing reads without detected PacBio adapter contamination + pattern: "*.filt.fastq.gz" + ontologies: + - edam: http://edamontology.org/format_1930 # FASTQ + - edam: http://edamontology.org/format_3989 # GZIP format + stats: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:true ] + - ${prefix}.stats: + type: file + description: Text summary of read counts and adapter-contaminated reads removed + pattern: "*.stats" + ontologies: + - edam: http://edamontology.org/format_2330 # Textual format + versions_hifiadapterfilt: + - - ${task.process}: + type: string + description: The process the versions were collected from + - hifiadapterfilt: + type: string + description: The tool name + - echo 3.0.0: + type: eval + description: The expression to obtain the version of the tool +topics: + versions: + - - ${task.process}: + type: string + description: The process the versions were collected from + - hifiadapterfilt: + type: string + description: The tool name + - echo 3.0.0: + type: eval + description: The expression to obtain the version of the tool +authors: + - "@vagkaratzas" +maintainers: + - "@vagkaratzas" diff --git a/modules/nf-core/hifiadapterfilt/tests/main.nf.test b/modules/nf-core/hifiadapterfilt/tests/main.nf.test new file mode 100644 index 00000000000..9e3108e91ce --- /dev/null +++ b/modules/nf-core/hifiadapterfilt/tests/main.nf.test @@ -0,0 +1,63 @@ +nextflow_process { + + name "Test Process HIFIADAPTERFILT" + script "../main.nf" + process "HIFIADAPTERFILT" + + tag "modules" + tag "modules_nfcore" + tag "hifiadapterfilt" + + test("homo_sapiens - pacbio fastq.gz") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/fastq/alz.ccs.fastq.gz', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert file(process.out.stats.get(0).get(1)).exists() }, + { assert snapshot( + process.out.blastout, + process.out.blocklist, + process.out.fastq, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() } + ) + } + + } + + test("homo_sapiens - pacbio fastq.gz - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/fastq/alz.ccs.fastq.gz', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(sanitizeOutput(process.out)).match() } + ) + } + + } + +} diff --git a/modules/nf-core/hifiadapterfilt/tests/main.nf.test.snap b/modules/nf-core/hifiadapterfilt/tests/main.nf.test.snap new file mode 100644 index 00000000000..4bf6fb557bc --- /dev/null +++ b/modules/nf-core/hifiadapterfilt/tests/main.nf.test.snap @@ -0,0 +1,94 @@ +{ + "homo_sapiens - pacbio fastq.gz - stub": { + "content": [ + { + "blastout": [ + [ + { + "id": "test" + }, + "test.contaminant.blastout:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "blocklist": [ + [ + { + "id": "test" + }, + "test.blocklist:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "fastq": [ + [ + { + "id": "test" + }, + "test.filt.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "stats": [ + [ + { + "id": "test" + }, + "test.stats:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions_hifiadapterfilt": [ + [ + "HIFIADAPTERFILT", + "hifiadapterfilt", + "3.0.0" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-04-25T09:25:43.311147037" + }, + "homo_sapiens - pacbio fastq.gz": { + "content": [ + [ + [ + { + "id": "test" + }, + "test.contaminant.blastout:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + [ + [ + { + "id": "test" + }, + "test.blocklist:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + [ + [ + { + "id": "test" + }, + "test.filt.fastq.gz:md5,23a6d8f301d0fd4d2da21f86ff0afac6" + ] + ], + { + "versions_hifiadapterfilt": [ + [ + "HIFIADAPTERFILT", + "hifiadapterfilt", + "3.0.0" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-04-25T09:38:42.6537421" + } +} \ No newline at end of file