interval

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 12 Imported by: 4

Documentation

Overview

Package interval provides functions for manipulating and analyzing intervals including sorting, calculating overlaps, and liftover functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreEqual added in v1.0.1

func AreEqual(a Interval, b Interval) bool

AreEqual takes in two intervals and returns a bool of whether they have the same coordinates or not

func BedSliceToIntervalMap added in v1.0.1

func BedSliceToIntervalMap(inBed []bed.Bed) map[string]*IntervalNode

BedSliceToIntervalMap takes in a slice of bed and returns a map of string -- *IntervalNode which can be used for interval.Query

func BuildTree

func BuildTree(intervals []Interval) map[string]*IntervalNode

BuildTree takes a slice of intervals and returns a map that can be used for Querying overlaps.

func CoordsToString

func CoordsToString(i Interval) string

CoordsToString takes in a interval and returns a string in the format of chr:start-end

func GoReadToChan

func GoReadToChan(inputFile string) <-chan Interval

GoReadToChan reads Interval interfaces to a channel from an input file (bed, axt, vcf, sam, chain).

func IntervalSimilarity added in v1.0.1

func IntervalSimilarity(a []Interval, b []Interval) (float64, float64, float64)

IntervalSimilarity takes in two slices of interval and returns the proportion of elements in the first slice that overlap an element in the second slice, the proportion of elements in the second slice that overlap an element in the first slice, and the average of those two metrics (a metric of how similar the two interval sets are). Interval sets must not be self-overlapping

func IntervalSize added in v1.0.1

func IntervalSize(i Interval) int

IntervalSize calculates the size of the interval

func Overlap added in v1.0.1

func Overlap(a, b Interval) bool

Overlap determines whether 2 intervals have overlap, assuming they are from the same genome

func OverlapSize added in v1.0.1

func OverlapSize(a, b Interval) int

OverlapSize calculates the size of the overlap between 2 intervals, assuming they are from the same genome

func PrettyPrint

func PrettyPrint(q Interval)

PrettyPrint displays the chrom, chromstart, and chromend on a line as a print for debugging.

func PrintRelationships

func PrintRelationships()

PrintRelationships is used to print the supported overlap relationships as part of the usage message

func QueryBool

func QueryBool(treeMap map[string]*IntervalNode, q Interval, relationship string, ans []Interval) bool

QueryBool searches the input treeMap and returns true if any interval satisfies the input relationship relative to the input interval q. QueryBool is faster than Query and is preferred when simply checking if the input q does or does not overlap the tree.

func ReadToChan

func ReadToChan(inputFile string, send chan<- Interval)

ReadToChan reads from a file (bed, axt, vcf, sam, chain) to send interval interfaces to a chan<- interval.

func SortByCoord added in v1.0.1

func SortByCoord(in []Interval)

SortByCoord takes in a slice of Interval and sorts the slice according to coordinates

func TestValidRelationship

func TestValidRelationship(op string) bool

TestValidRelationship tests that the input relationship string for a query is supported.

Types

type AggregateInterval

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

func (*AggregateInterval) GetChrom

func (a *AggregateInterval) GetChrom() string

func (*AggregateInterval) GetChromEnd

func (a *AggregateInterval) GetChromEnd() int

func (*AggregateInterval) GetChromStart

func (a *AggregateInterval) GetChromStart() int

type Interval

type Interval interface {
	GetChrom() string
	GetChromStart() int
	GetChromEnd() int
}

Interval is a type interface for any genomic datatype that has chromosomal coordinate info (chromosome, start, end). In order to satisfy this interface, a type must have GetChrom(), GetChromStart(), and GetChromEnd() methods. Note that the these methods must return positions for a 0-base half-closed interval [start - end).

func BedSliceToIntervals added in v1.0.1

func BedSliceToIntervals(inBed []bed.Bed) []Interval

BedSliceToIntervals takes in a slice of beds and returns a slice of intervals. Useful before using BuildTree

func MergeIntervals

func MergeIntervals(intervals []Interval) []Interval

MergeIntervals takes a slice of type Interval and returns a slice of type Interval in which all overlapping entries have been merged together.

func Query

func Query(treeMap map[string]*IntervalNode, q Interval, relationship string) []Interval

Query takes a map (built with BuildTree), a query interval, and a relationship and returns a slice of type Interval of treeMap entries that overlapped the query interval.

func Unique added in v1.0.1

func Unique(regions []Interval) []Interval

Unique takes in a slice of Interval and returns a slice of Interval with only unique interval entries (determined by coordinates). The first instance of each interval is kept. The output will be sorted by position

type IntervalNode

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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