1a2011f25ac0bd4ce02ed0eb093ff169724f9047
angie
  Mon May 2 16:39:23 2016 -0700
Added trackDb setting "tableBrowser noGenome", which allows tables to appear in TB and DI menus,
unlike "tableBrowser off", but does not allow genome-wide queries on the tables.  The new "noGenome"
setting is used for OMIM tracks -- OMIM gave the OK for non-genome-wide queries on their tables.

See #4458#note-53 for details of UI & functional changes to the TB and DI for noGenome tracks.

hg/lib/cartTrackDb.c handles access control based on trackDb tableBrowser settings (and the
seldom-used tableAccessControl database tables that restrict tables to be viewed only by
certain hosts).  As before, 'tableBrowser off' means that the track is removed from the
trackList so the TB & DI don't even know that it exists.  'tableBrowser noGenome' tracks are
included in the trackList, but the tracks and any tables listed after 'noGenome' are hashed
for later use by cartTrackDbIsNoGenome().  The hash used to contain permitted-host lists,
but now contains structs that combine the permitted-host lists with a noGenome flag.

hgIntegrator.c now includes a 'noGenome' flag in the JSONified groupedTrackDb, which the JS
code uses to identify noGenome tracks.  When executing a query, if the query region is genome
but hgi_querySpec has noGenome related tables left over from past position-only queries, those
related table settings are removed from the parsed JSON querySpec->config->relatedTables that is
passed down into annoStreamDb.  If one of the dataSources is noGenome but the region is genome
(should be possible only by URL-tweaking), the region is forced to position.

In hgTables, when region is genome, correlation and intersection track menu options for
noGenome tracks are disabled.  On the main page, JS code controls whether options are disabled
depending on the current region.  When listing related tables for filtering or selected fields
output, if region is genome then the checkboxes for noGenome tables are disabled.  If the cart
has noGenome related table or intersection settings left over from past searches, they are
ignored.  If a noGenome query URL is tweaked to have hgta_region=genome, the TB errors out.

hgIntegratorModel.js handles disabling of menu options and related table field settings for
noGenome tracks when region is genome.

refs #4458

diff --git src/hg/lib/cartJson.c src/hg/lib/cartJson.c
index e5a3bdb..2b2db48 100644
--- src/hg/lib/cartJson.c
+++ src/hg/lib/cartJson.c
@@ -325,30 +325,38 @@
     jsonWriteString(jw, "grp", tdb->grp);
 // NOTE: if you add a new field here, then also add it to nameIsTdbField above.
 if (tdb->settingsHash)
     {
     struct hashEl *hel;
     struct hashCookie cookie = hashFirst(tdb->settingsHash);
     while ((hel = hashNext(&cookie)) != NULL)
         {
         if (! nameIsTdbField(hel->name) && fieldOk(hel->name, fieldHash))
             {
             //#*** TODO: move jsonStringEscape inside jsonWriteString
             char *encoded = jsonStringEscape((char *)hel->val);
             jsonWriteString(jw, hel->name, encoded);
             }
         }
+    if (fieldOk("noGenome", fieldHash))
+        {
+        if ((hel = hashLookup(tdb->settingsHash, "tableBrowser")) != NULL)
+            {
+            if (startsWithWord("noGenome", (char *)(hel->val)))
+                jsonWriteBoolean(jw, "noGenome", TRUE);
+            }
+        }
     }
 }
 
 static int trackDbViewCmp(const void *va, const void *vb)
 /* *** I couldn't find anything like this in hgTracks or hui, but clearly views end up
  * *** being ordered alphabetically somehow.  Anyway...
  * Compare two trackDbs, first by view if both have a view setting, then the usual way
  * (by priority, then by shortLabel). */
 {
 const struct trackDb *a = *((struct trackDb **)va);
 const struct trackDb *b = *((struct trackDb **)vb);
 // The casts are necessary here unless one adds const to trackDbSetting decl
 char *viewA = trackDbSetting((struct trackDb *)a, "view");
 char *viewB = trackDbSetting((struct trackDb *)b, "view");
 int diff = 0;