Skip to content

Interval

Mojo struct 🡭

@register_passable_trivial
struct Interval

1-based closed genomic interval [start, end] (modeled on noodles_core::region::Interval).

Both start and end are 1-based and inclusive. Supports contains(), intersects(), length().

AnyType, Copyable, Equatable, ImplicitlyCopyable, ImplicitlyDestructible, Movable, RegisterPassable, TrivialRegisterPassable

def __init__(out self, start: Position, end: Position)

Args:

  • start (Position)
  • end (Position)
  • self (Self)

Returns:

Self

Raises:

def __init__(start: Position, end: Position, _unsafe: Bool) -> Self

Internal: use when start <= end is already guaranteed.

Args:

  • start (Position)
  • end (Position)
  • _unsafe (Bool)

Returns:

Self

def start(self) -> Position

Args:

  • self (Self)

Returns:

Position

def end(self) -> Position

Args:

  • self (Self)

Returns:

Position

def length(self) -> UInt64

Number of bases in the interval (end - start + 1 for closed [start, end]).

Args:

  • self (Self)

Returns:

UInt64

def is_empty(self) -> Bool

Args:

  • self (Self)

Returns:

Bool

def contains(self, position: Position) -> Bool

True if position is in [start, end] (1-based closed).

Args:

  • self (Self)
  • position (Position)

Returns:

Bool

def intersects(self, other: Self) -> Bool

True if this interval overlaps other (both 1-based closed).

Args:

  • self (Self)
  • other (Self)

Returns:

Bool