Skip to content

Commit

Permalink
Fix pybigtools rest field
Browse files Browse the repository at this point in the history
  • Loading branch information
jackh726 committed Nov 1, 2024
1 parent a999129 commit 26ba392
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pybigtools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ impl BigBedWrite {
.extract(py)
.unwrap();
let rest: String = tuple
.get_item(0)
.get_item(3)
.unwrap()
.downcast::<PyString>()?
.to_str()
Expand Down
15 changes: 15 additions & 0 deletions pybigtools/tests/test_bigwig.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ def genintervals():
assert a[1] == b[2]
assert math.isclose(a[2], b[3], abs_tol=0.00001)

def test_bigbed_write(tmpdir):
f = pybigtools.open(os.path.join(tmpdir, "test.bigBed"), "w")
f.write(
{"chr1": 1000, "chr2": 1000},
[
("chr1", 0, 100, "foo\tbar\t3"),
("chr2", 100, 200, "xxx\tyyy\t1.0"),
("chr2", 200, 300, "zzz\twww\t1.0")
]
)
f.close()

f = pybigtools.open(os.path.join(tmpdir, "test.bigBed"))
records = list(f.records("chr2"))
assert records[0][2] == 'xxx'

# TODO: bigWigAverageOverBed
# TODO: bigWigMerge

0 comments on commit 26ba392

Please sign in to comment.