add sort option to bowtie2

This commit is contained in:
Matthias De Smet 2022-05-13 15:26:41 +02:00
parent 919275103a
commit cbc47767f7
4 changed files with 46 additions and 8 deletions

View file

@ -11,6 +11,7 @@ process BOWTIE2_ALIGN {
tuple val(meta), path(reads)
path index
val save_unaligned
val sort_bam
output:
tuple val(meta), path("*.bam") , emit: bam
@ -36,8 +37,7 @@ process BOWTIE2_ALIGN {
reads_args = "-1 ${reads[0]} -2 ${reads[1]}"
}
def samtools_command = "samtools view -@ $task.cpus --bam --with-header ${args2} > ${prefix}.bam"
def samtools_command = sort_bam ? 'sort' : 'view'
"""
INDEX=`find -L ./ -name "*.rev.1.bt2" | sed "s/.rev.1.bt2//"`
@ -51,7 +51,7 @@ process BOWTIE2_ALIGN {
$unaligned \\
$args \\
2> ${prefix}.bowtie2.log \\
| $samtools_command
| samtools $samtools_command $args2 --threads $task.cpus -o ${prefix}.bam -
if [ -f ${prefix}.unmapped.fastq.1.gz ]; then
mv ${prefix}.unmapped.fastq.1.gz ${prefix}.unmapped_1.fastq.gz

View file

@ -29,6 +29,15 @@ input:
type: file
description: Bowtie2 genome index files
pattern: "*.ebwt"
- save_unaligned:
type: boolean
description: |
Save reads that do not map to the reference (true) or discard them (false)
(default: false)
- sort_bam:
type: boolean
description: use samtools sort (true) or samtools view (false)
pattern: "true or false"
output:
- bam:
type: file

View file

@ -14,9 +14,25 @@ workflow test_bowtie2_align_single_end {
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
save_unaligned = false
sort = false
BOWTIE2_BUILD ( fasta )
BOWTIE2_ALIGN ( input, BOWTIE2_BUILD.out.index, save_unaligned )
BOWTIE2_ALIGN ( input, BOWTIE2_BUILD.out.index, save_unaligned, sort )
}
workflow test_bowtie2_align_single_end_sorted {
input = [
[ id:'test', single_end:true ], // meta map
[
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)
]
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
save_unaligned = false
sort = true
BOWTIE2_BUILD ( fasta )
BOWTIE2_ALIGN ( input, BOWTIE2_BUILD.out.index, save_unaligned, sort )
}
workflow test_bowtie2_align_paired_end {
@ -29,9 +45,10 @@ workflow test_bowtie2_align_paired_end {
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
save_unaligned = false
sort = false
BOWTIE2_BUILD ( fasta )
BOWTIE2_ALIGN ( input, BOWTIE2_BUILD.out.index, save_unaligned )
BOWTIE2_ALIGN ( input, BOWTIE2_BUILD.out.index, save_unaligned, sort )
}
workflow test_bowtie2_align_single_end_large_index {
@ -43,9 +60,10 @@ workflow test_bowtie2_align_single_end_large_index {
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
save_unaligned = false
sort = false
BOWTIE2_BUILD ( fasta )
BOWTIE2_ALIGN ( input, BOWTIE2_BUILD.out.index, save_unaligned )
BOWTIE2_ALIGN ( input, BOWTIE2_BUILD.out.index, save_unaligned, sort )
}
workflow test_bowtie2_align_paired_end_large_index {
@ -58,7 +76,8 @@ workflow test_bowtie2_align_paired_end_large_index {
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
save_unaligned = false
sort = false
BOWTIE2_BUILD ( fasta )
BOWTIE2_ALIGN ( input, BOWTIE2_BUILD.out.index, save_unaligned )
}
BOWTIE2_ALIGN ( input, BOWTIE2_BUILD.out.index, save_unaligned, sort )
}

View file

@ -8,6 +8,16 @@
- path: ./output/bowtie2/test.bowtie2.log
- path: ./output/bowtie2/versions.yml
- name: bowtie2 align test_bowtie2_align_single_end
command: nextflow run ./tests/modules/bowtie2/align -entry test_bowtie2_align_single_end_sorted -c ./tests/config/nextflow.config -c ./tests/modules/bowtie2/align/nextflow.config
tags:
- bowtie2
- bowtie2/align
files:
- path: ./output/bowtie2/test.bam
- path: ./output/bowtie2/test.bowtie2.log
- path: ./output/bowtie2/versions.yml
- name: bowtie2 align test_bowtie2_align_paired_end
command: nextflow run tests/modules/bowtie2/align -entry test_bowtie2_align_paired_end -c tests/config/nextflow.config -c tests/modules/bowtie2/align/nextflow.config
tags: