064a6ba7c9f9e4a2055cd8363f6128ac475c576e
galt
  Fri Feb 25 15:30:32 2011 -0800
squashed my dev branch bigNetErrDisplay to test making code review easier; this code helps hgTracks display big network warnings and errors with a yellow background; it supports bigWig, bigBed, bam, and multiWig; In the case of multiWig, it can only draw the yellow background once at the beginning, and is limited to only drawing the first track that has a network error since overlapping multiple error messages would be unreadable
diff --git src/hg/hgTracks/bamTrack.c src/hg/hgTracks/bamTrack.c
index e229c46..35a6df4 100644
--- src/hg/hgTracks/bamTrack.c
+++ src/hg/hgTracks/bamTrack.c
@@ -6,47 +6,50 @@
 #include "common.h"
 #include "hCommon.h"
 #include "hash.h"
 #include "linefile.h"
 #include "htmshell.h"
 #include "jksql.h"
 #include "hdb.h"
 #include "hgTracks.h"
 #include "cds.h"
 #include "bamFile.h"
 #include "wigCommon.h"
 #if (defined USE_BAM && defined KNETFILE_HOOKS)
 #include "knetUdc.h"
 #include "udc.h"
 #endif//def USE_BAM && KNETFILE_HOOKS
+#include "bigWarn.h"
+#include "errCatch.h"
 
 static char const rcsid[] = "$Id: bamTrack.c,v 1.32 2010/05/27 21:13:24 angie Exp $";
 
 struct bamTrackData
     {
     struct track *tg;
     struct hash *pairHash;
     int minAliQual;
     char *colorMode;
     char *grayMode;
     char *userTag;
     int aliQualShadeMin;
     int aliQualShadeMax;
     int baseQualShadeMin;
     int baseQualShadeMax;
     };
 
+
 struct psl *pslFromBam(const bam1_t *bam)
 /* Translate BAM's numeric CIGAR encoding into PSL sufficient for cds.c (just coords,
  * no scoring info) */
 {
 const bam1_core_t *core = &bam->core;
 struct psl *psl;
 AllocVar(psl);
 boolean isRc = (core->flag & BAM_FREVERSE);
 psl->strand[0] = isRc ? '-' : '+';
 psl->qName = cloneString(bam1_qname(bam));
 psl->tName = cloneString(chromName);
 unsigned blockCount = 0;
 unsigned *blockSizes, *qStarts, *tStarts;
 AllocArray(blockSizes, core->n_cigar);
 AllocArray(qStarts, core->n_cigar);
@@ -443,30 +446,34 @@
 	    *retMin = sqlUnsigned(words[0]);
 	if (retMax != NULL)
 	    *retMax = sqlUnsigned(words[1]);
 	return;
 	}
     else
 	warn("track %s table %s: setting %s should be integer range min:max but is %s",
 	     tdb->track, tdb->table, settingName, range);
     }
 }
 
 void bamLoadItemsCore(struct track *tg, boolean isPaired)
 /* Load BAM data into tg->items item list, unless zoomed out so far
  * that the data would just end up in dense mode and be super-slow. */
 {
+/* protect against temporary network error */
+struct errCatch *errCatch = errCatchNew();
+if (errCatchStart(errCatch))
+    {
 struct hash *pairHash = isPaired ? hashNew(18) : NULL;
 int minAliQual = atoi(cartOrTdbString(cart, tg->tdb, BAM_MIN_ALI_QUAL, BAM_MIN_ALI_QUAL_DEFAULT));
 char *colorMode = cartOrTdbString(cart, tg->tdb, BAM_COLOR_MODE, BAM_COLOR_MODE_DEFAULT);
 char *grayMode = cartOrTdbString(cart, tg->tdb, BAM_GRAY_MODE, BAM_GRAY_MODE_DEFAULT);
 char *userTag = cartOrTdbString(cart, tg->tdb, BAM_COLOR_TAG, BAM_COLOR_TAG_DEFAULT);
 int aliQualShadeMin = 0, aliQualShadeMax = 99, baseQualShadeMin = 0, baseQualShadeMax = 40;
 parseIntRangeSetting(tg->tdb, "aliQualRange", &aliQualShadeMin, &aliQualShadeMax);
 parseIntRangeSetting(tg->tdb, "baseQualRange", &baseQualShadeMin, &baseQualShadeMax);
 struct bamTrackData btd = {tg, pairHash, minAliQual, colorMode, grayMode, userTag,
 			   aliQualShadeMin, aliQualShadeMax, baseQualShadeMin, baseQualShadeMax};
 char *fileName = trackDbSetting(tg->tdb, "bigDataUrl");
 if (fileName == NULL)
     {
     if (tg->customPt)
 	{
@@ -509,38 +516,49 @@
     else if (sameString(colorMode, BAM_COLOR_MODE_STRAND))
 	slSort(&(tg->items), linkedFeaturesCmpOri);
     else if (sameString(colorMode, BAM_COLOR_MODE_GRAY) &&
 	     sameString(grayMode, BAM_GRAY_MODE_ALI_QUAL))
 	slSort(&(tg->items), linkedFeaturesCmpScore);
     else
 	slSort(&(tg->items), linkedFeaturesCmpStart);
     if (slCount(tg->items) > MAX_ITEMS_FOR_MAPBOX)
         {
         // flag drawItems to make a mapBox for the whole track
         tg->customInt = 1;
 	tg->mapItem = dontMapItem;
         }
     }
 }
+errCatchEnd(errCatch);
+if (errCatch->gotError)
+    {
+    tg->networkErrMsg = cloneString(errCatch->message->string);
+    tg->drawItems = bigDrawWarning;
+    tg->totalHeight = bigWarnTotalHeight;
+    }
+errCatchFree(&errCatch);
+}
+
 
 void bamLoadItems(struct track *tg)
 /* Load single-ended-only BAM data into tg->items item list, unless zoomed out so far
  * that the data would just end up in dense mode and be super-slow. */
 {
 bamLoadItemsCore(tg, FALSE);
 }
 
+
 void bamPairedLoadItems(struct track *tg)
 /* Load possibly paired BAM data into tg->items item list, unless zoomed out so far
  * that the data would just end up in dense mode and be super-slow. */
 {
 bamLoadItemsCore(tg, TRUE);
 }
 
 void bamDrawAt(struct track *tg, void *item,
 	struct hvGfx *hvg, int xOff, int y, double scale,
 	MgFont *font, Color color, enum trackVisibility vis)
 /* Draw a single bam linkedFeatures item.  Borrows a lot from linkedFeaturesDrawAt,
  * but cuts a lot of unneeded features (like coding region) and adds a couple
  * additional sources of color. */
 {
 struct linkedFeatures *lf = item;