regions

package
Version: v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package regions provides an index for searching on intervals.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index is a searchable collection of intervals.

Example
gene0start, gene0end := 100, 200
gene1start, gene1end := 150, 250
gene2start, gene2end := 130, 300

starts := []int{gene0start, gene1start, gene2start}
ends := []int{gene0end, gene1end, gene2end}
idx := NewIndex(starts, ends)

fmt.Println(idx.At(140)) // Genes that overlap with position 140
fmt.Println(idx.At(200)) // Genes that overlap with position 200
Output:

[0 2]
[1 2]

func NewIndex

func NewIndex(starts, ends []int) *Index

NewIndex returns an index on the given interval starts and ends. Starts and ends should be of the same length. End positions are exclusive, meaning that an end value of n implies that the interval's last position is n-1.

func (*Index) At

func (idx *Index) At(i int) []int

At returns the intervals that overlap with position i. Returned values are the serial numbers of the start-end pairs for which starts[x] <= i < ends[x].

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL