f2f1a28c921a6f9c2bf1838d0940293492de4141
braney
  Thu Jul 17 11:42:05 2025 -0700
Revert "fix problem with hgLiftOver not setting default new assembly correctly"

This reverts commit 586f7cc282b1e3a2992ee81c4060277613c636a3.

diff --git src/hg/hgLiftOver/hgLiftOver.c src/hg/hgLiftOver/hgLiftOver.c
index 419952d167d..b9dba277453 100644
--- src/hg/hgLiftOver/hgLiftOver.c
+++ src/hg/hgLiftOver/hgLiftOver.c
@@ -59,31 +59,30 @@
 "document.mainForm.submit();";
 
 char *chainStringVal(struct liftOverChain *chain)
 /* keep the last chain in memory in this format */
 {
 char chainS[64];
 safef(chainS, sizeof(chainS), "%s.%s", chain->fromDb, chain->toDb);
 return cloneString(chainS);
 }
 
 void webMain(struct liftOverChain *chain, boolean multiple, boolean keepSettings, int minSizeQ, 
 	     int minChainT, float minBlocks, float minMatch, boolean fudgeThick, boolean extraNameInfo)
 /* set up page for entering data */
 {
 struct dbDb *dbList;
-printf("main %s\n", chain->toDb);
 char *fromOrg = hOrganism(chain->fromDb), *toOrg = hOrganism(chain->toDb);
 char *chainString = chainStringVal(chain);
 cgiParagraph(
     "This tool converts genome coordinates and annotation files "
     "from the original to the new assembly using an alignment.  "
     "The input regions can be entered into the text box or uploaded as a file.  "
     "For files over 500Mb, use the command-line tool described in our "
     "<a href=\"../goldenPath/help/hgTracksHelp.html#Liftover\">LiftOver documentation</a>."
     "&nbsp;&nbsp;If a pair of assemblies cannot be selected from the pull-down menus,"
     " a sequential lift may still be possible (e.g., mm9 to mm10 to mm39).&nbsp;&nbsp;"
     "If your desired conversion is still not available, please "
     "<a href=\"../../contacts.html\">contact us</a>."
     "");
 
 /* create HMTL form */
@@ -113,31 +112,30 @@
 /* from assembly */
 cgiSimpleTableFieldStart();
 printAllAssemblyListHtmlParm(chain->fromDb, dbList, HGLFT_FROMDB_VAR, 
 			     TRUE, "change", onChange);
 cgiTableFieldEnd();
 
 /* to assembly */
 
 cgiSimpleTableFieldStart();
 dbDbFreeList(&dbList);
 dbList = hGetLiftOverToDatabases(chain->fromDb);
 printLiftOverGenomeList(HGLFT_TOORG_VAR, chain->toDb, dbList, "change", onChange);
 cgiTableFieldEnd();
 
 cgiSimpleTableFieldStart();
-printf("new %s\n", chain->fromDb);
 printAllAssemblyListHtmlParm(chain->toDb, dbList, HGLFT_TODB_VAR, TRUE, NULL, NULL);
 cgiTableFieldEnd();
 
 cgiTableRowEnd();
 cgiTableEnd();
 
 printf("<br>");
 cgiSimpleTableStart();
 
 cgiSimpleTableRowStart();
 cgiTableField("Minimum ratio of bases that must remap:");
 cgiSimpleTableFieldStart();
 cgiMakeDoubleVar(HGLFT_MINMATCH, (keepSettings) ? minMatch : chain->minMatch,6);
 puts("&nbsp;");
 printInfoIcon("The minimum ratio of basepairs of the input region covered by an alignment. Regions scoring lower than this will not be lifted at all.");
@@ -401,61 +399,64 @@
 if (sameOk(cartOrg,chainToOrg)) 
     score +=  1000;
 
 score += 10*(maxRank-fromRank);
 score += (maxRank - toRank);
 
 return score;
 }
 
 
 struct liftOverChain *defaultChoices(struct liftOverChain *chainList,
 				     char *cartDb)
 /* Out of a list of liftOverChains and a cart, choose a
  * list to display. */
 {
-char *fromOrg, *fromDb, *toOrg, *toDb; 
+char *fromOrg, *fromDb, *toOrg, *toDb, *cartOrg;
 struct liftOverChain *choice = NULL;  
+struct hash *dbRank = hGetDatabaseRank();
+struct hash *dbDbHash = hDbDbHash();
+double bestScore = -1;
 struct liftOverChain *this = NULL;
 
 /* Get the initial values. */
 fromOrg = cartCgiUsualString(cart, HGLFT_FROMORG_VAR, "0");
 fromDb = cartCgiUsualString(cart, HGLFT_FROMDB_VAR, "0");
 toOrg = cartCgiUsualString(cart, HGLFT_TOORG_VAR, "0");
 toDb = cartCgiUsualString(cart, HGLFT_TODB_VAR, "0");
+cartOrg = hOrganism(cartDb);
 
 if (sameWord(fromOrg,"0"))
     fromOrg = NULL;
 if (sameWord(fromDb,"0"))
     fromDb = NULL;
 if (sameWord(toOrg,"0"))
     toOrg = NULL;
 if (sameWord(toDb,"0"))
     toDb = NULL;
 if (sameWord(cartDb,"0"))
     cartDb = NULL;
 
 for (this = chainList; this != NULL; this = this->next)
     {
-    if (sameString(this->fromDb ,fromDb) && sameString(this->toDb, toDb))
+    double score = scoreLiftOverChain(this, fromOrg, fromDb, toOrg, toDb, cartOrg, cartDb, dbRank, dbDbHash);
+    if (score > bestScore)
 	{
 	choice = this;
-        break;
+	bestScore = score;
 	}
     }
-if (choice == NULL)
-    errAbort("liftOverChain not found\n");
 
 return choice;
 }
 
 
 void doMiddle(struct cart *theCart)
 /* Set up globals and make web page */
 {
 char *userData;
 char *organism;
 char *db;
 float minBlocks, minMatch;
 boolean multiple, fudgeThick;
 int minSizeQ, minChainT;
 boolean refreshOnly = FALSE;