Skip to content

Commit

Permalink
Copy over libBigWig 0.3.1 and bump pyBigWig version to 0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dpryan79 committed Feb 21, 2017
1 parent 297528e commit 304e880
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libBigWig/bigWig.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C" {
/*!
* The library version number
*/
#define LIBBIGWIG_VERSION 0.3.0
#define LIBBIGWIG_VERSION 0.3.1

/*!
* The magic number of a bigWig file.
Expand Down
14 changes: 13 additions & 1 deletion libBigWig/bwWrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ int writeIndex(bigWigFile_t *fp) {
//This may or may not produce the requested number of zoom levels
int makeZoomLevels(bigWigFile_t *fp) {
uint32_t meanBinSize, i;
uint32_t multiplier = 4, zoom = 10;
uint32_t multiplier = 4, zoom = 10, maxZoom = 0;
uint16_t nLevels = 0;

meanBinSize = ((double) fp->writeBuffer->runningWidthSum)/(fp->writeBuffer->nEntries);
Expand All @@ -801,7 +801,15 @@ int makeZoomLevels(bigWigFile_t *fp) {
if(!fp->hdr->zoomHdrs->indexOffset) return 4;
if(!fp->hdr->zoomHdrs->idx) return 5;

//There's no point in having a zoom level larger than the largest chromosome
//This will none the less allow at least one zoom level, which is generally needed for IGV et al.
for(i=0; i<fp->cl->nKeys; i++) {
if(fp->cl->len[i] > maxZoom) maxZoom = fp->cl->len[i];
}
if(zoom > maxZoom) zoom = maxZoom;

for(i=0; i<fp->hdr->nLevels; i++) {
if(zoom > maxZoom) break; //prevent absurdly large zoom levels
fp->hdr->zoomHdrs->level[i] = zoom;
nLevels++;
if(((uint32_t)-1)/multiplier < zoom) break;
Expand Down Expand Up @@ -887,6 +895,10 @@ uint32_t updateInterval(bigWigFile_t *fp, bwZoomBuffer_t *buffer, double *sum, d
uint32_t rv = 0, offset = 0;
if(!buffer) return 0;
if(buffer->l+32 >= buffer->m) return 0;

//Make sure that we don't overflow a uint32_t by adding some huge value to start
if(start + size < start) size = ((uint32_t) -1) - start;

if(buffer->l) {
offset = buffer->l/32;
} else {
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
include_dirs = include_dirs)

setup(name = 'pyBigWig',
version = '0.3.2',
version = '0.3.3',
description = 'A package for accessing bigWig files using libBigWig',
author = "Devon P. Ryan",
author_email = "[email protected]",
url = "https://github.com/dpryan79/pyBigWig",
download_url = "https://github.com/dpryan79/pyBigWig/tarball/0.3.2",
download_url = "https://github.com/dpryan79/pyBigWig/tarball/0.3.3",
keywords = ["bioinformatics", "bigWig", "bigBed"],
classifier = ["Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand Down

0 comments on commit 304e880

Please sign in to comment.