SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert sra-lite format to fastq? tbusch0000 Bioinformatics 23 08-21-2013 09:53 PM
Convert fastq from NCBI SRA to fasta and qual? kmkocot Bioinformatics 7 10-09-2012 10:15 AM
Is it possible to convert FASTQ/FASTA files in HDF5 format? vincebaby6 Pacific Biosciences 5 08-30-2012 07:30 AM
How convert multiple .sra files into .fastq in one go? TuA Bioinformatics 5 05-27-2011 09:32 AM
Question about using sra_toolkit to transform the SRA format into FASTQ format areyousad Bioinformatics 0 05-16-2010 11:56 PM

Reply
 
Thread Tools
Old 07-20-2013, 05:02 PM   #1
caa5042
Junior Member
 
Location: texas

Join Date: Jul 2013
Posts: 6
Default 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
caa5042 is offline   Reply With Quote
Old 07-20-2013, 05:25 PM   #2
Richard Finney
Senior Member
 
Location: bethesda

Join Date: Feb 2009
Posts: 700
Default

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 ...
Richard Finney is offline   Reply With Quote
Old 07-20-2013, 07:07 PM   #3
caa5042
Junior Member
 
Location: texas

Join Date: Jul 2013
Posts: 6
Default

hmm that didnt work either

and how do I debug using ls?
caa5042 is offline   Reply With Quote
Old 07-20-2013, 08:17 PM   #4
Richard Finney
Senior Member
 
Location: bethesda

Join Date: Feb 2009
Posts: 700
Default

Get this to work


for fn in *.sra
do ls -l ${fn}
done
Richard Finney is offline   Reply With Quote
Old 07-21-2013, 06:08 AM   #5
caa5042
Junior Member
 
Location: texas

Join Date: Jul 2013
Posts: 6
Default

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

any other ideas?
caa5042 is offline   Reply With Quote
Old 07-21-2013, 06:18 AM   #6
Richard Finney
Senior Member
 
Location: bethesda

Join Date: Feb 2009
Posts: 700
Default

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.
Richard Finney is offline   Reply With Quote
Old 07-21-2013, 07:51 AM   #7
caa5042
Junior Member
 
Location: texas

Join Date: Jul 2013
Posts: 6
Default

it says /bin/bash when i run echo $SHELL
caa5042 is offline   Reply With Quote
Old 07-21-2013, 08:43 AM   #8
GenoMax
Senior Member
 
Location: East Coast USA

Join Date: Feb 2008
Posts: 7,087
Default

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.
GenoMax is offline   Reply With Quote
Old 07-21-2013, 11:13 AM   #9
chadn737
Senior Member
 
Location: US

Join Date: Jan 2009
Posts: 392
Default

Try this, its what I use.

Code:
DIR="$1/*.sra"

for file in $DIR

do

/path/to/fastq-dump $file

done
chadn737 is offline   Reply With Quote
Old 07-25-2013, 06:17 AM   #10
JamieHeather
@jamimmunology
 
Location: London

Join Date: Nov 2012
Posts: 96
Default

I feel like we've missed the easiest solution:

Code:
fastq-dump *
JamieHeather is offline   Reply With Quote
Old 07-25-2013, 06:32 AM   #11
caa5042
Junior Member
 
Location: texas

Join Date: Jul 2013
Posts: 6
Default

Hi Jamie. You mean type the code just like that? with no loop or any of the other code?
caa5042 is offline   Reply With Quote
Old 07-25-2013, 08:37 AM   #12
JamieHeather
@jamimmunology
 
Location: London

Join Date: Nov 2012
Posts: 96
Default

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
JamieHeather is offline   Reply With Quote
Old 07-25-2013, 08:44 AM   #13
genomeHunter
Member
 
Location: Canada

Join Date: Apr 2013
Posts: 26
Default

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 at 08:46 AM. Reason: Added find.
genomeHunter is offline   Reply With Quote
Old 07-30-2013, 04:57 AM   #14
JamieHeather
@jamimmunology
 
Location: London

Join Date: Nov 2012
Posts: 96
Default

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
JamieHeather is offline   Reply With Quote
Old 04-17-2018, 06:34 PM   #15
ThePresident
Member
 
Location: Sherbrooke / Canada

Join Date: Jun 2012
Posts: 72
Default

Quote:
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
ThePresident is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 06:04 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO