Feature#

class Feature(*, parent: Sequence | Alignment, seqid: str, map: FeatureMap, biotype: str, name: str, strand: int | str, xattr: dict[str, Any] | None = None)#

new style annotation, created on demand

Attributes:
biotype

type of biological feature

map

coordinate map and properties of this feature

name

name of the feature

parent

sequence or aligned or alignment

reversed

whether Feature is on the reverse strand relative to bound object

seqid

the sequence id of the parent sequence

xattr

extra attributes for this feature

Methods

as_one_span([name])

returns a feature that preserves any gaps in the underlying sequence

get_children([biotype])

generator returns sub-features of self optionally matching biotype

get_coordinates()

returns sequence coordinates of this Feature as [(start1, end1), ...]

get_drawable()

returns plotly trace

get_parent(**kwargs)

generator returns parent features of self optionally matching biotype

get_slice([complete, allow_gaps, apply_name])

The corresponding sequence fragment.

shadow([name])

returns new instance corresponding to disjoint of self coordinates

to_dict()

returns

union(features)

return as a single Feature

without_lost_spans()

Keeps only the parts which are actually present in the underlying sequence

remapped_to

as_one_span(name: str | None = None) Self#

returns a feature that preserves any gaps in the underlying sequence

Parameters:
name

The name of the one-span feature, by default ‘one-span <self name>’

property biotype: str#

type of biological feature

get_children(biotype: str | None = None, **kwargs) Iterable[Self]#

generator returns sub-features of self optionally matching biotype

get_coordinates() Sequence[Sequence[int | int32 | int64]]#

returns sequence coordinates of this Feature as [(start1, end1), …]

get_drawable() Shape#

returns plotly trace

get_parent(**kwargs) Iterable[Self]#

generator returns parent features of self optionally matching biotype

get_slice(complete: bool = False, allow_gaps: bool = False, apply_name: bool = True) Sequence | Alignment#

The corresponding sequence fragment.

Parameters:
complete

if feature not complete on parent, causes an exception to be raised. If False, gaps are removed.

allow_gaps

if on an alignment, includes the gap positions

apply_name

assigns self.name to the resulting seq.name

Returns:
a slice of self.parent

Notes

If ‘complete’ is true and the full length of this feature is not present in the sequence, then this method will fail.

property map: FeatureMap#

coordinate map and properties of this feature

property name: str#

name of the feature

property parent: Sequence | Alignment#

sequence or aligned or alignment

remapped_to(grandparent, gmap) Self#
property reversed: bool#

whether Feature is on the reverse strand relative to bound object

property seqid: str#

the sequence id of the parent sequence

shadow(name: str | None = None) Self#

returns new instance corresponding to disjoint of self coordinates

Parameters:
name

The name of the shadow feature, by default ‘not <self name>’

to_dict() dict[str, Any]#

returns

union(features: Iterable) Self#

return as a single Feature

Notes

Overlapping spans are merged

without_lost_spans() Self#

Keeps only the parts which are actually present in the underlying sequence

property xattr: dict[str, Any] | None#

extra attributes for this feature