Entering edit mode
4.9 years ago
evelyn
▴
230
I am trying to run bwa
for multiple paired end fastq files, located in a folder named sample_data
. I am using this code to get .sorted.bam
files to a new folder called output
:
total_files=`ls ./sample_data/*.fastq | wc -l`
arr=( $(ls ./sample_data/*.fastq) )
for ((i=0; i<$total_files; i+=2))
{
sample_name=`echo ${arr[$i]} | awk -F "_" '{print $1}'`
echo "[mapping running for] $sample_name"
printf "\n"
bwa mem -t 12 ref.fa ${arr[$i]} ${arr[$i+1]} | samtools sort -o output/$sample_name.sorted.bam
But the echo
says
[mapping running for] ./sample
And got only one sorted.bam file named sample.sorted.bam
It is not giving the output files named as input files.
Any suggestion is appreciated.