1
1
process BOWTIE2_ALIGN {
2
- tag " $meta . id "
2
+ tag " ${ meta.id} "
3
3
label ' process_high'
4
4
5
5
conda " ${ moduleDir} /environment.yml"
6
- container " ${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
7
- 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/b4/b41b403e81883126c3227fc45840015538e8e2212f13abc9ae84e4b98891d51c/data' :
8
- 'community.wave.seqera.io/library/bowtie2_htslib_samtools_pigz:edeb13799090a2a6' } "
6
+ container " ${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
7
+ ? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/b4/b41b403e81883126c3227fc45840015538e8e2212f13abc9ae84e4b98891d51c/data'
8
+ : 'community.wave.seqera.io/library/bowtie2_htslib_samtools_pigz:edeb13799090a2a6'} "
9
9
10
10
input:
11
- tuple val(meta) , path(reads)
11
+ tuple val(meta), path(reads)
12
12
tuple val(meta2), path(index)
13
13
tuple val(meta3), path(fasta)
14
- val save_unaligned
15
- val sort_bam
14
+ val save_unaligned
15
+ val sort_bam
16
16
17
17
output:
18
- tuple val(meta), path(" *.sam" ) , emit: sam , optional:true
19
- tuple val(meta), path(" *.bam" ) , emit: bam , optional:true
20
- tuple val(meta), path(" *.cram" ) , emit: cram , optional:true
21
- tuple val(meta), path(" *.csi" ) , emit: csi , optional:true
22
- tuple val(meta), path(" *.crai" ) , emit: crai , optional:true
23
- tuple val(meta), path(" *.log" ) , emit: log
24
- tuple val(meta), path(" *fastq.gz" ) , emit: fastq , optional:true
25
- path " versions.yml" , emit: versions
18
+ tuple val(meta), path(" *.sam" ), emit: sam, optional: true
19
+ tuple val(meta), path(" *.bam" ), emit: bam, optional: true
20
+ tuple val(meta), path(" *.cram" ), emit: cram, optional: true
21
+ tuple val(meta), path(" *.csi" ), emit: csi, optional: true
22
+ tuple val(meta), path(" *.crai" ), emit: crai, optional: true
23
+ tuple val(meta), path(" *.log" ), emit: log
24
+ tuple val(meta), path(" *fastq.gz" ), emit: fastq, optional: true
25
+ path " versions.yml" , emit: versions
26
26
27
27
when:
28
28
task. ext. when == null || task. ext. when
@@ -37,17 +37,20 @@ process BOWTIE2_ALIGN {
37
37
if (meta. single_end) {
38
38
unaligned = save_unaligned ? " --un-gz ${ prefix} .unmapped.fastq.gz" : " "
39
39
reads_args = " -U ${ reads} "
40
- } else {
40
+ }
41
+ else {
41
42
unaligned = save_unaligned ? " --un-conc-gz ${ prefix} .unmapped.fastq.gz" : " "
42
43
reads_args = " -1 ${ reads[0]} -2 ${ reads[1]} "
43
44
}
44
45
45
46
def samtools_command = sort_bam ? ' sort' : ' view'
46
47
def extension_pattern = / (-- output- fmt|- O)+ \s+ (\S+ )/
47
- def extension_matcher = (args2 =~ extension_pattern)
48
+ def extension_matcher = (args2 =~ extension_pattern)
48
49
def extension = extension_matcher. getCount() > 0 ? extension_matcher[0 ][2 ]. toLowerCase() : " bam"
49
- def reference = fasta && extension== " cram" ? " --reference ${ fasta} " : " "
50
- if (! fasta && extension== " cram" ) error " Fasta reference is required for CRAM output"
50
+ def reference = fasta && extension == " cram" ? " --reference ${ fasta} " : " "
51
+ if (! fasta && extension == " cram" ) {
52
+ error(" Fasta reference is required for CRAM output" )
53
+ }
51
54
52
55
"""
53
56
INDEX=`find -L ./ -name "*.rev.1.bt2" | sed "s/\\ .rev.1.bt2\$ //"`
@@ -56,12 +59,12 @@ process BOWTIE2_ALIGN {
56
59
57
60
bowtie2 \\
58
61
-x \$ INDEX \\
59
- $reads_args \\
60
- --threads $task . cpus \\
61
- $unaligned \\
62
- $args \\
62
+ ${ reads_args} \\
63
+ --threads ${ task.cpus} \\
64
+ ${ unaligned} \\
65
+ ${ args} \\
63
66
2>| >(tee ${ prefix} .bowtie2.log >&2) \\
64
- | samtools $samtools_command $ args2 --threads $task . cpus ${ reference} -o ${ prefix} .${ extension} -
67
+ | samtools ${ samtools_command} ${ args2} --threads ${ task.cpus} ${ reference} -o ${ prefix} .${ extension} -
65
68
66
69
if [ -f ${ prefix} .unmapped.fastq.1.gz ]; then
67
70
mv ${ prefix} .unmapped.fastq.1.gz ${ prefix} .unmapped_1.fastq.gz
@@ -83,19 +86,23 @@ process BOWTIE2_ALIGN {
83
86
def args2 = task. ext. args2 ?: " "
84
87
def prefix = task. ext. prefix ?: " ${ meta.id} "
85
88
def extension_pattern = / (-- output- fmt|- O)+ \s+ (\S+ )/
86
- def extension = ( args2 ==~ extension_pattern) ? (args2 =~ extension_pattern)[0 ][2 ]. toLowerCase() : " bam"
89
+ def extension = args2 ==~ extension_pattern ? (args2 =~ extension_pattern)[0 ][2 ]. toLowerCase() : " bam"
87
90
def create_unmapped = " "
88
91
if (meta. single_end) {
89
92
create_unmapped = save_unaligned ? " touch ${ prefix} .unmapped.fastq.gz" : " "
90
- } else {
93
+ }
94
+ else {
91
95
create_unmapped = save_unaligned ? " touch ${ prefix} .unmapped_1.fastq.gz && touch ${ prefix} .unmapped_2.fastq.gz" : " "
92
96
}
93
- if (! fasta && extension== " cram" ) error " Fasta reference is required for CRAM output"
97
+ if (! fasta && extension == " cram" ) {
98
+ error(" Fasta reference is required for CRAM output" )
99
+ }
94
100
95
101
def create_index = " "
96
102
if (extension == " cram" ) {
97
103
create_index = " touch ${ prefix} .crai"
98
- } else if (extension == " bam" ) {
104
+ }
105
+ else if (extension == " bam" ) {
99
106
create_index = " touch ${ prefix} .csi"
100
107
}
101
108
@@ -112,5 +119,4 @@ process BOWTIE2_ALIGN {
112
119
pigz: \$ ( pigz --version 2>&1 | sed 's/pigz //g' )
113
120
END_VERSIONS
114
121
"""
115
-
116
122
}
0 commit comments