Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Subworkflow: Bam_trim_primers_ivar #3130

Closed
wants to merge 10 commits into from
44 changes: 44 additions & 0 deletions subworkflows/nf-core/bam_trim_primers_ivar/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
include { IVAR_TRIM } from '../../../modules/nf-core/ivar/trim/main'
include { BAM_SORT_STATS_SAMTOOLS } from '../bam_sort_stats_samtools/main'

workflow BAM_TRIM_PRIMERS_IVAR {
take:
ch_bam // channel: [ val(meta), path(bam), path(bai) ]
ch_bed // channel: [ path(bed) ]
ch_fasta // channel: [ path(fasta) ]

main:
ch_versions = Channel.empty()

//
// iVar trim primers
//
IVAR_TRIM (
ch_bam,
ch_bed
)
ch_versions = ch_versions.mix(IVAR_TRIM.out.versions.first())

//
// Sort, index BAM file and run samtools stats, flagstat and idxstats
//
BAM_SORT_STATS_SAMTOOLS (
IVAR_TRIM.out.bam,
ch_fasta
)

ch_versions = ch_versions.mix(BAM_SORT_STATS_SAMTOOLS.out.versions.first())

emit:
bam_orig = IVAR_TRIM.out.bam // channel: [ val(meta), path(bam) ]
log_out = IVAR_TRIM.out.log // channel: [ val(meta), path(log) ]

bam = BAM_SORT_STATS_SAMTOOLS.out.bam // channel: [ val(meta), path(bam) ]
bai = BAM_SORT_STATS_SAMTOOLS.out.bai // channel: [ val(meta), path(bai) ]
csi = BAM_SORT_STATS_SAMTOOLS.out.csi // channel: [ val(meta), path(csi) ]
stats = BAM_SORT_STATS_SAMTOOLS.out.stats // channel: [ val(meta), path(stats) ]
flagstat = BAM_SORT_STATS_SAMTOOLS.out.flagstat // channel: [ val(meta), path(flagstat) ]
idxstats = BAM_SORT_STATS_SAMTOOLS.out.idxstats // channel: [ val(meta), path(idxstats) ]

versions = ch_versions // channel: [ path(versions.yml) ]
}
102 changes: 102 additions & 0 deletions subworkflows/nf-core/bam_trim_primers_ivar/meta.yml
Joon-Klaps marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: "bam_trim_primers_ivar"
description: Trim primers using IVAR tools and perform summary statistics.
keywords:
- amplicon sequencing
- trimming
- ivar
- fasta
- sort
- bam
- sam
- cram

modules:
- ivar/trim
- samtools/sort
- samtools/index
- samtools/stats
- samtools/idxstats
- samtools/flagstat

tools:
- ivar:
description: |
iVar - a computational package that contains functions broadly useful for viral amplicon-based sequencing.
homepage: https://github.com/andersen-lab/ivar
documentation: https://andersen-lab.github.io/ivar/html/manualpage.html
licence: ["GPL-3.0-or-later"]

input:
- ch_bam:
type: file
description: |
Structure: [ val(meta), path(bam), path(bai) ]
Groovy Map containing sample information
e.g. [ id:'test' ], BAM/CRAM/SAM file, index file for co-ordinate sorted BAM file
Joon-Klaps marked this conversation as resolved.
Show resolved Hide resolved
- ch_bed:
type: file
description: |
Structure: path(bed)
BED file with primer labels and positions
pattern: "*.bed"
- ch_fasta:
type: file
description: |
Structure: path(fasta)
Reference genome fasta file
pattern: "*.{fasta,fa}"

output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam_org:
type: file
description: |
Structure: [ val(meta), path(bam) ]
iVar generated trimmed bam file (unsorted)
- log_out:
type: file
description: |
Structure: [ val(meta), path(log) ]
Log file generated by iVar for use with MultiQC
pattern: "*.log"

- bam:
type: file
description: |
Structure: [ val(meta), path(bam) ]
Sorted BAM/CRAM/SAM file
- bai:
type: file
description: |
Structure: [ val(meta), path(bai) ]
BAM/CRAM/SAM index file
- crai:
type: file
description: |
Structure: [ val(meta), path(crai) ]
BAM/CRAM/SAM index file
- stats:
type: file
description: |
Structure: [ val(meta), path(stats) ]
File containing samtools stats output
- flagstat:
type: file
description: |
Structure: [ val(meta), path(flagstat) ]
File containing samtools flagstat output
- idxstats:
type: file
description: |
Structure: [ val(meta), path(idxstats) ]
File containing samtools idxstats output
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@Joon-Klaps"
3 changes: 3 additions & 0 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,9 @@ subworkflows/bam_sort_samtools:
subworkflows/bam_split_by_region:
- subworkflows/nf-core/bam_split_by_region/**
- tests/subworkflows/nf-core/bam_split_by_region/**
subworkflows/bam_trim_primers_ivar:
- subworkflows/nf-core/bam_trim_primers_ivar/**
- tests/subworkflows/nf-core/bam_trim_primers_ivar/**
subworkflows/bam_tumor_normal_somatic_variant_calling_gatk:
- subworkflows/nf-core/bam_tumor_normal_somatic_variant_calling_gatk/**
- tests/subworkflows/nf-core/bam_tumor_normal_somatic_variant_calling_gatk/**
Expand Down
19 changes: 19 additions & 0 deletions tests/subworkflows/nf-core/bam_trim_primers_ivar/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env nextflow

nextflow.enable.dsl = 2

include { BAM_TRIM_PRIMERS_IVAR } from '../../../../subworkflows/nf-core/bam_trim_primers_ivar/main.nf'

workflow test_bam_trim_primers_ivar {

input = [
[ id:'test'],
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true)
]
bed_file = file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)

fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)

BAM_TRIM_PRIMERS_IVAR ( input, bed_file, fasta )
}
12 changes: 12 additions & 0 deletions tests/subworkflows/nf-core/bam_trim_primers_ivar/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

withName: '.*:SAMTOOLS_.*' {
ext.prefix = { "${meta.id}.paired_end.sorted" }
}

withName: '.*:BAM_STATS_SAMTOOLS:.*' {
ext.prefix = { "${meta.id}.paired_end.sorted.bam" }
}
}
16 changes: 16 additions & 0 deletions tests/subworkflows/nf-core/bam_trim_primers_ivar/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- name: bam_trim_primers_ivar test_bam_trim_primers_ivar
command: nextflow run ./tests/subworkflows/nf-core/bam_trim_primers_ivar -entry test_bam_trim_primers_ivar -c ./tests/config/nextflow.config
tags:
- ivar
- ivar/trim
- subworkflows
- subworkflows/bam_sort_stats_samtools
- subworkflows/bam_trim_primers_ivar
files:
- path: output/ivar/test.bam
- path: output/ivar/test.ivar.log
- path: output/samtools/test.paired_end.sorted.bam
- path: output/samtools/test.paired_end.sorted.bam.bai
- path: output/samtools/test.paired_end.sorted.bam.flagstat
- path: output/samtools/test.paired_end.sorted.bam.idxstats
- path: output/samtools/test.paired_end.sorted.bam.stats
Loading