Skip to content

Commit e8d4ea2

Browse files
authored
Switch to the compressed granges list (#71)
1 parent 78434ff commit e8d4ea2

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changelog
22

3-
## Version 0.8.0
3+
## Version 0.8.0 - 0.8.1
44

55
- Implement parsers for compressed list objects.
6+
- Switch `GenomicRangesList` to the `CompressedGenomicRangesList` implementation.
67

78
## Version 0.7.0 - 0.7.3
89

setup.cfg

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ optional =
6666
hdf5array
6767
scipy
6868
biocframe
69-
genomicranges>=0.4.9
70-
summarizedexperiment>=0.4.1
71-
singlecellexperiment>=0.4.1
72-
multiassayexperiment
73-
compressed_lists>=0.3.0
69+
genomicranges>=0.8.4
70+
summarizedexperiment>=0.6.5
71+
singlecellexperiment>=0.6.2
72+
multiassayexperiment>=0.6.0
73+
compressed_lists>=0.4.4
74+
biocutils>=0.3.4
7475

7576
# Add here test requirements (semicolon/line-separated)
7677
testing =

src/rds2py/read_granges.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,22 @@ def read_genomic_ranges(robject: dict, **kwargs):
7676

7777

7878
def read_granges_list(robject: dict, **kwargs):
79-
"""Convert an R `GenomicRangesList` object to a Python :py:class:`~genomicranges.GenomicRangesList`.
79+
"""Convert an R `CompressedGenomicRangesList` object to a Python :py:class:`~genomicranges.grangeslist.CompressedGenomicRangesList`.
8080
8181
Args:
8282
robject:
83-
Dictionary containing parsed GenomicRangesList data.
83+
Dictionary containing parsed CompressedGenomicRangesList data.
8484
8585
**kwargs:
8686
Additional arguments.
8787
8888
Returns:
89-
A Python `GenomicRangesList` object containing containing multiple
89+
A Python `CompressedGenomicRangesList` object containing containing multiple
9090
`GenomicRanges` objects.
9191
"""
9292

93-
from genomicranges import GenomicRangesList
93+
from compressed_lists import Partitioning
94+
from genomicranges import CompressedGenomicRangesList
9495

9596
_cls = get_class(robject)
9697

@@ -106,11 +107,16 @@ def read_granges_list(robject: dict, **kwargs):
106107

107108
_partitionends = _dispatcher(robject["attributes"]["partitioning"]["attributes"]["end"], **kwargs)
108109

109-
_grelist = []
110+
_part_obj = Partitioning(ends=_partitionends, names=_groups)
110111

111-
current = 0
112-
for _pend in _partitionends:
113-
_grelist.append(_gre[current:_pend])
114-
current = _pend
112+
element_metadata = None
113+
if "elementMetadata" in robject["attributes"]:
114+
element_metadata = _dispatcher(robject["attributes"]["elementMetadata"], **kwargs)
115115

116-
return GenomicRangesList(ranges=_grelist, names=_groups)
116+
metadata = None
117+
if "metadata" in robject["attributes"]:
118+
metadata = _dispatcher(robject["attributes"]["metadata"], **kwargs)
119+
120+
return CompressedGenomicRangesList(
121+
unlist_data=_gre, partitioning=_part_obj, element_metadata=element_metadata, metadata=metadata
122+
)

tests/test_granges.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from rds2py import read_rds
22

3-
from genomicranges import GenomicRanges, GenomicRangesList
3+
from genomicranges import GenomicRanges, CompressedGenomicRangesList
44
import numpy as np
55

66
__author__ = "jkanche"
@@ -32,5 +32,5 @@ def test_granges():
3232
def test_granges_list():
3333
gr = read_rds("tests/data/grangeslist.rds")
3434

35-
assert isinstance(gr, GenomicRangesList)
35+
assert isinstance(gr, CompressedGenomicRangesList)
3636
assert len(gr) == 5

0 commit comments

Comments
 (0)