How to run a batch .sra to .fastq processing loop using linux bash?
3
1
Entering edit mode
5.4 years ago
vassialk ▴ 200

How to run a batch .sra to .fastq processing loop using linux bash and sratoolkit?

I am trying to run a script in  a bin folder of sra tools:

#!/bin/bash
        for i in `*.sra`;
        do
                ./fastq-dump
        done   

sequencing sequence software error wgs • 5.1k views
ADD COMMENT
0
Entering edit mode

I imagine you're missing the $I at the end of ./fastq-dump, but either way, this is best suited to stack overflow

ADD REPLY
0
Entering edit mode

stackoverflow sends to Biostars!!!

ADD REPLY
4
Entering edit mode
5.4 years ago

It will be a lot better to use parallel since it can do the work using all of the cores available in your computer at once, saving time

sudo apt-get install parallel  #Will install parallel if necessary
find *sra | parallel 'fastq-dump --split-3 {}'

An alternative that uses a different directory, 6 cores and a regular (not a legacy) extraction of the sra files

cat ../extdata/sraFiles.txt | parallel -j 6 fastq-dump -I --split-files ../sra/{}.sra
ADD COMMENT
1
Entering edit mode
5.4 years ago

You should remove backticks (`...`) for your code to work. If your have more than 1 processor available, you might want to run fastq-dump in parallel with xargs. For example, run up to 5 processes in parallel:

ls *.sra | xargs -I {} -P 5 -n 1 ./fastq-dump {}
ADD COMMENT
0
Entering edit mode
5.4 years ago
Chirag Nepal ★ 2.3k
for i in ls (*.sra)
do
    ./fastq-dump $i
done

Try this.

ADD COMMENT
0
Entering edit mode

Thank you, folks, how clever you are!!!

ADD REPLY
1
Entering edit mode

So you are vassialk ? xD

ADD REPLY
0
Entering edit mode

New User..... From South Africa this time...

ADD REPLY

Login before adding your answer.

Traffic: 1521 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6