87f5ac2d9279932b8d45b75e9c7d30fdd062a5b7 lrnassar Mon Aug 24 18:21:40 2026 -0700 Fixes from nightly CR: guard FLOSSIES carrier count, drop dead variable. refs #37399 refs #38139 Hardening on the FLOSSIES carrier-count fix, per nightly code review: - Add a consistency guard: carriers are summed from the per-population het and hom counts, and the build now raises if sum(pop_hets)+sum(pop_homs) does not equal allele_count. In this export the two are identical (allele_count is het+hom, not the usual het+2*hom), so this catches a future re-fetch that renames pop_hets/pop_homs or switches to standard allele-count semantics, instead of silently zeroing carriers and mis-tiering every coding variant. Verified the identity holds for all 118 current records. - Remove the now-dead hom (hom_count) local, left over from the old allele_count - hom_count formula. No output change (FLOSSIES bigBed is byte-identical; tiers unchanged). diff --git src/hg/makeDb/scripts/tp53/tp53Flossies.py src/hg/makeDb/scripts/tp53/tp53Flossies.py index 71ac996badf..266fe2ef1f5 100644 --- src/hg/makeDb/scripts/tp53/tp53Flossies.py +++ src/hg/makeDb/scripts/tp53/tp53Flossies.py @@ -186,37 +186,42 @@ ref = v['ref'] alt = v['alt'] pos_hg19 = int(v['pos']) if assembly == 'hg19': chrom = "chr{}".format(v['chrom']) start = pos_hg19 - 1 end = start + len(ref) else: if v['variant_id'] not in hg38_lookup: skipped += 1 continue chrom, start, end = hg38_lookup[v['variant_id']] conseq = v.get('major_consequence') or 'unknown' ac = int(v.get('allele_count') or 0) an = int(v.get('allele_num') or 0) - hom = int(v.get('hom_count') or 0) - # Carrier individuals = heterozygous + homozygous carriers. In this - # FLOSSIES export allele_count is already het + hom (not the usual - # het + 2*hom), so we sum the per-population het and hom counts directly - # rather than allele_count - hom_count, which would drop homozygotes. + # Carrier individuals = heterozygous + homozygous carriers, summed from + # the per-population het/hom counts. In this FLOSSIES export allele_count + # is already het + hom (not the usual het + 2*hom); the check below makes + # a future re-fetch that renames these keys or switches to standard + # allele-count semantics fail loudly instead of silently zeroing carriers. carriers = (sum(int(x or 0) for x in (v.get('pop_hets') or {}).values()) + sum(int(x or 0) for x in (v.get('pop_homs') or {}).values())) + if carriers != ac: + raise ValueError( + "FLOSSIES het+hom ({}) != allele_count ({}) for {}; " + "pop_hets/pop_homs schema may have changed".format( + carriers, ac, v.get('HGVSc') or v.get('variant_id'))) applies, pts, _ = bs2_tier(conseq, carriers) color = COLORS[applies] hgvsc = v.get('HGVSc') or '' hgvsp = v.get('HGVSp') or '' pop_acs = v.get('pop_acs') or {} pop_ans = v.get('pop_ans') or {} pop_breakdown = "; ".join( "{}={}/{}".format(p, pop_acs.get(p, 0), pop_ans.get(p, 0)) for p in pop_acs ) disp = "{}:{}{}>{}".format(chrom, start + 1, ref, alt) name = hgvsp if hgvsp else (hgvsc if hgvsc else disp) mo = mouseover(disp, hgvsc, hgvsp, conseq, applies, pts, carriers, ac, an, pop_acs, pop_ans) lines.append("\t".join([