Skip to content

Commit 9f94cf9

Browse files
committed
Fix #88
1 parent e685340 commit 9f94cf9

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Diff for: README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ For the sake of consistency with other tools, pyBigWig adopts this same methodol
144144
0.22213841940688142
145145
>>> bw.stats('chr1', 89294, 91629, exact=True)
146146
[0.22213841940688142]
147-
Additionally, `values()` can directly output a numpy vector:
148-
149-
>>> bw = bw.open("
150147

151148
## Retrieve values for individual bases in a range
152149

@@ -218,6 +215,8 @@ By default, up to 10 "zoom levels" are constructed for bigWig files. You can cha
218215

219216
>>> bw.addHeader([("chr1", 1000000), ("chr2", 1500000)], maxZooms=0)
220217

218+
If you set `maxTooms=0`, please note that IGV and many other tools WILL NOT WORK as they assume that at least one zoom level will be present. You are advised to use the default unless you do not expect the bigWig files to be used by other packages.
219+
221220
## Adding entries to a bigWig file
222221

223222
Assuming you've opened a file for writing and added a header, you can then add entries. Note that the entries **must** be added in order, as bigWig files always contain ordered intervals. There are three formats that bigWig files can use internally to store entries. The most commonly observed format is identical to a [bedGraph](https://genome.ucsc.edu/goldenpath/help/bedgraph.html) file:

Diff for: pyBigWig.c

+19
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ static PyObject *pyBwGetHeader(pyBigWigFile_t *self, PyObject *args) {
276276
PyErr_SetString(PyExc_RuntimeError, "The bigWig file handle is not opened!");
277277
return NULL;
278278
}
279+
if(bw->isWrite == 1) {
280+
PyErr_SetString(PyExc_RuntimeError, "The header cannot be accessed in files opened for writing!");
281+
return NULL;
282+
}
279283

280284
ret = PyDict_New();
281285
val = PyLong_FromUnsignedLong(bw->hdr->version);
@@ -321,6 +325,11 @@ static PyObject *pyBwGetChroms(pyBigWigFile_t *self, PyObject *args) {
321325
return NULL;
322326
}
323327

328+
if(bw->isWrite == 1) {
329+
PyErr_SetString(PyExc_RuntimeError, "Chromosomes cannot be accessed in files opened for writing!");
330+
return NULL;
331+
}
332+
324333
if(!(PyArg_ParseTuple(args, "|s", &chrom)) || !chrom) {
325334
ret = PyDict_New();
326335
for(i=0; i<bw->cl->nKeys; i++) {
@@ -380,6 +389,11 @@ static PyObject *pyBwGetStats(pyBigWigFile_t *self, PyObject *args, PyObject *kw
380389
return NULL;
381390
}
382391

392+
if(bw->isWrite == 1) {
393+
PyErr_SetString(PyExc_RuntimeError, "Statistics cannot be accessed in files opened for writing!");
394+
return NULL;
395+
}
396+
383397
if(bw->type == 1) {
384398
PyErr_SetString(PyExc_RuntimeError, "bigBed files have no statistics!");
385399
return NULL;
@@ -621,6 +635,11 @@ static PyObject *pyBwGetIntervals(pyBigWigFile_t *self, PyObject *args, PyObject
621635
return NULL;
622636
}
623637

638+
if(bw->isWrite == 1) {
639+
PyErr_SetString(PyExc_RuntimeError, "Intervals cannot be accessed in files opened for writing!");
640+
return NULL;
641+
}
642+
624643
if(bw->type == 1) {
625644
PyErr_SetString(PyExc_RuntimeError, "bigBed files have no intervals! Use 'entries()' instead.");
626645
return NULL;

0 commit comments

Comments
 (0)