taxadb API reference

class taxadb.taxadb.TaxaDB(**kwargs)[source]

Main TaxaDB package class

Parent class of the Taxadb application. Use this class to create inheriting classes.

Parameters:**kwargs – Arbitrary arguments. Supported (username, password, port, hostname, config, dbtype, dbname)
Raises:AttributeError – If cannot instantiate taxadb.schema.DatabaseFactory.
MAX_LIST

Maximum number of bind variables to pass to request methods. Due to SQLite limit of passed arguments to a statement, we limit number of accession and taxid to request to 999 (https://www.sqlite.org/c3ref/bind_blob.html)

Type:int
__del__()[source]

Ensure database connection is closed

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

_unmapped_taxid(acc, do_exit=False)[source]

Prints error message to stderr if an accession number is not mapped with a taxid

Source ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/accession2taxid/README >> If for some reason the source organism cannot be mapped to the taxonomy database, the column will contain 0.<<

Parameters:
  • acc (str) – Accession number not mapped with taxid
  • do_exit (bool) – Exit with code 1. Default False
static check_list_ids(ids)[source]

Check the list of ids is not longer that MAX_LIST

Parameters:ids (list) – List of bind values
Returns:True
Raises:SystemExit – If len of the list of greater than MAX_LIST.
check_table_exists(table)[source]

Check a table exists in the database

Parameters:table (str) – Database table name to check.
Returns:True
Raises:SystemExit – if table does not exist
get(name)[source]

Get a database setting from the connection arguments

Returns:value (str) if found, None otherwise
set(option, value, section='DBSETTINGS')[source]

Set a configuration value

Parameters:
  • option (str) – Config key
  • value (str) – Config value
  • section (str) – Config section, default ‘DBSETTINGS’
Returns:

True