anndata.ann package¶
Subpackages¶
- anndata.ann.annlabel package
- anndata.ann.annlocation package
- Submodules
- anndata.ann.annlocation.disjoint module
- anndata.ann.annlocation.duration module
- anndata.ann.annlocation.durationcompare module
- anndata.ann.annlocation.interval module
- anndata.ann.annlocation.intervalcompare module
- anndata.ann.annlocation.localization module
- anndata.ann.annlocation.localizationcompare module
- anndata.ann.annlocation.location module
- anndata.ann.annlocation.point module
- Module contents
Submodules¶
anndata.ann.annotation module¶
- filename
sppas.src.anndata.ann.annotation.py
- author
Brigitte Bigi
- contact
- summary
Representation of an annotation.
- class anndata.ann.annotation.sppasAnnotation(location, labels=[])[source]¶
Bases:
sppas.src.anndata.metadata.sppasMetaData
Represents an annotation.
A sppasAnnotation() is a container for:
a sppasLocation()
a list of sppasLabel()
- Example
>>> location = sppasLocation(sppasPoint(1.5, radius=0.01)) >>> labels = sppasLabel(sppasTag("foo")) >>> ann = sppasAnnotation(location, labels)
- __init__(location, labels=[])[source]¶
Create a new sppasAnnotation instance.
- Parameters
location – (sppasLocation) the location(s) where the annotation happens
labels – (sppasLabel, list) the label(s) to stamp this annotation, or a list of them.
- add_tag(tag, score=None, label_idx=0)[source]¶
Append an alternative tag in a label.
- Parameters
tag – (sppasTag)
score – (float)
label_idx – (int)
- Raises
AnnDataTypeError, IndexError
- append_label(label)[source]¶
Append a label into the list of labels.
- Parameters
label – (sppasLabel)
- contains_localization(localization)[source]¶
Return True if the given localization is in the location.
- contains_tag(tag, function='exact', reverse=False, label_idx=0)[source]¶
Return True if the given tag is in the label.
- Parameters
tag – (sppasTag)
function – Search function
reverse – Reverse the function.
label_idx – (int)
- copy()[source]¶
Return a full copy of the annotation.
The location, the labels and the metadata are all copied. The ‘id’ of the returned annotation is then the same.
- Returns
sppasAnnotation()
- get_best_tag(label_idx=0)[source]¶
Return the tag with the highest score of a label or an empty str.
- Parameters
label_idx – (int)
- remove_tag(tag, label_idx=0)[source]¶
Remove an alternative tag of the label.
- Parameters
tag – (sppasTag) the tag to be removed of the list.
label_idx – (int)
- serialize_labels(separator='\n', empty='', alt=True)[source]¶
DEPRECATED. Return labels serialized into a string.
TODO: REMOVE THIS METHOD. Use aioutils.serialize_labels() instead.
- Parameters
separator – (str) String to separate labels.
empty – (str) The text to return if a tag is empty or not set.
alt – (bool) Include alternative tags
- Returns
(str)
- set_best_localization(localization)[source]¶
Set the best localization of the location.
- Parameters
localization – (sppasBaseLocalization)
- set_labels(labels=[])[source]¶
Fix/reset the list of labels of this annotation.
- Parameters
labels – (sppasLabel, list) the label(s) to stamp this annotation, or a list of them.
- Raises
AnnDataTypeError, TypeError, CtrlVocabContainsError, HierarchyContainsError, HierarchyTypeError
- set_parent(parent=None)[source]¶
Set a parent tier.
- Parameters
parent – (sppasTier) The parent tier of this annotation.
- Raises
CtrlVocabContainsError, HierarchyContainsError, HierarchyTypeError
- set_score(score=None)[source]¶
Set or reset the score to this annotation.
- Parameters
score – (float)
- validate()[source]¶
Validate the annotation.
Check if the labels and location match the requirements.
- Raises
TypeError, CtrlVocabContainsError, HierarchyContainsError, HierarchyTypeError
anndata.ann.annset module¶
- filename
sppas.src.anndata.ann.annset.py
- author
Brigitte Bigi
- contact
- summary
Manager for a set of annotations.
- class anndata.ann.annset.sppasAnnSet[source]¶
Bases:
sppas.src.structs.basefset.sppasBaseSet
Manager for a set of annotations.
Mainly used with the data that are the result of the tier filter system. A sppasAnnSet() manages a dictionary with:
key: an annotation
value: a list of strings
- copy()[source]¶
Make a deep copy of self.
Overridden to return a sppasAnnSet() instead of a sppasBaseSet().
- to_tier(name='AnnSet', annot_value=False)[source]¶
Create a tier from the data set.
- Parameters
name – (str) Name of the tier to be returned
annot_value – (bool) format of the resulting annotation label. By default, the label of the annotation is used. Instead, its value in the data set is used.
- Returns
(sppasTier)