Because I will loop again and that makes it easier to recognise just the new files in that folder. Thanks !
• 0 views
•
link
So I have this bowtie bash script that is working:
#!bin/bash
for a in /Volumes/Norwegian_woods/*.fastq;
do
Reference=/Volumes/Norwegian_woods/Phaw_5.0;
bowtie2 -N 1 -p 8 --no-unal -x ${Reference} -q $a --al ${a%.fastq}_bowtie2.fq -S ${a%.fastq}_bowtie2.sam
done
However, I would like to change the output name and have bowtie2 written as a prefix, looking like this:
bowtie2_${a%.fastq}.fq, bowtie2_${a%.fastq}.sam.
But this is not working. Any suggestion would be appreciated! Thanks
Untested, but what you were trying to achieve is:
#!bin/bash
for a in /Volumes/Norwegian_woods/*.fastq;
do
Reference=/Volumes/Norwegian_woods/Phaw_5.0;
bowtie2 -N 1 -p 8 --no-unal -x "${Reference}" -q "$a" --al "${a%.fastq}"_bowtie2.fq -S "${a%.fastq}"_bowtie2.sam
done
#!/bin/bash
for a in /Volumes/Norwegian_woods/*.fastq;
do
Reference=/Volumes/Norwegian_woods/Phaw_5.0
bowtie2 -N 1 -p 8 --no-unal -x ${Reference} -q $a --al bowtie2_$(basename $a .fastq).fq -S bowtie2_$(basename $a .fastq).sam
done
Explanation: man basename
Why are you renaming your *fastq to *fq? Sound a bad thing.
Because I will loop again and that makes it easier to recognise just the new files in that folder. Thanks !
Log in to answer this question.
Soft quote your variables.
I tried that ('bowtie2_${a%.fastq}.fq') but the outputs now look like this: bowtie2_${a%.fastq}.fq
That's because that's a hard quote, not a soft quote.
I'd advise you to stop here and familiarise yourself with quotes in the shell. It's super important to get this right, especially if this code is going to be run on lots of files by others, or you won't know the input files well. At the moment, any white space in the file names would break this.
http://www.acadix.biz/Unix-guide/HTML/ch02s12.html
Nextflow/wdl/snakemake future you will thank you.