Skip to content

Commit

Permalink
Fix issue with combine operation merging seqnames (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkanche authored Oct 15, 2024
1 parent a22165f commit 81c93e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/genomicranges/GenomicRanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -3120,7 +3120,7 @@ def subtract(
def _fast_combine_GenomicRanges(*x: GenomicRanges) -> GenomicRanges:
return GenomicRanges(
ranges=ut.combine_sequences(*[y._ranges for y in x]),
seqnames=ut.combine_sequences(*[y._seqnames for y in x]),
seqnames=ut.combine_sequences(*[y.get_seqnames() for y in x]),
strand=ut.combine_sequences(*[y._strand for y in x]),
names=None,
mcols=None,
Expand Down Expand Up @@ -3149,7 +3149,7 @@ def _combine_GenomicRanges(*x: GenomicRanges) -> GenomicRanges:

return GenomicRanges(
ranges=ut.combine_sequences(*[y._ranges for y in x]),
seqnames=ut.combine_sequences(*[y._seqnames for y in x]),
seqnames=ut.combine_sequences(*[y.get_seqnames() for y in x]),
strand=ut.combine_sequences(*[y._strand for y in x]),
names=all_names,
mcols=ut.relaxed_combine_rows(*[y._mcols for y in x]),
Expand Down
17 changes: 16 additions & 1 deletion tests/test_gr_methods_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,23 @@ def test_combine():
assert g_src is not None
assert g_tgt is not None

out: GenomicRanges = ut.combine_sequences(g_src, g_tgt)
out = ut.combine_sequences(g_src, g_tgt)

assert out is not None
assert len(out) == 15
assert len(out.get_mcols().get_column_names()) == 2


def test_combine_diff():
a = GenomicRanges(["A"], IRanges([0], [10]))
b = GenomicRanges(["B"], IRanges([5], [15]))

assert a is not None
assert b is not None

out = ut.combine_sequences(a, b)

assert out is not None
assert len(out) == 2
assert len(out.get_mcols().get_column_names()) == 0
assert out.get_seqnames() == ["A", "B"]

0 comments on commit 81c93e8

Please sign in to comment.