Documentation ¶
Overview ¶
Package intervals is a library for representing genomic intervals, and for creating and reading elsites files.
Index ¶
- Constants
- func FromBed(bed *bed.Bed) (intervals map[string][]Interval)
- func FromBedFile(filename string) (map[string][]Interval, error)
- func FromElsitesFile(filename string) (intervals map[string][]Interval, err error)
- func FromVcf(vcf *vcf.Vcf) (intervals map[string][]Interval, err error)
- func FromVcfFile(filename string) (intervals map[string][]Interval, err error)
- func Overlap(intervals []Interval, start, end int32) bool
- func ParallelSortByStart(intervals []Interval)
- func SortByStart(intervals []Interval)
- func ToElsitesFile(intervals map[string][]Interval, filename string) (err error)
- type Interval
Constants ¶
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 FromBedFile ¶
FromBedFile returns a slice of intervals that correspond to the BED file entries.
func FromElsitesFile ¶
FromElsitesFile loads intervals from an elPrep-defined .elsites file.
func FromVcfFile ¶
FromVcfFile returns a slice of intervals that correspond to the Vcf file entries.
func Overlap ¶
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.
Types ¶
type Interval ¶
type Interval struct {
Start, End int32
}
Interval is a generic struct with a start and an end position.
func Flatten ¶
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 ¶
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 ¶
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 ¶
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.