8e96c1feec31b621eaae7748c43f6a8fb26bf4b5
angie
  Fri Mar 3 15:17:21 2023 -0800
Fixing error that could lead to doubled counts, caught by Jonathan in code review, thanks! refs #30709

diff --git src/hg/utils/otto/nextstrainNcov/nextstrain.py src/hg/utils/otto/nextstrainNcov/nextstrain.py
index e181536..de8b47d 100755
--- src/hg/utils/otto/nextstrainNcov/nextstrain.py
+++ src/hg/utils/otto/nextstrainNcov/nextstrain.py
@@ -345,31 +345,31 @@
             # Add to list of alts - unless it's an alt we've already seen, but from a different
             # serial mutation.  For example, there might be T>A but also T>G+G>A; don't add A twice.
             if (not thisAlt in alts):
                 alts.append(thisAlt)
                 if (thisName != varName):
                     if varName == trueRef + str(pos) + '-':
                         varName = mergedName
                     else:
                         varName += "," + mergedName
             alIx = alts.index(thisAlt) + 1
         for ix, sample in enumerate(samples):
             if (sample['variants'].get(thisName)):
                 sampleAlleles[ix] = alIx
                 if (alIx == 0 and thisRef != '-'):
                     backMutSamples.append(sampleName(sample))
-        if thisName != varName:
+        if thisRef != trueRef:
             # If this is a new merged mutation, add it to variantCounts.  If merging makes an
             # already-seen mutation then add to the existing count.
             if variantCounts.get(mergedName):
                 variantCounts[mergedName] += count
             else:
                 variantCounts[mergedName] = count
     # After handling back- and serial mutations, figure out true counts of each alt allele:
     altCounts = [ 0 for alt in alts ]
     for alIx in sampleAlleles:
         if (alIx > 0):
             altCounts[alIx - 1] += 1
     return [ [pos, varName, trueRef, ','.join(alts)],
              alts, altCounts, sampleAlleles, backMutSamples ]
 
 mergedVars = []