Question: Help with adding read groups in BWA bash loop script
2
gravatar for eric.londin
20 months ago by
eric.londin20
eric.londin20 wrote:

Hi all, I'm relatively new to bash scripting and working on one to map samples with BWA bash-loop.

My loop is the following:

for i in $(ls *.fastq.gz | rev | cut -c 10- | rev | uniq)
do

 ./bwa mem -t 60 -c 1 -R '@RG\tID:${i}\tSM:${i}\tPL:illumina\tPU:Lane1\tLB:exome' MyReference.fq ${i}.fastq.gz ${i}.fastq.gz > ${i}.sam
 done

The '-R' flag will add the read group info into the sam file. I am having trouble with having the actual sample name being added, rather than it just printed with a '${i}'. I've spending lot's of time googling, and trying to figure this out, but haven't been able to yet. Any advice would be appreciated.

bash-loop bwa next-gen • 1.3k views
ADD COMMENTlink modified 20 months ago by WouterDeCoster38k • written 20 months ago by eric.londin20
1

Troubleshooting hint

What is the output of this?

for i in $(ls *.fastq.gz | rev | cut -c 10- | rev | uniq)
do
echo '@RG\tID:${i}\tSM:${i}\tPL:illumina\tPU:Lane1\tLB:exome'
done

If this does not expands the variable $i, then your code is not going to work. Try the suggestion from WouterDeCoster

ADD REPLYlink written 20 months ago by Vijay Lakhujani4.0k
@RG\tID:${1}\tSM:${1}\tPL:illumina\tPU:Lane1\tLB:exome

Are you using 1 instead of i there?

ADD REPLYlink written 20 months ago by genomax65k

Sorry meant i instead of 1.

Typo on my part - edited the original post

ADD REPLYlink modified 20 months ago • written 20 months ago by eric.londin20
3
gravatar for WouterDeCoster
20 months ago by
Belgium
WouterDeCoster38k wrote:

Try " instead of ' for quoting. Variable expansion needs double quotes.

ADD COMMENTlink written 20 months ago by WouterDeCoster38k
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: 668 users visited in the last hour