Question: Issues creating loop for BWA job
0
gravatar for caranlove
18 months ago by
caranlove10
caranlove10 wrote:

Hi,

I am having issues creating a successful loop for processing ~200 files in the same directory. My BWA script runs successfully when run on individual scripts but I have been unsuccessful in creating a working loop that will process all files, not just one at a time. Below is an example script:

module load BWA/0.7.17-foss-2016b

for FNAME in $FILES 
do
time bwa mem -t 12 -M /Directory/Folder/Reference/Lisp_final /Directory/Folder/$FNAME\.1.fq.gz /Directory/Folder/$FNAME\.2.fq.gz > /Directory/Folder/Lisp/align_output/$FNAME\.sam
let "i+=1";
done

Thank you for any help!

snp alignment software error • 431 views
ADD COMMENTlink modified 18 months ago by genomax89k • written 18 months ago by caranlove10

There is not enough information here to debug. Where is $FILES coming from and what does it contain? What is let "i+=1" doing?

General comment. You should always use echo in/before your actual command (time bwa etc) until you are sure that the command lines look sane. At that point you can remove echo to run the real jobs.

You could do something like

for file in *r1.fq.gz 
do name=$(basename $file r1.fq.gz) 
echo bwa mem -t 12 -M /Directory/Folder/Reference/Lisp_final  ${name}.r1.fq.gz  ${name}.r2.fq.gz > ${name}.sam
done
ADD REPLYlink modified 18 months ago • written 18 months ago by genomax89k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1775 users visited in the last hour