Skip to content

Commit 6e0fc67

Browse files
committed
Add is_exonic field to transcript segment output
1 parent 5b14f4b commit 6e0fc67

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/cool_seq_tool/mappers/exon_genomic_coords.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class TxSegment(BaseModelForbidExtra):
6565
genomic_location: SequenceLocation = Field(
6666
..., description="The genomic position of a transcript segment."
6767
)
68+
is_exonic: bool = Field(default=True, description="If the position occurs on an exon")
6869

6970
model_config = ConfigDict(
7071
json_schema_extra={
@@ -79,6 +80,7 @@ class TxSegment(BaseModelForbidExtra):
7980
},
8081
"end": 154192135,
8182
},
83+
"is_exonic": True,
8284
}
8385
}
8486
)
@@ -136,6 +138,7 @@ def check_errors(cls, values: dict) -> dict: # noqa: N805
136138
},
137139
"end": 154192135,
138140
},
141+
"is_exonic": True,
139142
},
140143
"errors": [],
141144
}
@@ -202,6 +205,7 @@ def add_meta_check_errors(cls, values: dict) -> dict: # noqa: N805
202205
},
203206
"end": 154192135,
204207
},
208+
"is_exonic": True,
205209
},
206210
"seg_end": {
207211
"exon_ord": 7,
@@ -214,6 +218,7 @@ def add_meta_check_errors(cls, values: dict) -> dict: # noqa: N805
214218
},
215219
"start": 154170399,
216220
},
221+
"is_exonic": True,
217222
},
218223
}
219224
}
@@ -894,7 +899,9 @@ async def _genomic_to_tx_segment(
894899

895900
# Check if breakpoint occurs on an exon.
896901
# If not, determine the adjacent exon given the selected transcript
902+
is_exonic = True
897903
if not self._is_exonic_breakpoint(genomic_pos, tx_exons):
904+
is_exonic = False
898905
exon_num = self._get_adjacent_exon(
899906
tx_exons_genomic_coords=tx_exons,
900907
strand=strand,
@@ -925,6 +932,7 @@ async def _genomic_to_tx_segment(
925932
if err_msg:
926933
return GenomicTxSeg(errors=[err_msg])
927934

935+
#print(is_exonic)
928936
return GenomicTxSeg(
929937
gene=gene,
930938
genomic_ac=genomic_ac,
@@ -934,6 +942,7 @@ async def _genomic_to_tx_segment(
934942
exon_ord=exon_num,
935943
offset=offset,
936944
genomic_location=genomic_location,
945+
is_exonic=is_exonic,
937946
),
938947
)
939948

tests/mappers/test_exon_genomic_coords.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def tpm3_exon1():
184184
},
185185
"end": 154192135,
186186
},
187+
"is_exonic": True,
187188
},
188189
}
189190
return GenomicTxSeg(**params)
@@ -208,6 +209,7 @@ def tpm3_exon8():
208209
},
209210
"start": 154170399,
210211
},
212+
"is_exonic": True,
211213
},
212214
}
213215
return GenomicTxSeg(**params)
@@ -293,6 +295,7 @@ def mane_braf():
293295
},
294296
"end": 140801559,
295297
},
298+
"is_exonic": True,
296299
},
297300
"seg_end": {
298301
"exon_ord": 14,
@@ -305,6 +308,7 @@ def mane_braf():
305308
},
306309
"start": 140753336,
307310
},
311+
"is_exonic": True,
308312
},
309313
}
310314
return GenomicTxSegService(**params)
@@ -438,6 +442,7 @@ def zbtb10_exon3_end():
438442
},
439443
"end": 80514010,
440444
},
445+
"is_exonic": False,
441446
},
442447
}
443448
return GenomicTxSegService(**params)
@@ -462,6 +467,7 @@ def zbtb10_exon5_start():
462467
},
463468
"start": 80518580,
464469
},
470+
"is_exonic": False,
465471
},
466472
"seg_end": None,
467473
}
@@ -488,6 +494,7 @@ def tpm3_exon6_end():
488494
},
489495
"start": 154171410,
490496
},
497+
"is_exonic": False,
491498
},
492499
}
493500
return GenomicTxSegService(**params)
@@ -512,6 +519,7 @@ def tpm3_exon5_start():
512519
},
513520
"end": 154173080,
514521
},
522+
"is_exonic": False,
515523
},
516524
"seg_end": None,
517525
}
@@ -538,6 +546,7 @@ def gusbp3_exon2_end():
538546
},
539547
"start": 69680764,
540548
},
549+
"is_exonic": False,
541550
},
542551
}
543552
return GenomicTxSegService(**params)
@@ -562,6 +571,7 @@ def eln_grch38_intronic():
562571
},
563572
"start": 74028173,
564573
},
574+
"is_exonic": True
565575
},
566576
"seg_end": {
567577
"exon_ord": 7,
@@ -574,6 +584,7 @@ def eln_grch38_intronic():
574584
},
575585
"end": 74043599,
576586
},
587+
"is_exonic": False
577588
},
578589
}
579590
return GenomicTxSegService(**params)
@@ -598,6 +609,7 @@ def gusbp3_exon5_start():
598609
},
599610
"end": 69645878,
600611
},
612+
"is_exonic": False
601613
},
602614
"seg_end": None,
603615
}
@@ -648,6 +660,7 @@ def genomic_tx_seg_service_checks(actual, expected=None, is_valid=True):
648660
assert (
649661
actual_seg.genomic_location.end == expected_seg.genomic_location.end
650662
)
663+
assert actual_seg.is_exonic == expected_seg.is_exonic
651664

652665
assert actual.errors == expected.errors
653666
else:
@@ -715,6 +728,7 @@ def genomic_tx_seg_checks(actual, expected=None, is_valid=True):
715728
actual_seg.genomic_location.start == expected_seg.genomic_location.start
716729
)
717730
assert actual_seg.genomic_location.end == expected_seg.genomic_location.end
731+
assert actual_seg.is_exonic == expected_seg.is_exonic
718732

719733
assert actual.errors == expected.errors
720734
else:

0 commit comments

Comments
 (0)