skbio.metadata.MetadataMixin#
- class skbio.metadata.MetadataMixin(metadata=None)[source]#
Attributes
dict
containing metadata which applies to the entire object.Methods
Determine if the object has metadata.
Special methods
__copy__
()__deepcopy__
(memo)__eq__
(other)Return self==value.
__ne__
(other)Return self!=value.
Special methods (inherited)
__ge__
(value, /)Return self>=value.
__getstate__
(/)Helper for pickle.
__gt__
(value, /)Return self>value.
__le__
(value, /)Return self<=value.
__lt__
(value, /)Return self<value.
__str__
(/)Return str(self).
Details
- metadata#
dict
containing metadata which applies to the entire object.Notes
This property can be set and deleted. When setting new metadata a shallow copy of the dictionary is made.
Examples
Note
scikit-bio objects with metadata share a common interface for accessing and manipulating their metadata. The following examples use scikit-bio’s
Sequence
class to demonstrate metadata behavior. These examples apply to all other scikit-bio objects storing metadata.Create a sequence with metadata:
>>> from skbio import Sequence >>> seq = Sequence('ACGT', metadata={'description': 'seq description', ... 'id': 'seq-id'})
Retrieve metadata:
>>> print(seq.metadata) {'description': 'seq description', 'id': 'seq-id'}
Update metadata:
>>> seq.metadata['id'] = 'new-id' >>> seq.metadata['pubmed'] = 12345 >>> print(seq.metadata) {'description': 'seq description', 'id': 'new-id', 'pubmed': 12345}
Set metadata:
>>> seq.metadata = {'abc': 123} >>> seq.metadata {'abc': 123}
Delete metadata:
>>> seq.has_metadata() True >>> del seq.metadata >>> seq.metadata {} >>> seq.has_metadata() False