406740c2dc67f2bb8e217627dcbbe00a204fd594 kate Mon Dec 4 15:37:32 2017 -0800 Add support for item color, using Ensembl extension (RGB instead of value). http://www.ensembl.org/info/website/upload/pairwise.html diff --git src/hg/lib/longRange.c src/hg/lib/longRange.c index 8fc3ac4..b971f9a 100644 --- src/hg/lib/longRange.c +++ src/hg/lib/longRange.c @@ -15,82 +15,97 @@ int min, max, deflt, current; cartTdbFetchMinMaxPixels(cart, tdb, LONG_MINHEIGHT, LONG_MAXHEIGHT, atoi(LONG_DEFHEIGHT), &min, &max, &deflt, ¤t); safef(buffer, sizeof buffer, "%s.%s", tdb->track, LONG_HEIGHT); printf("
Track height: "); cgiMakeIntVar(buffer, current, 3); printf(" pixels (range: %d to %d, default: %d)", min, max, deflt); safef(buffer, sizeof buffer, "%s.%s", tdb->track, LONG_MINSCORE); double minScore = sqlDouble(cartUsualString(cart, buffer, LONG_DEFMINSCORE)); printf("

Minimum score: "); cgiMakeDoubleVar(buffer, minScore, 0); } -static char *getOther(struct bed *bed, unsigned *s, unsigned *e, double *score) +static char *getOther(struct bed *bed, unsigned *s, unsigned *e, + boolean *hasColor, double *score, unsigned *rgb) /* parse the name field of longTabix to get the other location */ { char *otherChrom = cloneString(bed->name); char *ptr = strchr(otherChrom, ':'); if (ptr == NULL) errAbort("bad longTabix bed name %s\n", bed->name); *ptr++ = 0; *s = atoi(ptr); ptr = strchr(ptr, '-'); if (ptr == NULL) errAbort("bad longTabix bed name %s\n", bed->name); ptr++; *e = atoi(ptr); ptr = strchr(ptr, ','); if (ptr == NULL) errAbort("bad longTabix bed name %s\n", bed->name); ptr++; -*score = sqlDouble(ptr); +// parse value or RGB (value after comma in name field) +*score = 0; +*hasColor = FALSE; +int rgbRet = -1; +if (strchr(ptr, ',')) + rgbRet = bedParseRgb(ptr); +if (rgbRet != -1) + { + *rgb = rgbRet; + *hasColor = TRUE; + } +else + *score = sqlDouble(ptr); return otherChrom; } struct longRange *parseLongTabix(struct bed *beds, unsigned *maxWidth, double minScore) /* Parse longTabix format into longRange structures */ { struct longRange *longRangeList = NULL; *maxWidth = 1; for(; beds; beds=beds->next) { double score; - unsigned otherS; - unsigned otherE; - char *otherChrom = getOther(beds, &otherS, &otherE, &score); + unsigned otherS, otherE; + unsigned rgb; + boolean hasColor; + char *otherChrom = getOther(beds, &otherS, &otherE, &hasColor, &score, &rgb); if (score < minScore) continue; - struct longRange *longRange; AllocVar(longRange); slAddHead(&longRangeList, longRange); - unsigned otherCenter = (otherS + otherE)/2; - unsigned otherWidth = otherE - otherS; - unsigned thisWidth = beds->chromEnd - beds->chromStart; - unsigned center = (beds->chromEnd + beds->chromStart) / 2; - // don't have oriented feet at the moment longRange->sOrient = longRange->eOrient = 0; - longRange->id = beds->score; + longRange->id = beds->score; // Id is field 5 in this format longRange->score = score; + longRange->hasColor = hasColor; + longRange->rgb = rgb; longRange->name = beds->name; + unsigned otherCenter = (otherS + otherE)/2; + unsigned otherWidth = otherE - otherS; + unsigned thisWidth = beds->chromEnd - beds->chromStart; + unsigned center = (beds->chromEnd + beds->chromStart) / 2; + if (sameString(beds->chrom, otherChrom) && (otherCenter < center)) { longRange->s = otherCenter; longRange->sw = otherWidth; longRange->sChrom = otherChrom; longRange->e = center; longRange->ew = thisWidth; longRange->eChrom = beds->chrom; } else { longRange->s = center; longRange->sw = thisWidth; longRange->sChrom = beds->chrom; longRange->e = otherCenter;