13407761de80485e6d82d05387698910fa309502
galt
  Tue Jan 28 17:30:54 2014 -0800
Fixes #12509. Create special chrom ordering for hg38 as specified in the ticket.
diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 560111e..f4148b6 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -5368,58 +5368,70 @@
 }
 
 void chromInfoTotalRow(int count, long long total)
 /* Make table row with total number of sequences and size from chromInfo. */
 {
 cgiSimpleTableRowStart();
 cgiSimpleTableFieldStart();
 printf("Total: %d", count);
 cgiTableFieldEnd();
 cgiSimpleTableFieldStart();
 printLongWithCommas(stdout, total);
 cgiTableFieldEnd();
 cgiTableRowEnd();
 }
 
-void chromInfoRowsChrom()
+void chromInfoRowsChromExt(char *sortType)
 /* Make table rows of chromosomal chromInfo name & size, sorted by name. */
 {
 struct slName *chromList = hAllChromNames(database);
 struct slName *chromPtr = NULL;
 long long total = 0;
 
+if (sameString(sortType,"default"))
     slSort(&chromList, chrSlNameCmp);
+else if (sameString(sortType,"withAltRandom"))
+    slSort(&chromList, chrSlNameCmpWithAltRandom);
+else
+    errAbort("unknown sort type in chromInfoRowsChromExt: %s", sortType);
+
 for (chromPtr = chromList;  chromPtr != NULL;  chromPtr = chromPtr->next)
     {
     unsigned size = hChromSize(database, chromPtr->name);
     cgiSimpleTableRowStart();
     cgiSimpleTableFieldStart();
     printf("<A HREF=\"%s?%s=%u&position=%s\">%s</A>",
            hgTracksName(), cartSessionVarName(), cartSessionId(cart),
            chromPtr->name, chromPtr->name);
     cgiTableFieldEnd();
     cgiTableFieldStartAlignRight();
     printLongWithCommas(stdout, size);
     puts("&nbsp;&nbsp;");
     cgiTableFieldEnd();
     cgiTableRowEnd();
     total += size;
     }
 chromInfoTotalRow(slCount(chromList), total);
 slFreeList(&chromList);
 }
 
+void chromInfoRowsChrom()
+/* Make table rows of chromosomal chromInfo name & size, sorted by name. */
+{
+chromInfoRowsChromExt("default");
+}
+
 static int  chromInfoCmpSize(const void *va, const void *vb)
 /* Compare to sort based on chrom size */
 {
 const struct chromInfo *a = *((struct chromInfo **)va);
 const struct chromInfo *b = *((struct chromInfo **)vb);
 
 return b->size - a->size;
 }
 
 void chromInfoRowsNonChromTrackHub(int limit)
 /* Make table rows of non-chromosomal chromInfo name & size */
 /* leaks chromInfo list */
 {
 struct chromInfo *chromInfo = trackHubAllChromInfo(database);
 slSort(&chromInfo, chromInfoCmpSize);
@@ -5609,31 +5621,33 @@
 puts("position ");
 hTextVar("position", addCommasToPos(database, position), 30);
 cgiMakeButton("Submit", "submit");
 puts("<P>");
 
 hTableStart();
 cgiSimpleTableRowStart();
 cgiSimpleTableFieldStart();
 puts("Sequence name &nbsp;");
 cgiTableFieldEnd();
 cgiSimpleTableFieldStart();
 puts("Length (bp) including gaps &nbsp;");
 cgiTableFieldEnd();
 cgiTableRowEnd();
 
-if ((startsWith("chr", defaultChrom) || startsWith("Group", defaultChrom)) &&
+if (sameString(database,"hg38"))
+    chromInfoRowsChromExt("withAltRandom");
+else if ((startsWith("chr", defaultChrom) || startsWith("Group", defaultChrom)) &&
     hChromCount(database) < 100)
     chromInfoRowsChrom();
 else
     chromInfoRowsNonChrom(1000);
 
 hTableEnd();
 cgiDown(0.9);
 
 hgPositionsHelpHtml(organism, database);
 puts("</FORM>");
 dyStringFree(&title);
 webEndSectionTables();
 }