Dear all,
I would like to write shell script to automatic alignment my pair end data with bowtie (or bwa) aligners.
Problem is, when I have lot of pair-end fastq files in one directory I have problem to loading data in for cycle.
Here is my code:
for i in $(ls *.fastq | rev | cut -c 22- | rev | uniq)
do ./bowtie2 --very-sensitive -p32 --rg-id ${i} --rg-sample ${i} --rg-library Illumina --rg-platform Illuimna -x $reference -1 ${i}_L001_R1_001.fatsq.gz -2 ${i}_L001_R2_001.fatsq.gz -S ${i%.fastq.gz}${i}.sam
done;
This is very nice solution help solved by RamRS. Is there any other way how to treat Bowtie or BWA with many samples (corresponding one sample to each read) in one for cycle?
my directory contains lot of fastq.gz:
name1_R1_001.fatsq.gz
name2_R2_001.fatsq.gz
...
...
...
Each sample name (prefix before R._001.fastq.gz
) has different name length so algorithm above doesn't work properly :-(
Thank you for any idea and solutions..
Hi Paul,
Not sure if you have this sorted but I managed to manipulate RamRS's bash to run for Bowtie2
Not sure if this is exactly what you want but it gives the output I'm after. I'm by no means an expert in the btw, it just worked for me. The format of my input files are like this:
65_S155_L001_R1_001.fastq
Cheers,
Todd
I assume you mean "one sample per file/pair of files" rather than "one sample to each read".
What have you tried other than that solution from RamRS and do you understand what it's doing? Once you know how that solution works, you should be able to do this without any help.
I don't understand very well what is exactly your question. Are you trying to run BWA/Bowtie for each pair of samples (assuming PE) in a folder? So, the problem is that you are not able to get the files two by two?
Presumably you meant to reply comment on the original post, not my comment :) I've moved it accordingly.
@airan: This might provide some context: bash loop for alignment RNA-seq data
Hi, this script depends not on the prefix length but only on the length of the
R[12]_001.fastq
part, which is constant (13). What is the problem you face, exactly?Also,
${MY_VARIABLE_NAME}
is the syntax to encapsulate a variable name; you're looking for the$(MY_COMMAND_OR_PIPE)
syntax, to execute a command or pipe.