Skip to content
Commits on Source (13)
......@@ -2,12 +2,13 @@
A C library for reading/parsing local and remote bigWig and bigBed files. While Kent's source code is free to use for these purposes, it's really inappropriate as library code since it has the unfortunate habit of calling `exit()` whenever there's an error. If that's then used inside of something like python then the python interpreter gets killed. This library is aimed at resolving these sorts of issues and should also use more standard things like curl and has a friendlier license to boot.
Documentation is automatically generated by doxygen and can be found under `docs/html` or online [here](https://cdn.rawgit.com/dpryan79/libBigWig/master/docs/html/index.html).
Documentation is automatically generated by doxygen and can be found under [`docs/html`](/docs/html) or online [here](https://cdn.rawgit.com/dpryan79/libBigWig/master/docs/html/index.html).
# Example
The only functions and structures that end users need to care about are in "bigWig.h". Below is a commented example. You can see the files under `test/` for further examples.
The only functions and structures that end users need to care about are in "bigWig.h". Below is a commented example. You can see the files under [`test/`](./test/) for further examples.
```c
#include "bigWig.h"
int main(int argc, char *argv[]) {
bigWigFile_t *fp = NULL;
......@@ -55,13 +56,15 @@ The only functions and structures that end users need to care about are in "bigW
bwCleanup();
return 0;
}
```
## Writing example
N.B., creation of bigBed files is not supported (there are no plans to change this).
Below is an example of how to write bigWig files. You can also find this file under `test/exampleWrite.c`. Unlike with Kent's tools, you can create bigWig files entry by entry without needing an intermediate wiggle or bedGraph file. Entries in bigWig files are stored in blocks with each entry in a block referring to the same chromosome and having the same type, of which there are three (see the [wiggle specification](http://genome.ucsc.edu/goldenpath/help/wiggle.html) for more information on this).
Below is an example of how to write bigWig files. You can also find this file under [`test/exampleWrite.c`](test/exampleWrite.c). Unlike with Kent's tools, you can create bigWig files entry by entry without needing an intermediate wiggle or bedGraph file. Entries in bigWig files are stored in blocks with each entry in a block referring to the same chromosome and having the same type, of which there are three (see the [wiggle specification](http://genome.ucsc.edu/goldenpath/help/wiggle.html) for more information on this).
```c
#include "bigWig.h"
int main(int argc, char *argv[]) {
......@@ -137,11 +140,13 @@ Below is an example of how to write bigWig files. You can also find this file un
bwCleanup();
return 1;
}
```
# Testing file types
As of version 0.3.0, this library supports accessing bigBed files, which are related to bigWig files. Applications that need to support both bigWig and bigBed input can use the `bwIsBigWig` and `bbIsBigBed` functions to determine if their inputs are bigWig/bigBed files:
```c
...code...
if(bwIsBigWig(input_file_name, NULL)) {
//do something
......@@ -150,6 +155,7 @@ As of version 0.3.0, this library supports accessing bigBed files, which are rel
} else {
//handle unknown input
}
```
Note that these two functions rely on the "magic number" at the beginning of each file, which differs between bigWig and bigBed files.
......@@ -220,12 +226,14 @@ Regardless of whether a bigWig or bigBed file is being used, the `bwIteratorNext
A full example is provided in `tests/testIterator.c`, but a small example of iterating over all bigWig intervals in `chr1:0-10000000` in chunks of 5 blocks follows:
```c
iter = bwOverlappingIntervalsIterator(fp, "chr1", 0, 10000000, 5);
while(iter->data) {
//Do stuff with iter->intervals
iter = bwIteratorNext(iter);
}
bwIteratorDestroy(iter);
```
# A note on bigWig statistics
......
......@@ -53,7 +53,7 @@ extern "C" {
/*!
* The library version number
*/
#define LIBBIGWIG_VERSION 0.4.2
#define LIBBIGWIG_VERSION 0.4.4
/*!
* If 1, then this library was compiled with remote file support.
......
......@@ -73,7 +73,7 @@ static bwZoomHdr_t *bwReadZoomHdrs(bigWigFile_t *bw) {
return NULL;
}
uint64_t *indexOffset = malloc(sizeof(uint64_t) * bw->hdr->nLevels);
if(!dataOffset) {
if(!indexOffset) {
free(zhdr);
free(level);
free(dataOffset);
......
......@@ -33,7 +33,7 @@ static bwRTree_t *readRTreeIdx(bigWigFile_t *fp, uint64_t offset) {
return NULL;
}
node = malloc(sizeof(bwRTree_t));
node = calloc(1, sizeof(bwRTree_t));
if(!node) return NULL;
if(bwRead(&(node->blockSize), sizeof(uint32_t), 1, fp) != 1) goto error;
......
libbigwig (0.4.4+dfsg-1) unstable; urgency=medium
* New upstream version
* debhelper-compat 12
* Standards-Version: 4.4.1
* Respect DEB_BUILD_OPTIONS in override_dh_auto_test target
* Remove trailing whitespace in debian/copyright
* Remove patches pythonVersion.patch that are missing from
debian/patches/series.
-- Steffen Moeller <moeller@debian.org> Thu, 05 Dec 2019 12:36:34 +0100
libbigwig (0.4.2+dfsg-2) unstable; urgency=medium
* Fixed FTBFS - missing dependency
......
Source: libbigwig
Priority: optional
Maintainer: Debian Med Packaging Team <debian-med-packaging@lists.debian.org>
Uploaders: Steffen Moeller <moeller@debian.org>
Build-Depends: debhelper (>= 11), libcurl4-gnutls-dev|libcurl-dev, zlib1g-dev
Build-Depends-Indep: doxygen
Standards-Version: 4.3.0
Section: libs
Homepage: https://github.com/dpryan79/libBigWig/
Priority: optional
Build-Depends: debhelper-compat (= 12),
libcurl4-gnutls-dev|libcurl-dev,
zlib1g-dev
Build-Depends-Indep: doxygen
Standards-Version: 4.4.1
Vcs-Browser: https://salsa.debian.org/med-team/libbigwig
Vcs-Git: https://salsa.debian.org/med-team/libbigwig.git
Homepage: https://github.com/dpryan79/libBigWig/
Package: libbigwig0
Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
Depends: ${shlibs:Depends},
${misc:Depends}
Recommends: curl
Description: C library for handling bigWig files
This package provides a C library for reading/parsing local and remote
......@@ -22,17 +25,18 @@ Description: C library for handling bigWig files
in case of errors.
Package: libbigwig-dev
Section: libdevel
Architecture: any
Multi-Arch: same
Depends: libbigwig0 (= ${binary:Version}), ${misc:Depends}
Section: libdevel
Depends: libbigwig0 (= ${binary:Version}),
${misc:Depends}
Description: C library for handling bigWig files - header files
This package provides the files needed to develop with the libBigWig
C library for reading/parsing local and remote bigWig and bigBed files.
Package: libbigwig-doc
Section: libdevel
Architecture: all
Section: libdevel
Depends: ${misc:Depends}
Description: C library for handling bigWig files - documentation
This package provides the doxygen-created inline documentation needed
......
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: libbigwig
Source:
Source: https://github.com/dpryan79/libBigWig/
Files-Excluded: docs
Files: *
Copyright: 2015 Devon Ryan
......
Index: libbigwig-0.4.2+dfsg/test/test.py
===================================================================
--- libbigwig-0.4.2+dfsg.orig/test/test.py
+++ libbigwig-0.4.2+dfsg/test/test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/python2.7
from subprocess import Popen, PIPE, check_call
from os import remove
......@@ -29,7 +29,9 @@ override_dh_auto_install:
mv *.so $(CURDIR)/debian/tmp/usr/lib/$(shell dpkg-architecture -qDEB_TARGET_MULTIARCH)
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
echo "W: Not testing - depending on online resources"
endif
override_dh_auto_clean:
dh_auto_clean
......
version=4
opts="dversionmangle=auto,oversionmangle=s/$/+dfsg/,filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%libbigwig-$1.tar.gz%" \
opts="repack,compression=xz,dversionmangle=auto,oversionmangle=s/$/+dfsg/,filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%libbigwig-$1.tar.gz%" \
https://github.com/dpryan79/libBigWig/tags \
(?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate
......@@ -133,7 +133,7 @@ CURLcode urlSeek(URL_t *URL, size_t pos) {
#ifndef NOCURL
} else {
//If the location is covered by the buffer then don't seek!
if(pos < URL->filePos || pos >= URL->filePos+URL->bufSize) {
if(pos < URL->filePos || pos >= URL->filePos+URL->bufLen) {
URL->filePos = pos;
URL->bufLen = 0; //Otherwise, filePos will get incremented on the next read!
URL->bufPos = 0;
......