b73fd861b426ef34c2a56da6a26a311850c276dc
tdreszer
  Mon Jul 16 17:30:32 2012 -0700
Maybe last batch of many checkins as dictated by Jim.  Formatting if and limiting lines to 100 chars.  Changes (mostly) limited to lines last touched by tdreszer (git blame) so as not to ruin history. Some things not mine were 'fixed' so that my changes were in context. None of these changes should affect executables in any way.
diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index bb1df42..3b422d3 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -533,31 +533,32 @@
     else
         {
         dyStringPrintf(dy, "&%s=%s", encodedTableName, hStringFromTv(vis));
         }
     subgroupFree(&view);
     freeMem(encodedTableName);
     }
 else
     {
     if (toggleGroup != NULL)
         {
         int vis = toggleGroup->visibility;
         char *encodedMapName = cgiEncode(toggleGroup->track);
         if (vis == tvDense)
             {
-            if(!toggleGroup->canPack || (tdbIsComposite(toggleGroup->tdb) && subgroupingExists(toggleGroup->tdb,"view")))
+            if (!toggleGroup->canPack
+            || (tdbIsComposite(toggleGroup->tdb) && subgroupingExists(toggleGroup->tdb,"view")))
                 vis = tvFull;
             else
                 vis = tvPack;
             }
         else if (vis == tvFull || vis == tvPack || vis == tvSquish)
             vis = tvDense;
         dyStringPrintf(dy, "&%s=%s", encodedMapName, hStringFromTv(vis));
         freeMem(encodedMapName);
         }
     }
 return dy;
 }
 
 boolean isWithCenterLabels(struct track *track)
 /* Cases: only TRUE when global withCenterLabels is TRUE
@@ -570,31 +571,33 @@
     {
     char *centerLabelsDense = trackDbSetting(track->tdb, "centerLabelsDense");
     if (centerLabelsDense)
         {
         return sameWord(centerLabelsDense, "on");
         }
     }
 return withCenterLabels;
 }
 
 boolean isCenterLabelConditionallySeen(struct track *track)
 // returns FALSE if track and prevTrack have same parent, and are both dense subtracks
 {
 if (isCenterLabelConditional(track))
     {
-    if (track->prevTrack && track->parent == track->prevTrack->parent && isCenterLabelConditional(track->prevTrack))
+    if (track->prevTrack
+    &&  track->parent == track->prevTrack->parent
+    &&  isCenterLabelConditional(track->prevTrack))
         return FALSE;
     }
 return isWithCenterLabels(track);
 }
 
 void mapStatusMessage(char *format, ...)
 /* Write out stuff that will cause a status message to
  * appear when the mouse is over this box. */
 {
 va_list(args);
 va_start(args, format);
 hPrintf(" TITLE=\"");
 hvPrintf(format, args);
 hPutc('"');
 va_end(args);
@@ -617,81 +620,85 @@
 
 if (extra != NULL)
     {
     dyStringAppend(ui, "&");
     dyStringAppend(ui, extra);
     }
 if (chrom == NULL)
     {
     chrom = chromName;
     start = winStart;
     end = winEnd;
     }
 if(theImgBox && curImgTrack)
     {
     char link[512];
-    safef(link,sizeof(link),"%s?position=%s:%d-%d&%s",hgTracksName(), chrom, start+1, end, ui->string); // NOTE: position may need removing due to portal
+    safef(link,sizeof(link),"%s?position=%s:%d-%d&%s",       // NOTE: position may need removing
+          hgTracksName(), chrom, start+1, end, ui->string);  //       due to portal
     if(!revCmplDisp && x < insideX)  // Do not toggle on side label!
         {
         width -= (insideX+1 - x);
         if(width <= 1)
             {
             freeDyString(&ui);
             return;
             }
         x = insideX+1;
         }
     else if(revCmplDisp && (x+width) >= insideWidth)
         {
         width -= (x+width) - insideWidth + 1;
         if(width <= 1)
             {
             freeDyString(&ui);
             return;
             }
         }
     //#ifdef IMAGEv2_SHORT_MAPITEMS
     //    if(x < insideX && x+width > insideX)
-    //        warn("mapBoxReinvoke(%s) map item spanning slices. LX:%d TY:%d RX:%d BY:%d  link:[%s]",hStringFromTv(toggleGroup->visibility),x, y, x+width, y+height, link);
+    //      warn("mapBoxReinvoke(%s) map item spanning slices. LX:%d TY:%d RX:%d BY:%d  link:[%s]",
+    //           hStringFromTv(toggleGroup->visibility),x, y, x+width, y+height, link);
     //#endif//def IMAGEv2_SHORT_MAPITEMS
-    imgTrackAddMapItem(curImgTrack,link,(char *)(message != NULL?message:NULL),x, y, x+width, y+height,
-                       track ? track->track : NULL);
+    imgTrackAddMapItem(curImgTrack,link,(char *)(message != NULL?message:NULL),x, y, x+width,
+                       y+height, track ? track->track : NULL);
     }
 else
     {
     hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, x+width, y+height);
     hPrintf("HREF=\"%s?position=%s:%d-%d",
         hgTracksName(), chrom, start+1, end);
     hPrintf("&%s\"", ui->string);
     if (message != NULL)
         mapStatusMessage("%s", message);
     hPrintf("%s>\n", dyStringContents(id));
     }
 freeDyString(&ui);
 freeDyString(&id);
 }
 
 void mapBoxToggleVis(struct hvGfx *hvg, int x, int y, int width, int height,
 	struct track *curGroup)
 /* Print out image map rectangle that would invoke this program again.
  * program with the current track expanded. */
 {
 char buf[256];
 if(tdbIsCompositeChild(curGroup->tdb))
-    safef(buf, sizeof(buf),"Click to alter the display density of %s and similar subtracks", curGroup->shortLabel);
+    safef(buf, sizeof(buf),"Click to alter the display density of %s and similar subtracks",
+          curGroup->shortLabel);
 else if(tdbIsComposite(curGroup->tdb))
-    safef(buf, sizeof(buf),"Click to alter the maximum display mode density for all %s subtracks", curGroup->shortLabel);
+    safef(buf, sizeof(buf),"Click to alter the maximum display mode density for all %s subtracks",
+          curGroup->shortLabel);
 else
     safef(buf, sizeof(buf),"Click to alter the display density of %s", curGroup->shortLabel);
 
 mapBoxReinvoke(hvg, x, y, width, height, curGroup, TRUE, NULL, 0, 0, buf, NULL);
 }
 
 void mapBoxJumpTo(struct hvGfx *hvg, int x, int y, int width, int height, struct track *track,
 	char *newChrom, int newStart, int newEnd, char *message)
 /* Print out image map rectangle that would invoke this program again
  * at a different window. */
 {
 mapBoxReinvoke(hvg, x, y, width, height, track, FALSE, newChrom, newStart, newEnd,
 	       message, NULL);
 
 }
