3101345a6900f9d8534b9128ff1057808cfda01e kent Mon Mar 4 21:35:16 2013 -0800 Renaming a local variable to be a bit more descriptive. diff --git src/lib/basicBed.c src/lib/basicBed.c index f6137ed..a651070 100644 --- src/lib/basicBed.c +++ src/lib/basicBed.c @@ -1330,161 +1330,161 @@ boolean result = FALSE; struct asObject *asStandard = NULL; if (numColumnsToCheck > 15) errAbort("There are only 15 standard BED columns defined and you have asked for %d.", numColumnsToCheck); if (numColumnsToCheck < 3) errAbort("All BED files have at least the first 3 columns the same."); char *asStandardText = bedAsDef(15,15); asStandard = asParseText(asStandardText); result = asCompareObjs("Yours", asYours, "BED Standard", asStandard, numColumnsToCheck, NULL, abortOnDifference); freeMem(asStandardText); asObjectFreeList(&asStandard); return result; } -void loadAndValidateBed(char *row[], int wordCount, int fieldCount, struct lineFile *lf, struct bed * bed, struct asObject *as, boolean isCt) +void loadAndValidateBed(char *row[], int bedFieldCount, int fieldCount, struct lineFile *lf, struct bed * bed, struct asObject *as, boolean isCt) /* Convert a row of strings to a bed and validate the contents. Abort with message if invalid data. Optionally validate bedPlus via asObject. * If a customTrack, then some errors are tolerated. */ { int count; int *blockSizes = NULL; int *chromStarts; int *expIds; float *expScores; bed->chrom = row[0]; // note this value is not cloned for speed, callers may need to clone it. // This check is usually redundant since the caller should be checking it against actual chromInfo names // however hgLoadBed might not always have that info available. if (strlen(bed->chrom) >= BB_MAX_CHROM_STRING) // must leave room for 0 terminator lineFileAbort(lf, "chrom [%s] is too long (must not exceed %d characters)", bed->chrom, BB_MAX_CHROM_STRING - 1); if (strlen(bed->chrom) < 1) lineFileAbort(lf, "chrom cannot be blank or empty"); lineFileAllInts(lf, row, 1, &bed->chromStart, FALSE, 4, "integer", FALSE); lineFileAllInts(lf, row, 2, &bed->chromEnd, FALSE, 4, "integer", FALSE); if (bed->chromEnd < bed->chromStart) lineFileAbort(lf, "chromStart after chromEnd (%u > %u)", bed->chromStart, bed->chromEnd); -if (wordCount > 3) +if (bedFieldCount > 3) { bed->name = row[3]; if (strlen(bed->name) > 255) lineFileAbort(lf, "name [%s] is too long (must not exceed 255 characters)", bed->name); if (isCt) bed->name = cloneString(bed->name); } -if (wordCount > 4) +if (bedFieldCount > 4) { lineFileAllInts(lf, row, 4, &bed->score, TRUE, 4, "integer", FALSE); if (!isCt && (bed->score < 0 || bed->score > 1000)) lineFileAbort(lf, "score (%d) must be between 0 and 1000", bed->score); } -if (wordCount > 5) +if (bedFieldCount > 5) { if (!isCt && strlen(row[5]) > 1) lineFileAbort(lf, "Expecting + or - or . in strand, found [%s]",row[5]); bed->strand[0] = row[5][0]; bed->strand[1] = 0; if (bed->strand[0] != '+' && bed->strand[0] != '-' && bed->strand[0] != '.') lineFileAbort(lf, "Expecting + or - or . in strand, found [%s]",row[5]); } -if (wordCount > 6) +if (bedFieldCount > 6) lineFileAllInts(lf, row, 6, &bed->thickStart, FALSE, 4, "integer", FALSE); else bed->thickStart = bed->chromStart; -if (wordCount > 7) +if (bedFieldCount > 7) { lineFileAllInts(lf, row, 7, &bed->thickEnd, FALSE, 4, "integer", FALSE); if (bed->thickEnd < bed->thickStart) lineFileAbort(lf, "thickStart after thickEnd"); if ((bed->thickStart != 0) && ((bed->thickStart < bed->chromStart) || (bed->thickStart > bed->chromEnd))) lineFileAbort(lf, "thickStart out of range (chromStart to chromEnd, or 0 if no CDS)"); if ((bed->thickEnd != 0) && ((bed->thickEnd < bed->chromStart) || (bed->thickEnd > bed->chromEnd))) lineFileAbort(lf, "thickEnd out of range for %s:%u-%u, thick:%u-%u (chromStart to chromEnd, or 0 if no CDS)", bed->name, bed->chromStart, bed->chromEnd, bed->thickStart, bed->thickEnd); } else bed->thickEnd = bed->chromEnd; -if (wordCount > 8) +if (bedFieldCount > 8) { if (strchr(row[8],',')) { unsigned char colors[4]; char *saveColorString = cloneString(row[8]); int numColors = lineFileAllIntsArray(lf, row, 8, colors, sizeof colors, FALSE, 1, "integer", FALSE); if (numColors == 3) { bed->itemRgb = (((unsigned)colors[0]) << 2*8) | (((unsigned)colors[1]) << 1*8) | (unsigned)colors[2]; } else lineFileAbort(lf, "Expecting color to consist of r,g,b values from 0 to 255. Got [%s]", saveColorString); freeMem(saveColorString); } else { lineFileAllInts(lf, row, 8, &bed->itemRgb, FALSE, 4, "integer", FALSE); } } int tempArraySize = 1; // How big arrays are below -if (wordCount > 9) +if (bedFieldCount > 9) { lineFileAllInts(lf, row, 9, &bed->blockCount, FALSE, 4, "integer", FALSE); if (!(bed->blockCount >= 1)) lineFileAbort(lf, "Expecting blockCount (%d) to be 1 or more.", bed->blockCount); tempArraySize = bed->blockCount; } int tempBlockSizes[tempArraySize]; int tempChromStarts[tempArraySize]; int tempExpIds[tempArraySize]; float tempExpScores[tempArraySize]; -if (wordCount > 10) +if (bedFieldCount > 10) { if (isCt) { AllocArray(bed->blockSizes,bed->blockCount+1); // having +1 allows us to detect incorrect size count = lineFileAllIntsArray(lf, row, 10, bed->blockSizes, bed->blockCount+1, TRUE, 4, "integer", TRUE); blockSizes = bed->blockSizes; } else { count = lineFileAllIntsArray(lf, row, 10, tempBlockSizes, tempArraySize, TRUE, 4, "integer", TRUE); blockSizes = tempBlockSizes; } if (count != bed->blockCount) lineFileAbort(lf, "Expecting %d elements in blockSizes list, found at least %d", bed->blockCount, count); int i; for (i=0; i < bed->blockCount; i++) { if (!(blockSizes[i] > 0)) lineFileAbort(lf, "BED blockSizes must be greater than 0, blockSize[%d] = %d", i, blockSizes[i]); } } -if (wordCount > 11) +if (bedFieldCount > 11) { int i; if (isCt) { AllocArray(bed->chromStarts,bed->blockCount+1); // having +1 allows us to detect incorrect size count = lineFileAllIntsArray(lf, row, 11, bed->chromStarts, bed->blockCount+1, TRUE, 4, "integer", TRUE); chromStarts = bed->chromStarts; } else { count = lineFileAllIntsArray(lf, row, 11, tempChromStarts, tempArraySize, TRUE, 4, "integer", TRUE); chromStarts = tempChromStarts; } if (count != bed->blockCount) lineFileAbort(lf, "Expecting %d elements in chromStarts list, found at least %d", bed->blockCount, count); @@ -1514,50 +1514,50 @@ } // chrom blocks must ascend without overlap if (!(chromStarts[i] >= chromStarts[i-1] + blockSizes[i-1])) lineFileAbort(lf, "BED blocks must be in ascending order without overlap. Blocks %d and %d overlap.", i-1, i); } // last block-end must match chromEnd i = bed->blockCount-1; if ((bed->chromStart + chromStarts[i] + blockSizes[i]) != bed->chromEnd) { lineFileAbort(lf, "BED blocks must span chromStart to chromEnd. (chromStart + " "chromStarts[last] + blockSizes[last]) must equal chromEnd."); } } -if (wordCount > 12) +if (bedFieldCount > 12) // get the microarray/colored-exon fields { lineFileAllInts(lf, row, 12, &bed->expCount, TRUE, 4, "integer", TRUE); if (!(bed->expCount >= 1)) lineFileAbort(lf, "Expecting expCount (%d) to be 1 or more.", bed->expCount); if (isCt) { AllocArray(bed->expIds,bed->expCount+1); // having +1 allows us to detect incorrect size count = lineFileAllIntsArray(lf, row, 13, bed->expIds, bed->expCount+1, TRUE, 4, "integer", TRUE); expIds = bed->expIds; } else { count = lineFileAllIntsArray(lf, row, 13, tempExpIds, tempArraySize, TRUE, 4, "integer", TRUE); expIds = tempExpIds; } if (count != bed->expCount) lineFileAbort(lf, "expecting %d elements in expIds list (bed field 14)", bed->expCount); - if (wordCount == 15) + if (bedFieldCount == 15) { if (isCt) { sqlFloatDynamicArray(row[14], &bed->expScores, &count); expScores = bed->expScores; } else { count = sqlFloatArray(row[14], tempExpScores, tempArraySize); expScores = tempExpScores; } if (count != bed->expCount) lineFileAbort(lf, "expecting %d elements in expScores list (bed field 15)", bed->expCount); } } @@ -1580,32 +1580,32 @@ if (asTypesIsInt(type)) { if (asCol->isSizeLink) // save the field value and index for later use in validating a list size. { int listSize = 0; // big enough to hold the list count lineFileAllInts(lf, row, i, &listSize, TRUE, 4, "integer", TRUE); if (!linkHash) linkHash = newHash(4); hashAddInt(linkHash, asCol->name, listSize); } } } asCol = asCol->next; } /* Validate bed-plus fields */ - asCol = slElementFromIx(as->columnList, wordCount); - for (i=wordCount; icolumnList, bedFieldCount); + for (i=bedFieldCount; ilowType->type; if (! (asCol->isList || asCol->isArray)) { if (asTypesIsInt(type)) lineFileAllInts(lf, row, i, NULL, !asTypesIsUnsigned(type), asTypesIntSize(type), asTypesIntSizeDescription(type), FALSE); else if (asTypesIsFloating(type)) lineFileNeedDouble(lf, row, i); else if (type == t_string) { if (strlen(row[i]) > 255) lineFileAbort(lf, "expecting length (%llu) of string (%s) not to exceed 255 in field %s", (unsigned long long)strlen(row[i]), row[i], asCol->name); } } else if (asCol->isList)