Package BioSQL :: Module BioSeqDatabase :: Class Adaptor
[hide private]
[frames] | no frames]

Class Adaptor

source code

object --+
         |
        Adaptor
Known Subclasses:

High level wrapper for a database connection and cursor.

Most database calls in BioSQL are done indirectly though this adaptor class. This provides helper methods for fetching data and executing sql.

Instance Methods [hide private]
 
__init__(self, conn, dbutils, wrap_cursor=False)
Create an Adaptor object.
source code
 
last_id(self, table)
Return the last row id for the selected table.
source code
 
autocommit(self, y=True)
Set the autocommit mode. True values enable; False value disable.
source code
 
commit(self)
Commit the current transaction.
source code
 
rollback(self)
Roll-back the current transaction.
source code
 
close(self)
Close the connection. No further activity possible.
source code
 
fetch_dbid_by_dbname(self, dbname)
Return the internal id for the sub-database using its name.
source code
 
fetch_seqid_by_display_id(self, dbid, name)
Return the internal id for a sequence using its display id.
source code
 
fetch_seqid_by_accession(self, dbid, name)
Return the internal id for a sequence using its accession.
source code
 
fetch_seqids_by_accession(self, dbid, name)
Return a list internal ids using an accession.
source code
 
fetch_seqid_by_version(self, dbid, name)
Return the internal id for a sequence using its accession and version.
source code
 
fetch_seqid_by_identifier(self, dbid, identifier)
Return the internal id for a sequence using its identifier.
source code
 
list_biodatabase_names(self)
Return a list of all of the sub-databases.
source code
 
list_bioentry_ids(self, dbid)
Return a list of internal ids for all of the sequences in a sub-databae.
source code
 
list_bioentry_display_ids(self, dbid)
Return a list of all sequence names in a sub-databae.
source code
 
list_any_ids(self, sql, args)
Return ids given a SQL statement to select for them.
source code
 
execute_one(self, sql, args=None)
Execute sql that returns 1 record, and return the record.
source code
 
execute(self, sql, args=None)
Just execute an sql command.
source code
 
executemany(self, sql, args)
Execute many sql commands.
source code
 
get_subseq_as_string(self, seqid, start, end)
Return a substring of a sequence.
source code
 
execute_and_fetch_col0(self, sql, args=None)
Return a list of values from the first column in the row.
source code
 
execute_and_fetchall(self, sql, args=None)
Return a list of tuples of all rows.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, conn, dbutils, wrap_cursor=False)
(Constructor)

source code 

Create an Adaptor object.

Arguments:
  • conn - A database connection
  • dbutils - A BioSQL.DBUtils object
  • wrap_cursor - Optional, whether to wrap the cursor object
Overrides: object.__init__

fetch_seqid_by_display_id(self, dbid, name)

source code 

Return the internal id for a sequence using its display id.

Arguments:
  • dbid - the internal id for the sub-database
  • name - the name of the sequence. Corresponds to the name column of the bioentry table of the SQL schema

fetch_seqid_by_accession(self, dbid, name)

source code 

Return the internal id for a sequence using its accession.

Arguments:
  • dbid - the internal id for the sub-database
  • name - the accession of the sequence. Corresponds to the accession column of the bioentry table of the SQL schema

fetch_seqids_by_accession(self, dbid, name)

source code 

Return a list internal ids using an accession.

Arguments:
  • dbid - the internal id for the sub-database
  • name - the accession of the sequence. Corresponds to the accession column of the bioentry table of the SQL schema

fetch_seqid_by_version(self, dbid, name)

source code 

Return the internal id for a sequence using its accession and version.

Arguments:
  • dbid - the internal id for the sub-database
  • name - the accession of the sequence containing a version number. Must correspond to <accession>.<version>

fetch_seqid_by_identifier(self, dbid, identifier)

source code 

Return the internal id for a sequence using its identifier.

Arguments:
  • dbid - the internal id for the sub-database
  • identifier - the identifier of the sequence. Corresponds to the identifier column of the bioentry table in the SQL schema.

list_bioentry_ids(self, dbid)

source code 

Return a list of internal ids for all of the sequences in a sub-databae.

Arguments:
  • dbid - The internal id for a sub-database

list_bioentry_display_ids(self, dbid)

source code 

Return a list of all sequence names in a sub-databae.

Arguments:
  • dbid - The internal id for a sub-database

list_any_ids(self, sql, args)

source code 

Return ids given a SQL statement to select for them.

This assumes that the given SQL does a SELECT statement that returns a list of items. This parses them out of the 2D list they come as and just returns them in a list.

get_subseq_as_string(self, seqid, start, end)

source code 

Return a substring of a sequence.

Arguments:
  • seqid - The internal id for the sequence
  • start - The start position of the sequence; 0-indexed
  • end - The end position of the sequence