<p>Here are some command lines I used for that purpose in bash.
Simply prepare a text file containing each accession number (SRR/ERR) you want and create a for loop. Here I used <a href="https://github.com/totosugito/prozilla-2.0.4" rel="nofollow noreferrer">prozilla</a> to speed up downloads but you may use <code>wget</code> either.</p>
<pre><code>for index in $(cat list_of_accessions) ; do

if [ <span class="math-container">${#index} -eq 9 ]; then
            proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/$</span>{index:0:6}/<span class="math-container">${index}/$</span>{index}_1.fastq.gz
            proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/<span class="math-container">${index:0:6}/$</span>{index}/<span class="math-container">${index}_2.fastq.gz
            else
            if [ $</span>{#index} -eq 10 ]; then
                    proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/<span class="math-container">${index:0:6}/00$</span>{index:9:9}/<span class="math-container">${index}/$</span>{index}_1.fastq.gz
                            proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/<span class="math-container">${index:0:6}/00$</span>{index:9:9}/<span class="math-container">${index}/$</span>{index}_2.fastq.gz
                    else
                    if [ <span class="math-container">${#index} -eq 11 ]; then
                     proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/$</span>{index:0:6}/0<span class="math-container">${index:9:10}/$</span>{index}/<span class="math-container">${index}_1.fastq.gz
                                        proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/$</span>{index:0:6}/0<span class="math-container">${index:9:10}/$</span>{index}/<span class="math-container">${index}_2.fastq.gz
                    else
                        proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/$</span>{index:0:6}/<span class="math-container">${index:9:11}/$</span>{index}/<span class="math-container">${index}_1.fastq.gz
                                                proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/$</span>{index:0:6}/<span class="math-container">${index:9:11}/$</span>{index}/${index}_2.fastq.gz
                        fi
                fi
            
            fi
done
<span class="math-container">```</span>
</code></pre>

CC BY-SA 4.0
2020-07-13T06:51:21.073Z
2020-07-13T06:51:21.073Z
thomas duge de bernonville
<p>They have an <a href="https://ena-docs.readthedocs.io/en/latest/retrieval/programmatic-access/browser-api.html" rel="nofollow noreferrer">API</a> you can interact with.</p>
<p>If you need to get files for only a few different projects:
Search for your accession ID in the browser (leading to <a href="https://www.ebi.ac.uk/ena/browser/view/PRJNA506829" rel="nofollow noreferrer">https://www.ebi.ac.uk/ena/browser/view/PRJNA506829</a>). Filter the show selected columns to only fastq_ftp, click download tsv to get the list of ftp links.</p>

CC BY-SA 4.0
2020-07-13T14:06:18.707Z
2022-07-04T07:48:17.030Z
2022-07-04T07:48:17.030Z
Pallie
<p>You can do this in one line using <a href="https://www.ncbi.nlm.nih.gov/books/NBK179288/" rel="nofollow noreferrer">NCBI's EntrezDirect e-utils</a>:</p>
<p><code>esearch -db sra -query PRJNA506829 | efetch -format runinfo</code></p>
<p>The output will be in csv, but you can format it to tab using <a href="https://pypi.org/project/csvkit/" rel="nofollow noreferrer">csvkit's</a> <code>csvformat -T</code></p>

CC BY-SA 4.0
2022-07-06T04:11:22.860Z
2022-07-06T04:11:22.860Z
user3479780
<p><a href="https://github.com/saketkc/pysradb" rel="nofollow noreferrer">pysradb</a> can fetch ENA/SRA fastq/bam links (if available):</p>
<pre class="lang-bash prettyprint-override"><code>$ pysradb metadata SRR8240860 --detailed
run_accession study_accession experiment_accession experiment_title                                               experiment_desc                                                organism_taxid  organism_name           library_strategy library_source  library_selection library_layout sample_accession sample_title instrument   total_spots total_size  run_total_spots run_total_bases run_alias      sra_url_alt1                                    sra_url_alt2                                    sra_url                                                                                  experiment_alias source_name strain/genotype developmental stage ena_fastq_http ena_fastq_http_1                                                                 ena_fastq_http_2                                                                 ena_fastq_ftp ena_fastq_ftp_1                                                                     ena_fastq_ftp_2                                                                    
SRR8240860    SRP170618       SRX5059122           GSM3487689: fer-15 Day1 rep1; Caenorhabditis elegans; RNA-Seq  GSM3487689: fer-15 Day1 rep1; Caenorhabditis elegans; RNA-Seq  6239            Caenorhabditis elegans  RNA-Seq          TRANSCRIPTOMIC  cDNA              PAIRED         SRS4075216       N/A          HiSeq X Ten  40494415    4755049874  40494415        12148324500     GSM3487689_r1  gs://sra-pub-src-3/SRR8240860/RRA0719_R2.fq.gz  s3://sra-pub-src-3/SRR8240860/RRA0719_R2.fq.gz  https://sra-downloadb.st-va.ncbi.nlm.nih.gov/sos2/sra-pub-run-3/SRR8240860/SRR8240860.1  GSM3487689       whole worm  fer-15(b26ts)   Adult day 1         N/A            http://ftp.sra.ebi.ac.uk/vol1/fastq/SRR824/000/SRR8240860/SRR8240860_1.fastq.gz  http://ftp.sra.ebi.ac.uk/vol1/fastq/SRR824/000/SRR8240860/SRR8240860_2.fastq.gz  N/A           era-fasp@fasp.sra.ebi.ac.uk:vol1/fastq/SRR824/000/SRR8240860/SRR8240860_1.fastq.gz  era-fasp@fasp.sra.ebi.ac.uk:vol1/fastq/SRR824/000/SRR8240860/SRR8240860_2.fastq.gz
</code></pre>

CC BY-SA 4.0
2020-09-16T20:48:34.050Z
2020-09-16T20:48:34.050Z
Saket Choudhary
<p>How can I programmatically obtain ftp links to RNA seq fastq files in ENA? Here's an example of a link that I would be interested in obtaining:</p>
<p><code>ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR824/000/SRR8240860/SRR8240860_1.fastq.gz</code></p>
<p>In particular, is there some tool that, given the BioProject ID (here, PRJNA506829), would be able give me all ftp links for the runs in the project, or would I need to write a web scraper to do it?</p>

<rna-seq><public-databases><data-retrieval>
How can I obtain FTP links to studies in ENA given a BioProject ID?
# How can I obtain FTP links to studies in ENA given a BioProject ID?

(Asked by: username_0 on 2020-07-12)

How can I programmatically obtain ftp links to RNA seq fastq files in ENA? Here's an example of a link that I would be interested in obtaining:

`ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR824/000/SRR8240860/SRR8240860_1.fastq.gz`

In particular, is there some tool that, given the BioProject ID (here, PRJNA506829), would be able give me all ftp links for the runs in the project, or would I need to write a web scraper to do it?

**Tags:** rna-seq, public-databases, data-retrieval

---

## 4 answers

### Answer by username_1 on 2020-07-13. Score: 2

Here are some command lines I used for that purpose in bash.
Simply prepare a text file containing each accession number (SRR/ERR) you want and create a for loop. Here I used prozilla to speed up downloads but you may use wget either.
for index in $(cat list_of_accessions) ; do

if [ ${#index} -eq 9 ]; then
            proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/${index:0:6}/${index}/${index}_1.fastq.gz
            proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/${index:0:6}/${index}/${index}_2.fastq.gz
            else
            if [ ${#index} -eq 10 ]; then
                    proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/${index:0:6}/00${index:9:9}/${index}/${index}_1.fastq.gz
                            proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/${index:0:6}/00${index:9:9}/${index}/${index}_2.fastq.gz
                    else
                    if [ ${#index} -eq 11 ]; then
                     proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/${index:0:6}/0${index:9:10}/${index}/${index}_1.fastq.gz
                                        proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/${index:0:6}/0${index:9:10}/${index}/${index}_2.fastq.gz
                    else
                        proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/${index:0:6}/${index:9:11}/${index}/${index}_1.fastq.gz
                                                proz -k=6 --no-curses ftp.sra.ebi.ac.uk/vol1/fastq/${index:0:6}/${index:9:11}/${index}/${index}_2.fastq.gz
                        fi
                fi
            
            fi
done
```


---

### Answer by username_2 on 2020-07-13. Score: 1

They have an [API](https://ena-docs.readthedocs.io/en/latest/retrieval/programmatic-access/browser-api.html) you can interact with.

If you need to get files for only a few different projects:
Search for your accession ID in the browser (leading to <https://www.ebi.ac.uk/ena/browser/view/PRJNA506829>). Filter the show selected columns to only fastq\_ftp, click download tsv to get the list of ftp links.


---

### Answer by username_3 on 2022-07-06. Score: 0

You can do this in one line using [NCBI's EntrezDirect e-utils](https://www.ncbi.nlm.nih.gov/books/NBK179288/):

`esearch -db sra -query PRJNA506829 | efetch -format runinfo`

The output will be in csv, but you can format it to tab using [csvkit's](https://pypi.org/project/csvkit/) `csvformat -T`


---

### Answer by username_4 on 2020-09-16. Score: 0

pysradb can fetch ENA/SRA fastq/bam links (if available):
$ pysradb metadata SRR8240860 --detailed
run_accession study_accession experiment_accession experiment_title                                               experiment_desc                                                organism_taxid  organism_name           library_strategy library_source  library_selection library_layout sample_accession sample_title instrument   total_spots total_size  run_total_spots run_total_bases run_alias      sra_url_alt1                                    sra_url_alt2                                    sra_url                                                                                  experiment_alias source_name strain/genotype developmental stage ena_fastq_http ena_fastq_http_1                                                                 ena_fastq_http_2                                                                 ena_fastq_ftp ena_fastq_ftp_1                                                                     ena_fastq_ftp_2                                                                    
SRR8240860    SRP170618       SRX5059122           GSM3487689: fer-15 Day1 rep1; Caenorhabditis elegans; RNA-Seq  GSM3487689: fer-15 Day1 rep1; Caenorhabditis elegans; RNA-Seq  6239            Caenorhabditis elegans  RNA-Seq          TRANSCRIPTOMIC  cDNA              PAIRED         SRS4075216       N/A          HiSeq X Ten  40494415    4755049874  40494415        12148324500     GSM3487689_r1  gs://sra-pub-src-3/SRR8240860/RRA0719_R2.fq.gz  s3://sra-pub-src-3/SRR8240860/RRA0719_R2.fq.gz  https://sra-downloadb.st-va.ncbi.nlm.nih.gov/sos2/sra-pub-run-3/SRR8240860/SRR8240860.1  GSM3487689       whole worm  fer-15(b26ts)   Adult day 1         N/A            http://ftp.sra.ebi.ac.uk/vol1/fastq/SRR824/000/SRR8240860/SRR8240860_1.fastq.gz  http://ftp.sra.ebi.ac.uk/vol1/fastq/SRR824/000/SRR8240860/SRR8240860_2.fastq.gz  N/A           era-fasp@fasp.sra.ebi.ac.uk:vol1/fastq/SRR824/000/SRR8240860/SRR8240860_1.fastq.gz  era-fasp@fasp.sra.ebi.ac.uk:vol1/fastq/SRR824/000/SRR8240860/SRR8240860_2.fastq.gz


---

