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.

Methods

drop()

Drop this Interval object from interval metadata it links to.

Special methods

__eq__(other)

Test if this Interval object is equal to another.

__ne__(other)

Test if this Interval object is not equal to another.

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

bounds#

The coordinates of the interval feature.

It should be a list of tuples of int pair. Each tuple stores the start and end coordinates of a span of the interval feature. The coordinates are zero-based. They are inclusive on the start and exclusive on the end.

dropped#

Boolean value indicating if the Interval object is dropped.

If it is dropped, it means it is not associated with IntervalMetadata object any more.

Notes

This property is not writable.

fuzzy#

The openness of each coordinate.

This indicates that the exact bound of a interval feature is unknown. The bound may begin or end at some points outside the specified coordinates. This accommodates the bound format [1] of INSDC.

References

metadata#

The metadata of the interval feature.

It stores the metadata (eg. gene name, function, ID, etc.) of the interval feature as a dict.

__eq__(other)[source]#

Test if this Interval object is equal to another.

The equality is performed by checking if the metadata, bounds and fuzzy are equal. Since the bounds and the fuzzy are sorted, the permutations of them during the Interval construction or assignment won’t matter.

Parameters:
otherInterval

Interval to test for equality against.

Returns:
bool

Indicates if the two objects are equal.

__ne__(other)[source]#

Test if this Interval object is not equal to another.

Parameters:
otherInterval

Interval to test for inequality against.

Returns:
bool

Indicates if the two objects are not equal.