mgkit.db.dbm module

New in version 0.2.1.

This module contains functions and classes to use for a dbm like representation of annotations using the semidbm package

class mgkit.db.dbm.GFFDB(db=None)[source]

Bases: object

New in version 0.2.1.

A wrapper for a semidbm instance, used to convert the GFF line stored in the DB into an mgkit.io.gff.Annotation instance. If a string is passed to the init method, a DB will be opened with the c flag.

The object behaves like a dictionary, wrapping the access to annoations using a uid as key and converting the line into an mgkit.io.gff.Annotation instance.

db = None
items()[source]
iteritems()[source]
itervalues()[source]
values()[source]
mgkit.db.dbm.create_gff_dbm(annotations, file_name)[source]

New in version 0.2.1.

Creates a semidbm database, using an annotation uid as key and the gff line as value. The object is synced before being returned.

Note

A GFF line is used instead of a json representation because it was more compact when semidbm was tested.

Parameters
  • annotations (iterable) – iterable of annotations

  • file_name (str) – database file name, opened with the c flag.

Returns

a semidbm database object

Return type

object