@@ -714,55 +721,55 @@
                        char *extra)
 /* Print out image map rectangle that would invoke the hgc (human genome click)
  * program. */
 {
 struct dyString *id = dyStringNew(0);
 if (x < 0) x = 0;
 x = hvGfxAdjXW(hvg, x, width);
 int xEnd = x+width;
 int yEnd = y+height;
 dyStringPrintf(id, " id='%s'", track);
 
 if (x < xEnd)
     {
     char *encodedItem = cgiEncode(item);
     char *encodedTrack = cgiEncode(track);
-
     if(theImgBox && curImgTrack)
         {
         char link[512];
         if (directUrl)
             {
             safef(link,sizeof(link),directUrl, item, chromName, start, end, encodedTrack, database);
             if (withHgsid)
                 safef(link+strlen(link),sizeof(link)-strlen(link),"&%s", cartSidUrlString(cart));
             }
         else
             {
             safef(link,sizeof(link),"%s&c=%s&o=%d&t=%d&g=%s&i=%s",
                 hgcNameAndSettings(), chromName, start, end, encodedTrack, encodedItem); // NOTE: chopped out winStart/winEnd
             }
         if (extra != NULL)
             safef(link+strlen(link),sizeof(link)-strlen(link),"&%s", extra);
         // Add map item to currnent map (TODO: pass in map)
         #ifdef IMAGEv2_SHORT_MAPITEMS
-            if(!revCmplDisp && x < insideX && xEnd > insideX)  // Why does insideX=118 in reverse complement??
+        if (!revCmplDisp && x < insideX && xEnd > insideX)
                     x = insideX;
             else if (revCmplDisp && x < insideWidth && xEnd > insideWidth)
                     xEnd = insideWidth - 1;
         #endif//def IMAGEv2_SHORT_MAPITEMS
-        imgTrackAddMapItem(curImgTrack,link,(char *)(statusLine!=NULL?statusLine:NULL),x, y, xEnd, yEnd, track);
+        imgTrackAddMapItem(curImgTrack,link,(char *)(statusLine!=NULL?statusLine:NULL),
+                           x, y, xEnd, yEnd, track);
         }
     else
         {
         hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, xEnd, yEnd);
         if (directUrl)
             {
             hPrintf("HREF=\"");
             hPrintf(directUrl, item, chromName, start, end, encodedTrack, database);
             if (withHgsid)
                 hPrintf("&%s", cartSidUrlString(cart));
             }
         else
             {
             hPrintf("HREF=\"%s&c=%s&o=%d&t=%d&g=%s&i=%s&c=%s&l=%d&r=%d&db=%s&pix=%d",
                 hgcNameAndSettings(), chromName, start, end, encodedTrack, encodedItem,
@@ -925,32 +932,32 @@
 	}
     else
         {
         /* restore char for unaligned sequence to lower case */
         if (tolower(cBuf[0]) == tolower(UNALIGNED_SEQ))
             cBuf[0] = UNALIGNED_SEQ;
 
         /* display bases */
         hvGfxTextCentered(hvg, x1+x, y, x2-x1, height, clr, font, cBuf);
         }
     }
 freez(&inMotif);
 }
 
 void spreadAlignStringProt(struct hvGfx *hvg, int x, int y, int width, int height,
-		       Color color, MgFont *font, char *text,
-		       char *match, int count, bool dots, bool isCodon, int seqStart, int offset)
+                           Color color, MgFont *font, char *text, char *match, int count,
+                           bool dots, bool isCodon, int seqStart, int offset)
 /* Draw evenly spaced letters in string for protein sequence.
  * For multiple alignments,
  * supply a non-NULL match string, and then matching letters will be colored
  * with the main color, mismatched letters will have alt color (or
  * matching letters with a dot, and mismatched bases with main color if this
  * option is selected).
  * Draw a vertical bar in orange where sequence lacks gaps that
  * are in reference sequence (possible insertion) -- this is indicated
  * by an escaped insert count in the sequence.  The escape char is backslash.
  * The count param is the number of bases to print, not length of
  * the input line (text) */
 {
 char cBuf[2] = "";
 int i,j,textPos=0;
 int x1, x2, xx1, xx2;
@@ -1084,33 +1091,32 @@
                     }
             	else
                     {
                     hvGfxBox(hvg, xx1+x, y, xx2-xx1, height, color2);
                     }
 
 		/* display AA */
 	    	hvGfxTextCentered(hvg, x1+x, y, x2-x1, height, clr, font, cBuf);
 	    	}
 	    }
 	}
     }
 freez(&inMotif);
 }
 
-void spreadBasesString(struct hvGfx *hvg, int x, int y, int width,
-                        int height, Color color, MgFont *font,
-                        char *s, int count, bool isCodon)
+void spreadBasesString(struct hvGfx *hvg, int x, int y, int width, int height, Color color,
+                       MgFont *font, char *s, int count, bool isCodon)
 /* Draw evenly spaced letters in string. */
 {
 spreadAlignString(hvg, x, y, width, height, color, font, s,
                         NULL, count, FALSE, isCodon);
 }
 
 void drawScaledBox(struct hvGfx *hvg, int chromStart, int chromEnd,
 	double scale, int xOff, int y, int height, Color color)
 /* Draw a box scaled from chromosome to window coordinates.
  * Get scale first with scaleForPixels. */
 {
 int x1 = round((double)(chromStart-winStart)*scale) + xOff;
 int x2 = round((double)(chromEnd-winStart)*scale) + xOff;
 int w = x2-x1;
 if (w < 1)
@@ -1596,34 +1602,34 @@
 char query[256];
 struct sqlConnection *conn = hAllocConn(database);
 
 safef(query, sizeof(query), "select * from oregannoAttr where id = '%s' and attribute = 'type'", el->id);
 attr = oregannoAttrLoadByQuery(conn, query);
 hFreeConn(&conn);
 if (attr == NULL)
     {
     AllocVar(attr);
     attr->attrVal = cloneString("NULL");
     attr->id = NULL; /* so free will work */
     attr->attribute = NULL;
     }
 for (cnt = 0; cnt < oregannoTypeSize; cnt++)
     {
-    if (!cartVarExists(cart, oregannoTypeString[cnt]) ||
-        (cartString(cart, oregannoTypeString[cnt]) != NULL &&
-        differentString(cartString(cart, oregannoTypeString[cnt]), "0") &&
-        sameString(oregannoTypeDbValue[cnt], attr->attrVal)))
+    if (!cartVarExists(cart, oregannoTypeString[cnt])
+    ||  (  cartString(cart, oregannoTypeString[cnt]) != NULL
+        && differentString(cartString(cart, oregannoTypeString[cnt]), "0")
+        && sameString(oregannoTypeDbValue[cnt], attr->attrVal)))
         {
         oregannoAttrFree(&attr);
         return TRUE; /* include this type */
         }
     }
 oregannoAttrFree(&attr);
 return FALSE;
 }
 
 void loadOreganno (struct track *tg)
 /* loads the oreganno track */
 {
 struct oreganno *list = NULL;
 struct sqlConnection *conn = hAllocConn(database);
 struct sqlResult *sr;
@@ -1981,43 +1987,46 @@
     safef(pos, sizeof(pos), "%s:%d-%d", chromName, winStart+1, winEnd);
     cartSetString(cart, "position", cloneString(pos));
     }
 }
 
 enum {blackShadeIx=9,whiteShadeIx=0};
 
 char *getScoreFilterClause(struct cart *cart,struct trackDb *tdb,char *scoreColumn)
 // Returns "score >= ..." extra where clause if one is needed
 {
 if (scoreColumn == NULL)
     scoreColumn = "score";
 
 struct dyString *extraWhere = newDyString(128);
 boolean and = FALSE;
-extraWhere = dyAddFilterByClause(cart,tdb,extraWhere,NULL,&and); // gets trackDb 'filterBy' clause, which may filter by 'score', 'name', etc
+// gets trackDb 'filterBy' clause, which may filter by 'score', 'name', etc
+extraWhere = dyAddFilterByClause(cart,tdb,extraWhere,NULL,&and);
 extraWhere = dyAddAllScoreFilters(cart,tdb,extraWhere,&and); // All *Filter style filters
-if (and == FALSE || strstrNoCase(extraWhere->string,"score in ") == NULL) // Cannot have both 'filterBy' score and 'scoreFilter'
+if (and == FALSE      // Cannot have both 'filterBy' score and 'scoreFilter'
+||  strstrNoCase(extraWhere->string,"score in ") == NULL)
     extraWhere = dyAddFilterAsInt(cart,tdb,extraWhere,SCORE_FILTER,"0:1000",scoreColumn,&and);
 if (sameString(extraWhere->string, ""))
     return NULL;
 return dyStringCannibalize(&extraWhere);
 }
 
 
 void loadLinkedFeaturesWithLoaders(struct track *tg, struct slList *(*itemLoader)(char **row),
 				   struct linkedFeatures *(*lfFromWhatever)(struct slList *item),
-				   char *scoreColumn, char *moreWhere, boolean (*itemFilter)(struct slList *item))
+                                   char *scoreColumn, char *moreWhere,
+                                   boolean (*itemFilter)(struct slList *item))
 /* Make a linkedFeatures loader by providing three functions: (1) a regular */
 /* item loader found in all autoSql modules, (2) a custom myStruct->linkedFeatures */
 /* translating function, and (3) a function to free the the thing loaded in (1). */
 {
 struct sqlConnection *conn = hAllocConn(database);
 struct sqlResult *sr = NULL;
 char **row;
 int rowOffset;
 struct linkedFeatures *lfList = NULL;
 char extraWhere[256] ;
 /* Use tg->tdb->track because subtracks inherit composite track's tdb
  * by default, and the variable is named after the composite track. */
 if ((scoreColumn != NULL) && (cartVarExistsAnyLevel(cart, tg->tdb, FALSE, SCORE_FILTER)))
     {
     char *scoreFilterClause = getScoreFilterClause(cart, tg->tdb,scoreColumn);
@@ -2334,33 +2343,32 @@
 const struct linkedFeatures *b = *((struct linkedFeatures **)vb);
 int diff = a->filterColor - b->filterColor;
 if (diff == 0)
     diff = a->grayIx - b->grayIx;
 return diff;
 }
 
 int linkedFeaturesCmpStart(const void *va, const void *vb)
 /* Help sort linkedFeatures by starting pos. */
 {
 const struct linkedFeatures *a = *((struct linkedFeatures **)va);
 const struct linkedFeatures *b = *((struct linkedFeatures **)vb);
 return a->start - b->start;
 }
 
-void clippedBarbs(struct hvGfx *hvg, int x, int y,
-	int width, int barbHeight, int barbSpacing, int barbDir, Color color,
-	boolean needDrawMiddle)
+void clippedBarbs(struct hvGfx *hvg, int x, int y, int width,
+                  int barbHeight, int barbSpacing, int barbDir, Color color, boolean needDrawMiddle)
 /* Draw barbed line.  Clip it to fit the window first though since
  * some barbed lines will span almost the whole chromosome, and the
  * clipping at the lower level is not efficient since we added
  * PostScript output support. */
 {
 int x2 = x + width;
 
 if (barbDir == 0)
     return;
 
 x = max(x, hvg->clipMinX);
 x2 = min(x2, hvg->clipMaxX);
 width = x2 - x;
 if (width > 0)
     hvGfxBarbedHorizontalLine(hvg, x, y, width, barbHeight, barbSpacing, barbDir,
@@ -2693,68 +2701,67 @@
 	    drawScaledBoxSample(hvg, s2, e, scale, xOff, y+shortOff, shortHeight,
 		lf->highlightColor, lf->score);
 	    drawScaledBoxSample(hvg, s2, e, scale, xOff+1, y+shortOff+1, shortHeight-2,
 		color, lf->score);
 	    }
 	else
 	    {
 	    drawScaledBoxSample(hvg, s2, e, scale, xOff, y+shortOff, shortHeight,
 		color, lf->score);
 	    }
 	e = s2;
 	}
     /* Draw "tall" portion of exon (or codon) */
     if (e > s)
 	{
-        if (drawOpt > baseColorDrawOff &&
-            e + 6 >= winStart && s - 6 < winEnd &&
-	    (e-s <= 3 || !baseColorNeedsCodons))
-                baseColorDrawItem(tg, lf, sf->grayIx, hvg, xOff, y,
-				  scale, font, s, e, heightPer,
-				  zoomedToCodonLevel, mrnaSeq, sf, psl,
-				  drawOpt,
-				  MAXPIXELS, winStart, color);
+        if (drawOpt > baseColorDrawOff
+        &&  e + 6 >= winStart
+        &&  s - 6 <  winEnd
+        &&  (e-s <= 3 || !baseColorNeedsCodons))
+            baseColorDrawItem(tg, lf, sf->grayIx, hvg, xOff, y, scale, font, s, e, heightPer,
+                              zoomedToCodonLevel, mrnaSeq, sf, psl, drawOpt, MAXPIXELS, winStart,
+                              color);
         else
             {
 	    if (lf->highlightColor && (lf->highlightMode == highlightOutline))
 		{
 		drawScaledBoxSample(hvg, s, e, scale, xOff, y, heightPer,
 				    lf->highlightColor, lf->score );
 		drawScaledBoxSample(hvg, s, e, scale, xOff+1, y+1, heightPer-2,
 				    color, lf->score );
 		}
 	    else
 		{
 		drawScaledBoxSample(hvg, s, e, scale, xOff, y, heightPer,
 				    color, lf->score );
 		}
 
-            if (exonArrowsAlways || (exonArrows &&
                 /* Display barbs only if no intron is visible on the item.
                    This occurs when the exon completely spans the window,
                    or when it is the first or last intron in the feature and
                    the following/preceding intron isn't visible */
-                (sf->start <= winStart || sf->start == lf->start) &&
-                (sf->end >= winEnd || sf->end == lf->end)))
+            if (exonArrowsAlways
+            || (  exonArrows
+               && (sf->start <= winStart || sf->start == lf->start)
+               && (sf->end   >= winEnd   || sf->end   == lf->end)))
                     {
                     Color barbColor = hvGfxContrastingColor(hvg, color);
                     x1 = round((double)((int)s-winStart)*scale) + xOff;
                     x2 = round((double)((int)e-winStart)*scale) + xOff;
                     w = x2-x1;
-                    clippedBarbs(hvg, x1+1, midY, x2-x1-2,
-		    		tl.barbHeight, tl.barbSpacing, lf->orientation,
-                                barbColor, TRUE);
+                clippedBarbs(hvg, x1+1, midY, x2-x1-2, tl.barbHeight, tl.barbSpacing,
+                             lf->orientation, barbColor, TRUE);
                     }
             }
 	}
     }
 if ((intronGap > 0) || chainLines)
     lfDrawSpecialGaps(lf, intronGap, chainLines, gapFactor,
 		      tg, hvg, xOff, y, scale, color, bColor, vis);
 
 if (vis != tvDense)
     {
     /* If highlighting differences between aligned sequence and genome when
      * zoomed way out, this must be done in a separate pass after exons are
      * drawn so that exons sharing the pixel don't overdraw differences. */
     if (indelShowQueryInsert || indelShowPolyA)
 	baseColorOverdrawQInsert(tg, lf, hvg, xOff, y, scale, heightPer,
@@ -2882,32 +2889,32 @@
 		    char *itemName, char *mapItemName, int start, int end,
 		    int x, int y, int width, int height)
 /* This is meant to be used by genericDrawItems to set to tg->mapItem in */
 /* case tg->mapItem isn't set to anything already. */
 {
 // Don't bother if we are imageV2 and a dense child.
 if(!theImgBox || tg->limitedVis != tvDense || !tdbIsCompositeChild(tg->tdb))
     {
     char *directUrl = trackDbSetting(tg->tdb, "directUrl");
     boolean withHgsid = (trackDbSetting(tg->tdb, "hgsid") != NULL);
     mapBoxHgcOrHgGene(hvg, start, end, x, y, width, height, tg->track,
                     mapItemName, itemName, directUrl, withHgsid, NULL);
     }
 }
 
-void genericDrawNextItemStuff(struct track *tg, struct hvGfx *hvg, enum trackVisibility vis, struct slList *item,
-                    int x2, int textX, int y, int heightPer,
+void genericDrawNextItemStuff(struct track *tg, struct hvGfx *hvg, enum trackVisibility vis,
+                              struct slList *item, int x2, int textX, int y, int heightPer,
                     boolean snapLeft, Color color)
 /* After the item is drawn in genericDrawItems, draw next/prev item related */
 /* buttons and the corresponding mapboxes. */
 {
 int buttonW = heightPer-1 + 2*NEXT_ITEM_ARROW_BUFFER;
 int s = tg->itemStart(tg, item);
 int e = tg->itemEnd(tg, item);
 boolean rButton = FALSE;
 boolean lButton = FALSE;
 /* Draw the actual triangles.  These are always at the edge of the window. */
 if (s < winStart)
     {
     lButton = TRUE;
     hvGfxNextItemButton(hvg, insideX + NEXT_ITEM_ARROW_BUFFER, y,
             heightPer-1, heightPer-1, color, MG_WHITE, FALSE);
@@ -2926,32 +2933,32 @@
         {
         tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
                 s, e, textX, y, insideX-textX, heightPer);
         tg->nextPrevExon(tg, hvg, item, insideX, y, buttonW, heightPer, FALSE);
         if (rButton)
             {
             tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
                 s, e, insideX + buttonW, y, x2 - (insideX + 2*buttonW), heightPer);
             tg->nextPrevExon(tg, hvg, item, x2-buttonW, y, buttonW, heightPer, TRUE);
             }
         else
             tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
                 s, e, insideX + buttonW, y, x2 - (insideX + buttonW), heightPer);
         }
     else if (snapLeft && rButton)
-        /* This is a special case where there's a next-item button, NO */
-        /* prev-item button, AND the gene name is drawn left of the browser window. */
+        // This is a special case where there's a next-item button, NO prev-item button,
+        // AND the gene name is drawn left of the browser window.
         {
         tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
                 s, e, textX, y, x2 - buttonW - textX, heightPer);
         tg->nextPrevExon(tg, hvg, item, x2-buttonW, y, buttonW, heightPer, TRUE);
         }
     else if (rButton)
         {
         tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
                 s, e, textX, y, w - buttonW, heightPer);
         tg->nextPrevExon(tg, hvg, item, x2-buttonW, y, buttonW, heightPer, TRUE);
         }
     else
         tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
                 s, e, textX, y, w, heightPer);
         }
@@ -3134,32 +3141,31 @@
     if (w > 0)
         {
         if (nextItemCompatible(tg))
             genericDrawNextItemStuff(tg, hvg, vis, item, x2, textX, y, tg->heightPer, FALSE,
                                      color);
         else
             {
             tg->mapItem(tg, hvg, item, tg->itemName(tg, item),
                         tg->mapItemName(tg, item), s, e, textX, y, w, tg->heightPer);
             }
         }
     }
     withIndividualLabels = TRUE; /* reset in case done with pgSnp */
 }
 
-static void genericDrawItemsPackSquish(struct track *tg,
-        int seqStart, int seqEnd,
+static void genericDrawItemsPackSquish(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width,
         MgFont *font, Color color, enum trackVisibility vis)
 /* genericDrawItems logic for pack and squish modes */
 {
 double scale = scaleForWindow(width, seqStart, seqEnd);
 int lineHeight = tg->lineHeight;
 struct spaceNode *sn;
 int maxHeight = maximumTrackHeight(tg);
 int overflowRow = (maxHeight - tl.fontHeight +1) / lineHeight;
 boolean firstOverflow = TRUE;
 
 hvGfxSetClip(hvg, insideX, yOff, insideWidth, tg->height);
 assert(tg->ss);
 
 /* Loop through and draw each item individually */
@@ -3167,32 +3173,31 @@
     {
     if (sn->row >= overflowRow)
         {
         genericDrawOverflowItem(tg, sn, hvg, xOff, yOff, width, font, color,
                                 scale, overflowRow, firstOverflow);
         firstOverflow = FALSE;
         }
     else
         genericDrawItem(tg, sn, hvg, xOff, yOff, width, font, color, color, vis,
                         scale, withLeftLabels);
     }
 
 hvGfxUnclip(hvg);
 }
 
-static void genericDrawItemsFullDense(struct track *tg,
-        int seqStart, int seqEnd,
+static void genericDrawItemsFullDense(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width,
         MgFont *font, Color color, enum trackVisibility vis)
 /* genericDrawItems logic for full and dense modes */
 {
 double scale = scaleForWindow(width, seqStart, seqEnd);
 struct slList *item;
 int y = yOff;
 for (item = tg->items; item != NULL; item = item->next)
     {
     if(tg->itemColor != NULL)
         color = tg->itemColor(tg, item, hvg);
     tg->drawItemAt(tg, item, hvg, xOff, y, scale, font, color, vis);
     if (vis == tvFull)
         {
         /* The doMapItems will make the mapboxes normally but make */
@@ -3221,53 +3226,51 @@
                     hvGfxTextRight(hvg,textX,y,nameWidth,tg->heightPer,itemNameColor,font,name);
                     }
                 }
         #endif ///def IMAGEv2_NO_LEFTLABEL_ON_FULL
             genericDrawNextItemStuff(tg, hvg, vis, item, x2, x1, y, tg->heightPer, FALSE,color);
             }
 #else//ifndef IMAGEv2_SHORT_MAPITEMS
             genericDrawNextItemStuff(tg, hvg, vis, item, -1, -1, y, tg->heightPer, FALSE,
                                      color);
 #endif//ndef IMAGEv2_SHORT_MAPITEMS
         y += tg->lineHeight;
         }
     }
 }
 
