struct autoTest *autoTestLoad(char **row) /* Load a autoTest from row fetched with select * from autoTest * from database. Dispose of this with autoTestFree(). */ { struct autoTest *ret; AllocVar(ret); ret->ptCount = sqlSigned(row[5]); ret->difCount = sqlSigned(row[7]); ret->valCount = sqlSigned(row[10]); ret->id = sqlUnsigned(row[0]); safecpy(ret->shortName, sizeof(ret->shortName), row[1]); ret->longName = cloneString(row[2]); { char *s = cloneString(row[3]); sqlStringArray(s, ret->aliases, 3); } { char *s = row[4]; if(s != NULL && differentString(s, "")) ret->threeD = pointCommaIn(&s, NULL); } { int sizeOne; sqlShortDynamicArray(row[6], &ret->pts, &sizeOne); assert(sizeOne == ret->ptCount); } { int sizeOne; sqlUbyteDynamicArray(row[8], &ret->difs, &sizeOne); assert(sizeOne == ret->difCount); } sqlSignedArray(row[9], ret->xy, 2); { int sizeOne; sqlStringDynamicArray(row[11], &ret->vals, &sizeOne); assert(sizeOne == ret->valCount); } ret->dblVal = sqlDouble(row[12]); ret->fltVal = sqlFloat(row[13]); { int sizeOne; sqlDoubleDynamicArray(row[14], &ret->dblArray, &sizeOne); assert(sizeOne == ret->valCount); } { int sizeOne; sqlFloatDynamicArray(row[15], &ret->fltArray, &sizeOne); assert(sizeOne == ret->valCount); } return ret; }
struct bed *bedFromRow( char *chrom, /* Chromosome bed is on. */ char **row, /* Row with other data for bed. */ int fieldCount, /* Number of fields in final bed. */ boolean isPsl, /* True if in PSL format. */ boolean isGenePred, /* True if in GenePred format. */ boolean isBedWithBlocks, /* True if BED with block list. */ boolean *pslKnowIfProtein,/* Have we figured out if psl is protein? */ boolean *pslIsProtein, /* True if we know psl is protien. */ struct lm *lm) /* Local memory pool */ /* Create bed from a database row when we already understand * the format pretty well. The bed is allocated inside of * the local memory pool lm. Generally use this in conjunction * with the results of a SQL query constructed with the aid * of the bedSqlFieldsExceptForChrom function. */ { char *strand, tStrand, qStrand; struct bed *bed; int i, blockCount; lmAllocVar(lm, bed); bed->chrom = chrom; bed->chromStart = sqlUnsigned(row[0]); bed->chromEnd = sqlUnsigned(row[1]); if (fieldCount < 4) return bed; bed->name = lmCloneString(lm, row[2]); if (fieldCount < 5) return bed; bed->score = atoi(row[3]); if (fieldCount < 6) return bed; strand = row[4]; qStrand = strand[0]; tStrand = strand[1]; if (tStrand == 0) bed->strand[0] = qStrand; else { /* psl: use XOR of qStrand,tStrand if both are given. */ if (tStrand == qStrand) bed->strand[0] = '+'; else bed->strand[0] = '-'; } if (fieldCount < 8) return bed; bed->thickStart = sqlUnsigned(row[5]); bed->thickEnd = sqlUnsigned(row[6]); if (fieldCount < 12) return bed; bed->blockCount = blockCount = sqlUnsigned(row[7]); lmAllocArray(lm, bed->blockSizes, blockCount); sqlSignedArray(row[8], bed->blockSizes, blockCount); lmAllocArray(lm, bed->chromStarts, blockCount); sqlSignedArray(row[9], bed->chromStarts, blockCount); if (isGenePred) { /* Translate end coordinates to sizes. */ for (i=0; i<bed->blockCount; ++i) bed->blockSizes[i] -= bed->chromStarts[i]; } else if (isPsl) { if (!*pslKnowIfProtein) { /* Figure out if is protein using a rather elaborate but * working test I think Angie or Brian must have figured out. */ if (tStrand == '-') { int tSize = sqlUnsigned(row[10]); *pslIsProtein = (bed->chromStart == tSize - ( 3*bed->blockSizes[bed->blockCount - 1] + bed->chromStarts[bed->blockCount - 1])); } else { *pslIsProtein = (bed->chromEnd == 3*bed->blockSizes[bed->blockCount - 1] + bed->chromStarts[bed->blockCount - 1]); } *pslKnowIfProtein = TRUE; } if (*pslIsProtein) { /* if protein then blockSizes are in protein space */ for (i=0; i<blockCount; ++i) bed->blockSizes[i] *= 3; } if (tStrand == '-') { /* psl: if target strand is '-', flip the coords. * (this is the target part of pslRc from src/lib/psl.c) */ int tSize = sqlUnsigned(row[10]); for (i=0; i<blockCount; ++i) { bed->chromStarts[i] = tSize - (bed->chromStarts[i] + bed->blockSizes[i]); } reverseInts(bed->chromStarts, bed->blockCount); reverseInts(bed->blockSizes, bed->blockCount); } } if (!isBedWithBlocks) { /* non-bed: translate absolute starts to relative starts */ for (i=0; i < bed->blockCount; i++) bed->chromStarts[i] -= bed->chromStart; } return bed; }