Skip to content

Commit

Permalink
Add exact summaries and zoom table fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
nvictus committed Feb 17, 2024
1 parent e5e4a90 commit 67a8931
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 73 deletions.
38 changes: 25 additions & 13 deletions bbi/_bbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def chromsizes(inFile):
Returns
-------
OrderedDict (str -> int)
dict[str, int]
"""
with cbbi.open(inFile) as f:
Expand All @@ -44,7 +44,7 @@ def zooms(inFile):
Returns
-------
list of int
list[int]
"""
with cbbi.open(inFile) as f:
Expand All @@ -70,26 +70,38 @@ def info(inFile):


@documented_by(cbbi.BBIFile.fetch)
def fetch(inFile, chrom, start, end, bins=-1, missing=0.0, oob=np.nan, summary="mean"):
def fetch(
inFile,
chrom,
start,
end,
bins=-1,
missing=0.0,
oob=np.nan,
summary="mean",
exact=False,
):
with cbbi.open(inFile) as f:
return f.fetch(chrom, start, end, bins, missing, oob, summary)
return f.fetch(chrom, start, end, bins, missing, oob, summary, exact)


@documented_by(cbbi.BBIFile.stackup)
def stackup(
inFile, chroms, starts, ends, bins=-1, missing=0.0, oob=np.nan, summary="mean"
inFile,
chroms,
starts,
ends,
bins=-1,
missing=0.0,
oob=np.nan,
summary="mean",
exact=False,
):
with cbbi.open(inFile) as f:
return f.stackup(chroms, starts, ends, bins, missing, oob, summary)
return f.stackup(chroms, starts, ends, bins, missing, oob, summary, exact)


@documented_by(cbbi.BBIFile.fetch_intervals)
def fetch_intervals(
inFile,
chrom,
start,
end,
iterator=True
):
def fetch_intervals(inFile, chrom, start, end, iterator=True):
with cbbi.open(inFile) as f:
return f.fetch_intervals(chrom, start, end, iterator)
6 changes: 3 additions & 3 deletions bbi/cbbi.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ cdef extern from "bigWig.h":
int start,
int end,
bbiSummaryType summaryType,
double defaultVal);
double defaultVal)
boolean bigWigSummaryArray(
bbiFile *bwf,
char *chrom,
Expand Down Expand Up @@ -312,15 +312,15 @@ cdef extern from "bigBed.h":
bits32 start,
bits32 end,
int summarySize,
bbiSummaryElement *summary);
bbiSummaryElement *summary)
char *bbiCachedChromLookup(
bbiFile *bbi,
int chromId,
int lastChromId,
char *chromBuf,
int chromBufSize)
char *bigBedAutoSqlText(bbiFile *bbi)
asObject *bigBedAs(bbiFile *bbi);
asObject *bigBedAs(bbiFile *bbi)
asObject *bigBedAsOrDefault(bbiFile *bbi)
asObject *bigBedFileAsObjOrDefault(char *fileName)

Expand Down
Loading

0 comments on commit 67a8931

Please sign in to comment.