cb8f8b8e1fa7a5e122b4e0e5c7fb84bf4027d008 hiram Fri Sep 18 13:03:08 2020 -0700 assembly hubs and now display alias names on sequence display page refs #24396 diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index afe705d..29e2707 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -9903,40 +9903,46 @@ cartSetDbPosition(cart, database, lastDbPosCart); if (cartUsualBoolean(cart, "hgt.psOutput", FALSE)) handlePostscript(); else doTrackForm(NULL, NULL); boolean gotExtTools = extToolsEnabled(); setupHotkeys(gotExtTools); if (gotExtTools) printExtMenuData(chromName); if (recTrackSetsEnabled()) printRecTrackSets(); } -void chromInfoTotalRow(int count, long long total) +static void chromInfoTotalRow(int count, long long total, boolean hasAlias) /* Make table row with total number of sequences and size from chromInfo. */ { cgiSimpleTableRowStart(); cgiSimpleTableFieldStart(); printf("Total: %d", count); cgiTableFieldEnd(); cgiSimpleTableFieldStart(); printLongWithCommas(stdout, total); cgiTableFieldEnd(); +if (hasAlias) + { + cgiSimpleTableFieldStart(); + puts(" "); + cgiTableFieldEnd(); + } cgiTableRowEnd(); } static char *chrAliases(struct hash *aliasHash, char *sequenceName) /* lookup the sequenceName in the aliasHash and return csv string * of alias names */ { if (NULL == aliasHash) return NULL; struct dyString *returned = dyStringNew(512); struct hashEl *hel = hashLookup(aliasHash, sequenceName); if (hel) { dyStringPrintf(returned, "%s", ((struct chromAlias *)hel->val)->alias); @@ -9983,82 +9989,96 @@ printLongWithCommas(stdout, size); puts(" "); cgiTableFieldEnd(); if (hasAlias) { cgiSimpleTableFieldStart(); if (aliasNames) htmlPrintf("%s", aliasNames); else htmlPrintf(" "); cgiTableFieldEnd(); } cgiTableRowEnd(); total += size; } -chromInfoTotalRow(slCount(chromList), total); +chromInfoTotalRow(slCount(chromList), total, hasAlias); 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); int seqCount = slCount(chromInfo); +struct hash *aliasHash = trackHubAllChromAlias(database); +boolean hasAlias = FALSE; +if (aliasHash) + hasAlias = TRUE; long long total = 0; char msg1[512], msg2[512]; boolean truncating; int count = limit; truncating = (limit > 0) && (seqCount > limit); for(;count-- && (chromInfo != NULL); chromInfo = chromInfo->next) { + char *aliasNames = chrAliases(aliasHash, chromInfo->chrom); unsigned size = chromInfo->size; cgiSimpleTableRowStart(); cgiSimpleTableFieldStart(); htmlPrintf("<A HREF=\"%s|none|?%s|url|=%s|url|&position=%s|url|\">%s</A>", hgTracksName(), cartSessionVarName(), cartSessionId(cart), chromInfo->chrom,chromInfo->chrom); cgiTableFieldEnd(); cgiTableFieldStartAlignRight(); printLongWithCommas(stdout, size); puts(" "); cgiTableFieldEnd(); + if (hasAlias) + { + cgiSimpleTableFieldStart(); + if (aliasNames) + htmlPrintf("%s", aliasNames); + else + htmlPrintf(" "); + cgiTableFieldEnd(); + } cgiTableRowEnd(); total += size; } if (!truncating) { - chromInfoTotalRow(seqCount, total); + chromInfoTotalRow(seqCount, total, hasAlias); } else { safef(msg1, sizeof(msg1), "Limit reached"); safef(msg2, sizeof(msg2), "%d rows displayed", limit); cgiSimpleTableRowStart(); cgiSimpleTableFieldStart(); puts(msg1); cgiTableFieldEnd(); cgiSimpleTableFieldStart(); puts(msg2); cgiTableFieldEnd(); for(;limit-- && (chromInfo != NULL); chromInfo = chromInfo->next) total += chromInfo->size; @@ -10138,31 +10158,31 @@ cgiTableFieldEnd(); if (hasAlias) { cgiSimpleTableFieldStart(); if (aliasNames) htmlPrintf("%s", aliasNames); else htmlPrintf(" "); cgiTableFieldEnd(); } cgiTableRowEnd(); total += size; } if (!truncating) { - chromInfoTotalRow(seqCount, total); + chromInfoTotalRow(seqCount, total, hasAlias); } else { safef(msg1, sizeof(msg1), "Limit reached"); safef(msg2, sizeof(msg2), "%d rows displayed", limit); cgiSimpleTableRowStart(); cgiSimpleTableFieldStart(); puts(msg1); cgiTableFieldEnd(); cgiSimpleTableFieldStart(); puts(msg2); cgiTableFieldEnd(); sqlFreeResult(&sr); sqlSafef(query, sizeof(query), "select count(*),sum(size) from chromInfo"); sr = sqlGetResult(conn, query); @@ -10241,30 +10261,36 @@ hTableStart(); cgiSimpleTableRowStart(); cgiSimpleTableFieldStart(); puts("Sequence name "); cgiTableFieldEnd(); cgiSimpleTableFieldStart(); puts("Length (bp) including gaps "); cgiTableFieldEnd(); if (hTableExists(database, "chromAlias")) { cgiSimpleTableFieldStart(); puts("alias sequence names "); cgiTableFieldEnd(); } +else if (trackHubAliasFile(database)) + { + cgiSimpleTableFieldStart(); + puts("alias sequence names "); + cgiTableFieldEnd(); + } cgiTableRowEnd(); if (sameString(database,"hg38")) chromInfoRowsChromExt("withAltRandom"); else if ((startsWith("chr", defaultChrom) || startsWith("Group", defaultChrom)) && hChromCount(database) < 100) chromInfoRowsChrom(); else chromInfoRowsNonChrom(1000); chromSizesDownloadRow(); hTableEnd(); cgiDown(0.9); hgPositionsHelpHtml(organism, database);