skbio.metadata.Interval#

class skbio.metadata.Interval(interval_metadata, bounds, fuzzy=None, metadata=None)[source]#

Stores the bounds and metadata of an interval feature.

This class stores an interval feature. An interval feature is defined as a sub-region of a biological sequence or sequence alignment that is a functional entity, e.g., a gene, a riboswitch, an exon, etc. It can span a single contiguous region or multiple non-contiguous regions (e.g. multiple exons in a transcript, or multiple genes in an operon).

Parameters:
interval_metadataobject

A reference to the IntervalMetadata object that this Interval object is associated to.

boundsiterable of tuple of int

Tuples representing start and end coordinates. It is zero-based numbering. It is always inclusive on start bound and exclusive on end bound.

fuzzyiterable of tuple of bool, optional

Tuples representing the fuzziness of each bound coordinates. If this isn’t specified, then the fuzziness of all bound coordinates are False. If any of the coordinate fuzziness is True, it indicates that the exact bound point of a interval feature is unknown. The bound may begin or end at some points outside the specified coordinates. This accommodates the location format [1] of INSDC.

metadatadict, optional

Dictionary of attributes storing information of the feature such as “strand”, “gene_name”, or “product”.

Notes

While the construction of an Interval object automatically add itself to its associated IntervalMetadata object, IntervalMetadata.add is the typical/easier way to create and add it to IntervalMetadata.

References

Examples

Hypothetically, let’s say we have a gene called “genA” with 10 nt as shown in the following diagram. The second row represents the two exons (indicated by “=”) on this gene:

TGGATTCTGC
-====--==-
0123456789

We can create an Interval object to represent the exons of the gene:

>>> from skbio.metadata import Interval, IntervalMetadata
>>> interval_metadata = IntervalMetadata(10)

Remember the coordinates are inclusive in lower bound and exclusive on upper bound:

>>> gene = Interval(interval_metadata,
...                 bounds=[(1, 5), (7, 9)],
...                 metadata={'name': 'genA'})
>>> gene    
Interval(interval_metadata=..., bounds=[(1, 5), (7, 9)], fuzzy=[(False, False), (False, False)], metadata={'name': 'genA'})

Attributes

bounds

The coordinates of the interval feature.

dropped

Boolean value indicating if the Interval object is dropped.

fuzzy

The openness of each coordinate.

metadata

The metadata of the interval feature.

Built-ins

__eq__(other)

Test if this Interval object is equal to another.

__ge__(value, /)

Return self>=value.

__getstate__(/)

Helper for pickle.

__gt__(value, /)

Return self>value.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(other)

Test if this Interval object is not equal to another.

__str__(/)

Return str(self).

Methods

drop()

Drop this Interval object from interval metadata it links to.