8931ab6b05b124503660f86d60fe34a38266d716
max
  Fri May 29 06:53:20 2020 -0700
OMIM: not showing phenotype table when there are no phenotypes and add more spaces, refs #18419

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 32ee090..c4926cf 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -10576,42 +10576,48 @@
 struct sqlResult *sr;
 char query[256];
 char **row;
 
 // be tolerant of old table schema
 if (sqlColumnExists(conn, "omimPhenotype", "inhMode"))
     sqlSafef(query, sizeof(query),
           "select description, %s, phenotypeId, inhMode from omimPhenotype where omimId=%s order by description",
           omimPhenotypeClassColName, itemName);
 else
     // E.g. on a mirror that has not updated their OMIM tables yet
     sqlSafef(query, sizeof(query),
           "select description, %s, phenotypeId, 'data-missing' from omimPhenotype where omimId=%s order by description",
           omimPhenotypeClassColName, itemName);
 
-sr = sqlMustGetResult(conn, query);
+sr = sqlStoreResult(conn, query);
+
+if (sqlCountRows(sr)==0) {
+    sqlFreeResult(&sr);
+    return;
+}
+
 char *phenotypeClass, *phenotypeId, *disorder, *inhMode;
 
-printf("<table class='omimTbl'>\n");
-printf("<thead>\n");
-printf("<th>Phenotype</th>\n");
-printf("<th style='width:100px'>Phenotype MIM Number</th>\n");
-printf("<th>Inheritance</th>\n");
-printf("<th>Phenotype Key</th>\n");
-printf("</thead>\n");
+puts("<table style='margin-top: 15px' class='omimTbl'>\n");
+puts("<thead>\n");
+puts("<th>Phenotype</th>\n");
+puts("<th style='width:100px'>Phenotype MIM Number</th>\n");
+puts("<th>Inheritance</th>\n");
+puts("<th>Phenotype Key</th>\n");
+puts("</thead>\n");
 
-printf("<tbody>\n");
+puts("<tbody>\n");
 while ((row = sqlNextRow(sr)) != NULL)
     {
     disorder       = row[0];
     phenotypeClass = row[1];
     phenotypeId    = row[2];
     inhMode        = row[3];
 
     puts("<tr>\n");
 
     puts("<td>");
     if (disorder)
         puts(disorder);
     puts("</td>\n");
 
     puts("<td>");
@@ -10642,32 +10648,32 @@
                 {
                 puts(" - ");
                 puts(descs[phenoClass-1]);
                 }
             else
                 // just in case that they ever add another class in the future
                 puts(phenotypeClass);
             }
         }
     puts("</td>");
 
     puts("</tr>");
     }
 
 sqlFreeResult(&sr);
-printf("<tbody>\n");
-printf("</table>\n");
+puts("<tbody>\n");
+puts("</table>\n");
 }
 
 void printOmimGene2Details(struct trackDb *tdb, char *itemName, boolean encode)
 /* Print details of an omimGene2 entry. */
 {
 struct sqlConnection *conn  = hAllocConn(database);
 char query[256];
 struct sqlResult *sr;
 char **row;
 char *url = tdb->url;
 char *chrom, *chromStart, *chromEnd;
 
 chrom      = cartOptionalString(cart, "c");
 chromStart = cartOptionalString(cart, "o");
 chromEnd   = cartOptionalString(cart, "t");
@@ -10689,31 +10695,31 @@
 
     struct dyString *symQuery = newDyString(1024);
     sqlDyStringPrintf(symQuery, "SELECT approvedSymbol from omimGeneMap2 where omimId=%s", itemName);
     char *approvSym = sqlQuickString(conn, symQuery->string);
     if (approvSym) {
 	printf("<B>HGNC-approved symbol:</B> %s", approvSym);
     }
 
     sqlSafef(query, sizeof(query),
           "select geneName from omimGeneMap2 where omimId=%s;", itemName);
     char *longName = sqlQuickString(conn, query);
     if (longName) {
 	printf(" &mdash; %s", longName);
         freez(&longName);
     }
-    puts("<BR>");
+    puts("<BR><BR>");
 
     printPosOnChrom(chrom, atoi(chromStart), atoi(chromEnd), NULL, FALSE, itemName);
 
     sqlSafef(query, sizeof(query),
           "select geneSymbol from omimGeneMap2 where omimId=%s;", itemName);
     char *altSyms = sqlQuickString(conn, query);
 
     if (altSyms)
         {
         if (approvSym) 
             {
             char symRe[255];
             safef(symRe, sizeof(symRe), "^%s, ", approvSym);
             altSyms = replaceRegEx(altSyms, "", symRe, 0);
             }