Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • 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

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


    • #3
      hmm that didnt work either

      and how do I debug using ls?

      Comment


      • #4
        Get this to work


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

        Comment


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

          any other ideas?

          Comment


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


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

              Comment


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


                • #9
                  Try this, its what I use.

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

                  Comment


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

                    Code:
                    fastq-dump *

                    Comment


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

                      Comment


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


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


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


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

                              • seqadmin
                                Current Approaches to Protein Sequencing
                                by seqadmin


                                Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
                                04-04-2024, 04:25 PM
                              • seqadmin
                                Strategies for Sequencing Challenging Samples
                                by seqadmin


                                Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
                                03-22-2024, 06:39 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by seqadmin, 04-11-2024, 12:08 PM
                              0 responses
                              30 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 04-10-2024, 10:19 PM
                              0 responses
                              32 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 04-10-2024, 09:21 AM
                              0 responses
                              28 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 04-04-2024, 09:00 AM
                              0 responses
                              53 views
                              0 likes
                              Last Post seqadmin  
                              Working...
                              X