ngs_tools.gtf.Segment

Module Contents

Classes

Segment

Class to represent an integer interval segment, zero-indexed, start-inclusive

exception ngs_tools.gtf.Segment.SegmentError

Bases: Exception

Common base class for all non-exit exceptions.

class ngs_tools.gtf.Segment.Segment(start: int, end: int)

Class to represent an integer interval segment, zero-indexed, start-inclusive and end-exclusive.

_start

Segment start; for internal use only. Use start instead.

_end

Segment end; for internal use only. Use end instead.

property start: int

Segment start

property end: int

Segment end

property width: int

Segment width

is_in(i: int) bool

Evaluate whether an integer is contained within the segment.

Parameters:

i – Integer number to check

Returns:

True or False

is_exclusive(segment: Segment) bool

Evaluate whether this segment is exclusive of another segment.

Parameters:

segmentSegment object to check

Returns:

True or False

is_overlapping(segment: Segment) bool

Evaluate whether this segment overlaps with another segment.

Parameters:

segmentSegment object to check

Returns:

True or False

is_subset(segment: Segment) bool

Evaluate whether this segment is a subset of another segment.

Parameters:

segmentSegment object to check

Returns:

True or False

is_superset(segment: Segment) bool

Evaluate whether this segment is a superset of another segment.

Parameters:

segmentSegment object to check

Returns:

True or False

flank(l: int, left: Optional[int] = None, right: Optional[int] = None) Segment

Construct a new segment with start and end flanks of length l. Optionally, limit the size of the new segment.

Parameters:
  • l – Flank length

  • left – Clip the resulting segment’s start to this value. Defaults to None. If not provided, no clipping is performed.

  • right – Clip the resulting segment’s end to this value. Defaults to None. If not provided, no clipping is performed.

Returns:

The new segment

__iter__()
__eq__(other)

Return self==value.

__lt__(other)

Return self<value.

__gt__(other)

Return self>value.

__repr__()

Return repr(self).