3fbac7335e8422a13de52910b6099fa5ad29ccb0
Merge parents 582ef61 748aa2c
tdreszer
  Mon Oct 31 15:42:22 2011 -0700
Merge mixup mashup
diff --cc src/hg/lib/trackDbCustom.c
index 7bc01f6,0e8957f..bacf6eb
--- src/hg/lib/trackDbCustom.c
+++ src/hg/lib/trackDbCustom.c
@@@ -674,125 -673,81 +674,125 @@@
  	    printf("%s<BR>\n", origAssembly);
  	else if (stringIn(origAssembly, freeze))
  	    printf("%s<BR>\n", freeze);
  	else
  	    printf("%s (%s)<BR>\n", freeze, origAssembly);
          }
      }
  }
  
  eCfgType cfgTypeFromTdb(struct trackDb *tdb, boolean warnIfNecessary)
  /* determine what kind of track specific configuration is needed,
     warn if not multi-view compatible */
  {
  eCfgType cType = cfgNone;
  char *type = tdb->type;
 +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))
 -    {
 +else if(startsWith("netAlign", type)
 +     || startsWith("net", tdb->track)) // SPECIAL CASE from hgTrackUi which might not be needed
      cType = cfgNetAlign;
 -    warnIfNecessary = FALSE;
 -    }
  else if(sameWord("bed5FloatScore",       type)
       || sameWord("bed5FloatScoreWithFdr",type))
 -    cType = cfgBedScore;
 -else if(sameWord("narrowPeak",type)
 -     || sameWord("broadPeak", type)
 -     || sameWord("encodePeak",type)
 -     || sameWord("gappedPeak",type))
 +    {
 +    if (bedScoreHasCfgUi(tdb))
 +        cType = cfgBedScore;
 +    }
 +else if(encodePeakHasCfgUi(tdb))
      cType = cfgPeak;
 -else if(sameWord("genePred",type))
 -        cType = cfgGenePred;
 -else if(sameWord("bedLogR",type) || sameWord("peptideMapping", 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))
+ else if(startsWith("bed ", type) || startsWith("bigBed", type))
      {
 -    char *words[3];
 -    chopLine(cloneString( type), words);
      if (trackDbSetting(tdb, "bedFilter") != NULL)
 -	   cType = cfgBedFilt;
 -    else if (atoi(words[1]) >= 5 && trackDbSettingClosestToHome(tdb, "noScoreFilter") == NULL)
 -        cType = cfgBedScore;
 +           cType = cfgBedFilt;
 +    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 .'
 +            || (!tdbIsTrackUiTopLevel(tdb) && trackDbSettingClosestToHome(tdb, "wgEncode")))) // but encode didn't follow bed n .
 +            {
 +            cType = cfgBedScore;
 +
 +            if (!bedScoreHasCfgUi(tdb))
 +                cType = cfgNone;
 +
 +            // FIXME: UGLY SPECIAL CASE should be handled in trackDb!
 +            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 configurableByAjax(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 if determined
 +{
 +if (tdbIsMultiTrackSubtrack(tdb))
 +    return cfgNone; // multitrack subtracks are never allowed to be separately configured.
 +int ctPopup = (int)cfgTypeIfKnown;
 +if (ctPopup <= cfgNone)
 +    ctPopup = (int)cfgTypeFromTdb(tdb,FALSE);
 +if (ctPopup <= cfgNone && !tdbIsSubtrack(tdb)) // subtracks must receive CfgType!
 +    ctPopup = cfgUndetermined; // cfgTypeFromTdb() does not work for every case.
 +
 +if (ctPopup > cfgNone)
 +{
 +    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)
 +    ||  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)