File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/cool_seq_tool/mappers Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,24 @@ class TxSegment(BaseModelForbidExtra):
6969 default = True , description = "If the position occurs on an exon"
7070 )
7171
72+ @model_validator (mode = "before" )
73+ def check_seg_pos (cls , values : dict ) -> dict : # noqa: N805
74+ """Ensure that only one of `start` or `end` is set in the
75+ genomic_location field
76+
77+ :param values: The values in the TxSegment class
78+ :raises ValueError: If `start` and `end` are both set in
79+ `genomic_location`
80+ :return: Values in model
81+ """
82+ loc = values .get ("genomic_location" )
83+ start = getattr (loc , "start" , None )
84+ end = getattr (loc , "end" , None )
85+ if start and end :
86+ err_msg = "Only one of `start` or `end` may be set as this describes the start or end of a transcript segment"
87+ raise ValueError (err_msg )
88+ return values
89+
7290 model_config = ConfigDict (
7391 json_schema_extra = {
7492 "example" : {
You can’t perform that action at this time.
0 commit comments