@@ -82,10 +82,12 @@ def get_ref_allele_coords(self, chrom, pos, ref):
8282
8383 # check the reference allele matches the reference sequence
8484 ref_seq = self .get_ref_seq (chrom , ref_start , ref_stop ).lower ()
85- assert ref_seq == ref .lower (), (
86- "reference allele does not match reference sequence, "
87- f"expected { ref_seq !r} , found { ref .lower ()!r} "
88- )
85+ if ref_seq != ref .lower ():
86+ raise ValueError (
87+ f"Reference allele does not match reference sequence at "
88+ f"{ chrom } :{ ref_start } -{ ref_stop } . Expected { ref_seq !r} , "
89+ f"found { ref .lower ()!r} ."
90+ )
8991
9092 return ref_start , ref_stop
9193
@@ -147,7 +149,12 @@ def get_effects(self, transcript, variants, progress=None):
147149 )
148150
149151 # reference allele falls within current transcript
150- assert feature_start <= ref_start <= ref_stop <= feature_stop
152+ if not (feature_start <= ref_start <= ref_stop <= feature_stop ):
153+ raise ValueError (
154+ f"Variant coordinates ({ ref_start } -{ ref_stop } ) fall outside "
155+ f"transcript boundaries ({ feature_start } -{ feature_stop } ) "
156+ f"on { chrom } ."
157+ )
151158
152159 effect = _get_within_transcript_effect (
153160 ann = self ,
@@ -234,7 +241,11 @@ def _get_cds_effect(ann, base_effect, cds, cdss):
234241 cds_stop = cds .end
235242
236243 # reference allele falls within current transcript
237- assert cds_start <= ref_start <= ref_stop <= cds_stop
244+ if not (cds_start <= ref_start <= ref_stop <= cds_stop ):
245+ raise ValueError (
246+ f"Variant coordinates ({ ref_start } -{ ref_stop } ) fall outside "
247+ f"CDS boundaries ({ cds_start } -{ cds_stop } )."
248+ )
238249 return _get_within_cds_effect (ann , base_effect , cds , cdss )
239250
240251
0 commit comments