Skip to content

Commit 26ba392

Browse files
committed
Fix pybigtools rest field
1 parent a999129 commit 26ba392

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

pybigtools/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,7 @@ impl BigBedWrite {
21722172
.extract(py)
21732173
.unwrap();
21742174
let rest: String = tuple
2175-
.get_item(0)
2175+
.get_item(3)
21762176
.unwrap()
21772177
.downcast::<PyString>()?
21782178
.to_str()

pybigtools/tests/test_bigwig.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ def genintervals():
7272
assert a[1] == b[2]
7373
assert math.isclose(a[2], b[3], abs_tol=0.00001)
7474

75+
def test_bigbed_write(tmpdir):
76+
f = pybigtools.open(os.path.join(tmpdir, "test.bigBed"), "w")
77+
f.write(
78+
{"chr1": 1000, "chr2": 1000},
79+
[
80+
("chr1", 0, 100, "foo\tbar\t3"),
81+
("chr2", 100, 200, "xxx\tyyy\t1.0"),
82+
("chr2", 200, 300, "zzz\twww\t1.0")
83+
]
84+
)
85+
f.close()
86+
87+
f = pybigtools.open(os.path.join(tmpdir, "test.bigBed"))
88+
records = list(f.records("chr2"))
89+
assert records[0][2] == 'xxx'
7590

7691
# TODO: bigWigAverageOverBed
7792
# TODO: bigWigMerge

0 commit comments

Comments
 (0)