8ea61fe719baa254eb7411b93cdd3de71c9cc7f3
angie
  Thu Aug 13 13:32:18 2020 -0700
Suppress diploid-specific descriptions when species is not diploid.  refs #25409

diff --git src/hg/hgc/vcfClick.c src/hg/hgc/vcfClick.c
index eb6f2b6..a7ad5f3 100644
--- src/hg/hgc/vcfClick.c
+++ src/hg/hgc/vcfClick.c
@@ -247,64 +247,74 @@
 }
 
 static void vcfGenotypeTable(struct vcfRecord *rec, char *track, char **displayAls)
 /* Put the table containing details about each genotype into a collapsible section. */
 {
 static struct dyString *tmp1 = NULL;
 if (tmp1 == NULL)
     tmp1 = dyStringNew(0);
 jsBeginCollapsibleSection(cart, track, "genotypes", "Detailed genotypes", FALSE);
 dyStringClear(tmp1);
 dyStringAppend(tmp1, rec->format);
 struct vcfFile *vcff = rec->file;
 enum vcfInfoType formatTypes[256];
 char *formatKeys[256];
 int formatCount = chopString(tmp1->string, ":", formatKeys, ArraySize(formatKeys));
-puts("<B>Genotype info key:</B><BR>");
+boolean firstInfo = TRUE;
 int i;
 for (i = 0;  i < formatCount;  i++)
     {
     if (sameString(formatKeys[i], vcfGtGenotype))
 	continue;
+    if (firstInfo)
+        {
+        puts("<B>Genotype info key:</B><BR>");
+        firstInfo = FALSE;
+        }
     const struct vcfInfoDef *def = vcfInfoDefForGtKey(vcff, formatKeys[i]);
     char *desc = def ? def->description : "<em>not described in VCF header</em>";
     printf("&nbsp;&nbsp;<B>%s:</B> %s<BR>\n", formatKeys[i], desc);
     formatTypes[i] = def ? def->type : vcfInfoString;
     }
 hTableStart();
-puts("<TR><TH>Sample ID</TH><TH>Genotype</TH><TH>Phased?</TH>");
+boolean isDiploid = sameString(vcfHaplotypeOrSample(cart), "Haplotype");
+puts("<TR><TH>Sample ID</TH><TH>Genotype</TH>");
+if (isDiploid)
+    puts("<TH>Phased?</TH>");
 for (i = 0;  i < formatCount;  i++)
     {
     if (sameString(formatKeys[i], vcfGtGenotype))
 	continue;
     printf("<TH>%s</TH>", formatKeys[i]);
     }
 puts("</TR>\n");
 for (i = 0;  i < vcff->genotypeCount;  i++)
     {
     struct vcfGenotype *gt = &(rec->genotypes[i]);
     char *hapA = ".", *hapB = ".";
     if (gt->hapIxA >= 0)
 	hapA = displayAls[(unsigned char)gt->hapIxA];
     if (gt->isHaploid)
 	hapB = "";
     else if (gt->hapIxB >= 0)
 	hapB = displayAls[(unsigned char)gt->hapIxB];
     char sep = gt->isHaploid ? ' ' : gt->isPhased ? '|' : '/';
     char *phasing = gt->isHaploid ? NA : gt->isPhased ? "Y" : "n";
-    printf("<TR><TD>%s</TD><TD>%s%c%s</TD><TD>%s</TD>", vcff->genotypeIds[i],
-	   hapA, sep, hapB, phasing);
+    printf("<TR><TD>%s</TD><TD>%s%c%s</TD>", vcff->genotypeIds[i],
+	   hapA, sep, hapB);
+    if (isDiploid)
+        printf("<TD>%s</TD>", phasing);
     int j;
     for (j = 0;  j < gt->infoCount;  j++)
 	{
 	if (sameString(formatKeys[j], vcfGtGenotype))
 	    continue;
 	printf("<TD>");
 	struct vcfInfoElement *el = &(gt->infoElements[j]);
 	int k;
 	for (k = 0;  k < el->count;  k++)
 	    {
 	    if (k > 0)
 		printf(", ");
 	    if (el->missingData[k])
 		printf(".");
 	    else
@@ -327,38 +337,45 @@
 static void vcfGenotypesDetails(struct vcfRecord *rec, struct trackDb *tdb, char **displayAls)
 /* Print summary of allele and genotype frequency, plus collapsible section
  * with table of genotype details. */
 {
 struct vcfFile *vcff = rec->file;
 if (vcff->genotypeCount == 0)
     return;
 // Wrapper table for collapsible section:
 puts("<TABLE>");
 pushWarnHandler(ignoreEm);
 vcfParseGenotypes(rec);
 popWarnHandler();
 int *gtCounts = NULL, *alCounts = NULL;;
 int phasedGts = 0, diploidCount = 0;
 vcfCountGenotypes(rec, &gtCounts, &alCounts, &phasedGts, &diploidCount);
+boolean isDiploid = sameString(vcfHaplotypeOrSample(cart), "Haplotype");
+if (isDiploid)
+    {
     printf("<B>Genotype count:</B> %d", vcff->genotypeCount);
     if (diploidCount == 0)
         printf(" (haploid)");
     else if (diploidCount != vcff->genotypeCount)
         printf(" (%d phased, %d diploid, %d haploid)", phasedGts, diploidCount,
                vcff->genotypeCount - diploidCount);
     else
         printf(" (%d phased)", phasedGts);
+    }
+else
+    printf("<B>Sample count:</B> %d", vcff->genotypeCount);
+
 puts("<BR>");
 int totalAlleles = vcff->genotypeCount + diploidCount;
 double refAf = (double)alCounts[0]/totalAlleles;
 printf("<B>Alleles:</B> %s: %d (%.3f%%)", displayAls[0], alCounts[0], 100*refAf);
 int i;
 for (i = 1;  i < rec->alleleCount;  i++)
     {
     double altAf = (double)alCounts[i]/totalAlleles;
     printf("; %s: %d (%.3f%%)", displayAls[i], alCounts[i], 100*altAf);
     }
 if (alCounts[rec->alleleCount] > 0)
     printf("; unknown: %d (%.3f%%)", alCounts[rec->alleleCount],
            100 * (double)alCounts[rec->alleleCount]/totalAlleles);
 puts("<BR>");
 if (vcff->genotypeCount > 1 && diploidCount > 0)