Public Member Functions | Static Public Attributes

MGT::TaxaIODb::NodeStorageDb Class Reference

List of all members.

Public Member Functions

def loadAttribute
def saveAttributes
def loadSeqLen

Static Public Attributes

string tblNames = "taxa_names"
 Currently, we consider taxa names immutable and originating from the initial NCBI taxonomy dump file, so load them from a fixed DB table named by 'tblNames'.

Detailed Description

Taxonomy nodes storage in SQL DB

Member Function Documentation

def MGT::TaxaIODb::NodeStorageDb::loadAttribute (   self,
  tree,
  name,
  sql,
  default = None,
  setDefault = True,
  ignoreKeyError = True,
  typeCast = None 
)
Execute 'sql' which should return a unique mapping taxid -> value and assign result to each node.
@param name - name of the new treee nodee attribbute to set
@param sql - statement to execute. It must return (id,value) pairs (in that order) with 'id' corresponding to tree node id's.
Actual column names do not matter.
@param default - assign this value to those nodes for which taxid is not present in the 'sql' result set (if 'setDeafult' is True)
@param setDefault - if False, do not assign default value to nodes
@param ignoreKeyError - if True, do not raise exception if 'sql' results set contains an id that is not present in the tree.
def MGT::TaxaIODb::NodeStorageDb::loadSeqLen (   self,
  tree,
  name = "seq_len",
  sql = "select taxid,
  seq_len,
  from,
  taxa_seq_len 
)
Load sequence length from DB and also assign accumulated subtree sequence to attribute name+'_tot'
Parameters have the same meaning as for for loadAttribute().
Default value of 0L is used.
def MGT::TaxaIODb::NodeStorageDb::saveAttributes (   self,
  tree,
  nameToSql,
  table 
)
Save attribute values of tree nodes as a new table indexed by node id.
@param tree - tree to work on
@nameToSql - mapping of attribute names into SQL, by example: {'rankUpper':{'name':'rank_upper','type':'char(20)','createIndex':True,default=0}}. If 'name' is not present, the key of the dictionary will be used as is for SQL column
name. That might lead to problems if SQL server converts all names to lower case, for instance. It is not a good
idea to rely on identifier case in SQL code anyway.
@param table - SQL table name to create

Member Data Documentation

string MGT::TaxaIODb::NodeStorageDb::tblNames = "taxa_names" [static]

Currently, we consider taxa names immutable and originating from the initial NCBI taxonomy dump file, so load them from a fixed DB table named by 'tblNames'.

This assumes that all other trees that we construct are reductions of that original NCBI tree. This might change in the future, in which case we will use specific name table for each tree. It will still make sense to keep the names in a separate table because they are long and rarely needed strings. Currently we just expect the 'tblNames' to be loaded into the database already.


The documentation for this class was generated from the following file: