0bfe2cd2da0c27acc68dd0f4a462f7b45274a063 angie Wed Aug 12 11:26:43 2015 -0700 Use isnan instead of comparing to NAN, which does not work! diff --git src/lib/annoGrateWig.c src/lib/annoGrateWig.c index 47cda06..b0814f1 100644 --- src/lib/annoGrateWig.c +++ src/lib/annoGrateWig.c @@ -16,50 +16,52 @@ static void tidyUp(const struct annoRow *rowIn, struct annoRow **pOutList, uint primaryStart, uint primaryEnd, struct lm *callerLm) /* This takes a wiggle chunk coming from a .wig/database row and makes it into * zero or more tidy little NAN-less annoRows. Trim rowIn to the bounds of * primary, trim NANs from beginning and break into multiple rows where there * are NANs in the middle. If the rowIn is contiguous with the row at the * head of outList, expand that row to include rowIn's data. */ { uint start = max(rowIn->start, primaryStart); uint end = min(rowIn->end, primaryEnd); float *vector = rowIn->data; while (end > start) { uint offset = start - rowIn->start; - if (vector[offset] == NAN) + if (isnan(vector[offset])) start++; else { // If there is a NAN before end, that's the end of this row: uint thisEnd = start; - while (thisEnd < end && vector[thisEnd - rowIn->start] != NAN) + while (thisEnd < end && ! isnan(vector[thisEnd - rowIn->start])) thisEnd++; struct annoRow *headRow = *pOutList; if (headRow == NULL || rowIn->start > headRow->end) { // allocate a new row struct annoRow *rowOut = annoRowWigNew(rowIn->chrom, start, thisEnd, FALSE, vector + offset, callerLm); slAddHead(pOutList, rowOut); } else { // glom new data onto headRow - assert(thisEnd > headRow->end); + if (thisEnd < headRow->end) + errAbort("Expected thisEnd (%u) to be greater than or equal to headRow->end (%u)", + thisEnd, headRow->end); uint oldEnd = headRow->end; uint oldLen = oldEnd - headRow->start; uint newLen = thisEnd - headRow->start; headRow->data = lmAllocMoreMem(callerLm, headRow->data, oldLen*sizeof(vector[0]), newLen*sizeof(vector[0])); headRow->end = thisEnd; float *newData = (float *)rowIn->data + (oldEnd - rowIn->start); float *newSpace = (float *)headRow->data + oldLen; CopyArray(newData, newSpace, (thisEnd - oldEnd)); } start = thisEnd; } } }