src/hg/lib/customFactory.c 1.109

1.109 2009/11/09 22:31:15 angie
Added customFactoryEnableExtraChecking, intended to be called only by hgCustom. When the user first loads a custom track, it's a good time for more expensive testing (like opening remote BAM files). However, hgTracks etc. can save time by not duplicating that work every time they parse existing tracks. Currently only bamLoader uses this.
Index: src/hg/lib/customFactory.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/customFactory.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -b -B -U 4 -r1.108 -r1.109
--- src/hg/lib/customFactory.c	5 Nov 2009 18:48:36 -0000	1.108
+++ src/hg/lib/customFactory.c	9 Nov 2009 22:31:15 -0000	1.109
@@ -33,8 +33,10 @@
 #endif//def USE_BAM
 
 static char const rcsid[] = "$Id$";
 
+static boolean doExtraChecking = FALSE;
+
 /*** Utility routines used by many factories. ***/
 
 char *customFactoryNextTilTrack(struct customPp *cpp)
 /* Return next line.  Return NULL at end of input or at line starting with
@@ -1522,11 +1524,14 @@
 struct hash *settings = track->tdb->settingsHash;
 char *bigDataUrl = hashFindVal(settings, "bigDataUrl");
 if (bigDataUrl == NULL)
     errAbort("Missing bigDataUrl setting from track of type=bam (%s)", track->tdb->shortLabel);
-if (!bamFileExists(bigDataUrl))
+if (doExtraChecking)
+    {
+    if (!bamFileExists(bigDataUrl))
     errAbort("Can't access %s's bigDataUrl %s and/or the associated index file %s.bai",
 	     track->tdb->shortLabel, bigDataUrl, bigDataUrl);
+    }
 return track;
 }
 
 static struct customFactory bamFactory = 
@@ -2403,4 +2408,13 @@
 /* return initial setting by user for track line */
 {
 return trackDbSetting(ct->tdb, "origTrackLine");
 }
+
+void customFactoryEnableExtraChecking(boolean enable)
+/* Enable/disable extra checking of custom tracks in customFactoryParse.
+ * E.g. extra checking is great the first time we read in a custom track,
+ * but we don't need it for every hgTracks call. */
+{
+doExtraChecking = enable;
+}
+