schema API reference

class taxadb2.schema.Accession(*args, **kwargs)

table Accession.

Each row is a sequence from nucl_*.accession2taxid.gz. Each sequence

has a taxid.

id

the primary key

Type:

pw.AutoField

taxid

reference to a taxon in the table Taxa.

Type:

pw.ForeignKeyField

accession

the accession number of the sequence.

Type:

pw.CharField

DoesNotExist

alias of AccessionDoesNotExist

__repr__()

Return repr(self).

class taxadb2.schema.DatabaseFactory(config=None, **kwargs)

Database factory to support multiple database type.

This class may be used to create a database for different type (SQLite,

PostgreSQL, MySQL).

Parameters:
  • config (str) – Path to configuration file.

  • **kwargs – Arbitrary arguments. Supported (username, password, port, hostname)

Raises:

AttributeError – If error occurred during database object build

__init__(config=None, **kwargs)
__weakref__

list of weak references to the object (if defined)

_load_config(config=None)

Load configuration file

Parameters:

config (str) – Path to configuration file

Returns:

True

_set_args(args)

Set database connection settings and info as config

Parameters:

args (dict) – Dictionary for database settings

Returns:

True

get(name, section='DBSETTINGS')

Get a database connection setting

First checks if the configuration has been set and if the setting is in here. Otherwise, check if this setting is set as an attribute.

Parameters:
  • name (str) – Database setting to request

  • section (str) – Section to look for, default ‘DBSETTINGS’

Returns:

value (str) if set, None otherwise

get_database()

Returns the correct database driver

Returns:

pw.Database

Raises:

AttributeError – if –username or –password not passed (if –dbtype [postgres|mysql])

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

set_config(config=None, args=None)

Read configuration file with database settings

It :param config: Path to configuration file :type config: str :param args: Option arguments :type args: dict

Returns:

configparser.ConfigParser

class taxadb2.schema.DeprecatedTaxID(*args, **kwargs)

Table DeprecatedTaxID.

This table stores mappings of deprecated (old) taxIDs to their corresponding new taxIDs.

DoesNotExist

alias of DeprecatedTaxIDDoesNotExist

__repr__()

Return repr(self).

class taxadb2.schema.Taxa(*args, **kwargs)

table Taxa.

Each row is a taxon.

ncbi_taxid

the TaxID of the taxon (from nodes.dmp)

Type:

pw.IntegerField

parent_taxid

the TaxID of the parent taxon (from nodes.dmp)

Type:

pw.IntegerField

tax_name

the scientific name of the taxon (from names.dmp)

Type:

pw.CharField

lineage_level

the level of lineage of the taxon (from nodes.dmp)

Type:

pw.CharField

DoesNotExist

alias of TaxaDoesNotExist

__repr__()

Return repr(self).