This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How can I change the default path to which SRA files are downloaded?

By default, SRA files will be downloaded to ~/ncbi/ncbi_public/sra by using sratoolkit from ncbi. However, there is limited space. So I want to change the path. Is there a way to download SRA files using sratoolkit (fastq-dump) or can I download the SRA files directly without parsing converting it into fastq files?

rna-seq

5 answers

Yes, one of the shortcomings of sratoolkit is, that it stores huge temporary files in your home directory, which may have limited space and my be mounted via NFS.

The official way for changing several settings is to use vdb-config. This program simply creates a config file named $HOME/.ncbi/user-settings.mkfg. But its much easier to create and edit this file with a text editor or on the command line.

The following will change the cache directory to /tmp:

echo '/repository/user/main/public/root = "/tmp"' > $HOME/.ncbi/user-settings.mkfg

I always downloaded SRA files directly using wget, and then converted them to fastq.tar.gz locally with fastq-dump.

The file address for SRA file is like this format:

/sra/sra-instant/reads/ByRun/sra/{SRR|ERR|DRR}/<first 6 characters of accession>/<accession>/<accession>.sra

For example:

ftp://ftp-trace.ncbi.nih.gov/sra/sra-instant/reads/ByRun/sra/SRR/SRR119/SRR1192353/SRR1192353.sra

This is simple! Thanks!

This is super easy, but you still have to extract the FASTQ files from the SRA file using fastq-dump. So it might be just easier to just use fastq-dump, changing the default save directory, according to piet's post.

[UPDATE] Funny enough, just because I posted this, I changed the configuration as by piet's post (which it has worked for me in the past), but now files are still being saved to my home directory for no reason.. gah... downloading SRA files and extracting fastq locally using fastq-dump will probably be the way to move forward.

Check this out!

https://github.com/ncbi/sra-tools/wiki/Toolkit-Configuration

You can use fastq-dump with an SRR identifier to download FASTQ files directly without saving an SRA file. Remember to use the --split-files flag if it is a paired-end run.

Quick warning in case memory is a potential issue: I believe fastq-dump downloads an sra file to the deafult sra directory, converts it to fastq, then deletes the sra file.

I executed below, where fetch is a file with each line consisting of an accession number.

while read -r line
do
    accession_number="$line"
    fastq-dump --split-files --gzip $accession_number
done < ${fetch}

A couple of my jobs failed due to cluster memory issues, so I checked my ~/ncbi/public/sra directory, and, lo and behold, tons of sra files.

You will find the answer here and here.

So complicated! Thanks!

Log in to answer this question.