5247d2f093c036439e46930a40607d2a47a05f25
chmalee
  Thu Mar 5 11:34:12 2026 -0800
For hgConvert only, filter the popular genomes list in the toDb section by what liftover chains we have available for the fromDb, refs #36232

diff --git src/hg/hgConvert/hgConvert.c src/hg/hgConvert/hgConvert.c
index 9d3bfd6b5e0..2b3f701ba0c 100644
--- src/hg/hgConvert/hgConvert.c
+++ src/hg/hgConvert/hgConvert.c
@@ -152,30 +152,37 @@
 puts("<div style='text-align: center; margin-top: 20px;'>\n");
 cgiMakeButton(HGLFT_DO_CONVERT, "Submit");
 puts("</div>\n");
 
 /* JavaScript initialization for autocomplete with liftOver filtering */
 jsInlineF(
     "let validTargets = new Set();\n"
     "\n"
     "fetch('../cgi-bin/hubApi/liftOver/listExisting?fromGenome=%s')\n"
     "    .then(response => response.json())\n"
     "    .then(data => {\n"
     "        if (data.existingLiftOvers) {\n"
     "            data.existingLiftOvers.forEach(chain => validTargets.add(chain.toDb));\n"
     "        }\n"
     "\n"
+    "        // Filter popular genomes to only those with a liftOver from source\n"
+    "        let dataEl = document.getElementById('%sPopularData');\n"
+    "        if (dataEl) {\n"
+    "            let popular = JSON.parse(dataEl.textContent);\n"
+    "            dataEl.textContent = JSON.stringify(popular.filter(p => validTargets.has(p.db)));\n"
+    "        }\n"
+    "\n"
     "        // Custom onServerReply that processes results and filters to valid targets\n"
     "        function processAndFilterResults(result, term) {\n"
     "            let processed = processFindGenome(result, term);\n"
     "            let filtered = processed.filter(item => validTargets.has(item.genome));\n"
     "            if (filtered.length === 0 && processed.length > 0) {\n"
     "                // Found genomes but none have liftOver from source\n"
     "                return [{label: 'No liftOver available for matching genomes', value: '', genome: '', disabled: true}];\n"
     "            } else if (filtered.length === 0) {\n"
     "                // No genomes matched the search at all\n"
     "                return [{label: 'No genomes found', value: '', genome: '', disabled: true}];\n"
     "            }\n"
     "            return filtered;\n"
     "        }\n"
     "\n"
     "        // Error handler for API failures (e.g. HTTP 400)\n"
@@ -214,30 +221,31 @@
     "            wasOpen = $input.autocompleteCat('widget').is(':visible');\n"
     "        });\n"
     "        toggle.addEventListener('click', () => {\n"
     "            let $input = $('[id=\\x27%s\\x27]');\n"
     "            if (wasOpen) {\n"
     "                $input.autocompleteCat('close');\n"
     "            } else {\n"
     "                $input.val('');\n"
     "                $input.autocompleteCat('search', '');\n"
     "                $input.focus();\n"
     "            }\n"
     "        });\n"
     "    }\n"
     "});\n"
     , liftOver->fromDb
+    , searchBarId
     , HGLFT_TOORG_VAR
     , HGLFT_TODB_VAR
     , searchBarId, searchBarId, searchBarId, searchBarId
     , searchBarId, searchBarId, searchBarId
 );
 
 puts("</FORM>\n");
 
 cartWebEnd();
 }
 
 static double scoreLiftOverChain(struct liftOverChain *chain,
     char *fromOrg, char *fromDb, char *toOrg, char *toDb, struct hash *dbRank )
 /* Score the chain in terms of best match for cart settings */
 {