lib5c.core.mixins module¶
-
class
lib5c.core.mixins.
Annotatable
[source]¶ Mixin class for storing and accessing arbitrary annotation information on object instances.
-
data
¶ Dict to store arbitrary annotation data. Typically, the keys will be strings.
Type: dict
Notes
This mixin requires initialization. Subclasses must explicitly call
Annotatable.__init__(self)
somewhere in their constructor.
When a subclass’s bound functions return a new instance, the following guidelines are recommended:
- addition/summing operations: create a new dict and update it
- other operations: copy a reference to
data
into the new instance
-
get_data
()[source]¶ Get this instance’s
data
attribute.Returns: This instance’s data
attribute.Return type: dict
-
get_value
(key)[source]¶ Get the value of some key in data. This is equivalent to a get-or-None function for
data[key]
.Parameters: key (str) – The key to search for in this instance’s data
.Returns: The value of data[key]
, or None if the key does not exist.Return type: any Examples
>>> from lib5c.core.loci import Locus >>> locus = Locus('chr3', 34109023, 34113109, num_genes=10) >>> locus.get_value('num_genes') 10 >>> locus.get_value('num_ctcf_sites') is None True
-
-
class
lib5c.core.mixins.
Loggable
[source]¶ Mixin class for supporting object event logging.
-
log
¶ Each string in the list describes an event in this object’s history.
Type: list of str
Notes
This mixin requires initialization. Subclasses must explicitly call
Loggable.__init__(self)
somewhere in their constructor.
When a subclass’s bound functions return a new instance, the following guidelines are recommended:
- addition/summing operations: use the empty log of the new instance
- other operations: copy a reference to
log
into the new instance
-
-
class
lib5c.core.mixins.
Picklable
[source]¶ Mixin class for providing easy reading and writing of instances to disk via the pickle module.