<p>I'd suggest the <code>bit-dl-ncbi-assemblies</code> from the <a href="https://github.com/AstrobioMike/bit" rel="nofollow noreferrer">Bioinformatics Tools</a> package.</p>
<pre><code>$ bit-dl-ncbi-assemblies

 --------------------------------  HELP INFO  --------------------------------- 

  This program downloads assembly files for NCBI genomes. It takes as input
  assembly accessions (either GCA_* or GCF_*) and optionally a specification of
  which format to download (currently: genbank, fasta, protein, or gff). For
  version info, run `bit-version`.

    Required input:

        - [-w &lt;file&gt;] single-column file of NCBI assembly accessions

    Optional arguments include:

        - [-f &lt;str&gt;] default: genbank
                  Specify the desired format. Available options currently
                  include: genbank, fasta, protein, gff, feature_tab, report, stats.

        - [-j &lt;int&gt; ] default: 1
                  The number of downloads you'd like to run in parallel. Write speeds
                  can become problematic generally with around 15 or more, so a max
                  of 12 will be used to be safe even if more are requested.

    Example usage:

     bit-dl-ncbi-assemblies -w ncbi_accessions.txt -f protein -j 4
</code></pre>
<p>Alternatively, you can use this code from the <a href="http://biopython.org/DIST/docs/tutorial/Tutorial.html#sec149" rel="nofollow noreferrer">Biopython cookbook</a>:</p>
<pre class="lang-py prettyprint-override"><code>import os
from Bio import SeqIO
from Bio import Entrez

Entrez.email = &quot;A.N.Other@example.com&quot;  # Always tell NCBI who you are

seq_ids = [&quot;EU490707&quot;] # Your accessions go in this list
for sid in seq_ids:
    filename = f&quot;{sid}.fasta&quot;
    if not os.path.isfile(filename):
        # Downloading...
        net_handle = Entrez.efetch(
            db=&quot;nucleotide&quot;, id=sid, rettype=&quot;fasta&quot;, retmode=&quot;text&quot;
        )
        out_handle = open(filename, &quot;w&quot;)
        out_handle.write(net_handle.read())
        out_handle.close()
        net_handle.close()
        print(&quot;Saved&quot;)
</code></pre>

CC BY-SA 4.0
2021-07-20T13:12:20.150Z
2021-07-20T13:12:20.150Z
Throckmorton
<p>I need to download some of the genomes of human gut microbiome in FASTA format. Anybody has any script to download?</p>

<computational-biochemistry>
How to download the whole genome of an organism from NCBI using R or Python?
# How to download the whole genome of an organism from NCBI using R or Python?

(Asked by: username_0 on 2021-07-20)

I need to download some of the genomes of human gut microbiome in FASTA format. Anybody has any script to download?

**Tags:** computational-biochemistry

---

## 1 answers

### Answer by username_1 on 2021-07-20. Score: 3

I'd suggest the bit-dl-ncbi-assemblies from the Bioinformatics Tools package.
$ bit-dl-ncbi-assemblies

 --------------------------------  HELP INFO  --------------------------------- 

  This program downloads assembly files for NCBI genomes. It takes as input
  assembly accessions (either GCA_* or GCF_*) and optionally a specification of
  which format to download (currently: genbank, fasta, protein, or gff). For
  version info, run `bit-version`.

    Required input:

        - [-w ] single-column file of NCBI assembly accessions

    Optional arguments include:

        - [-f ] default: genbank
                  Specify the desired format. Available options currently
                  include: genbank, fasta, protein, gff, feature_tab, report, stats.

        - [-j  ] default: 1
                  The number of downloads you'd like to run in parallel. Write speeds
                  can become problematic generally with around 15 or more, so a max
                  of 12 will be used to be safe even if more are requested.

    Example usage:

     bit-dl-ncbi-assemblies -w ncbi_accessions.txt -f protein -j 4

Alternatively, you can use this code from the Biopython cookbook:
import os
from Bio import SeqIO
from Bio import Entrez

Entrez.email = "A.N.Other@example.com"  # Always tell NCBI who you are

seq_ids = ["EU490707"] # Your accessions go in this list
for sid in seq_ids:
    filename = f"{sid}.fasta"
    if not os.path.isfile(filename):
        # Downloading...
        net_handle = Entrez.efetch(
            db="nucleotide", id=sid, rettype="fasta", retmode="text"
        )
        out_handle = open(filename, "w")
        out_handle.write(net_handle.read())
        out_handle.close()
        net_handle.close()
        print("Saved")


---

