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
                                Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
                                by SEQadmin2



                                CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

                                Despite this, “CRISPR helped turn genome editing from a specialized technique into
                                ...
                                07-31-2026, 11:01 AM
                              • SEQadmin2
                                Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                                by SEQadmin2


                                Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                                The systematic characterization of the human proteome has
                                ...
                                07-20-2026, 11:48 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, Yesterday, 12:22 PM
                              0 responses
                              12 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 08-11-2026, 10:35 AM
                              0 responses
                              14 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 08-06-2026, 07:41 AM
                              0 responses
                              31 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 08-03-2026, 10:13 AM
                              0 responses
                              50 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...