78cdae7249c8609dcbc743e996ea7e5eec33d75a
max
  Mon Aug 17 08:15:39 2026 -0700
lrSv: fix off-by-one anchor base in deletion coordinates across converters, refs #38099

VCF/pangenome deletions carry a non-deleted anchor (padding) base at POS.
Several lrSv converters set chromStart = pos-1, which includes that anchor, so
each deletion was 1 bp too wide on the left and svLen was 1 too big. Callsets
handled this inconsistently, so the same deletion appeared at offset coordinates
and failed to merge in lrSvAll.

For deletions only (INS/INV/CPX unchanged), advance chromStart past the anchor
so the interval covers exactly the deleted bases (svLen == |SVLEN|). Verified
against the hg38 reference: the old left base is present in both REF and ALT
(i.e. retained by the sample), so it should not be inside the deletion.

Fixed 11 converters: lrSv1kLin1218VcfToBed, lrSv1kgOntVcfToBed,
lrSvGustafsonVcfToBed, lrSvGa4kSvVcfToBed, lrSvDecodeVcfToBed,
lrSvAou1kCsvToBed, lrSvColorsDbSvVcfToBed, lrSvCardBbToBed, lrSvAprVcfToBed,
lrSvCpc1VcfToBed, lrSvVcfToBed (generic, used by han945).

Left unchanged, verified already anchor-correct: hgsvc3 and hgsvc2 (0-based
source), hprc2v21 (Ro converter prefix-trims), noyvert/tommoJp (POS is the
first deleted base), chirmade101 (1-based-closed source).

Rebuilt all affected bigBeds (hg38 + hs1 where present) and the lrSvAll merge:
3,111,026 -> 2,963,093 rows as ~148k duplicate deletions now merge.

diff --git src/hg/makeDb/scripts/lrSv/lrSvCardBbToBed.py src/hg/makeDb/scripts/lrSv/lrSvCardBbToBed.py
index 0b8fd2ce266..5d70a416ceb 100755
--- src/hg/makeDb/scripts/lrSv/lrSvCardBbToBed.py
+++ src/hg/makeDb/scripts/lrSv/lrSvCardBbToBed.py
@@ -59,30 +59,36 @@
                 continue
             nIn += 1
             f = line.rstrip("\n").split("\t")
             chrom = f[0]
             chromStart = int(f[1])
             chromEnd = int(f[2])
             svTypeRaw = f[9]
             svLenSigned = int(f[10])
             alleleFreq = fmtAf(f[11])
             alleleCount = int(f[12])
             nabecAc = int(f[13])
             hbccAc = int(f[14])
 
             svType = normalizeSvType(TYPE_FIX.get(svTypeRaw, svTypeRaw))
 
+            # The source bigBed keeps the VCF anchor base on the left of
+            # deletions; drop it so DEL coordinates match anchor-excluded
+            # callsets (svLen below is recomputed from the shifted start).
+            if svType == "DEL":
+                chromStart += 1
+
             # Canonical svLen is the feature's span on the reference; for INS
             # that is 1 bp, and the inserted-sequence length lives in insLen.
             svLen = chromEnd - chromStart
             if svType == "INS":
                 insLen = abs(svLenSigned)
             else:
                 insLen = 0
 
             # CARD now publishes diploid allele counts, matching the
             # supertrack's AC convention directly.
             ac = alleleCount
 
             featLen = insLen if svType == "INS" else svLen
             name = svName(svType, featLen, ac)
             color = svColor(svType)