taxadb2 API reference

class taxadb2.taxadb.TaxaDB(**kwargs)

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__()

Ensure database connection is closed

__init__(**kwargs)
__weakref__

list of weak references to the object (if defined)

_unmapped_taxid(acc, do_exit=False)

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)

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)

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)

Get a database setting from the connection arguments

Returns:

value (str) if found, None otherwise

set(option, value, section='DBSETTINGS')

Set a configuration value

Parameters:
  • option (str) – Config key

  • value (str) – Config value

  • section (str) – Config section, default ‘DBSETTINGS’

Returns:

True