lib

Types

BigWig = ref object
  bw: ptr bigWigFile_t
  path: string
  isBigBed: bool
  starts: seq[uint32]
  stops: seq[uint32]
  values: seq[float32]
  cs: cstringArray
BigWigHeader = seq[tuple[name: string, length: int, tid: uint32]]
Stat {...}{.pure.} = enum
  mean = 0, stdev = 1, max = 2, min = 3, coverage = 4, sum = 5

Procs

proc close(bw: BigWig) {...}{.raises: [], tags: [].}
close the file and free up resources
proc open(bw: var BigWig; path: string; mode: FileMode = fmRead; maxZooms: int = 8): bool {...}{.
    raises: [], tags: [].}
open the bigwig file. maxZooms is only used when opening in write mode.
proc SQL(bw: BigWig): string {...}{.raises: [], tags: [].}
proc header(bw: var BigWig): BigWigHeader {...}{.raises: [], tags: [].}
proc values(bw: var BigWig; values: var seq[float32]; chrom: string; start: int = 0;
           stop: int = -1; includeNA: bool = true) {...}{.raises: [KeyError], tags: [].}
exctract values for the given range into values
proc stats(bw: var BigWig; chrom: string; start: int = 0; stop: int = -1;
          stat: Stat = Stat.mean; nBins = 1): seq[float64] {...}{.raises: [KeyError], tags: [].}
proc setHeader(bw: BigWig; header: BigWigHeader) {...}{.raises: [], tags: [].}
set the header of a bigwig file opened for writing
proc writeHeader(bw: BigWig) {...}{.raises: [], tags: [].}
write the header (which must have been added in setHeader to file.
proc add[T: int | uint32 | uint64 | int32 | int64](bw: BigWig; chrom: string;
    intervals: seq[tuple[start: T, stop: T, value: float32]])
add intervals to the bigwig.
proc add[T: int | uint32 | uint64 | int32 | int64; U: int | uint32 | uint64 | int32 | int64](
    bw: BigWig; chrom: string; span: U;
    intervals: seq[tuple[start: T, value: float32]])
add spans to the bigwig. this adds fixed-length (span) intervals starting at the given positions.
proc add(bw: BigWig; chrom: string; start: uint32; values: var seq[float32];
        step: uint32 = 1; span: uint32 = 1) {...}{.raises: [], tags: [].}
add values to the bigwig starting at start and stepping by step. this is the most efficient way (space and performance) to add to a bigwig file if your intervals match this format.

Iterators

iterator entries(bw: var BigWig; chrom: string; start: int = 0; stop: int = -1): tuple[
    start: int, stop: int, value: cstring] {...}{.raises: [KeyError], tags: [].}
yield bigbed entries. any values is returned as a string
iterator intervals(bw: var BigWig; chrom: string; start: int = 0; stop: int = -1): tuple[
    start: int, stop: int, value: float32] {...}{.raises: [KeyError, ValueError], tags: [].}
iterate over the values in the given region

Templates

template isBigBed(b: BigWig): bool
indicate wether file is BigBed (true) or BigWig (false)