Skip to content

Commit 6b7ec05

Browse files
authored
Merge branch 'master' into refactor/het-analysis
2 parents 70ebc6e + a1ebb6e commit 6b7ec05

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

malariagen_data/anoph/cnv_frq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def _gene_cnv_frequencies_advanced(
586586
nobs[:, cohort_index] = np.repeat(cohort_n_called, 2)
587587
else:
588588
assert nobs_mode == "fixed"
589-
nobs[:, cohort_index] = cohort.size * 2
589+
nobs[:, cohort_index] = cohort.size
590590

591591
debug("compute frequency")
592592
with np.errstate(divide="ignore", invalid="ignore"):

malariagen_data/veff.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)