Question: Sra-Toolkit 2.3.1 Fastq-Dump Multiplefiles At Once Windows Command Line
1
gravatar for deepbiofever
5.6 years ago by
deepbiofever10
deepbiofever10 wrote:

I am not software professional so bare with me if I am asking some silly questions.

I have downloaded SRP003329 study, which contains 20 sub-directory with .sra files. Now I am able to convert all these files individually into fastq format using fastq-dump command.

/bin/fastq-dump -A [file name] [File path] -O [output path]

but I want to know how I can do the same for all the .sra files in my dir SRP003329 at once. something like find all .sra files in my directory and fastq-dump all at once.

Thanks Deep

sra • 8.3k views
ADD COMMENTlink modified 6 days ago by juan.olvido0 • written 5.6 years ago by deepbiofever10
2
gravatar for Devon Ryan
5.6 years ago by
Devon Ryan85k
Freiburg, Germany
Devon Ryan85k wrote:

Sounds like you just need to learn how to do shell scripting. Perhaps changing to that directory and typing the following will work:

for /D %%d in (*) do ( 
    cd %%d
    for %%f in (*.sra) do (
        fastq-dump %%f
    )
    cd .. 
)

You should, of course, change the fastq-dump command to whatever exactly you need. BTW, your life is going to be more difficult if you stick to windows. You'll find much of this sort of thing to be less clunky on Linux and Mac OSX.

ADD COMMENTlink modified 6 days ago by RamRS18k • written 5.6 years ago by Devon Ryan85k

+1 for making me realize the Windows shell can be used for something

ADD REPLYlink written 5.6 years ago by Matt Shirley8.6k

Thanks, I still wouldn't recommend it. It seems clunky.

ADD REPLYlink written 5.6 years ago by Devon Ryan85k
2
gravatar for Sukhdeep Singh
5.6 years ago by
Sukhdeep Singh9.5k
Netherlands
Sukhdeep Singh9.5k wrote:

I don't know what your tree looks like, but on a general note this should work.

Using for loop;

for i in SRP003329/*/*.sra; do fastq-dump -A $i ; done

Using GNU-Parallel

# replace the j with number of free processors in your computer
parallel -j 5 'fastq-dump {}' ::: SRP003329/*/*.sra

I don't give the output file name, it automatically takes care of it, produces file name with .fastq extension but same name.

ADD COMMENTlink modified 6 days ago by RamRS18k • written 5.6 years ago by Sukhdeep Singh9.5k
0
gravatar for juan.olvido
6 days ago by
juan.olvido0 wrote:

Create a notepad file and open it. In the file, write:

FOR %%x IN (X:\sourcepath\*.sra) DO (X:\SRAToolkitpath\fastq-dump -O X:\destionationpath %%x)pause

Save the file. Change the file extension from ".txt" to ".bat".

Run the windows cmd with administrator rights.

In the cmd, go to the SRA Toolkit folder, where you should also have the .bat file you just created. Once in the SRA Toolkit folder, run the .bat file by typing its name and hitting "enter" (be careful with spaces and stuff in the filename).

You can customize the settings of the fastq conversion by specifying between "fastq-dump" and "-O X:..." (check the SRA Toolkit docu for details).

ADD COMMENTlink written 6 days ago by juan.olvido0

Hi,

How is your answer an enhancement/value-add over Devon's (which is over 5 years old at the moment)? If you were to mention that, it would be easier for people looking for a solution to pick yours (assuming it addresses a gap in logic that Devon's answer doesn't address).

ADD REPLYlink written 6 days ago by RamRS18k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1982 users visited in the last hour