22dd60838217f9e01a5420bab79a724f694da54c
hiram
Fri Jan 22 17:21:30 2021 -0800
correct sizing of assembly hub sequence when more than display limit refs #26584
diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index a49db1c..1545ab1 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -10072,77 +10072,78 @@
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;
+int lineCount = 0;
truncating = (limit > 0) && (seqCount > limit);
-for(;count-- && (chromInfo != NULL); chromInfo = chromInfo->next)
+for( ;lineCount < seqCount && (chromInfo != NULL); ++lineCount, chromInfo = chromInfo->next)
{
- char *aliasNames = chrAliases(aliasHash, chromInfo->chrom);
unsigned size = chromInfo->size;
+ if (lineCount < limit)
+ {
+ char *aliasNames = chrAliases(aliasHash, chromInfo->chrom);
cgiSimpleTableRowStart();
cgiSimpleTableFieldStart();
htmlPrintf("%s",
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, 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;
unsigned scafCount = seqCount;
cgiTableRowEnd();
safef(msg1, sizeof(msg1), "contig/scaffold
count:");
safef(msg2, sizeof(msg2), "total size:");
cgiSimpleTableRowStart();
cgiSimpleTableFieldStart();
puts(msg1);
cgiTableFieldEnd();
cgiSimpleTableFieldStart();
puts(msg2);
cgiTableFieldEnd();
cgiTableRowEnd();
cgiSimpleTableRowStart();
cgiSimpleTableFieldStart();