Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • jddavis
    Junior Member
    • May 2013
    • 7

    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
  • mastal
    Senior Member
    • Mar 2009
    • 666

    #2
    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, 02:41 PM. Reason: corrected error in code

    Comment

    • jddavis
      Junior Member
      • May 2013
      • 7

      #3
      Hi Mastal:

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

      -Jennifer

      Comment

      Latest Articles

      Collapse

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, 06-09-2026, 11:58 AM
      0 responses
      16 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 06-05-2026, 10:09 AM
      0 responses
      26 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 06-04-2026, 08:59 AM
      0 responses
      37 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 06-02-2026, 12:03 PM
      0 responses
      61 views
      0 reactions
      Last Post SEQadmin2  
      Working...