rotifer.db.ncbi.GenomeCursor#

class rotifer.db.ncbi.GenomeCursor(readers=['mirror', 'ftp'], writers=[], progress=True, tries=3, sleep_between_tries=1, batch_size=None, threads=None, timeout=10, mirror='/databases/genomes', cache='/tmp', *args, **kwargs)[source]#

Bases: GenomeCursor, SequentialDelegatorCursor

Fetch annotated genome sequences.

Genomes are located by their assembly accession and parsed from GenBank flat files into Bio.SeqRecord objects. A local mirror of the NCBI genomes repository, when available, is tried before the NCBI FTP site.

Parameters:
readerslist of str, default ['mirror', 'ftp']

Backend reader modules, tried in order.

writerslist of str, default []

Backend writer modules.

progressbool, default True

Whether to print a progress bar.

triesint, default 3

Number of attempts to download data.

sleep_between_triesint, default 1

Number of seconds to wait between download attempts.

batch_sizeint, optional

Number of accessions per batch.

threadsint, optional

Number of processes used for parallel downloads.

timeoutint, default 10

Maximum time, in seconds, to wait for a server connection.

mirrorstr, optional

Path to a local mirror of the NCBI FTP genomes repository. Defaults to the mirror configuration entry.

cachestr, optional

Directory for temporary files. Defaults to the rotifer cache directory.

See also

GenomeFeaturesCursor

genome annotation as dataframes

rotifer.db.ncbi.ftp.GenomeCursor

the FTP backend

rotifer.db.ncbi.mirror.GenomeCursor

the local mirror backend

Examples

Load a sample of genomes:

>>> from rotifer.db import ncbi
>>> q = ['GCA_018744545.1', 'GCA_901308185.1']
>>> gc = ncbi.GenomeCursor(progress=True)
>>> g = gc.fetchall(q)