@@ -76,21 +76,22 @@ def read_genomic_ranges(robject: dict, **kwargs):
7676
7777
7878def 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+ )
0 commit comments