e69c419df164bddedb48d8c5a66db0f87fb06518
max
  Thu Apr 3 09:53:49 2014 -0700
again, changing the way 2bits are replacing nib files. refs #11957
diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index ff66a38..ae974bf 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -947,31 +947,41 @@
         safecpy(trackName, HDB_MAX_TABLE_STRING, ptr+1);
 	}
     }
 }
 
 int hChromSize(char *db, char *chromName)
 /* Return size of chromosome. */
 {
 struct chromInfo *ci = mustGetChromInfo(db, chromName);
 return ci->size;
 }
 
 void hNibForChrom(char *db, char *chromName, char retNibName[HDB_MAX_PATH_STRING])
 /* Get .nib file associated with chromosome. */
 {
-if (hDbIsActive(db) && cfgOptionBooleanDefault("allowNib", TRUE))
+if (cfgOptionBooleanDefault("allowNib", TRUE) == FALSE)
+    {
+    char buf[HDB_MAX_PATH_STRING];
+    safef(buf, HDB_MAX_PATH_STRING, "/gbdb/%s/%s.2bit", db, db);
+    char *newPath = hReplaceGbdb(buf);
+    safecpy(retNibName, HDB_MAX_PATH_STRING, newPath);
+    freeMem(newPath);
+    return;
+    }
+
+if (hDbIsActive(db))
     {
     struct chromInfo *ci = mustGetChromInfo(db, chromName);
     safef(retNibName, HDB_MAX_PATH_STRING, "%s", ci->fileName);
     }
 else
     {
     char *nibPath = hDbDbNibPath(db);
 
     if (nibPath == NULL)
 	errAbort("nibPath is NULL for database '%s'", db);
 
     safef(retNibName, HDB_MAX_PATH_STRING, "%s/%s.2bit",
 	nibPath, db);
     if (!fileExists(retNibName))
 	{
@@ -1267,50 +1277,53 @@
 return list;
 }
 
 char *hReplaceGbdbLocal(char* fileName)
  /* Returns a gbdb filename, potentially rewriting it according to hg.conf's gbdbLoc1 */
  /* Result has to be freed */
 {
 if (fileName==NULL)
     return fileName;
 
 char* newGbdbLoc = cfgOption("gbdbLoc1");
 char* path;
 
 // if no config option set or not a /gbdb filename, then just return
 // otherwise replace /gbdb/ with the new prefix and return it
-if (newGbdbLoc==NULL || !startsWith("/gbdb/", fileName))
+if ((newGbdbLoc==NULL) || (!startsWith("/gbdb/", fileName)))
    return cloneString(fileName);
 
 path = replaceChars(fileName, "/gbdb/", newGbdbLoc);
 return path;
 }
 
 char *hReplaceGbdb(char* fileName)
  /* Returns a gbdb filename, potentially rewriting it according to hg.conf
   * If the settings gbdbLoc1 and gbdbLoc2 are found, try them in order, by 
   * replacing /gbdb/ with the new locations.
   * If after the replacement of gbdbLoc1 the resulting fileName does not exist,
   * gbdbLoc2 is used.
   * This function does not guarantee that the returned filename exists.
   * We assume /gbdb/ does not appear somewhere inside a fileName.
   * Result has to be free'd.
  * */
 {
 if (fileName == NULL)
     return fileName;
+if (!startsWith("/gbdb/", fileName))
+    return cloneString(fileName);
+
 char *path = hReplaceGbdbLocal(fileName);
 if (fileExists(path))
     return path;
 
 // if the file did not exist, replace with gbdbLoc2
 char* newGbdbLoc = cfgOption("gbdbLoc2");
 if (newGbdbLoc==NULL)
     return path;
 
 freeMem(path);
 path = replaceChars(fileName, "/gbdb/", newGbdbLoc);
 return path;
 }
 
 char *hReplaceGbdbSeqDir(char *path, char *db)
@@ -2433,31 +2446,30 @@
 }
 
 char *hDbDbNibPath(char *database)
 /* return nibPath from dbDb for database, has to be freed */
 {
 char* seqDir = NULL;
 bool useNib = cfgOptionBooleanDefault("allowNib", TRUE);
 if (useNib)
     seqDir = hDbDbOptionalField(database, "nibPath");
 else
     {
     char buf[4096];
     safef(buf, sizeof(buf), "/gbdb/%s", database);
     char *twoBitDir = hReplaceGbdbSeqDir(buf, database);
     seqDir = twoBitDir;
-    fprintf(stderr, "twoBitDir %s\n", twoBitDir);
     }
 return seqDir;
 }
 
 char *hGenome(char *database)
 /* Return genome associated with database.
  * use freeMem on this when done. */
 {
 return hDbDbOptionalField(database, "genome");
 }
 
 char *hScientificName(char *database)
 /* Return scientific name for organism represented by this database */
 /* Return NULL if unknown database */
 /* NOTE: must free returned string after use */