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


1 Answer 1


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 <file>] single-column file of NCBI assembly accessions

    Optional arguments include:

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

        - [-j <int> ] 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 = "[email protected]"  # 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")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.