intervals

package
v4.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: AGPL-3.0, AGPL-3.0-or-later Imports: 11 Imported by: 0

Documentation

Overview

Package intervals is a library for representing genomic intervals, and for creating and reading elsites files.

Index

Constants

View Source
const ElsitesHeader = "# elsites format version 1.0\n"

ElsitesHeader is the header line that every .elsites file starts with.

Variables

This section is empty.

Functions

func FromBed

func FromBed(bed *bed.Bed) (intervals map[string][]Interval)

FromBed returns a slice of intervals that correspond to the BED file entries.

func FromBedFile

func FromBedFile(filename string) (map[string][]Interval, error)

FromBedFile returns a slice of intervals that correspond to the BED file entries.

func FromElsitesFile

func FromElsitesFile(filename string) (intervals map[string][]Interval, err error)

FromElsitesFile loads intervals from an elPrep-defined .elsites file.

func FromVcf

func FromVcf(vcf *vcf.Vcf) (intervals map[string][]Interval, err error)

FromVcf returns a slice of intervals that correspond to the Vcf file entries.

func FromVcfFile

func FromVcfFile(filename string) (intervals map[string][]Interval, err error)

FromVcfFile returns a slice of intervals that correspond to the Vcf file entries.

func Overlap

func Overlap(intervals []Interval, start, end int32) bool

Overlap determines whether the given start/end range overlaps with any of the given intervals. intervals must be Flattened and sorted by Start.

func ParallelSortByStart

func ParallelSortByStart(intervals []Interval)

ParallelSortByStart sorts a slice of Interval by Start position using a parallel stable sort.

func SortByStart

func SortByStart(intervals []Interval)

SortByStart sorts a slice of Interval by Start position.

func ToElsitesFile

func ToElsitesFile(intervals map[string][]Interval, filename string) (err error)

ToElsitesFile stores intervals in an elPrep-defined .elsites file.

Types

type Interval

type Interval struct {
	Start, End int32
}

Interval is a generic struct with a start and an end position.

func Flatten

func Flatten(intervals []Interval) []Interval

Flatten merges overlapping intervals into larger intervals. intervals must be sorted by Start before calling Flatten. The resulting slice is sorted by Start, and no two intervals in the result overlap with each other. The result shares memory with the intervals argument.

func Intersect

func Intersect(intervals []Interval, start, end int32) []Interval

Intersect returns a slice of all intervals that overlap with the given start/end range. intervals must be Flattened and sorted by Start. The result shares memory with the intervals argument.

func ParallelFlatten

func ParallelFlatten(intervals []Interval) []Interval

ParallelFlatten merges overlapping intervals into larger intervals, using a parallel algorithm. intervals must be sorted by Start before calling Flatten. The resulting slice is sorted by Start, and no two intervals in the result overlap with each other. The result shares memory with the intervals argument.

func (*Interval) Extend

func (interval1 *Interval) Extend(interval2 Interval) bool

Extend makes interval1 larger if it overlaps with interval2, by storing max(interval1.End, interval2.End) in interval1.End; otherwise, interval1 remains unchanged. Returns true if the two intervals overlap, false otherwise. interval2.Start >= interval1.Start must be true before calling Extend.

Jump to

Keyboard shortcuts

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