f6133a3e4e9f571295e8e6c5b9ac9ea886b49826
chmalee
  Mon Aug 24 16:36:58 2020 -0700
Fix vcf color by function when in intergenic region, refs #26108

diff --git src/hg/hgTracks/vcfTrack.c src/hg/hgTracks/vcfTrack.c
index 6488e4f..b340224 100644
--- src/hg/hgTracks/vcfTrack.c
+++ src/hg/hgTracks/vcfTrack.c
@@ -854,30 +854,32 @@
 
 static struct txInfo *txInfoLoadNcbiRefSeq(struct seqWindow *gSeqWin, struct trackDb *gTdb)
 /* Load ncbiRefSeq[Curated] PSL (+ CDS and sequence) in current window and make txInfo for each. */
 {
 struct txInfo *txiList = NULL;
 if (!trackHubDatabase(database) && hDbHasNcbiRefSeq(database))
     {
     struct sqlConnection *conn = hAllocConn(database);
     struct hash *txiHash = hashNew(0);
     char *extraWhere = NULL;
     if (sameString(gTdb->track, "ncbiRefSeqCurated"))
         extraWhere = "qName not like 'X%'";
     else if (sameString(gTdb->track, "ncbiRefSeqPredicted"))
         extraWhere = "qName like 'X%'";
     txiList = txInfoInitFromPsl(conn, "ncbiRefSeqPsl", extraWhere, &txiHash);
+    if (txiList)
+        {
         // Now get CDS for each psl/txi:
         struct dyString *query = sqlDyStringCreate("select * from ncbiRefSeqCds where id in ");
         txiInfoAppendIdList(query, txiList);
         txInfoAddCdsFromQuery(txiHash, conn, query->string);
         // Now get transcript sequence for each psl/txi:
         struct hash *extNcbi = hashExtNcbiRefSeq(conn);
         dyStringClear(query);
         sqlDyStringPrintf(query, "select acc,extFile,file_offset,file_size from seqNcbiRefSeq "
                           "where acc in ");
         txiInfoAppendIdList(query, txiList);
         struct sqlResult *sr = sqlGetResult(conn, query->string);
         char **row;
         while ((row = sqlNextRow(sr)) != NULL)
             {
             char *name = row[0];
@@ -898,61 +900,65 @@
         sqlDyStringPrintf(query, "select id, protAcc, seq from ncbiRefSeqLink nl, ncbiRefSeqPepTable np "
                           "where nl.protAcc = np.name and id in ");
         txiInfoAppendIdList(query, txiList);
         sr = sqlGetResult(conn, query->string);
         while ((row = sqlNextRow(sr)) != NULL)
             {
             char *txId = row[0];
             char *protId = row[1];
             char *protSeq = cloneString(row[2]);
             struct txInfo *txi = hashMustFindVal(txiHash, txId);
             txi->protSeq = newDnaSeq(protSeq, strlen(protSeq), protId);
             }
         sqlFreeResult(&sr);
         hFreeConn(&conn);
         }
+    }
 return txiList;
 }
 
 static struct txInfo *txInfoLoadRefGene(struct seqWindow *gSeqWin, struct trackDb *gTdb)
 /* Load refSeqAli PSL (+ genbank CDS and sequence) in current window and make txInfo for each. */
 {
 struct txInfo *txiList = NULL;
 if (!trackHubDatabase(database))
     {
     initGenbankTableNames(database);
     struct sqlConnection *conn = hAllocConn(database);
     struct hash *txiHash = NULL;
     txiList = txInfoInitFromPsl(conn, "refSeqAli", NULL, &txiHash);
+    if (txiList)
+        {
         // Now get CDS for each psl/txi:
         struct dyString *query = sqlDyStringCreate("select i.acc, c.name from %s i, %s c "
                                                    "where c.id = i.cds and i.acc in ",
                                                    gbCdnaInfoTable, cdsTable);
         txiInfoAppendIdList(query, txiList);
         txInfoAddCdsFromQuery(txiHash, conn, query->string);
         // Now get transcript and translated sequence for each psl/txi:
         struct txInfo *txi;
         for (txi = txiList;  txi != NULL;  txi = txi->next)
             {
             txi->txSeq = hGenBankGetMrna(database, txi->psl->qName, NULL);
             if (txi->cds->end > txi->cds->start && txi->cds->startComplete)
                 {
                 txi->protSeq = translateSeq(txi->txSeq, txi->cds->start, FALSE);
                 aaSeqZToX(txi->protSeq);
                 }
             }
         }
+    }
 return txiList;
 }
 
 static struct txInfo *txInfoLoadBigGenePred(struct seqWindow *gSeqWin, struct trackDb *gTdb)
 /* Load up bigGenePred items in current window and make txInfo for each. */
 {
 struct txInfo *txiList = NULL;
 char *fileName = cloneString(trackDbSetting(gTdb, "bigDataUrl"));
 if (fileName == NULL)
     fileName = cloneString(trackDbSetting(gTdb, "bigGeneDataUrl"));
 if (isNotEmpty(fileName))
     {
     struct bbiFile *bbi = bigBedFileOpen(fileName);
     struct lm *lm = lmInit(0);
     struct bigBedInterval *bbList = bigBedIntervalQuery(bbi, chromName, winStart,