Skip to main content

NCBI Genome Downloading Scripts

Build Status
Code Health
Some script to download bacterial and fungal genomes from NCBI after they
restructured their FTP a while ago.
Idea shamelessly stolen from Mick Watson’s Kraken downloader scripts
that can also be found in Mick’s GitHub repo. However, Mick’s
scripts are [STRIKEOUT:written in Perl] specific to actually building a Kraken database
(as advertised).

So this is a set of scripts that focuses on the actual genome downloading.

Installation

pip install ncbi-genome-download

Alternatively, clone this repository from GitHub, then run (in a python virtual environment)

pip install .

If this fails on older versions of Python, try updating your pip tool first:

pip install --upgrade pip

and then rerun the ncbi-genome-download install.

ncbi-genome-download is only developed and tested on Python releases still under active
support by the Python project. At the moment, this means versions 2.7, 3.3, 3.4, 3.5 and 3.6.
Specifically, no attempt at testing under Python versions older than 2.7 or 3.3 is being made.
If your system is stuck on an older version of Python, consider using a tool like
Homebrew or Linuxbrew to obtain a more up-to-date
version.

Usage

To download all bacterial RefSeq genomes in GenBank format from NCBI, run the following:

ncbi-genome-download bacteria

If you’re on a reasonably fast connection, you might want to try running multiple downloads in parallel:

ncbi-genome-download bacteria --parallel 4

To download all fungal GenBank genomes from NCBI in GenBank format, run:

ncbi-genome-download --section genbank fungi

To download all viral RefSeq genomes in FASTA format, run:

ncbi-genome-download --format fasta viral

To download only completed bacterial RefSeq genomes in GenBank format, run:

ncbi-genome-download --assembly-level complete bacteria

To download bacterial RefSeq genomes of the genus Streptomyces, run:

ncbi-genome-download --genus Streptomyces bacteria

Note: This is a simple string match on the organism name provided by NCBI only.

You can also use this with a slight trick to download genomes of a certain species as well:

ncbi-genome-download --genus "Streptomyces coelicolor" bacteria
Note: The quotes are important. Again, this is a simple string match on the organism
name provided by the NCBI.

To download bacterial RefSeq genomes based on their NCBI species taxonomy ID, run:

ncbi-genome-download --species-taxid 562 bacteria

Note: The above command will download all RefSeq genomes belonging to Escherichia coli.

To download a specific bacterial RefSeq genomes based on its NCBI taxonomy ID, run:

ncbi-genome-download --taxid 511145 bacteria

Note: The above command will download the RefSeq genome belonging to Escherichia coli str. K-12 substr. MG1655.

It is possible to also create a human-readable directory structure in parallel to mirroring
the layout used by NCBI:
ncbi-genome-download --human-readable bacteria
This will use links to point to the appropriate files in the NCBI directory structure,
so it saves file space. Note that links are not supported on some Windows file systems and some
older versions of Windows.

To get an overview of all options, run

ncbi-genome-download --help

License

All code is available under the Apache License version 2, see the
`LICENSE <LICENSE>`__ file for details.

Metadata

Release files for ncbi-genome-download 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ncbi-genome-download 0.2.1
File Size Uploaded Provenance Actions
ncbi-genome-download-0.2.1.tar.gz 13.2 kB Without provenance Details for ncbi-genome-download-0.2.1.tar.gz

Release files / ncbi-genome-download-0.2.1.tar.gz

Download URL ncbi-genome-download-0.2.1.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
65eea76b0da141d41edbd5e22720225d0156f0a2a336e858ca6dc99eedb908e5
BLAKE2b-256 checksum
How to use checksums
dfe57345ffbd9f57d70e88061beaa76ba15caa1c709ceefff277f93147b74ba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for ncbi-genome-download 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page