BLAST Database#

Reader#

class pyncbitk.objtools.DatabaseReader#

A reader over the contents of a BLAST database.

This class implements access to the BLAST database as a Mapping of SeqId objects to BioSeq objects.

classmethod __new__(*args, **kwargs)#
__getitem__(key, /)#

Return self[key].

__init__(name, type=None)#

Create a new reader for a database of the given name.

Parameters:
  • name (str or os.PathLike) – The name of the database, as given when the database was created.

  • type (str or None) – The type of sequences in the database, either nucleotide or protein. If None given, the database type will be detected from the metadata.

__iter__()#

Implement iter(self).

__len__()#

Return len(self).

__reduce__()#

Helper for pickle.

keys()#

Get a set-like view over the keys of the database.

Returns:

DatabaseKeys – The keys of the database, i.e. the SeqId of the sequences stored in the database.

values()#

Get a set-like view over the values of the database.

Returns:

DatabaseValues – The values of the database, i.e. the BioSeq storing the sequences in the database.

version#

The database format version.

Type:

int

class pyncbitk.objtools.DatabaseKeys#

A set-like view over the keys of a BLAST database.

classmethod __new__(*args, **kwargs)#
__contains__(key, /)#

Return bool(key in self).

__init__(*args, **kwargs)#
__iter__()#

Implement iter(self).

__len__()#

Return len(self).

__reduce__()#

Helper for pickle.

class pyncbitk.objtools.DatabaseValues#

A set-like view over the values of a BLAST database.

classmethod __new__(*args, **kwargs)#
__contains__(key, /)#

Return bool(key in self).

__init__(*args, **kwargs)#
__iter__()#

Implement iter(self).

__len__()#

Return len(self).

__reduce__()#

Helper for pickle.

Writer#

class pyncbitk.objtools.DatabaseWriter#

A handle allowing to write sequences to a BLAST database.

classmethod __new__(*args, **kwargs)#
__init__(name, type='nucleotide', *, title=None, version=4)#

Create a new database writer.

Parameters:
  • name (str) – The name of the database, which is used as a path prefix to create the database files.

  • type (str) – Either "nucleotide" for a nucleotide database, or "protein" for a protein database.

  • title (str or None) – The title of the database.

  • version (int) – The database format version, either 4 (the default) or 5.

__reduce__()#

Helper for pickle.

append(sequence)#

Add a sequence to the database.

Parameters:

sequence (BioSeq) – The sequence to add to the database.

close()#

Close the database and write the remaining buffered sequences.

files#

The list of files written by the writer.

Type:

list of str

volumes#

The list of volumes written by the writer.

Type:

list or str