sugar.core.meta module

Metadata related classes, Attr and Meta

class sugar.core.meta.Attr(*args, **kwargs)[source]

Bases: MutableMapping

A class which behaves like a dictionary.

Parameters:

data (dict) – Dictionary with initial keywords.

Basic Usage

You can use the following syntax to modify or access data in this class.

>>> attr = Attr()
>>> attr.comment = 'bla'
>>> attr['another_comment'] = 'yeah'
>>> print(attr.get('comment'))
bla
>>> print(attr['comment'])
bla
>>> print(attr.comment)
bla
copy()[source]

Return a deep copy of the object

setdefault(k, *args)[source]

Like setdefault(), but creates a new Attr instance when no value is present and no default is set

Example:

>>> seqs = read()
>>> seqs[0].meta.setdefault('_stockholm').setdefault('GR').mykey = 'value'
>>> print(seqs[0].meta._stockholm)
Attr(GR=Attr(mykey='value'))
update(adict={})[source]

Update from other mapping or iterable

class sugar.core.meta.Meta(*args, **kwargs)[source]

Bases: Attr

A class representing sequence or feature metadata

tostr(w=80)[source]

Return string describing the metadata, used by __str__() method.