How to Download Multiple FASTA/FASTQ Files

ShortLong-Seq Bioinformatics
3 min readDec 14, 2022

--

Welcome back! By now you should be able to set up the SRA tool and download at least one FASTA/FASTQ file. As you noticed, if not that’s fine, there are multiple files under that one article.

So, how can I download multiple files in one go?

You are in luck! In this chapter, I will highlight a couple of methods that you can use to download several files.

Option 1: Running Multiple Terminal Screens

This can be a bit laborious since you have to create multiple terminals to run the iteration. But I think for a beginner, this method can be a good practice to hone Linux/Ubuntu command skills and acclimate to the workflow.

Step 1. Open up a new tab or terminal window. For Mac users at the top-left-hand side of the computer monitor, click ‘Shell’ > ‘New Tab’ or press the Command+N keys. For Windows users just right-click the currently running Terminal icon to create a new window.

Repeat this step per the number of files you need to download.

Step 2. Head to the directory where you will be downloading and storing the FASTA/FASTQ files using the cd command. In the previous chapter, our first downloaded file was at sra_data.

Note: If you are using an ssh server make sure you are logged in to all the new terminal window(s) you have created.

Step 3. Run the same command (below) on each new terminal window to download the files. Replace brackets with the SRR IDs or accession numbers for each file.

fastq-dump -A [paste the SRR ID] --split-3 --gzip

Phew! That was quite cumbersome, wasn’t it?
If you like a challenge, then you will like the next method which I’m about to show you.

Option 2: Creating and Running Bash Script

This method requires an extra bit of coding. We will be creating and running a custom script that is in a way ‘automating’ the repetitive process.

Step 1. Enter vi <name your script>.sh in the terminal. The vi command opens up the editor where you will be writing the codes. I’m going to name the script as ‘testing,’ so in the terminal it should look like this, for me:
vi testing.sh

Step 2. When running the above command, the screen will change into editing mode. Input the below to create your script. Replace the bracket with the appropriate SSR ID/Accession number for each file:

#!/bin/bash

fastq-dump -A [enter SRR ID/ Accession Number] --split-3 --gzip
fastq-dump -A [enter SRR ID/ Accession Number] --split-3 --gzip
fastq-dump -A [enter SRR ID/ Accession Number] --split-3 --gzip
fastq-dump -A [enter SRR ID/ Accession Number] --split-3 --gzip

Save and exit the editor by entering :wq

To check whether your script has been properly saved, enter cat <name of your script>.sh or in this example case cat testing.sh in the terminal. It should show you the exact script that you have coded.

Step 3. To run the script enter sh <name of your script>.sh or in this example case sh testing.sh

Now all you need to do is let it do its magic and you are all done!

--

--

ShortLong-Seq Bioinformatics
ShortLong-Seq Bioinformatics

Written by ShortLong-Seq Bioinformatics

Bioinformatics | Systems Biology | Computational Biology| Data Science |

No responses yet