I have following accession numbers of the 10 chromosomes of Theobroma cacao genome.

NC_030850.1
NC_030851.1
NC_030852.1
NC_030853.1
NC_030854.1
NC_030855.1
NC_030856.1
NC_030857.1
NC_030858.1
NC_030859.1


I need to download these FASTA files using the terminal because I'm working on a server. I'll be grateful if someone can help me. Thank you.

Alternatively, you can use the NCBI Entrez Direct UNIX E-utilities

In the terminal, install it using: source ./install-edirect.sh

esearch -db nucleotide -query "NC_030850.1" | efetch -format fasta > NC_030850.1.fasta

As you have several sequences to download, I think it will be quite easy to add this command into a little bash script to process all of them.

• Thank you very much for all the support. Nov 13, 2019 at 18:02
• @MudithMMBc, you're welcome ;)
– dc37
Nov 13, 2019 at 18:49

Just wget or curl each as https://www.ncbi.nlm.nih.gov/nuccore/NC_030853.1?report=fasta&log$=seqview&format=text... • Thank you very much. Nov 13, 2019 at 18:02 • This doesn’t seem to work (any longer?). For instance, curl -L 'https://www.ncbi.nlm.nih.gov/nuccore/NC_030853.1?report=fasta&log$=seqview&format=text' downloads a HTML page with an (invisible) form on it, not a FASTA file. May 27, 2021 at 15:30

The best way to download FASTA sequences for an entire genome is to search for the genome, for example Theobroma cacao genome in the NCBI Assembly portal and use the big blue Download button.

For a given assembly, if you want to download the FASTA sequences for a bunch of chromosomes, you can do that by going to the Genomes FTP path highlighted in the screenshot: Once you are in the Genomes FTP path, you can navigate to the FASTA folder as follows: Theobroma FTP directory >> Assembly Structure >> Primary Assembly >> Assembled Chromosomes >> FASTA.

If you were to use Entrez Direct for this purpose, I'd not bother with a bash script and use epost to first post the entire list of accessions and then pipe it to efetch as shown below:

epost -db nuccore -input <file_with_accs> -format acc \
| efetch -format fasta > sequences.fasta

• Thank you very much for all the support. Nov 13, 2019 at 18:02
1. Go to the main FASTA sequence page, view source, and get the "ncbi_uidlist" value. In this case, it's 1061361601
(Sorry, I can't post a comment with my reputation score). @vkkodali, interesting command I did not know about it ;). However, your command is downloading all sequences from the input file into a single fasta file. I believe that if you have a big bunch of sequences, it could be a little bit tricky after to manipulate that kind of file. Just by curiosity, do you have a trick to create one sequence per file using efetch ?
• If you have a big bunch of sequences, you will end up with a lot of files. Whether you want a large number of files or just one file is, I guess, a personal choice. A multifasta file is fairly standard though. I don't think you can create individual files for each sequence using epost and efetch; you will have to either use a bash script or postprocess the efetch output using the unix tool split. Nov 8, 2019 at 2:28