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

Bowtie: nf add file_id var for single-end like for paired-end

parent 2ce05607
No related branches found
No related tags found
No related merge requests found
...@@ -96,14 +96,18 @@ fi ...@@ -96,14 +96,18 @@ fi
/* /*
* for single-end data * for single-end data
*/ */
params.fastq = "$baseDir/data/fastq/*.fastq" params.mean = 200
params.sd = 100
log.info "fastq files : ${params.fastq}" log.info "fastq files : ${params.fastq}"
log.info "index files : ${params.index}" log.info "index files : ${params.index}"
log.info "mean read size: ${params.mean}"
log.info "sd read size: ${params.sd}"
Channel Channel
.fromPath( params.fastq ) .fromPath( params.fastq )
.ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" } .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" }
.map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]}
.set { fastq_files } .set { fastq_files }
Channel Channel
.fromPath( params.index ) .fromPath( params.index )
...@@ -111,33 +115,24 @@ Channel ...@@ -111,33 +115,24 @@ Channel
.set { index_files } .set { index_files }
process mapping_fastq { process mapping_fastq {
tag "$reads.baseName" tag "$file_id"
cpus 4 cpus 4
publishDir "results/mapping/bams/", mode: 'copy' publishDir "results/mapping/quantification/", mode: 'copy'
input: input:
file reads from fastq_files set file_id, file(reads) from fastq_files
file index from index_files.collect() file index from index_files.collect()
output: output:
file "*.bam" into bam_files file "*" into count_files
file "*_report.txt" into mapping_report
script: script:
index_id = index[0]
for (index_file in index) {
if (index_file =~ /.*\.1\.ebwt/ && !(index_file =~ /.*\.rev\.1\.ebwt/)) {
index_id = ( index_file =~ /(.*)\.1\.ebwt/)[0][1]
}
}
""" """
bowtie --best -v 3 -k 1 --sam -p ${task.cpus} ${index_id} \ mkdir ${file_id}
-q ${reads} 2> \ kallisto quant -i ${index} -t ${task.cpus} --single \
${reads.baseName}_bowtie_report.txt | \ --bias --bootstrap-samples 100 -o ${file_id} \
samtools view -Sb - > ${reads.baseName}.bam -l ${params.mean} -s ${params.sd} \
${reads} > ${file_id}_kallisto_report.txt
if grep -q "Error" ${reads.baseName}_bowtie_report.txt; then
exit 1
fi
""" """
} }
...@@ -6,6 +6,7 @@ log.info "index files : ${params.index}" ...@@ -6,6 +6,7 @@ log.info "index files : ${params.index}"
Channel Channel
.fromPath( params.fastq ) .fromPath( params.fastq )
.ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" } .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" }
.map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]}
.set { fastq_files } .set { fastq_files }
Channel Channel
.fromPath( params.index ) .fromPath( params.index )
...@@ -13,16 +14,16 @@ Channel ...@@ -13,16 +14,16 @@ Channel
.set { index_files } .set { index_files }
process mapping_fastq { process mapping_fastq {
tag "$reads.baseName" tag "$file_id"
cpus 4 cpus 4
publishDir "results/mapping/bams/", mode: 'copy' publishDir "results/mapping/bams/", mode: 'copy'
input: input:
file reads from fastq_files set file_id, file(reads) from fastq_files
file index from index_files.collect() file index from index_files.collect()
output: output:
file "*.bam" into bam_files set file_id, "*.bam" into bam_files
file "*_report.txt" into mapping_report file "*_report.txt" into mapping_report
script: script:
...@@ -35,10 +36,10 @@ for (index_file in index) { ...@@ -35,10 +36,10 @@ for (index_file in index) {
""" """
bowtie --best -v 3 -k 1 --sam -p ${task.cpus} ${index_id} \ bowtie --best -v 3 -k 1 --sam -p ${task.cpus} ${index_id} \
-q ${reads} 2> \ -q ${reads} 2> \
${reads.baseName}_bowtie_report.txt | \ ${file_id}_bowtie_report.txt | \
samtools view -Sb - > ${reads.baseName}.bam samtools view -Sb - > ${file_id}.bam
if grep -q "Error" ${reads.baseName}_bowtie_report.txt; then if grep -q "Error" ${file_id}_bowtie_report.txt; then
exit 1 exit 1
fi fi
""" """
......
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