-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
include { BWA_INDEX } from '../../../modules/nf-core/bwa/index/main' | ||
include { BWA_MEM } from '../../../modules/nf-core/bwa/mem/main' | ||
include { SAMBLASTER } from '../../../modules/nf-core/samblaster/main' | ||
|
||
workflow FASTQ_BWA_MEM_SAMBLASTER { | ||
|
||
take: | ||
ch_fastq // channel: [ val(meta), [ fq ] ]; meta ~ [ id: 'sample' ] | ||
ch_reference // channel: [ val(meta2), fasta, index ]; fasta | index; meta2 ~ [ id: 'genome' ] | ||
|
||
main: | ||
ch_versions = Channel.empty() | ||
|
||
ch_has_index = ch_reference | ||
| branch { meta2, fasta, index -> | ||
yes: index | ||
no: !index | ||
} | ||
|
||
// MODULE: BWA_INDEX | ||
BWA_INDEX ( ch_has_index.no.map { meta2, fasta, index -> [ meta2, fasta ] } ) | ||
|
||
ch_bwa_index = BWA_INDEX.out.index | ||
| mix( | ||
ch_has_index.yes | ||
| map { meta2, fasta, index -> | ||
[ meta2, index ] | ||
} | ||
) | ||
|
||
ch_versions = ch_versions.mix(BWA_INDEX.out.versions.first()) | ||
|
||
// MODULE: BWA_MEM | ||
ch_mem_inputs = ch_fastq | ||
| combine( | ||
ch_bwa_index | ||
) | ||
| map { meta, fq, meta2, index -> | ||
[ meta + [ ref_id: meta2.id ], fq, index ] | ||
} | ||
|
||
def sort_bam = false | ||
BWA_MEM( | ||
ch_mem_inputs.map { meta, fq, index -> [ meta, fq ] }, | ||
ch_mem_inputs.map { meta, fq, index -> [ [], index ] }, | ||
[ [], [] ], | ||
sort_bam | ||
) | ||
|
||
ch_mem_bam = BWA_MEM.out.bam | ||
ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) | ||
|
||
// MODULE: SAMBLASTER | ||
SAMBLASTER ( ch_mem_bam ) | ||
|
||
ch_blasted_bam = SAMBLASTER.out.bam | ||
ch_versions = ch_versions.mix(SAMBLASTER.out.versions.first()) | ||
|
||
emit: | ||
bam = SAMBLASTER.out.bam // channel: [ val(meta), bam ]; meta ~ [ id: 'sample', ref_id: 'genome' ] | ||
versions = ch_versions // channel: [ versions.yml ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json | ||
name: "fastq_bwa_mem_samblaster" | ||
description: Index fasta if needed, map reads with BWA MEM and filter with samblaster | ||
keywords: | ||
- sort | ||
- bam | ||
- duplicate marking | ||
components: | ||
- bwa/index | ||
- bwa/mem | ||
- samblaster | ||
input: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false ] | ||
- reads: | ||
type: file | ||
description: | | ||
List of input FastQ files of size 1 and 2 for single-end and paired-end data, | ||
respectively. | ||
- meta2: | ||
type: map | ||
description: | | ||
Groovy Map containing reference information | ||
e.g. [ id:'genome' ] | ||
- fasta: | ||
type: file | ||
description: Input genome fasta file | ||
- index: | ||
type: file | ||
description: BWA genome index files | ||
pattern: "Directory containing BWA index *.{amb,ann,bwt,pac,sa}" | ||
output: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false, ref_id:'genome' ] | ||
- bam: | ||
type: file | ||
description: Tagged or filtered BAM file | ||
pattern: "*.bam" | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
authors: | ||
- "@GallVp" | ||
maintainers: | ||
- "@GallVp" |
75 changes: 75 additions & 0 deletions
75
subworkflows/nf-core/fastq_bwa_mem_samblaster/tests/main.nf.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
nextflow_workflow { | ||
|
||
name "Test Subworkflow FASTQ_BWA_MEM_SAMBLASTER" | ||
script "../main.nf" | ||
workflow "FASTQ_BWA_MEM_SAMBLASTER" | ||
config './nextflow.config' | ||
|
||
tag "subworkflows" | ||
tag "subworkflows_nfcore" | ||
tag "subworkflows/fastq_bwa_mem_samblaster" | ||
tag "samblaster" | ||
tag "bwa/index" | ||
tag "bwa/mem" | ||
|
||
|
||
test("sarscov2-fq-gz") { | ||
|
||
when { | ||
workflow { | ||
""" | ||
input[0] = Channel.of( | ||
[ | ||
[ id:'test' ], | ||
[ | ||
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), | ||
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) | ||
] | ||
] | ||
) | ||
input[1] = Channel.of( | ||
[ [ id: 'genome' ], file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true), [] ] | ||
) | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert workflow.success}, | ||
{ assert snapshot(workflow.out).match()} | ||
) | ||
} | ||
} | ||
|
||
test("sarscov2-fq-gz-stub") { | ||
|
||
options '-stub' | ||
|
||
when { | ||
workflow { | ||
""" | ||
input[0] = Channel.of( | ||
[ | ||
[ id:'test' ], | ||
[ | ||
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), | ||
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) | ||
] | ||
] | ||
) | ||
input[1] = Channel.of( | ||
[ [ id: 'genome' ], file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true), [] ] | ||
) | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert workflow.success}, | ||
{ assert snapshot(workflow.out).match()} | ||
) | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
subworkflows/nf-core/fastq_bwa_mem_samblaster/tests/main.nf.test.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"sarscov2-fq-gz": { | ||
"content": [ | ||
{ | ||
"0": [ | ||
[ | ||
{ | ||
"id": "test", | ||
"ref_id": "genome" | ||
}, | ||
"test.on.genome.samblaster.bam:md5,8c47b2669f5250ad2d24365b42566d78" | ||
] | ||
], | ||
"1": [ | ||
"versions.yml:md5,3b59736950270bca59c29afeb5289b4f", | ||
"versions.yml:md5,46f2d5384c2b4c6111293bc8642cc43a", | ||
"versions.yml:md5,6a2baa7f2d1d555fe604e451624f414b" | ||
], | ||
"bam": [ | ||
[ | ||
{ | ||
"id": "test", | ||
"ref_id": "genome" | ||
}, | ||
"test.on.genome.samblaster.bam:md5,8c47b2669f5250ad2d24365b42566d78" | ||
] | ||
], | ||
"versions": [ | ||
"versions.yml:md5,3b59736950270bca59c29afeb5289b4f", | ||
"versions.yml:md5,46f2d5384c2b4c6111293bc8642cc43a", | ||
"versions.yml:md5,6a2baa7f2d1d555fe604e451624f414b" | ||
] | ||
} | ||
], | ||
"meta": { | ||
"nf-test": "0.8.4", | ||
"nextflow": "23.10.1" | ||
}, | ||
"timestamp": "2024-05-03T15:58:33.221762" | ||
}, | ||
"sarscov2-fq-gz-stub": { | ||
"content": [ | ||
{ | ||
"0": [ | ||
[ | ||
{ | ||
"id": "test", | ||
"ref_id": "genome" | ||
}, | ||
"test.on.genome.samblaster.bam:md5,d41d8cd98f00b204e9800998ecf8427e" | ||
] | ||
], | ||
"1": [ | ||
"versions.yml:md5,3b59736950270bca59c29afeb5289b4f", | ||
"versions.yml:md5,46f2d5384c2b4c6111293bc8642cc43a", | ||
"versions.yml:md5,6a2baa7f2d1d555fe604e451624f414b" | ||
], | ||
"bam": [ | ||
[ | ||
{ | ||
"id": "test", | ||
"ref_id": "genome" | ||
}, | ||
"test.on.genome.samblaster.bam:md5,d41d8cd98f00b204e9800998ecf8427e" | ||
] | ||
], | ||
"versions": [ | ||
"versions.yml:md5,3b59736950270bca59c29afeb5289b4f", | ||
"versions.yml:md5,46f2d5384c2b4c6111293bc8642cc43a", | ||
"versions.yml:md5,6a2baa7f2d1d555fe604e451624f414b" | ||
] | ||
} | ||
], | ||
"meta": { | ||
"nf-test": "0.8.4", | ||
"nextflow": "23.10.1" | ||
}, | ||
"timestamp": "2024-05-03T16:03:28.825915" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
subworkflows/nf-core/fastq_bwa_mem_samblaster/tests/nextflow.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
process { | ||
withName: BWA_MEM { | ||
ext.prefix = { "${meta.id}.on.${meta.ref_id}.bwa.mem" } | ||
ext.args = '-5SP' | ||
} | ||
|
||
withName: SAMBLASTER { | ||
ext.prefix = { "${meta.id}.on.${meta.ref_id}.samblaster" } | ||
ext.args3 = '-h -F 2316' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
subworkflows/fastq_bwa_mem_samblaster: | ||
- subworkflows/nf-core/fastq_bwa_mem_samblaster/** |