9eb4e0937782954c19d664e7d384d210bffb3b25
max
  Sat Jun 13 16:01:42 2026 -0700
lrSv: QA fixes from Lou's review - dedup, shared color palette, deCODE/AoU cleanup

- Drop kwanhoSv (KimPD) from the lrSvAll merge in databases.tsv; it stays on
dev/alpha until published, which also removes its >5 Mb breakend artifacts
from the merged track.
- Remove searchIndex from colorsDbSv, lrSv1kLin and lrSvAll (and the merge
generator): the bigBeds were built without a name index, so by-name search
never worked.
- Single shared per-SV-type color palette in lrSvCommon.py (svColor), used by
every converter and the merge. CPX is purple everywhere (was orange in
1kgOnt/apr/cpc1, colliding with INV's orange), colorsDb DEL is 200,0,0 like
the rest, and TRA/INSDEL get their own colors.
- deCODE: drop byte-identical duplicate rows and blank the fake AC=50
placeholder (AC is now a string field, omitted from the name and mouseOver).
- AoU: numeric-entity-encode non-ASCII gene/trait text and drop duplicate rows.
- gustafson, chirmade101, hprc2v21: drop byte-identical duplicate rows.
- lrSvMergeAll.py: skip byte-identical duplicate source rows instead of summing
their allele counts, which had inflated the per-database and total AC.

refs #36258

diff --git src/hg/makeDb/scripts/lrSv/lrSvDecodeVcfToBed.py src/hg/makeDb/scripts/lrSv/lrSvDecodeVcfToBed.py
index 80cd78bda6e..8526967ed67 100644
--- src/hg/makeDb/scripts/lrSv/lrSvDecodeVcfToBed.py
+++ src/hg/makeDb/scripts/lrSv/lrSvDecodeVcfToBed.py
@@ -1,104 +1,111 @@
 #!/usr/bin/env python3
 """Convert the deCODE high-confidence long-read SV VCF to BED9+ for bigBed.
 
 Usage:
     lrSvDecodeVcfToBed.py input.vcf.gz output.bed
+
+The source VCF has no allele count, so the AC column is left empty (it used to
+carry a fake placeholder of 50). The source also lists some variants more than
+once (byte-identical records); those duplicate rows are collapsed here.
 """
 
 import gzip
 import os
 import sys
 
 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
-from lrSvCommon import svName, normalizeSvType
-
-SV_COLORS = {
-    "DEL": "200,0,0",       # red
-    "INS": "0,0,200",       # blue
-    "INSDEL": "140,0,200",  # purple (combined INS/DEL)
-}
+from lrSvCommon import svName, normalizeSvType, svColor
 
 
 def parseInfo(infoStr):
     d = {}
     for item in infoStr.split(";"):
         if "=" in item:
             k, v = item.split("=", 1)
             d[k] = v
         else:
             d[item] = True
     return d
 
 
 def main():
     if len(sys.argv) != 3:
         print(__doc__, file=sys.stderr)
         sys.exit(1)
 
     inFile, outFile = sys.argv[1], sys.argv[2]
     opener = gzip.open if inFile.endswith(".gz") else open
 
+    seen = set()
+    nIn = 0
+    nDup = 0
     with opener(inFile, "rt") as fIn, open(outFile, "w") as fOut:
         for line in fIn:
             if line.startswith("#"):
                 continue
+            nIn += 1
 
             fields = line.rstrip("\n").split("\t")
             chrom = fields[0]
             pos = int(fields[1])
-            rowName = fields[2]
             info = parseInfo(fields[7])
 
             svTypeRaw = info.get("SVTYPE", ".")
             svType = normalizeSvType(svTypeRaw)
             end = int(info.get("END", pos))
             svLenRaw = int(float(info.get("SVLEN", "0")))
             trrBegin = info.get("TRRBEGIN", ".")
             trrEnd = info.get("TRREND", ".")
 
             if trrBegin == ".":
                 trrBegin = ""
             if trrEnd == ".":
                 trrEnd = ""
 
             chromStart = pos - 1
             chromEnd = end
             if chromEnd <= chromStart:
                 chromEnd = chromStart + 1
 
             svLen = chromEnd - chromStart
             if svType in ("INS", "MEI"):
                 insLen = abs(svLenRaw)
             else:
                 insLen = 0  # DEL/INSDEL
 
-            # placeholder; awaiting real values from deCODE (#35059 ...)
-            ac = 50
-
-            color = SV_COLORS.get(svType, "100,100,100")
+            color = svColor(svType)
 
             featLen = insLen if svType in ("INS", "MEI") else svLen
-            name = svName(svType, featLen, ac)
+            # deCODE publishes no allele count, so omit AC from the name.
+            name = svName(svType, featLen)
 
             row = [
                 chrom,
                 str(chromStart),
                 str(chromEnd),
                 name,
                 "0",
                 ".",
                 str(chromStart),
                 str(chromEnd),
                 color,
                 svType,
                 str(svLen),
                 str(insLen),
-                str(ac),
+                "",          # AC: deCODE has none (was a fake placeholder of 50)
                 trrBegin,
                 trrEnd,
             ]
-            fOut.write("\t".join(row) + "\n")
+            line_out = "\t".join(row)
+            if line_out in seen:
+                nDup += 1
+                continue
+            seen.add(line_out)
+            fOut.write(line_out + "\n")
+
+    print(f"deCODE: {nIn:,} input records, {nDup:,} duplicate rows dropped, "
+          f"{nIn - nDup:,} written", file=sys.stderr)
 
 
 if __name__ == "__main__":
     main()