b5820fe28821425cd0703ba4d92bfb36d7abb8e6 chmalee Wed Mar 25 13:43:40 2026 -0700 Fix hgConvert for genark toDb selections. Previously the toDb cgi variable was in a <select>, and so choosing a genark search result that wasn't in the pre-existing select submits the form with the old value. Now the <select> gets a separate variable name, and on choosing a result the toDb variable is updated appropriately. Also fix weird default chain selection, if the toDb is explicitly provided, then choose that chain if it exists rather than scoring all of them to find a 'default' choice, refs Braney email diff --git src/hg/hgConvert/hgConvert.c src/hg/hgConvert/hgConvert.c index fd4951ad84f..2d93041e59e 100644 --- src/hg/hgConvert/hgConvert.c +++ src/hg/hgConvert/hgConvert.c @@ -35,31 +35,31 @@ /* CGI Variables */ #define HGLFT_TOORG_VAR "hglft_toOrg" /* TO organism */ #define HGLFT_TODB_VAR "hglft_toDb" /* TO assembly */ #define HGLFT_DO_CONVERT "hglft_doConvert" /* Do the actual conversion */ /* Global Variables */ static struct cart *cart; /* CGI and other variables */ static struct hash *oldVars = NULL; static char *organism = NULL; static char *database = NULL; /* Javascript to support New Assembly pulldown when New Genome changes. */ /* Copies selected values to a hidden form */ -char *onChangeToOrg = "document.mainForm.submit();"; +char *onChangeToOrg = "document.mainForm.hglft_toDb.value = this.value; document.mainForm.submit();"; static struct dbDb *matchingDb(struct dbDb *list, char *name) /* Find database of given name in list or die trying. */ { struct dbDb *db; for (db = list; db != NULL; db = db->next) { if (sameString(name, db->name)) return db; } struct dbDb *toDb = genarkLiftOverDb(name); if (toDb == NULL) errAbort("Can't find %s in matchingDb", name); return toDb; @@ -109,46 +109,47 @@ puts("<div class='convertGrid'>\n"); /* SOURCE SECTION (read-only) */ puts("<div class='convertSection'>\n"); puts("<div class='sectionLabel'>Source</div>\n"); hPrintf("<div class='fieldRow'><span class='fieldLabel'>Genome:</span> %s</div>\n", fromDb->organism); hPrintf("<div class='fieldRow'><span class='fieldLabel'>Assembly:</span> %s</div>\n", fromDb->description); puts("</div>\n"); /* DESTINATION SECTION (editable) */ puts("<div class='convertSection'>\n"); puts("<div class='sectionLabel'>Destination</div>\n"); /* Hidden fields for form submission */ hPrintf("<input name='%s' value='%s' type='hidden'>\n", HGLFT_TOORG_VAR, toDb->organism); +hPrintf("<input name='%s' value='%s' type='hidden'>\n", HGLFT_TODB_VAR, liftOver->toDb); /* Search bar */ char *searchBarId = "toGenomeSearch"; puts("<div class='fieldRow'>\n"); puts("<span class='fieldLabel'>Search:</span>\n"); printGenomeSearchBar(searchBarId, "Search for target genome...", NULL, TRUE, NULL, NULL); puts("</div>\n"); /* Current selection display */ char *selectedLabel = getCurrentGenomeLabel(liftOver->toDb); hPrintf("<div class='currentSelection' id='toGenomeLabel'>%s</div>\n", selectedLabel); /* Assembly dropdown (updates based on genome selection) */ puts("<div class='fieldRow'>\n"); puts("<span class='fieldLabel'>Assembly:</span>\n"); dbList = hGetLiftOverToDatabases(liftOver->fromDb); -printAllAssemblyListHtmlParm(liftOver->toDb, dbList, HGLFT_TODB_VAR, TRUE, "change", onChangeToOrg); +printAllAssemblyListHtmlParm(liftOver->toDb, dbList, "hglft_toDbSelect", TRUE, "change", onChangeToOrg); puts("</div>\n"); /* QuickLift option */ if (askAboutQuickLift) { puts("<div class='fieldRow' style='margin-top: 15px;'>\n"); cgiMakeCheckBoxWithId("doQuickLift", quickLift, "doQuickLift"); puts(" <label for='doQuickLift' title='Display tracks from the source assembly mapped onto the target assembly'>QuickLift tracks</label>\n"); puts(" <a href='https://docs.google.com/document/d/1wecESHUpgTlE6U_Mj0OnfHeSZBrTX9hkZRN5jlJS8ZQ/edit?usp=sharing' " "target='ucscHelp' title='QuickLift is in beta testing. Click to view more documentation about this feature.' " "style='color:#8A2BE2;font-weight:bold;text-transform:uppercase;font-size:smaller;padding:2px " "4px;background:lavender;border-radius:3px;text-decoration:none;margin-left:6px;'>beta</a>\n"); puts("</div>\n"); } @@ -313,32 +314,38 @@ { char *toOrg, *toDb; struct liftOverChain *choice = NULL; struct hash *dbRank = hGetDatabaseRank(); double bestScore = -1; struct liftOverChain *this = NULL; /* Get the initial values. */ toOrg = cartCgiUsualString(cart, HGLFT_TOORG_VAR, "0"); toDb = cartCgiUsualString(cart, HGLFT_TODB_VAR, "0"); if (sameWord(toOrg,"0")) toOrg = NULL; if (sameWord(toDb,"0")) toDb = NULL; -if ((toDb != NULL) && !sameWordOk(toOrg, hOrganism(toDb))) - toDb = NULL; + +/* If toDb was explicitly set, find exact match in chain list */ +if (toDb != NULL) + { + for (this = chainList; this != NULL; this = this->next) + if (sameString(toDb, this->toDb)) + return this; + } if (toOrg == NULL) toOrg = "Human"; for (this = chainList; this != NULL; this = this->next) { double score = scoreLiftOverChain(this, fromOrg, fromDb, toOrg, toDb, dbRank); if (score > bestScore) { choice = this; bestScore = score; } } return choice;