deeptools / pyBigWig

A python extension for quick access to bigWig and bigBed files
MIT License
212 stars 48 forks source link

Cannot add entries of value type int, but only float #126

Open XikunZhang opened 2 years ago

XikunZhang commented 2 years ago

pybigwig version: 0.3.18

When I tried adding entries of int type like

import pyBigWig
import numpy as np
hg19_chr1_len = 249250621
with pyBigWig.open("/path/to/a/bigwig", "w") as bw:
    bw.addHeader([("chr1", hg19_chr1_len)])
    bw.addEntries("chr1", [0], values=[0], span=hg19_chr1_len)

, I encountered this error

RuntimeError: You must provide a valid set of entries. These can be comprised of any of the following:
1. A list of each of chromosomes, start positions, end positions and values.
2. A list of each of start positions and values. Also, a chromosome and span must be specified.
3. A list values, in which case a single chromosome, start position, span and step must be specified.

. After I changed the value type from int to float, like

import pyBigWig
import numpy as np
hg19_chr1_len = 249250621
with pyBigWig.open("/path/to/a/bigwig", "w") as bw:
    bw.addHeader([("chr1", hg19_chr1_len)])
    bw.addEntries("chr1", [0], values=[0.], span=hg19_chr1_len)

, the code ran successfully. I think it can be good to allow adding entries of int type.

dpryan79 commented 2 years ago

BigWig files themselves only support float values.

XikunZhang commented 2 years ago

OK, but it can be good to auto-convert integers to floats or give more interpretable error messages. The current error message is not helpful to let people know what is going wrong.

On Wed, May 11, 2022 at 8:08 AM Devon Ryan @.***> wrote:

BigWig files themselves only support float values.

— Reply to this email directly, view it on GitHub https://github.com/deeptools/pyBigWig/issues/126#issuecomment-1123905811, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGE4WBIB2M5XJWI4B65SJLDVJPEN7ANCNFSM5VTKT3DQ . You are receiving this because you authored the thread.Message ID: @.***>