SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Make Wiggle file from RNA-seq bam masylichu Bioinformatics 2 11-16-2012 04:38 AM
Does anyone make your own gtf file? awenxu RNA Sequencing 0 05-30-2012 12:36 AM
Running stampy in bash script grafab Bioinformatics 7 04-23-2012 02:00 AM
Custom directory install coco2001 454 Pyrosequencing 2 11-29-2011 05:59 PM
Disable iterative search in BWA aln yanasmann Bioinformatics 1 08-31-2010 10:38 AM

Reply
 
Thread Tools
Old 05-22-2013, 11:16 AM   #1
jddavis
Junior Member
 
Location: Texas

Join Date: May 2013
Posts: 7
Default how to use bash script to make iterative loop through directory with two file types

Well you've all been wonderful about answering my novice questions...so here is another. I thank you in advance for generously providing an answer.

What I'm trying to do is loop through a directory, using simple bash script, to a set of files and then process the files to a *.sam format using bwa...here's the code I have so far...

#!bin/bash
#basic syntax below
#bwa samse ref.fa aln_sa.sai short_read.fq > aln-se.sam

module load bwa

FILE1="$WORK/trimmed/*se.fq"
FILE2="$WORK/trimmed/*.sai"

for f in FILE1 and FILE2
do
bwa samse whole_genome.fa "$f2".sai "$f1".fq > "$f".sam
done
jddavis is offline   Reply With Quote
Old 05-22-2013, 01:08 PM   #2
mastal
Senior Member
 
Location: uk

Join Date: Mar 2009
Posts: 667
Default how to use bash script to make iterative loop through directory with two file types

if your *.sai and *se.fq files have the same prefix (presumably you have one file of each type for each bwa alignment you want to run), you could try:

Code:
FILE2="$WORK/trimmed/*.sai"
WORKDIR="$WORK/trimmed/"

for f in $FILE2
do

      prefix=`basename $f .sai`

      bwa samse whole_genome.fa ${WORKDIR}${prefix}.sai     ${WORKDIR}${prefix}se.fq > ${WORKDIR}${prefix}.sam

done

Last edited by mastal; 05-22-2013 at 02:41 PM. Reason: corrected error in code
mastal is offline   Reply With Quote
Old 05-23-2013, 07:02 AM   #3
jddavis
Junior Member
 
Location: Texas

Join Date: May 2013
Posts: 7
Default

Hi Mastal:

Thank you for the reply, and I will certainly try this out...they do have similar prefixes...

-Jennifer
jddavis is offline   Reply With Quote
Reply

Tags
!bin/bash script, bwa, interative looping

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 08:43 PM.


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