Overlappers (Wasm)
Wasm binding for gtars-overlaprs: a low-level interval overlap engine. Build an Overlapper once from a set of reference regions (the "universe"), then ask which of those regions each query region overlaps. For whole-region-set operations (intersections, unions, statistics), use RegionSet instead.
import init, { Overlapper } from '@databio/gtars';
await init();Construction
Section titled โConstructionโconst universe = [ ['chr1', 100, 200, 'a'], ['chr1', 150, 250, 'b'], ['chr2', 300, 400, 'c'],];
const overlapper = new Overlapper(universe, 'ailist');universe: an array of[chr, start, end, name]entries. The binding reads each entry as a four-element tuple, so include aname(any string; it is not used).backend: the index to build for each chromosome, either'ailist'(augmented interval list) or'bits'(binary interval search). Any other value throwsInvalid backend specified.
Methods
Section titled โMethodsโget_backend()
Section titled โget_backend()โReturns the backend name the overlapper was built with ('ailist' or 'bits').
find(regions)
Section titled โfind(regions)โTakes an array of query regions in the same [chr, start, end, name] form and returns one flat array of the universe regions they overlap, each as [chr, start, end]. Overlaps from all queries are concatenated in query order, so a universe region that overlaps two queries appears twice. Queries on a chromosome that is not in the universe contribute nothing.
const hits = overlapper.find([['chr1', 180, 220, 'q1']]);// [['chr1', 100, 200], ['chr1', 150, 250]]