Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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


    • #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

      • seqadmin
        New Genomics Tools and Methods Shared at AGBT 2025
        by seqadmin


        This year’s Advances in Genome Biology and Technology (AGBT) General Meeting commemorated the 25th anniversary of the event at its original venue on Marco Island, Florida. While this year’s event didn’t include high-profile musical performances, the industry announcements and cutting-edge research still drew the attention of leading scientists.

        The Headliner
        The biggest announcement was Roche stepping back into the sequencing platform market. In the years since...
        03-03-2025, 01:39 PM
      • seqadmin
        Investigating the Gut Microbiome Through Diet and Spatial Biology
        by seqadmin




        The human gut contains trillions of microorganisms that impact digestion, immune functions, and overall health1. Despite major breakthroughs, we’re only beginning to understand the full extent of the microbiome’s influence on health and disease. Advances in next-generation sequencing and spatial biology have opened new windows into this complex environment, yet many questions remain. This article highlights two recent studies exploring how diet influences microbial...
        02-24-2025, 06:31 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by seqadmin, Today, 12:50 PM
      0 responses
      9 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 03-03-2025, 01:15 PM
      0 responses
      181 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 02-28-2025, 12:58 PM
      0 responses
      275 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 02-24-2025, 02:48 PM
      0 responses
      663 views
      0 likes
      Last Post seqadmin  
      Working...
      X