Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • caa5042
    Junior Member
    • Jul 2013
    • 6

    Convert multiple sra files to fastq format

    Hi guys,

    I am trying to write a for loop in the terminal (im on a mac) to convert several .sra files to fastq format.

    SO this command works for just a single file:

    ./sratoolkit.2.3.2-5-mac-64/bin/fastq-dump ./SRR770514.sra

    Now I'm trying to use a for loop to do the same thing for multiple files. This is what I have:

    for fn in *.sra
    do ./sratoolkit.2.3.2-5-mac-64/bin/fastq-dump ./"$fn".sra
    done

    but its not working...i've tried several variations..like "$fn.sra" and even tried without the quotes but nothing works..please help
  • Richard Finney
    Senior Member
    • Feb 2009
    • 701

    #2
    get rid of the ".sra" at the end of the command line in the middle of the for loop.

    You can debug by just using ls instead of the fastqdump command ... like this ...

    Comment

    • caa5042
      Junior Member
      • Jul 2013
      • 6

      #3
      hmm that didnt work either

      and how do I debug using ls?

      Comment

      • Richard Finney
        Senior Member
        • Feb 2009
        • 701

        #4
        Get this to work


        for fn in *.sra
        do ls -l ${fn}
        done

        Comment

        • caa5042
          Junior Member
          • Jul 2013
          • 6

          #5
          I think the terminal is just not responding to for loops...i dont get an error or anything either

          any other ideas?

          Comment

          • Richard Finney
            Senior Member
            • Feb 2009
            • 701

            #6
            What shell are you running?

            type "echo $SHELL" at the command prompt.

            The syntax I provided is "bash shell".

            You can run bash by simply typing "bash" and hit return at the command line.

            Comment

            • caa5042
              Junior Member
              • Jul 2013
              • 6

              #7
              it says /bin/bash when i run echo $SHELL

              Comment

              • GenoMax
                Senior Member
                • Feb 2008
                • 7142

                #8
                Have you tried providing full path to the SRA files in the for loop?

                Code:
                for fn in *.sra
                do ./sratoolkit.2.3.2-5-mac-64/bin/fastq-dump /full_path_to/"$fn".sra
                done
                When you say it is not working what does that exact mean? Are you getting errors or nothing is happening.

                Comment

                • chadn737
                  Senior Member
                  • Jan 2009
                  • 392

                  #9
                  Try this, its what I use.

                  Code:
                  DIR="$1/*.sra"
                  
                  for file in $DIR
                  
                  do
                  
                  /path/to/fastq-dump $file
                  
                  done

                  Comment

                  • JamieHeather
                    @jamimmunology
                    • Nov 2012
                    • 96

                    #10
                    I feel like we've missed the easiest solution:

                    Code:
                    fastq-dump *

                    Comment

                    • caa5042
                      Junior Member
                      • Jul 2013
                      • 6

                      #11
                      Hi Jamie. You mean type the code just like that? with no loop or any of the other code?

                      Comment

                      • JamieHeather
                        @jamimmunology
                        • Nov 2012
                        • 96

                        #12
                        Just like that - works fine in bash anyway. If you have any files that aren't .sras in the directory you'll have to get a bit more specific, like so (with a little bit of tidying up after):

                        Code:
                        fastq-dump *.sra
                        rm *.sra

                        Comment

                        • genomeHunter
                          Member
                          • Apr 2013
                          • 26

                          #13
                          If you have multiple cores, this could be even better:

                          find . -name *.sra | xargs -P $NUM_CORES -n 1 fastq-dump

                          My disk can easily handle 16 simultaneous dumps.

                          Cheers,
                          GH
                          Last edited by genomeHunter; 07-25-2013, 07:46 AM. Reason: Added find.

                          Comment

                          • JamieHeather
                            @jamimmunology
                            • Nov 2012
                            • 96

                            #14
                            Just noticed that the solution I posted earlier doesn't work if you use the --split flag; when required I use this:

                            Code:
                            for i in *sra; do fastq-dump --split-3 $i; done

                            Comment

                            • ThePresident
                              Member
                              • Jun 2012
                              • 72

                              #15
                              Originally posted by JamieHeather View Post
                              Just noticed that the solution I posted earlier doesn't work if you use the --split flag; when required I use this:

                              Code:
                              for i in *sra; do fastq-dump --split-3 $i; done
                              Saved my life man!

                              TP

                              Comment

                              Latest Articles

                              Collapse

                              • SEQadmin2
                                Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                                by SEQadmin2



                                Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                                ...
                                07-09-2026, 11:10 AM
                              • SEQadmin2
                                Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                                by SEQadmin2



                                Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                                There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                                07-08-2026, 05:17 AM
                              • GATTACAT
                                Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                                by GATTACAT
                                Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                                07-01-2026, 11:43 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, Yesterday, 10:26 AM
                              0 responses
                              15 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-09-2026, 10:04 AM
                              0 responses
                              29 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-08-2026, 10:08 AM
                              0 responses
                              16 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-07-2026, 11:05 AM
                              0 responses
                              33 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...