Skip to content
Snippets Groups Projects
Verified Commit d0d8b68b authored by Laurent Modolo's avatar Laurent Modolo
Browse files

bowtie2.nf: improve root finding of index file name as asked by @elabaron

parent 4ca980bb
No related branches found
No related tags found
No related merge requests found
...@@ -57,25 +57,31 @@ Channel ...@@ -57,25 +57,31 @@ Channel
.set { index_files } .set { index_files }
process mapping_fastq { process mapping_fastq {
tag "$pair_id" tag "$reads.baseName"
cpus 4 cpus 4
publishDir "results/mapping/bams/", mode: 'copy' publishDir "results/mapping/bams/", mode: 'copy'
input: input:
set pair_id, file(reads) from fastq_files file reads from fastq_files
file index from index_files.toList() file index from index_files.toList()
output: output:
set pair_id, "*.bam" into bam_files file "*.bam" into bam_files
script: script:
index_id = index[0]
for (index_file in index) {
if (index_file =~ /.*\.1\.bt2/) {
index_id = ( index_file =~ /(.*)\.1\.bt2/)[0][1]
}
}
""" """
bowtie2 --very-sensitive -p ${task.cpus} -x ${index[0].baseName} \ bowtie2 --very_sensitive -p ${task.cpus} -x ${index_id} \
-1 ${reads[0]} -2 ${reads[1]} 2> \ -U ${reads} 2> \
${pair_id}_bowtie2_report.txt | \ ${reads.baseName}_bowtie2_report.txt | \
samtools view -Sb - > ${pair_id}.bam samtools view -Sb - > ${reads.baseName}.bam
if grep -q "Error" ${pair_id}_bowtie2_report.txt; then if grep -q "Error" ${reads.baseName}_bowtie2_report.txt; then
exit 1 exit 1
fi fi
""" """
......
...@@ -26,11 +26,17 @@ process mapping_fastq { ...@@ -26,11 +26,17 @@ process mapping_fastq {
set pair_id, "*.bam" into bam_files set pair_id, "*.bam" into bam_files
script: script:
index_id = index[0]
for (index_file in index) {
if (index_file =~ /.*\.1\.bt2/) {
index_id = ( index_file =~ /(.*)\.1\.bt2/)[0][1]
}
}
""" """
bowtie2 --very-sensitive -p ${task.cpus} -x ${index[0].baseName} \ bowtie2 --very-sensitive -p ${task.cpus} -x ${index_id} \
-1 ${reads[0]} -2 ${reads[1]} 2> \ -1 ${reads[0]} -2 ${reads[1]} 2> \
${pair_id}_bowtie2_report.txt | \ ${pair_id}_bowtie2_report.txt | \
samtools view -Sb - > ${pair_id}.bam samtools view -Sb - > ${pair_id}.bam
if grep -q "Error" ${pair_id}_bowtie2_report.txt; then if grep -q "Error" ${pair_id}_bowtie2_report.txt; then
exit 1 exit 1
......
...@@ -25,8 +25,14 @@ process mapping_fastq { ...@@ -25,8 +25,14 @@ process mapping_fastq {
file "*.bam" into bam_files file "*.bam" into bam_files
script: script:
index_id = index[0]
for (index_file in index) {
if (index_file =~ /.*\.1\.bt2/) {
index_id = ( index_file =~ /(.*)\.1\.bt2/)[0][1]
}
}
""" """
bowtie2 --very_sensitive -p ${task.cpus} -x ${index[0].baseName} \ bowtie2 --very_sensitive -p ${task.cpus} -x ${index_id} \
-U ${reads} 2> \ -U ${reads} 2> \
${reads.baseName}_bowtie2_report.txt | \ ${reads.baseName}_bowtie2_report.txt | \
samtools view -Sb - > ${reads.baseName}.bam samtools view -Sb - > ${reads.baseName}.bam
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment