237713163275ccedf5f184da1ae21233ac0fdefc
larrym
  Wed May 2 12:28:16 2012 -0700
remove pubsLoadMarkerItem code which was unnecessarily calling loadSimpleBedAsLinkedFeaturesPerBase (and thus making the pubsMarkerBand track quite slow); move itemName call in genericDrawItem so it's only done when needed
diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index f19dc56..03308fa 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -3017,45 +3017,45 @@
 static void genericDrawItem(struct track *tg, struct spaceNode *sn,
                             struct hvGfx *hvg, int xOff, int yOff, int width,
                             MgFont *font, Color color, Color labelColor, enum trackVisibility vis,
                             double scale, boolean withLeftLabels)
 /* draw one non-overflow item */
 {
 struct slList *item = sn->val;
 boolean withLabels = (withLeftLabels && (vis == tvPack) && !tg->drawName);
 int s = tg->itemStart(tg, item);
 int e = tg->itemEnd(tg, item);
 int sClp = (s < winStart) ? winStart : s;
 int eClp = (e > winEnd)   ? winEnd   : e;
 int x1 = round((sClp - winStart)*scale) + xOff;
 int x2 = round((eClp - winStart)*scale) + xOff;
 int textX = x1;
-char *name = tg->itemName(tg, item);
 
 if(tg->itemNameColor != NULL)
     {
     color = tg->itemNameColor(tg, item, hvg);
     labelColor = color;
     if (withLeftLabels && isTooLightForTextOnWhite(hvg, color))
 	labelColor = somewhatDarkerColor(hvg, color);
     }
 int y = yOff + tg->lineHeight * sn->row;
 tg->drawItemAt(tg, item, hvg, xOff, y, scale, font, color, vis);
 /* pgSnp tracks may change flags between items */
 withLabels = (withLeftLabels && withIndividualLabels && (vis == tvPack) && !tg->drawName);
 if (withLabels)
     {
+    char *name = tg->itemName(tg, item);
     int nameWidth = mgFontStringWidth(font, name);
     int dotWidth = tl.nWidth/2;
     boolean snapLeft = FALSE;
     boolean drawNameInverted = highlightItem(tg, item);
     textX -= nameWidth + dotWidth;
     snapLeft = (textX < insideX);
     /* Special tweak for expRatio in pack mode: force all labels
      * left to prevent only a subset from being placed right: */
     snapLeft |= (startsWith("expRatio", tg->tdb->type));
 #ifdef IMAGEv2_NO_LEFTLABEL_ON_FULL
     if (theImgBox == NULL && snapLeft)
 #else///ifndef IMAGEv2_NO_LEFTLABEL_ON_FULL
     if (snapLeft)        /* Snap label to the left. */
 #endif ///ndef IMAGEv2_NO_LEFTLABEL_ON_FULL
         {
@@ -12345,62 +12345,46 @@
 if (!theImgBox || tg->limitedVis != tvDense || !tdbIsCompositeChild(tg->tdb)) 
 {
     struct linkedFeatures *lf = item;
     pubsAddExtra(tg, lf);
     struct pubsExtra* extra = lf->extra;
     char* mouseOver = NULL;
     if (extra != NULL) 
         mouseOver = extra->mouseOver;
     else
         mouseOver = itemName;
 
     mapBoxHc(hvg, start, end, x, y, width, height, tg->track, mapItemName, mouseOver); 
 }
 }
 
-static void pubsLoadMarkerItem (struct track *tg)
-/* copy item names into extra field */
-{
-//loadSimpleBed(tg);
-loadSimpleBedAsLinkedFeaturesPerBase(tg);
-//tg->items = simpleBedListToLinkedFeatures(tg->items, tg->bedSize, TRUE, FALSE);
-//if (! (hashFindVal(tdb->settingsHash, "pubsMarkerTable")))
-enum trackVisibility vis = tg->visibility;
-if (vis == tvDense || vis == tvSquish) 
-    return;
-
-struct linkedFeatures *lf = NULL;
-for (lf = tg->items; lf != NULL; lf = lf->next)
-    lf->extra = lf->name;
-}
-
 char *pubsMarkerItemName(struct track *tg, void *item)
 /* retrieve article count from score field and return.*/
 {
-struct linkedFeatures *lf = item;
+struct bed *bed = item;
 char newName[64];
-safef(newName, sizeof(newName), "%d articles", (int) lf->score);
+safef(newName, sizeof(newName), "%d articles", (int) bed->score);
 return cloneString(newName);
 }
 
 static void pubsMarkerMapItem(struct track *tg, struct hvGfx *hvg, void *item,
 				char *itemName, char *mapItemName, int start, int end,
 				int x, int y, int width, int height)
 {
-struct linkedFeatures *lf = item;
+struct bed *bed = item;
 genericMapItem(tg, hvg, item,
-		    lf->extra, lf->extra, start, end,
+		    bed->name, bed->name, start, end,
 		    x, y, width, height);
 }
 
 static struct hash* pubsLookupSequences(struct track *tg, struct sqlConnection* conn, char* articleId, bool getSnippet)
 /* create a hash with a mapping annotId -> snippet or annotId -> shortSeq for an articleId*/
 {
     char query[LARGEBUF];
     char *sequenceTable = trackDbRequiredSetting(tg->tdb, "pubsSequenceTable");
     char *selectValSql = NULL;
     if (getSnippet)
         selectValSql = "replace(replace(snippet, \"<B>\", \"\\n>>> \"), \"</B>\", \" <<<\\n\")";
     else
         selectValSql = "concat(substr(sequence,1,4),\"...\",substr(sequence,-4))";
 
     safef(query, sizeof(query), "SELECT annotId, %s  FROM %s WHERE articleId='%s' ", 
@@ -12489,33 +12473,30 @@
 tg->mapItem   = pubsMapItem;
 }
 
 static void pubsBlatMethods(struct track *tg)
 /* publication blat tracks are bed12+2 tracks of sequences in text, mapped with BLAT */
 {
 //bedMethods(tg);
 tg->loadItems = pubsLoadKeywordYearItems;
 tg->itemName  = pubsItemName;
 tg->mapItem   = pubsMapItem;
 }
 
 static void pubsMarkerMethods(struct track *tg)
 /* publication marker tracks are bed5 tracks of genome marker occurences like rsXXXX found in text*/
 {
-//bedMethods(tg);
-tg->bedSize   = 5;
-tg->loadItems = pubsLoadMarkerItem;
 tg->mapItem   = pubsMarkerMapItem;
 tg->itemName  = pubsMarkerItemName;
 }
 
 void fillInFromType(struct track *track, struct trackDb *tdb)
 /* Fill in various function pointers in track from type field of tdb. */
 {
 char *typeLine = tdb->type, *words[8], *type;
 int wordCount;
 if (typeLine == NULL)
     return;
 wordCount = chopLine(cloneString(typeLine), words);
 if (wordCount <= 0)
     return;
 type = words[0];