2022-05-03 07:34:27 +00:00
|
|
|
//
|
|
|
|
// Remove host reads via alignment and export off-target reads
|
|
|
|
//
|
|
|
|
|
2022-10-05 11:40:43 +00:00
|
|
|
include { MINIMAP2_INDEX } from '../../modules/nf-core/minimap2/index/main'
|
|
|
|
include { MINIMAP2_ALIGN } from '../../modules/nf-core/minimap2/align/main'
|
|
|
|
include { SAMTOOLS_VIEW } from '../../modules/nf-core/samtools/view/main'
|
|
|
|
include { SAMTOOLS_BAM2FQ } from '../../modules/nf-core/samtools/bam2fq/main'
|
2022-10-28 09:40:50 +00:00
|
|
|
include { SAMTOOLS_INDEX } from '../../modules/nf-core/samtools/index/main'
|
|
|
|
include { SAMTOOLS_STATS } from '../../modules/nf-core/samtools/stats/main'
|
2022-05-03 07:34:27 +00:00
|
|
|
|
|
|
|
workflow LONGREAD_HOSTREMOVAL {
|
|
|
|
take:
|
|
|
|
reads // [ [ meta ], [ reads ] ]
|
|
|
|
reference // /path/to/fasta
|
|
|
|
index // /path/to/index
|
|
|
|
|
|
|
|
main:
|
|
|
|
ch_versions = Channel.empty()
|
|
|
|
ch_multiqc_files = Channel.empty()
|
|
|
|
|
|
|
|
if ( !params.longread_hostremoval_index ) {
|
2022-10-11 10:38:18 +00:00
|
|
|
ch_minimap2_index = MINIMAP2_INDEX ( [ [], reference ] ).index.map { it[1] }
|
2022-05-03 07:34:27 +00:00
|
|
|
ch_versions = ch_versions.mix( MINIMAP2_INDEX.out.versions )
|
|
|
|
} else {
|
|
|
|
ch_minimap2_index = index
|
|
|
|
}
|
|
|
|
|
|
|
|
MINIMAP2_ALIGN ( reads, ch_minimap2_index, true, false, false )
|
|
|
|
ch_versions = ch_versions.mix( MINIMAP2_ALIGN.out.versions.first() )
|
|
|
|
ch_minimap2_mapped = MINIMAP2_ALIGN.out.bam
|
|
|
|
.map {
|
|
|
|
meta, reads ->
|
|
|
|
[ meta, reads, [] ]
|
|
|
|
}
|
|
|
|
|
2023-02-07 10:43:40 +00:00
|
|
|
// Generate unmapped reads FASTQ for downstream taxprofiling
|
2022-10-05 11:49:35 +00:00
|
|
|
SAMTOOLS_VIEW ( ch_minimap2_mapped , [], [] )
|
2022-05-03 07:34:27 +00:00
|
|
|
ch_versions = ch_versions.mix( SAMTOOLS_VIEW.out.versions.first() )
|
|
|
|
|
|
|
|
SAMTOOLS_BAM2FQ ( SAMTOOLS_VIEW.out.bam, false )
|
|
|
|
ch_versions = ch_versions.mix( SAMTOOLS_BAM2FQ.out.versions.first() )
|
|
|
|
|
2023-02-07 10:43:40 +00:00
|
|
|
// Indexing whole BAM for host removal statistics
|
|
|
|
SAMTOOLS_INDEX ( MINIMAP2_ALIGN.out.bam )
|
2022-10-28 09:40:50 +00:00
|
|
|
ch_versions = ch_versions.mix( SAMTOOLS_INDEX.out.versions.first() )
|
|
|
|
|
2022-11-22 15:50:50 +00:00
|
|
|
bam_bai = MINIMAP2_ALIGN.out.bam
|
2023-03-07 12:48:38 +00:00
|
|
|
.join(SAMTOOLS_INDEX.out.bai)
|
2022-10-28 09:40:50 +00:00
|
|
|
|
|
|
|
SAMTOOLS_STATS ( bam_bai, reference )
|
|
|
|
ch_versions = ch_versions.mix(SAMTOOLS_STATS.out.versions.first())
|
|
|
|
ch_multiqc_files = ch_multiqc_files.mix( SAMTOOLS_STATS.out.stats )
|
|
|
|
|
2022-05-03 07:34:27 +00:00
|
|
|
emit:
|
2022-10-28 09:40:50 +00:00
|
|
|
stats = SAMTOOLS_STATS.out.stats //channel: [val(meta), [reads ] ]
|
2022-05-03 07:34:27 +00:00
|
|
|
reads = SAMTOOLS_BAM2FQ.out.reads // channel: [ val(meta), [ reads ] ]
|
|
|
|
versions = ch_versions // channel: [ versions.yml ]
|
2022-10-28 09:40:50 +00:00
|
|
|
mqc = ch_multiqc_files
|
2022-05-03 07:34:27 +00:00
|
|
|
}
|
|
|
|
|