364f07e7cacf56df0bbd4a257956fcaac60f476b
angie
  Fri Jan 11 16:43:06 2013 -0800
Fixing VCF-to-pgSnp translation for sketchy VCF from Complete Genomics that has AN(=0) and no AC.
diff --git src/hg/lib/pgSnp.c src/hg/lib/pgSnp.c
index 8db8265..e777f12 100644
--- src/hg/lib/pgSnp.c
+++ src/hg/lib/pgSnp.c
@@ -736,52 +736,57 @@
 	gotTotalCount = TRUE;
 	// Set ref allele to total count, subtract alt counts below.
 	alCounts[0] = rec->infoElements[i].values[0].datInt;
 	break;
 	}
 for (i = 0;  i < rec->infoCount;  i++)
     if (sameString(rec->infoElements[i].key, "AC"))
 	{
 	if (rec->infoElements[i].count > 0)
 	    {
 	    gotAltCounts = TRUE;
 	    int j;
 	    for (j = 0;  j < rec->infoElements[i].count && j < alDescCount-1;  j++)
 		{
 		if (rec->infoElements[i].missingData[j])
-		    continue;
+		    alCounts[1+j] = -1;
+		else
+		    {
 		int ac = rec->infoElements[i].values[j].datInt;
 		alCounts[1+j] = ac;
 		if (gotTotalCount)
 		    alCounts[0] -= ac;
 		}
-	    while (j++ < alDescCount-1)
-		alCounts[1+j] = -1;
+		}
 	    if (gotTotalCount)
 		dyStringPrintf(dy, "%d", alCounts[0]);
 	    else
 		dyStringAppend(dy, "-1");
 	    for (j = 1;  j < alDescCount;  j++)
 		if (alCounts[j] >= 0)
 		    dyStringPrintf(dy, ",%d", alCounts[j]);
 		else
 		    dyStringAppend(dy, ",-1");
 	    }
 	break;
 	}
 if (gotTotalCount && !gotAltCounts)
+    {
     dyStringPrintf(dy, "%d", alCounts[0]);
+    for (i = 1;  i < alDescCount;  i++)
+	dyStringAppend(dy, ",-1");
+    }
 else if (!gotTotalCount && !gotAltCounts && rec->file->genotypeCount > 0)
     {
     vcfParseGenotypes(rec);
     for (i = 0;  i < alDescCount;  i++)
 	alCounts[i] = 0;
     for (i = 0;  i < rec->file->genotypeCount;  i++)
 	{
 	struct vcfGenotype *gt = &(rec->genotypes[i]);
 	if (gt == NULL)
 	    uglyf("i=%d gt=NULL wtf?\n", i);
 	if (gt->hapIxA >= 0)
 	    alCounts[(unsigned char)gt->hapIxA]++;
 	if (!gt->isHaploid && gt->hapIxB >= 0)
 	    alCounts[(unsigned char)gt->hapIxB]++;
 	}