You can download .sra
files using SRA Toolkit.
Install SRA Toolkit
Download the latest version of SRA Toolkit from here. In this post, I downloaded the sratoolkit.2.10.5-mac64.tar
file for macOS and unpack the SRA Toolkit (Options: x = extract, v = verbose, f = file).
tar -xvf sratoolkit.2.10.5-mac64.tar
sratoolkit.2.10.5-mac64/bin/prefetch SRR5721625
When I ran the above command on macOS Catalina (version 10.15.3), I got the following error:“sratools.2.10.5” cannot be opened because the developer cannot be verified.
Click the “Cancel” button to close the error message window. Go to System Preferences > Security & Privacy > General, and click the “Allow Anyway” button right to the "sratools.2.10.5" was blocked from use because it is not from an identified developer.
message.
When I ran sratoolkit.2.10.5-mac64/bin/prefetch
command again, I saw macOS cannot verify the developer of “sratools.2.10.5”. Are you sure you want to open it?
message. I clicked the “Open” button. But another file (vdb-config.2.10.5
) was blocked for the same reason. I repeated the similar things until it finally worked.
The default download directory is Users/[user name]/ncbi/public/sra
in macOS.
Another options
Go to System Preferences > Security & Privacy > Privacy, and select “Developer Tools.” Allow Terminal.app. And then restart Terminal.app.
Or you can install using homebrew
:brew install -v sratoolkit
Download SRA files using sratoolkit
You can use the prefetch utility in the SRA Toolkit to download SRA data and any required reference sequences in a single operation. Prefetch can be used on single data file or to batch download several at a time.
# Download a single file
sratoolkit.2.10.5-mac64/bin/prefetch SRR5721625
# Download multiple files
sratoolkit.2.10.5-mac64/bin/prefetch SRR5721625 SRR5721626
# Download all of the files listed in the SraAccList.txt file
sratoolkit.2.10.5-mac64/bin/prefetch --option-file SraAccList.txt
### SraAccList.txt ###
SRR5721625
SRR5721626
SRR5721629
SRR5721632
SRR5721633
######################
Convert SRA files to FASTQ files
# Paired-end
fastq-dump -I --split-files SRR5721625.sra
In this case, the output files are SRR5721625_1.fastq
and SRR5721625+2.fastq
.
If you are familiar with Docker, you can use NCBI’s Docker image:
docker run --rm -v "$(pwd)":/data -w /data ncbi/sra-tools fastq-dump --split-files SRR5721625.sra --gzip
Also, you can use multi-threaded fasterq-dump
. You can specify the number of thread by -e
. Note that unlike fastq-dump
, there is no --gzip|--bizp2
option (as of 2021/05/02), so you may want to compress your files after they have been written (link).
docker run --rm -v "$(pwd)":/data -w /data ncbi/sra-tools fasterq-dump SRR5721625.sra -e 10
gzip *.fastq
# Or you can use pigz
# https://rachaellappan.github.io/pigz/
pigz *.fastq
Comments