Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is alignment score when using bwa aln and sampe commands are used ? hxlei Bioinformatics 0 09-21-2016 08:11 AM
filtering - find-if commands frz Bioinformatics 3 01-23-2014 03:15 PM
BowTie 1 Commands ? Arupsss Bioinformatics 0 06-21-2012 09:54 AM
Run hundreds of BWA commands without waiting CNVboy Bioinformatics 5 06-14-2011 06:40 PM
testing bwa with 454 hsap data: infinite loop on sam generation? drio Bioinformatics 2 10-24-2009 11:33 AM

Thread Tools
Old 11-24-2019, 05:31 PM   #1
Junior Member
Location: Utah

Join Date: Nov 2019
Posts: 1
Default Loop in bwa commands


I'm trying to loop multiple input files with matching prefixes and different file types in bwa sampe ; here's the general structure:
bwa sampe /Users/xxx/Desktop/Index_align/GRCh37_latest_genomic.fna H2_S16_L001_read1.sai H2_S16_L001_read2.sai \
H2_S16_L001_R1_001.fastq.gz H2_S16_L001_R2_001.fastq.gz > aln_H2_S16_L001.sam
I'm trying to make a loop like:
for i in /Users/xxx/Desktop/Index_align/Fastq/fastq_run4/ \
do bwa sampe /Users/xxx/Desktop/Index_align/GRCh37_latest_genomic.fna \
$i\-read1.sai $i\-read2.sai $i\-R1_001.fastq.gz $i\-R2_001.fastq.gz > $i\-aln.sam; done
Does anyone have suggestions for what I am missing? Like perhaps I need to create a list of the prefix file names? I would greatly appreciate any advice. Thanks!
Kax is offline   Reply With Quote
Old 07-08-2020, 12:30 AM   #2
Junior Member
Location: Beirut, Lebanon

Join Date: Sep 2016
Posts: 2

You can do the following:
for f in /Users/xxx/Desktop/Index_align/Fastq/fastq_run4/*.fastq.gz; do
name=$(basename $f _L001_R1_001.fastq.gz)
bwa sampe /Users/xxx/Desktop/Index_align/GRCh37_latest_genomic.fna \
${name}_L001_read1.sai ${name}_L001_read2.sai \
${name}_L001_R1_001.fastq.gz ${name}_L001_R2_001.fastq.gz > ${name}_aln.sam
abedkurdi is offline   Reply With Quote

bash loop, bwa, multiple bwa input files, python loop

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -8. The time now is 01:51 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO