Skip to content

Commit

Permalink
Fasta index bismark bwameth (nf-core#7010)
Browse files Browse the repository at this point in the history
* init fasta_create_index_bismark_bwameth subworkflow

* add tests + snap

* Change name

* update snap

---------

Co-authored-by: Simon Pearce <[email protected]>
  • Loading branch information
sateeshperi and SPPearce authored Nov 27, 2024
1 parent 3628d82 commit e24c973
Show file tree
Hide file tree
Showing 5 changed files with 784 additions and 0 deletions.
102 changes: 102 additions & 0 deletions subworkflows/nf-core/fasta_index_bismark_bwameth/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
include { UNTAR } from '../../../modules/nf-core/untar/main'
include { GUNZIP } from '../../../modules/nf-core/gunzip/main'
include { BISMARK_GENOMEPREPARATION } from '../../../modules/nf-core/bismark/genomepreparation/main'
include { BWAMETH_INDEX } from '../../../modules/nf-core/bwameth/index/main'
include { SAMTOOLS_FAIDX } from '../../../modules/nf-core/samtools/faidx/main'

workflow FASTA_INDEX_BISMARK_BWAMETH {

take:
fasta // channel: [ val(meta), [ fasta ] ]
fasta_index // channel: [ val(meta), [ fasta index ] ]
bismark_index // channel: [ val(meta), [ bismark index ] ]
bwameth_index // channel: [ val(meta), [ bwameth index ] ]

main:

ch_fasta = Channel.empty()
ch_fasta_index = Channel.empty()
ch_bismark_index = Channel.empty()
ch_bwameth_index = Channel.empty()
ch_versions = Channel.empty()

if (fasta.toString().endsWith('.gz')) {
GUNZIP (
[ [:], file(fasta, checkIfExists: true) ]
)
ch_fasta = GUNZIP.out.gunzip
ch_versions = ch_versions.mix(GUNZIP.out.versions)
} else {
ch_fasta = Channel.value([[:], file(fasta, checkIfExists: true)])
}

// Aligner: bismark or bismark_hisat
if( params.aligner =~ /bismark/ ){
/*
* Generate bismark index if not supplied
*/
if (bismark_index) {
if (bismark_index.toString().endsWith('.gz')) {
UNTAR (
[ [:], file(bismark_index, checkIfExists: true) ]
)
ch_bismark_index = UNTAR.out.untar
ch_versions = ch_versions.mix(UNTAR.out.versions)
} else {
ch_bismark_index = Channel.value([[:], file(bismark_index, checkIfExists: true)])
}
} else {
BISMARK_GENOMEPREPARATION (
ch_fasta
)
ch_bismark_index = BISMARK_GENOMEPREPARATION.out.index
ch_versions = ch_versions.mix(BISMARK_GENOMEPREPARATION.out.versions)
}
}

// Aligner: bwameth
else if ( params.aligner == 'bwameth' ){
/*
* Generate bwameth index if not supplied
*/
if (bwameth_index) {
if (bwameth_index.toString().endsWith('.gz')) {
UNTAR (
[ [:], file(bwameth_index, checkIfExists: true) ]
)
ch_bwameth_index = UNTAR.out.untar
ch_versions = ch_versions.mix(UNTAR.out.versions)
} else {
ch_bwameth_index = Channel.value([[:], file(bwameth_index, checkIfExists: true)])
}
} else {
BWAMETH_INDEX (
ch_fasta
)
ch_bwameth_index = BWAMETH_INDEX.out.index
ch_versions = ch_versions.mix(BWAMETH_INDEX.out.versions)
}

/*
* Generate fasta index if not supplied
*/
if (fasta_index) {
ch_fasta_index = Channel.value(file(fasta_index, checkIfExists: true))
} else {
SAMTOOLS_FAIDX(
ch_fasta,
[[:], []]
)
ch_fasta_index = SAMTOOLS_FAIDX.out.fai
ch_versions = ch_versions.mix(SAMTOOLS_FAIDX.out.versions)
}
}

emit:
fasta = ch_fasta // channel: [ val(meta), [ fasta ] ]
fasta_index = ch_fasta_index // channel: [ val(meta), [ fasta index ] ]
bismark_index = ch_bismark_index // channel: [ val(meta), [ bismark index ] ]
bwameth_index = ch_bwameth_index // channel: [ val(meta), [ bwameth index ] ]
versions = ch_versions // channel: [ versions.yml ]
}

72 changes: 72 additions & 0 deletions subworkflows/nf-core/fasta_index_bismark_bwameth/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json
name: "fasta_index_bismark_bwameth"
description: Generate index files from reference fasta for bismark and bwameth
keywords:
- bismark
- bwameth
- prepare genome
- index
components:
- untar
- gunzip
- bismark/genomepreparation
- bwameth/index
- samtools/faidx
input:
- fasta:
type: file
description: |
Reference genome
Structure: [ val(meta), path(fasta) ]
pattern: "*.{fa/fa.gz}"
- fasta_index:
type: file
description: |
Reference genome index file
Structure: [ val(meta), path(fasta) ]
pattern: "*.fai"
- bismark_index:
type: file
description: |
Bismark genome index files
Structure: [ val(meta), path(bismark_index) ]
- bwameth_index:
type: file
description: |
Bwameth genome index files
Structure: [ val(meta), path(bwameth_index) ]
output:
- fasta:
type: file
description: |
Reference genome
Structure: [ val(meta), path(fasta) ]
pattern: "*.fa"
- fasta_index:
type: file
description: |
Reference genome index file
Structure: [ val(meta), path(fasta) ]
pattern: "*.fai"
- bismark_index:
type: file
description: |
Bismark genome index files
Structure: [ val(meta), path(bismark_index) ]
pattern: "BismarkIndex"
- bwameth_index:
type: file
description: |
Bwameth genome index files
Structure: [ val(meta), path(bwameth_index) ]
pattern: "index"
- versions:
type: file
description: |
File containing software versions
Structure: [ path(versions.yml) ]
pattern: "versions.yml"
authors:
- "@sateeshperi"
maintainers:
- "@sateeshperi"
Loading

0 comments on commit e24c973

Please sign in to comment.