106895cbff17848866e9b5cfeefb0ce1985203a1
tdreszer
  Wed Oct 5 16:52:11 2011 -0700
More tightening of screws.  Several special cases solved. Altererd which right-click menu items for cfg appear and regularized this with subCfg availability.
diff --git src/hg/lib/trackDbCustom.c src/hg/lib/trackDbCustom.c
index 8e5dbad..cf7e001 100644
--- src/hg/lib/trackDbCustom.c
+++ src/hg/lib/trackDbCustom.c
@@ -3,30 +3,31 @@
  * MySQL table out of the trackDb.ra files. */
 
 #include "common.h"
 #include "linefile.h"
 #include "jksql.h"
 #include "trackDb.h"
 #include "hdb.h"
 #include "hui.h"
 #include "ra.h"
 #include "hash.h"
 #include "net.h"
 #include "sqlNum.h"
 #include "obscure.h"
 #include "hgMaf.h"
 #include "customTrack.h"
+#include "regexHelper.h"
 
 static char const rcsid[] = "$Id: trackDbCustom.c,v 1.90 2010/05/18 22:37:36 kent Exp $";
 
 /* ----------- End of AutoSQL generated code --------------------- */
 
 struct trackDb *trackDbNew()
 /* Allocate a new trackDb with just very minimal stuff filled in. */
 {
 struct trackDb *tdb;
 AllocVar(tdb);
 tdb->canPack = 2;	/* Unknown value. */
 return tdb;
 }
 
 int trackDbCmp(const void *va, const void *vb)
@@ -688,75 +689,106 @@
 assert(type != NULL);
 
 if(startsWith("wigMaf", type))
     cType = cfgWigMaf;
 else if(startsWith("wig", type))
     cType = cfgWig;
 else if(startsWith("bigWig", type))
     cType = cfgWig;
 else if(startsWith("bedGraph", type))
     cType = cfgWig;
 else if(startsWith("netAlign", type)
      || startsWith("net", tdb->track)) // SPECIAL CASE from hgTrackUi which might not be needed
     cType = cfgNetAlign;
 else if(sameWord("bed5FloatScore",       type)
      || sameWord("bed5FloatScoreWithFdr",type))
+    {
+    if (bedScoreHasCfgUi(tdb))
     cType = cfgBedScore;
+    }
 else if(encodePeakHasCfgUi(tdb))
     cType = cfgPeak;
-else if(startsWithWord("genePred",type))
+else if(startsWithWord("genePred",type)
+     && !startsWith("encodeGencodeRaceFrags", tdb->track))  // SPECIAL CASE should be handled in trackDb!
         cType = cfgGenePred;
 else if(sameWord("bedLogR",type)
      || sameWord("peptideMapping", type))
     cType = cfgBedScore;
 else if(startsWithWord("bed", type))
     {
-    char *words[3];
-    int wordCount = chopLine(cloneString( type), words);
     if (trackDbSetting(tdb, "bedFilter") != NULL)
 	   cType = cfgBedFilt;
-    else if ((atoi(words[1]) >= 5 || trackDbSetting(tdb, "scoreMin") != NULL)
-         && (wordCount == 3 || !tdbIsTrackUiTopLevel(tdb))) // Historically needed 'bed n .'
+    else
+        {
+       char *words[3];
+        int wordCount = chopLine(cloneString( type), words);
+        if ((atoi(words[1]) >= 5 || trackDbSetting(tdb, "scoreMin") != NULL)
+        && (wordCount >= 3)) // Historically needed 'bed n .'
         {
         cType = cfgBedScore;
 
+            if (!bedScoreHasCfgUi(tdb))
+                cType = cfgNone;
+
         // FIXME: UGLY SPECIAL CASE should be handled in trackDb!
-        if (startsWith("encodeGencodeIntron", tdb->track))
+            else if (startsWith("encodeGencodeIntron", tdb->track))
             cType = cfgNone;
         }
     }
+    }
 else if(startsWith("chain",type))
     cType = cfgChain;
 else if (startsWith("bamWig", type))
     cType = cfgWig;
 else if (startsWith("bam", type))
     cType = cfgBam;
 else if (startsWith("psl", type))
     cType = cfgPsl;
 else if (sameWord("vcfTabix",type))
     cType = cfgVcf;
 // TODO: Only these are configurable so far
 
 if(cType == cfgNone && warnIfNecessary)
     {
     if(!startsWith("bed ", type) && !startsWith("bigBed", type)
     && subgroupFind(tdb,"view",NULL))
         warn("Track type \"%s\" is not yet supported in multi-view composites for %s.",type,tdb->track);
     }
 return cType;
 }
 
+int configurableByPopup(struct trackDb *tdb, eCfgType cfgTypeIfKnown)
+// Is this track configurable by right-click popup, or in hgTrackUi subCfg?
+// returns 0 = no; <0=explicitly blocked;  >0=allowed and will be cfgType
+{
+int ctPopup = (int)cfgTypeIfKnown;
+if (!ctPopup)
+    ctPopup = (int)cfgTypeFromTdb(tdb,FALSE);
+
+if (ctPopup > 0)
+{
+    if (regexMatch(tdb->track, "^snp[0-9]+")     // Special cases to be removed
+    ||  regexMatch(tdb->track, "^cons[0-9]+way") // (matches logic in json setup in imageV2.c)
+    ||  regexMatch(tdb->track, "^multiz")
+    ||  startsWith("hapmapSnps", tdb->track)
+    ||  startsWith("hapmapAlleles", tdb->track)
+    ||  SETTING_IS_OFF(trackDbSettingClosestToHome(tdb, "configureByPopup")))
+        ctPopup *= -1;
+}
+return ctPopup;
+}
+
 char *trackDbSetting(struct trackDb *tdb, char *name)
 /* Look for a trackDb setting from lowest level on up chain of parents. */
 {
 struct trackDb *generation;
 char *trackSetting = NULL;
 for (generation = tdb; generation != NULL; generation = generation->parent)
     {
     trackSetting = trackDbLocalSetting(generation,name);
     if (trackSetting != NULL)
         break;
     }
 return trackSetting;
 }
 
 char *trackDbSettingByView(struct trackDb *tdb, char *name)