+1 for making me realize the Windows shell can be used for something
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
3 answers
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.
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.
Thanks, I still wouldn't recommend it. It seems clunky.
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).
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).
Log in to answer this question.