anndata.ann package

Subpackages

Submodules

anndata.ann.annotation module

filename

sppas.src.anndata.ann.annotation.py

author

Brigitte Bigi

contact

develop@sppas.org

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_all_points()[source]

Return the list of a copy of all points of this annotation.

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)

get_highest_localization()[source]

Return a copy of the sppasPoint with the highest loc.

get_label_type()[source]

Return the current type of tags, or an empty string.

get_labels()[source]

Return the list of sppasLabel() of this annotation.

get_labels_best_tag()[source]

Return a list with the best tag of each label.

get_location()[source]

Return the sppasLocation() of this annotation.

get_lowest_localization()[source]

Return a copy of the sppasPoint with the lowest localization.

get_parent()[source]

Return the parent tier or None.

get_score()[source]

Return the score of this annotation or None if no score is set.

is_labelled()[source]

Return True if at least a sppasTag exists and is not None.

label_is_bool()[source]

Return True if the type of the labels is ‘bool’.

label_is_filled()[source]

Return True if at least one BEST tag is filled.

label_is_float()[source]

Return True if the type of the labels is ‘float’.

label_is_int()[source]

Return True if the type of the labels is ‘int’.

label_is_string()[source]

Return True if the type of the labels is ‘str’.

location_is_disjoint()[source]

Return True if the location is made of sppasDisjoint locs.

location_is_interval()[source]

Return True if the location is made of sppasInterval locs.

location_is_point()[source]

Return True if the location is made of sppasPoint locs.

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

validate_label(label)[source]

Validate the label.

Check if the label matches the requirements of this annotation.

Raises

CtrlVocabContainsError, TypeError

validate_location()[source]

Validate the location of the annotation.

Raises

anndata.ann.annset module

filename

sppas.src.anndata.ann.annset.py

author

Brigitte Bigi

contact

develop@sppas.org

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

__init__()[source]

Create a sppasAnnSet instance.

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)

Module contents