Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addHeader does not support multiple calls #142

Open
rlowe-altoslabs opened this issue Aug 1, 2023 · 1 comment
Open

addHeader does not support multiple calls #142

rlowe-altoslabs opened this issue Aug 1, 2023 · 1 comment

Comments

@rlowe-altoslabs
Copy link

Not sure if this is intended or not but running addHeader multiple times seems to overwrite the existing header?

Example

import pyBigWig

with pyBigWig.open("example.bw", "w") as bw:
    header=[("chr1", 1000000), ("chr2", 1500000)]
    for item in header:
        bw.addHeader([item])
    items = [
        ["chr1", 0,5,0.0],
        ["chr1", 100,120,1.0],
        ["chr1", 125,126,200.0]
    ]
    for item in items:
        bw.addEntries([item[0]],[item[1]],ends=[item[2]],values=[item[3]])

Expected the above to work but instead fails on bw.addEntries with

RuntimeError: The entries you tried to add are out of order, precede already added entries, or otherwise use illegal values.

A couple of options in my opinion:

  1. Update docs and explicitly mention this behaviour
  2. Prevent addHeader being run a second time with some appropriate error
  3. Support this case. Reason the header is often read from a file and so the header could be added line by line. The addEntries supports this.

Obviously this is not hard to work around given one can create the list object and then call addHeader once complete.

@wang3702
Copy link

Same error here. Also, the writing order of addEntries should follow the same order as we defined in bw.addHeader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants