Unconfigured Ad

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

    #1

    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
                                Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                                by SEQadmin2



                                Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                                Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                                ...
                                10-14-2026, 09:55 AM
                              • SEQadmin2
                                New Genomics Technologies Take Aim at Long-Standing Limits
                                by SEQadmin2


                                Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                                We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                                ...
                                09-28-2026, 10:25 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, 10-15-2026, 10:52 AM
                              0 responses
                              23 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-14-2026, 05:39 AM
                              0 responses
                              27 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-13-2026, 09:56 AM
                              0 responses
                              23 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-09-2026, 11:14 AM
                              0 responses
                              28 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...