diff --git a/CHANGELOG.md b/CHANGELOG.md index 59f50133..7e061055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Added` +- [#229](https://github.com/nf-core/bacass/pull/229) Add homopolish for nanopore-only assembly. - [#195](https://github.com/nf-core/bacass/pull/195) Update nf-core/bacass to the new nf-core 3.2.0 `TEMPLATE`. ### `Fixed` diff --git a/README.md b/README.md index 01c607d1..ae9724f0 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ This pipeline is primarily for bacterial assembly of next-generation sequencing For users that only have Nanopore data, the pipeline quality trims these using [PoreChop](https://github.com/rrwick/Porechop) and assesses basic sequencing QC utilizing [NanoPlot](https://github.com/wdecoster/NanoPlot) and [PycoQC](https://github.com/a-slide/pycoQC). Contamination of the assembly is checked using [Kraken2](https://ccb.jhu.edu/software/kraken2/) and [Kmerfinder](https://bitbucket.org/genomicepidemiology/kmerfinder/src/master/) to verify sample purity. -The pipeline can then perform long read assembly utilizing [Unicycler](https://github.com/rrwick/Unicycler), [Miniasm](https://github.com/lh3/miniasm) in combination with [Racon](https://github.com/isovic/racon), [Canu](https://github.com/marbl/canu) or [Flye](https://github.com/fenderglass/Flye) by using the [Dragonflye](https://github.com/rpetit3/dragonflye)(\*) pipeline. Long reads assembly can be polished using [Medaka](https://github.com/nanoporetech/medaka) or [NanoPolish](https://github.com/jts/nanopolish) with Fast5 files. +The pipeline can then perform long read assembly utilizing [Unicycler](https://github.com/rrwick/Unicycler), [Miniasm](https://github.com/lh3/miniasm) in combination with [Racon](https://github.com/isovic/racon), [Canu](https://github.com/marbl/canu) or [Flye](https://github.com/fenderglass/Flye) by using the [Dragonflye](https://github.com/rpetit3/dragonflye)(\*) pipeline. Long reads assembly can be polished using [Medaka](https://github.com/nanoporetech/medaka), **Medaka** folowed by [Homopolish](https://github.com/ythuang0522/homopolish) or [NanoPolish](https://github.com/jts/nanopolish) with Fast5 files. > [!NOTE] > Dragonflye is a comprehensive pipeline designed for genome assembly of Oxford Nanopore Reads. It facilitates the utilization of Flye (default), Miniasm, and Raven assemblers, along with Racon (default) and Medaka polishers. For more information, visit the [Dragonflye GitHub](https://github.com/rpetit3/dragonflye) repository. diff --git a/conf/modules.config b/conf/modules.config index 2e2da16e..b86c2746 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -158,6 +158,24 @@ process { ] } + withName: 'HOMOPOLISH_SKETCH_PREPARATION' { + ext.args = '' + publishDir = [ + path: { "${params.outdir}/Homopolish_sketch" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename } + ] + } + + withName: 'HOMOPOLISH' { + ext.args = '' + publishDir = [ + path: { "${params.outdir}/Homopolish" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename } + ] + } + withName: 'KRAKEN2' { ext.args = '' publishDir = [ diff --git a/modules/local/homopolish/environment.yml b/modules/local/homopolish/environment.yml new file mode 100644 index 00000000..506c9996 --- /dev/null +++ b/modules/local/homopolish/environment.yml @@ -0,0 +1,8 @@ +name: homopolish +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::homopolish=0.4.1 + - conda-forge::more-itertools=9.1.0 diff --git a/modules/local/homopolish/main.nf b/modules/local/homopolish/main.nf new file mode 100644 index 00000000..b16baf43 --- /dev/null +++ b/modules/local/homopolish/main.nf @@ -0,0 +1,35 @@ +process HOMOPOLISH { + tag "$meta.id" + label 'process_high' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/homopolish:0.4.1--pyhdfd78af_1' : + 'biocontainers/homopolish:0.4.1--pyhdfd78af_0' }" + + input: + tuple val(meta), path(medaka_genome) + tuple val(meta_gunzip), path(bacteria_sketch) + + output: + tuple val(meta), path('*_genome_homopolished.fasta') , emit: assembly + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + homopolish polish \ + -a $medaka_genome \ + -s $bacteria_sketch \ + -m $params.homopolish_model \ + -o . + cat <<-END_VERSIONS > versions.yml + "${task.process}": + homopolish: \$( homopolish --version 2>&1 | sed 's/Homopolish VERSION: *//g' ) + END_VERSIONS + + """ +} diff --git a/modules/local/homopolish/sketch_preparation/environment.yml b/modules/local/homopolish/sketch_preparation/environment.yml new file mode 100644 index 00000000..93cd1cdd --- /dev/null +++ b/modules/local/homopolish/sketch_preparation/environment.yml @@ -0,0 +1,7 @@ +name: homopolish_sketch_preparation +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - conda-forge::sed=4.7 diff --git a/modules/local/homopolish/sketch_preparation/main.nf b/modules/local/homopolish/sketch_preparation/main.nf new file mode 100644 index 00000000..ee7d9ae8 --- /dev/null +++ b/modules/local/homopolish/sketch_preparation/main.nf @@ -0,0 +1,25 @@ +process HOMOPOLISH_SKETCH_PREPARATION { + label 'process_low' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/curl:7.80.0' : + 'biocontainers/curl:7.80.0' }" + + input: + val(meta) + path(url) + + output: + tuple val(meta), path("bacteria.msh.gz"), emit: sketch + path "versions.yml" , emit: versions + + script: + """ + curl $params.homopolish_bacteria_sketch_url + cat <<-END_VERSIONS > versions.yml + "${task.process}": + Homopolish_Sketch Bacteria: $params.homopolish_bacteria_last + END_VERSIONS + """ +} diff --git a/nextflow.config b/nextflow.config index 00a777f6..be1af874 100644 --- a/nextflow.config +++ b/nextflow.config @@ -33,7 +33,11 @@ params { dragonflye_args = '' // Assembly polishing - polish_method = 'medaka' // Allowed: ['medaka', 'nanopolish'] + polish_method = 'medaka' // Allowed: ['medaka', 'nanopolish', 'medaka_homopolish'] + homopolish_bacteria_sketch_url = 'https://bioinfo.cs.ccu.edu.tw/bioinfo/downloads/Homopolish_Sketch/bacteria.msh.gz' + homopolish_bacteria_last = '2024-08-16' // From: https://bioinfo.cs.ccu.edu.tw/bioinfo/download.html + homopolish_model = 'R9.4.pkl' // Allowed: ['R9.4.pkl', 'R10.3.pkl', 'pb.pkl'] + homopolish_reload_sketch = false // Annotation annotation_tool = 'prokka' // Allowed: ['prokka', 'bakta','dfast'] diff --git a/nextflow_schema.json b/nextflow_schema.json index 45ac9f85..5ec772bf 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -153,7 +153,36 @@ "fa_icon": "fas fa-hotdog", "description": "Which assembly polishing method to use.", "help_text": "Can be used to define which polishing method is used by default for long reads.", - "enum": ["medaka", "nanopolish"] + "enum": ["medaka", "nanopolish", "medaka_homopolish"] + }, + "homopolish_model": { + "type": "string", + "default": "R9.4.pkl", + "fa_icon": "fas fa-hotdog", + "description": "Which homopolish polishing model to use.", + "help_text": "Used to define which homopolish polishing model is used for long reads after medaka.", + "enum": ["R9.4.pkl", "R10.3.pkl", "pb.pkl"] + }, + "homopolish_reload_sketch": { + "type": "boolean", + "default": false, + "fa_icon": "fas fa-hotdog", + "description": "Reload homopolish bacteria sketch.", + "help_text": "Used to define if homopolish bacteria sketch has to be reloaded from its download webpage." + }, + "homopolish_bacteria_sketch_url": { + "type": "string", + "default": "https://bioinfo.cs.ccu.edu.tw/bioinfo/downloads/Homopolish_Sketch/bacteria.msh.gz", + "fa_icon": "fas fa-hotdog", + "description": "Homopolish Bacteria Sketch download URL.", + "help_text": "Can be used to define the URL for downloading the bacteria Homopolish Sketch." + }, + "homopolish_bacteria_last": { + "type": "string", + "default": "2024-08-16", + "fa_icon": "fas fa-hotdog", + "description": "Homopolish Bacteria Sketch version date.", + "help_text": "Defines the Homopolish Sketch version date for version reporting." } } }, diff --git a/subworkflows/local/utils_nfcore_bacass_pipeline/main.nf b/subworkflows/local/utils_nfcore_bacass_pipeline/main.nf index 49a08558..3198ea75 100644 --- a/subworkflows/local/utils_nfcore_bacass_pipeline/main.nf +++ b/subworkflows/local/utils_nfcore_bacass_pipeline/main.nf @@ -221,6 +221,7 @@ def toolCitationText() { "Canu (Sergey Koren et al. 2017)", "Medaka (Heng Li)", "Nanopolish (Loman 2015)", + "Homopolish (Huang, Y.-T., Liu, P.-Y., and Shih, P.-W. 2021)", "Quast (Alexey Gurevich et al. 2013)", "Prokka (Torsten Seemann 2014)", "Bakta (Oliver Schwengers 2021)", @@ -249,6 +250,7 @@ def toolBibliographyText() { "
  • Koren S, Walenz BP, Berlin K, Miller JR, Bergman NH, Phillippy AM. Canu: scalable and accurate long-read assembly via adaptive k-mer weighting and repeat separation. Genome Res. 2017 May;27(5):722-736. doi: 10.1101/gr.215087.116.
  • ", "
  • Medaka: Sequence correction provided by ONT Research. https://github.com/nanoporetech/medaka,
  • ", "
  • Loman, N., Quick, J. & Simpson, J. A complete bacterial genome assembled de novo using only nanopore sequencing data. Nat Methods 12, 733–735 (2015). https://doi.org/10.1038/nmeth.3444
  • ", + "
  • Huang, Y.-T., Liu, P.-Y., and Shih, P.-W. Homopolish: a method for the revmoal of systematic errors in nanopore sequencing by homologous polishing, Genome Biology, 2021. https://genomebiology.biomedcentral.com/articles/10.1186/s13059-021-02282-6
  • ", "
  • Gurevich A, Saveliev V, Vyahhi N, Tesler G. QUAST: quality assessment tool for genome assemblies. Bioinformatics. 2013 Apr 15;29(8):1072-5. doi: 10.1093/bioinformatics/btt086. Epub 2013 Feb 19.
  • ", "
  • Seemann T. Prokka: rapid prokaryotic genome annotation. Bioinformatics. 2014 Jul 15;30(14):2068-9. doi: 10.1093/bioinformatics/btu153.
  • ", "
  • Schwengers O, Jelonek L, Dieckmann MA, Beyvers S, Blom J, Goesmann A. Bakta: rapid and standardized annotation of bacterial genomes via alignment-free sequence identification. Microb Genom. 2021 Nov;7(11):000685. doi: 10.1099/mgen.0.000685.
  • ", diff --git a/workflows/bacass.nf b/workflows/bacass.nf index 3a45774d..da78fc1e 100644 --- a/workflows/bacass.nf +++ b/workflows/bacass.nf @@ -8,12 +8,14 @@ // // MODULE: Local to the pipeline // -include { PYCOQC } from '../modules/local/pycoqc' -include { NANOPOLISH } from '../modules/local/nanopolish' -include { MEDAKA } from '../modules/local/medaka' -include { KRAKEN2_DB_PREPARATION } from '../modules/local/kraken2/db_preparation' -include { DFAST } from '../modules/local/dfast' -include { CUSTOM_MULTIQC } from '../modules/local/custom/multiqc' +include { PYCOQC } from '../modules/local/pycoqc' +include { NANOPOLISH } from '../modules/local/nanopolish' +include { MEDAKA } from '../modules/local/medaka' +include { KRAKEN2_DB_PREPARATION } from '../modules/local/kraken2/db_preparation' +include { DFAST } from '../modules/local/dfast' +include { CUSTOM_MULTIQC } from '../modules/local/custom/multiqc' +include { HOMOPOLISH_SKETCH_PREPARATION } from '../modules/local/homopolish/sketch_preparation' +include { HOMOPOLISH } from '../modules/local/homopolish' // // MODULE: Installed directly from nf-core/modules @@ -37,6 +39,7 @@ include { KRAKEN2_KRAKEN2 as KRAKEN2_LONG } from '../modules/nf-core/krake include { QUAST } from '../modules/nf-core/quast' include { QUAST as QUAST_BYREFSEQID } from '../modules/nf-core/quast' include { GUNZIP } from '../modules/nf-core/gunzip' +include { GUNZIP as GUNZIP_HOMOPOLISH } from '../modules/nf-core/gunzip' include { PROKKA } from '../modules/nf-core/prokka' // @@ -304,13 +307,40 @@ workflow BACASS { .join( ch_assembly ) .map { meta, sr, lr, fasta -> tuple(meta, lr, fasta) } .set { ch_polish_long } // channel: [ val(meta), path(lr), path(fasta) ] - if (params.polish_method == 'medaka'){ + if (params.polish_method in ['medaka', 'medaka_homopolish'] ){ // // MODULE: Medaka, polishes assembly - should take either miniasm, canu, or unicycler consensus sequence // MEDAKA ( ch_polish_long ) ch_assembly = MEDAKA.out.assembly ch_versions = ch_versions.mix(MEDAKA.out.versions) + // If homopolish after medaka + if (params.polish_method == 'medaka_homopolish') { + // Check if sketch file already exists + sketch_path = "$baseDir/$params.outdir/Homopolish_sketch/bacteria.msh.gz" + sketch_file = new File(sketch_path) + // If sketch exists and not forced to reload, unzip sketch from outdir + if (sketch_file.exists() & !params.homopolish_reload_sketch) { + ch_sketch = tuple( + ch_assembly.collect{it[1]}, // meta from assembly channel + sketch_path + ) + GUNZIP_HOMOPOLISH( ch_sketch ) + } else { + // MODULE: Download bacteria sketch + HOMOPOLISH_SKETCH_PREPARATION( + ch_assembly.collect{it[1]}, // meta + params.homopolish_bacteria_sketch_url + ) + ch_versions = ch_versions.mix(HOMOPOLISH_SKETCH_PREPARATION.out.versions) + // Unzip bacteria sketch + GUNZIP_HOMOPOLISH ( HOMOPOLISH_SKETCH_PREPARATION.out.sketch ) + } + // MODULE: Homopolish, polishes MEDAKA assembly + HOMOPOLISH ( ch_assembly, GUNZIP_HOMOPOLISH.out.gunzip ) + ch_assembly = HOMOPOLISH.out.assembly + ch_versions = ch_versions.mix(HOMOPOLISH.out.versions) + } } else if (params.polish_method == 'nanopolish') { // // MODULE: Nanopolish, polishes assembly using FAST5 files