Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog

## Version 0.8.0
## Version 0.8.0 - 0.8.1

- Implement parsers for compressed list objects.
- Switch `GenomicRangesList` to the `CompressedGenomicRangesList` implementation.

## Version 0.7.0 - 0.7.3

Expand Down
11 changes: 6 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ optional =
hdf5array
scipy
biocframe
genomicranges>=0.4.9
summarizedexperiment>=0.4.1
singlecellexperiment>=0.4.1
multiassayexperiment
compressed_lists>=0.3.0
genomicranges>=0.8.4
summarizedexperiment>=0.6.5
singlecellexperiment>=0.6.2
multiassayexperiment>=0.6.0
compressed_lists>=0.4.4
biocutils>=0.3.4

# Add here test requirements (semicolon/line-separated)
testing =
Expand Down
26 changes: 16 additions & 10 deletions src/rds2py/read_granges.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,22 @@ def read_genomic_ranges(robject: dict, **kwargs):


def read_granges_list(robject: dict, **kwargs):
"""Convert an R `GenomicRangesList` object to a Python :py:class:`~genomicranges.GenomicRangesList`.
"""Convert an R `CompressedGenomicRangesList` object to a Python :py:class:`~genomicranges.grangeslist.CompressedGenomicRangesList`.

Args:
robject:
Dictionary containing parsed GenomicRangesList data.
Dictionary containing parsed CompressedGenomicRangesList data.

**kwargs:
Additional arguments.

Returns:
A Python `GenomicRangesList` object containing containing multiple
A Python `CompressedGenomicRangesList` object containing containing multiple
`GenomicRanges` objects.
"""

from genomicranges import GenomicRangesList
from compressed_lists import Partitioning
from genomicranges import CompressedGenomicRangesList

_cls = get_class(robject)

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

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

_grelist = []
_part_obj = Partitioning(ends=_partitionends, names=_groups)

current = 0
for _pend in _partitionends:
_grelist.append(_gre[current:_pend])
current = _pend
element_metadata = None
if "elementMetadata" in robject["attributes"]:
element_metadata = _dispatcher(robject["attributes"]["elementMetadata"], **kwargs)

return GenomicRangesList(ranges=_grelist, names=_groups)
metadata = None
if "metadata" in robject["attributes"]:
metadata = _dispatcher(robject["attributes"]["metadata"], **kwargs)

return CompressedGenomicRangesList(
unlist_data=_gre, partitioning=_part_obj, element_metadata=element_metadata, metadata=metadata
)
4 changes: 2 additions & 2 deletions tests/test_granges.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rds2py import read_rds

from genomicranges import GenomicRanges, GenomicRangesList
from genomicranges import GenomicRanges, CompressedGenomicRangesList
import numpy as np

__author__ = "jkanche"
Expand Down Expand Up @@ -32,5 +32,5 @@ def test_granges():
def test_granges_list():
gr = read_rds("tests/data/grangeslist.rds")

assert isinstance(gr, GenomicRangesList)
assert isinstance(gr, CompressedGenomicRangesList)
assert len(gr) == 5
Loading