@@ -92,10 +92,12 @@ def get_ref_allele_coords(self, chrom, pos, ref):
9292
9393 # check the reference allele matches the reference sequence
9494 ref_seq = self .get_ref_seq (chrom , ref_start , ref_stop ).lower ()
95- assert ref_seq == ref .lower (), (
96- "reference allele does not match reference sequence, "
97- f"expected { ref_seq !r} , found { ref .lower ()!r} "
98- )
95+ if ref_seq != ref .lower ():
96+ raise ValueError (
97+ f"Reference allele does not match reference sequence at "
98+ f"{ chrom } :{ ref_start } -{ ref_stop } . Expected { ref_seq !r} , "
99+ f"found { ref .lower ()!r} ."
100+ )
99101
100102 return ref_start , ref_stop
101103
@@ -170,7 +172,12 @@ def get_effects(self, transcript, variants, progress=None):
170172 )
171173
172174 # reference allele falls within current transcript
173- assert feature_start <= ref_start <= ref_stop <= feature_stop
175+ if not (feature_start <= ref_start <= ref_stop <= feature_stop ):
176+ raise ValueError (
177+ f"Variant coordinates ({ ref_start } -{ ref_stop } ) fall outside "
178+ f"transcript boundaries ({ feature_start } -{ feature_stop } ) "
179+ f"on { chrom } ."
180+ )
174181
175182 effect = _get_within_transcript_effect (
176183 ann = self ,
@@ -276,7 +283,11 @@ def _get_cds_effect(ann, base_effect, cds, cdss):
276283 cds_stop = cds .end
277284
278285 # reference allele falls within current transcript
279- assert cds_start <= ref_start <= ref_stop <= cds_stop
286+ if not (cds_start <= ref_start <= ref_stop <= cds_stop ):
287+ raise ValueError (
288+ f"Variant coordinates ({ ref_start } -{ ref_stop } ) fall outside "
289+ f"CDS boundaries ({ cds_start } -{ cds_stop } )."
290+ )
280291 return _get_within_cds_effect (ann , base_effect , cds , cdss )
281292
282293
0 commit comments