-void genericDrawItems(struct track *tg,
-        int seqStart, int seqEnd,
+void genericDrawItems(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width,
         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw generic item list.  Features must be fixed height
  * and tg->drawItemAt has to be filled in. */
 {
 if (tg->mapItem == NULL)
     tg->mapItem = genericMapItem;
 if (vis != tvDense && (! bedItemRgb(tg->tdb)) && baseColorCanDraw(tg))
     baseColorInitTrack(hvg, tg);
 if (vis == tvPack || vis == tvSquish)
 {
     genericDrawItemsPackSquish(tg, seqStart, seqEnd, hvg, xOff, yOff, width,
                                font, color, vis);
 }
 else
     genericDrawItemsFullDense(tg, seqStart, seqEnd, hvg, xOff, yOff, width,
                               font, color, vis);
 }
 
-void linkedFeaturesSeriesDraw(struct track *tg,
-	int seqStart, int seqEnd,
+void linkedFeaturesSeriesDraw(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width,
         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw linked features items. */
 {
 clearColorBin();
 if (vis == tvDense && tg->colorShades)
     slSort(&tg->items, cmpLfsWhiteToBlack);
 genericDrawItems(tg, seqStart, seqEnd, hvg, xOff, yOff, width,
 	font, color, vis);
 }
 
 void linkedFeaturesDraw(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width,
         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw linked features items. */
@@ -3420,32 +3423,31 @@
 
 Color *colors = needMem(sizeof(Color) * width);
 grayThreshold(useCounts, width, colors);
 hvGfxVerticalSmear(hvg,xOff,yOff,width,lineHeight,colors,TRUE);
 freeMem(useCounts);
 if (gapUseCounts != NULL)
     {
     int midY = yOff + (tg->heightPer>>1);
     grayThreshold(gapUseCounts, width, colors);
 
     hvGfxVerticalSmear(hvg,xOff,midY,width,1,colors,TRUE);
     freeMem(gapUseCounts);
     }
 }
 
-void linkedFeaturesAverageDense(struct track *tg,
-	int seqStart, int seqEnd,
+void linkedFeaturesAverageDense(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width,
         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw dense linked features items. */
 {
 if (vis == tvDense)
     linkedFeaturesDrawAverage(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis);
 else
     linkedFeaturesDraw(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis);
 }
 
 int lfCalcGrayIx(struct linkedFeatures *lf)
 /* Calculate gray level from components. */
 {
 struct simpleFeature *sf;
 int count = 0;
@@ -3663,42 +3665,45 @@
     if ((row = sqlNextRow(sr)) != NULL)
 	{
 	struct psl *psl = pslLoad(row+rowOffset);
 	lf = lfFromPsl(psl, FALSE);
 	slAddHead(&lfList, lf);
 	}
     sqlFreeResult(&sr);
     }
 slReverse(&lfList);
 sqlFreeResult(&sr);
 hFreeConn(&conn);
 lfs->features = lfList;
 return lfs;
 }
 
-static struct linkedFeaturesSeries *lfsFromBedsInRange(char *table, int start, int end, char *chromName)
+static struct linkedFeaturesSeries *lfsFromBedsInRange(char *table, int start, int end,
+                                                       char *chromName)
 /* Return linked features from range of table. */
 {
 struct sqlConnection *conn = hAllocConn(database);
 struct sqlResult *sr = NULL;
 char **row;
 int rowOffset;
 struct linkedFeaturesSeries *lfsList = NULL, *lfs;
 
 char optionScoreStr[256]; /* Option -  score filter */
-safef(optionScoreStr, sizeof(optionScoreStr), "%s.%s", table,SCORE_FILTER); // Special case where getScoreFilterClause is too much trouble
-int optionScore = cartUsualInt(cart, optionScoreStr, 0);   // Special case where CloserToHome not appropriate
+// Special case where getScoreFilterClause is too much trouble
+safef(optionScoreStr, sizeof(optionScoreStr), "%s.%s", table,SCORE_FILTER);
+// Special case where CloserToHome not appropriate
+int optionScore = cartUsualInt(cart, optionScoreStr, 0);
 if (optionScore > 0)
     {
     char extraWhere[128];
     safef(extraWhere, sizeof(extraWhere), "score >= %d", optionScore);
     sr = hOrderedRangeQuery(conn, table, chromName, start, end,
 	extraWhere, &rowOffset);
     }
 else
     {
     sr = hOrderedRangeQuery(conn, table, chromName, start, end,
 	NULL, &rowOffset);
     }
 while ((row = sqlNextRow(sr)) != NULL)
     {
     struct lfs *lfsbed = lfsLoad(row+rowOffset);
@@ -4207,33 +4212,32 @@
         lf->tallEnd = gp->cdsEnd;
         }
     // Don't free gp; it might be used in the drawing phase by baseColor code.
     lf->original = gp;
     slAddHead(&lfList, lf);
     }
 slReverse(&lfList);
 genePredReaderFree(&gpr);
 
 if (tg->visibility != tvDense)
     slSort(&lfList, linkedFeaturesCmpStart);
 
 return lfList;
 }
 
-struct linkedFeatures *connectedLfFromGenePredInRange(
-        struct track *tg, struct sqlConnection *conn, char *table,
-	char *chrom, int start, int end)
+struct linkedFeatures *connectedLfFromGenePredInRange(struct track *tg, struct sqlConnection *conn,
+                                                      char *table, char *chrom, int start, int end)
 /* Return linked features from range of a gene prediction table after
  * we have already connected to database. */
 {
 return connectedLfFromGenePredInRangeExtra(tg, conn, table, chrom,
                                                 start, end, FALSE);
 }
 
 struct linkedFeatures *lfFromGenePredInRange(struct track *tg, char *table,
 	char *chrom, int start, int end)
 /* Return linked features from range of a gene prediction table. */
 {
 struct linkedFeatures *lfList = NULL;
 struct sqlConnection *conn = hAllocConn(database);
 lfList = connectedLfFromGenePredInRange(tg, conn, table, chrom, start, end);
 hFreeConn(&conn);
@@ -5990,32 +5994,31 @@
 
     /* Now lookup orientation of each est. */
     for(lf = lfList; lf != NULL; lf = lf->next)
 	{
 	estOrient = hashIntValDefault(orientHash, lf->name, 0);
 	if(estOrient < 0)
 	    lf->orientation = -1 * lf->orientation;
 	else if(estOrient == 0)
             lf->orientation = 0;  // not known, don't display chevrons
 	}
     hashFree(&orientHash);
     }
 hFreeConn(&conn);
 }
 
-void linkedFeaturesAverageDenseOrientEst(struct track *tg,
-	int seqStart, int seqEnd,
+void linkedFeaturesAverageDenseOrientEst(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width,
         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw dense linked features items. */
 {
 if(vis == tvSquish || vis == tvPack || vis == tvFull)
     orientEsts(tg);
 
 if (vis == tvDense)
     linkedFeaturesDrawAverage(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis);
 else
     linkedFeaturesDraw(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis);
 }
 
 
 
@@ -6255,32 +6258,32 @@
     {
     scoreMinGrayLevel = scoreMin * maxShade/scoreMax;
     if (scoreMinGrayLevel <= 0)
         scoreMinGrayLevel = 1;
     char *setting = trackDbSettingClosestToHome(tdb, MIN_GRAY_LEVEL);
     cartMinGrayLevel = cartUsualIntClosestToHome(cart, tdb, FALSE, MIN_GRAY_LEVEL,
                                 setting ? atoi(setting) : scoreMinGrayLevel);
     newScoreMin = cartMinGrayLevel * scoreMax/maxShade;
     prevTrackName = tdb->track;
     }
 if (cartMinGrayLevel != scoreMinGrayLevel)
     {
     float realScore = (float)(bed->score - scoreMin) / (scoreMax - scoreMin);
     bed->score = newScoreMin + (realScore * (scoreMax - newScoreMin)) + 0.5;
     }
-else if(scoreMin != 0 && scoreMax == 1000) // Changes gray level even when UI does not allow selecting it.
-    {
+else if (scoreMin != 0 && scoreMax == 1000) // Changes gray level even when
+    {                                       // UI does not allow selecting it.
     float realScore = (float)(bed->score) / 1000;
     bed->score = scoreMin + (realScore * (scoreMax - scoreMin)) + 0.5;
     }
 }
 
 void bedLoadItemByQuery(struct track *tg, char *table,
 			char *query, ItemLoader loader)
 /* Generic tg->item loader. If query is NULL use generic
  hRangeQuery(). */
 {
 struct sqlConnection *conn = hAllocConn(database);
 int rowOffset = 0;
 struct sqlResult *sr = NULL;
 char **row = NULL;
 struct slList *itemList = NULL, *item = NULL;
@@ -9246,75 +9249,73 @@
         {
         enum trackVisibility vis = tg->visibility;
         int h;
         int maxHeight = maximumTrackHeight(tg);
 
         if (vis == tvHide)
             {
             tg->height = 0;
             tg->limitedVis = tvHide;
             return tvHide;
             }
         if (tg->subtracks != NULL)
             {
             struct track *subtrack;
             int subCnt = subtrackCount(tg->subtracks);
-            maxHeight = maxHeight * max(subCnt,1);  // Without further restruction does this ever accomplish anything?
+            maxHeight = maxHeight * max(subCnt,1);
             //if (subCnt > 4)
             //    maxHeight *= 2; // NOTE: Large composites should suffer an additional restriction.
 	    if (!tg->syncChildVisToSelf)
 		{
 		for (subtrack = tg->subtracks;  subtrack != NULL; subtrack = subtrack->next)
 		    limitVisibility(subtrack);
 		}
             }
         while((h = tg->totalHeight(tg, vis)) > maxHeight && vis != tvDense)
             {
             if (vis == tvFull && tg->canPack)
                 vis = tvPack;
             else if (vis == tvPack)
                 vis = tvSquish;
             else
                 vis = tvDense;
-            //if (tg->visibility != vis)
-            //    warn("DEMOTION: %s -> %s %s  maxHeight:%d  totHeight:%d",
-            //         hStringFromTv(tg->visibility),hStringFromTv(vis),tg->track,maxHeight,tg->height);
             }
         tg->height = h;
         if (tg->limitedVis == tvHide)
             tg->limitedVis = vis;
         else
             tg->limitedVis = tvMin(vis,tg->limitedVis);
         }
 
     if (tg->syncChildVisToSelf)
         {
 	struct track *subtrack;
 	for (subtrack = tg->subtracks;  subtrack != NULL; subtrack = subtrack->next)
 	    {
 	    subtrack->visibility = tg->visibility;
 	    subtrack->limitedVis = tg->limitedVis;
 	    subtrack->limitedVisSet = tg->limitedVisSet;
 	    }
 	}
-    else if (tdbIsComposite(tg->tdb)) // If a composite is restricted, it's children should be atleast as restricted.
-        {
+    else if (tdbIsComposite(tg->tdb)) // If a composite is restricted,
+        {                             // it's children should be atleast as restricted.
         struct track *subtrack;
         for (subtrack = tg->subtracks;  subtrack != NULL; subtrack = subtrack->next)
             {
             subtrack->limitedVis = tvMin(subtrack->limitedVis, tg->limitedVis);
-            //subtrack->limitedVisSet = tg->limitedVisSet; // But don't prevent subtracks from being further restricted!
+            // But don't prevent subtracks from being further restricted!
+            //subtrack->limitedVisSet = tg->limitedVisSet;
             }
         }
 
     if (tg->height == 0 && tg->limitedVis != tvHide)
         tg->limitedVisSet = FALSE;  // Items may not be loaded yet, so going to need to check again
     }
 return tg->limitedVis;
 }
 
 void compositeTrackVis(struct track *track)
 /* set visibilities of subtracks */
 {
 struct track *subtrack;
 
 if (track->visibility == tvHide)
@@ -10134,31 +10135,33 @@
 {
 tg->items = lfFromGenePredInRange(tg, tg->table, chromName, winStart, winEnd);
 /* filter items on selected criteria if filter is available */
 filterItems(tg, genePredClassFilter, "include");
 }
 
 void loadGenePredWithConfiguredName(struct track *tg)
 /* Convert gene pred info in window to linked feature. Include name
  * in "extra" field (gene name, accession, or both, depending on UI) */
 {
 char *geneLabel;
 boolean useGeneName, useAcc;
 struct linkedFeatures *lf;
 
 geneLabel = cartUsualStringClosestToHome(cart, tg->tdb, FALSE, "label","gene");
-useGeneName = sameString(geneLabel, "gene") || sameString(geneLabel, "name") || sameString(geneLabel, "both");
+useGeneName =  sameString(geneLabel, "gene")
+            || sameString(geneLabel, "name")
+            || sameString(geneLabel, "both");
 useAcc = sameString(geneLabel, "accession") || sameString(geneLabel, "both");
 
 loadGenePredWithName2(tg);
 for (lf = tg->items; lf != NULL; lf = lf->next)
     {
     struct dyString *name = dyStringNew(SMALLDYBUF);
     if (useGeneName && !isEmpty((char*)lf->extra))
         {
         dyStringAppend(name, lf->extra);
         if (useAcc)
             dyStringAppendC(name, '/');
         }
     if (useAcc)
         dyStringAppend(name, lf->name);
     lf->extra = dyStringCannibalize(&name);
@@ -10944,32 +10947,32 @@
 
 /* NOTE: The definition of Others class is kind of tricky.
 
    The Other class is defined as:
 
 	1. does not have class 1 or 2 or 3, or 4; some may have class '-1'.
 	2. for an entry of omimId that the omimPhenotype table does not even have a row with omimId
 */
 {
 boolean result;
 char answer[255];
 struct sqlConnection *conn = hAllocConn(database);
 char query[256];
 safef(query,sizeof(query),
       "select %s from omimPhenotype where omimId =%s and (%s=1 or %s=2 or %s=3 or %s=4)",
-      omimPhenotypeClassColName, omimId, omimPhenotypeClassColName, omimPhenotypeClassColName, omimPhenotypeClassColName,
-      omimPhenotypeClassColName);
+      omimPhenotypeClassColName, omimId, omimPhenotypeClassColName, omimPhenotypeClassColName,
+      omimPhenotypeClassColName, omimPhenotypeClassColName);
 char *ret = sqlQuickQuery(conn, query, answer, sizeof(answer));
 
 if (ret == NULL)
     {
     result = TRUE;
     }
 else
     {
     result = FALSE;
     }
 hFreeConn(&conn);
 return(result);
 }
 
 int hasOmimPhenotypeClass(char *omimId, int targetClass)