Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Add support for checking before/after transcript boundaries #381

Merged
merged 2 commits into from
Dec 3, 2024
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
18 changes: 16 additions & 2 deletions src/cool_seq_tool/mappers/exon_genomic_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,14 +1169,28 @@ def _get_adjacent_exon(
:param end: Genomic coordinate of breakpoint
:return: Exon number corresponding to adjacent exon. Will be 0-based
"""
for i in range(len(tx_exons_genomic_coords) - 1):
# Check if a breakpoint occurs before/after the transcript boundaries
bp = start if start else end
exon_list_len = len(tx_exons_genomic_coords) - 1

if strand == Strand.POSITIVE:
if bp < tx_exons_genomic_coords[0].alt_start_i:
return 0
if bp > tx_exons_genomic_coords[exon_list_len].alt_end_i:
return exon_list_len
if strand == Strand.NEGATIVE:
if bp > tx_exons_genomic_coords[0].alt_end_i:
return 0
if bp < tx_exons_genomic_coords[exon_list_len].alt_start_i:
return exon_list_len

for i in range(exon_list_len):
exon = tx_exons_genomic_coords[i]
if start == exon.alt_start_i:
break
if end == exon.alt_end_i:
break
next_exon = tx_exons_genomic_coords[i + 1]
bp = start if start else end
if strand == Strand.POSITIVE:
lte_exon = exon
gte_exon = next_exon
Expand Down
26 changes: 26 additions & 0 deletions tests/mappers/test_exon_genomic_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,32 @@ async def test_get_adjacent_exon(
)
assert resp == 4

# Check cases where breakpoint occurs in before/after transcript boundaries
resp = test_egc_mapper._get_adjacent_exon(
tx_exons_genomic_coords=nm_001105539_exons_genomic_coords,
start=80486220,
strand=Strand.POSITIVE,
)
assert resp == 0
resp = test_egc_mapper._get_adjacent_exon(
tx_exons_genomic_coords=nm_001105539_exons_genomic_coords,
start=80526285,
strand=Strand.POSITIVE,
)
assert resp == 5
resp = test_egc_mapper._get_adjacent_exon(
tx_exons_genomic_coords=nm_152263_exons_genomic_coords,
end=154192110,
strand=Strand.NEGATIVE,
)
assert resp == 0
resp = test_egc_mapper._get_adjacent_exon(
tx_exons_genomic_coords=nm_152263_exons_genomic_coords,
end=154161809,
strand=Strand.NEGATIVE,
)
assert resp == 9


def test_is_exonic_breakpoint(test_egc_mapper, nm_001105539_exons_genomic_coords):
"""Test is breakpoint occurs on exon"""
Expand Down
Loading