struct linkedFeatures *lfFromRetroGene(struct ucscRetroInfo *pg) /* Return a linked feature from a retroGene. */ { struct linkedFeatures *lf; struct simpleFeature *sf, *sfList = NULL; int grayIx = grayInRange(pg->score, 0, 1000); int *starts = pg->chromStarts, start; int *sizes = pg->blockSizes; int blockCount = pg->blockCount, i; assert(starts != NULL && sizes != NULL && blockCount > 0); AllocVar(lf); lf->grayIx = grayIx; lf->name = cloneString(pg->name); lf->orientation = orientFromChar(pg->strand[0]); for (i=0; i<blockCount; ++i) { AllocVar(sf); start = starts[i] + pg->chromStart; sf->start = start; sf->end = start + sizes[i]; sf->grayIx = grayIx; slAddHead(&sfList, sf); } slReverse(&sfList); lf->components = sfList; linkedFeaturesBoundsAndGrays(lf); lf->tallStart = pg->thickStart; lf->tallEnd = pg->thickEnd; lf->extra = pg; return lf; }
static struct linkedFeatures *lfFromEncodePeak(struct slList *item, struct trackDb *tdb, int scoreMin, int scoreMax) /* Translate an {encode,narrow,broad,gapped}Peak item into a linkedFeatures. */ { struct encodePeak *peak = (struct encodePeak *)item; struct linkedFeatures *lf; struct simpleFeature *sfList = NULL; if (!peak) return NULL; AllocVar(lf); lf->start = peak->chromStart; lf->end = peak->chromEnd; if (peak->peak > -1) { lf->tallStart = peak->chromStart + peak->peak; lf->tallEnd = lf->tallStart + 1; } lf->filterColor = -1; lf->orientation = orientFromChar(peak->strand[0]); adjustBedScoreGrayLevel(tdb, (struct bed *)peak, scoreMin, scoreMax); lf->grayIx = grayInRange((int)peak->score, scoreMin, scoreMax); lf->name = cloneString(peak->name); if (peak->blockCount > 0) { int i; for (i = 0; i < peak->blockCount; i++) { struct simpleFeature *sf; AllocVar(sf); sf->start = lf->start + peak->blockStarts[i]; sf->end = lf->start + peak->blockStarts[i] + peak->blockSizes[i]; sf->grayIx = lf->grayIx; slAddHead(&sfList, sf); } slReverse(&sfList); } else { AllocVar(sfList); sfList->start = lf->start; sfList->end = lf->end; sfList->grayIx = lf->grayIx; } lf->components = sfList; return lf; }
void bigBedDrawDense(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color) /* Use big-bed summary data to quickly draw bigBed. */ { struct bbiSummaryElement *summary = tg->summary; if (summary) { char *denseCoverage = trackDbSettingClosestToHome(tg->tdb, "denseCoverage"); if (denseCoverage != NULL) { double startVal = 0, endVal = atof(denseCoverage); if (endVal <= 0) { struct bbiSummaryElement sumAll = *tg->sumAll; double mean = sumAll.sumData/sumAll.validCount; double std = calcStdFromSums(sumAll.sumData, sumAll.sumSquares, sumAll.validCount); rangeFromMinMaxMeanStd(0, sumAll.maxVal, mean, std, &startVal, &endVal); } int x; for (x=0; x<width; ++x) { if (summary[x].validCount > 0) { Color color = shadesOfGray[grayInRange(summary[x].maxVal, startVal, endVal)]; hvGfxBox(hvg, x+xOff, yOff, 1, tg->heightPer, color); } } } else { int x; for (x=0; x<width; ++x) { if (summary[x].validCount > 0) { hvGfxBox(hvg, x+xOff, yOff, 1, tg->heightPer, color); } } } } freez(&tg->summary); }
struct linkedFeatures *lfFromBed6(struct codeBlast *bed, int scoreMin, int scoreMax) /* Return a linked feature from a (full) bed. */ { struct linkedFeatures *lf; struct simpleFeature *sf; int grayIx = grayInRange(bed->score, scoreMin, scoreMax); AllocVar(lf); lf->grayIx = grayIx; lf->name = cloneString(bed->name); lf->orientation = orientFromChar(bed->strand[0]); AllocVar(sf); sf->start = bed->chromStart; sf->end = bed->chromEnd; sf->grayIx = grayIx; lf->components = sf; linkedFeaturesBoundsAndGrays(lf); lf->tallStart = bed->chromStart; lf->tallEnd = bed->chromEnd; return lf; }
struct linkedFeatures *lfFromSample(struct sample *sample) /* Return a linked feature from a full sample (wiggle) track. */ { struct linkedFeatures *lf; struct simpleFeature *sf, *sfList = NULL; int grayIx = grayInRange(sample->score, 0, 1000); int start, i; unsigned *X = sample->samplePosition; int *Y = sample->sampleHeight; unsigned sampleCount = sample->sampleCount; assert(X != NULL && Y != NULL && sampleCount > 0); AllocVar(lf); lf->grayIx = grayIx; lf->name = cloneString(sample->name); lf->orientation = orientFromChar(sample->strand[0]); for (i=0; i<sampleCount; ++i) { AllocVar(sf); start = X[i] + sample->chromStart; sf->start = start; if( Y[i] < 0 ) /*hack for negative values not loading correctly*/ sf->end = start; else if( Y[i] == 0 ) sf->end = start + 1; else sf->end = start + Y[i]; sf->grayIx = grayIx; slAddHead(&sfList, sf); } slReverse(&sfList); lf->components = sfList; linkedFeaturesBoundsAndGrays(lf); lf->start = sample->chromStart; lf->end = sample->chromEnd; return lf; }
void bedDrawSimpleAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y, double scale, MgFont *font, Color color, enum trackVisibility vis) /* Draw a single simple bed item at position. */ { struct bed *bed = item; int heightPer = tg->heightPer; int s = max(bed->chromStart, winStart), e = min(bed->chromEnd, winEnd); if (s > e) return; int x1 = round((s-winStart)*scale) + xOff; int x2 = round((e-winStart)*scale) + xOff; int w = x2 - x1; if (w < 1) w = 1; struct trackDb *tdb = tg->tdb; int scoreMin = atoi(trackDbSettingClosestToHomeOrDefault(tdb, "scoreMin", "0")); int scoreMax = atoi(trackDbSettingClosestToHomeOrDefault(tdb, "scoreMax", "1000")); char *directUrl = trackDbSetting(tdb, "directUrl"); boolean withHgsid = (trackDbSetting(tdb, "hgsid") != NULL); boolean thickDrawItem = (trackDbSetting(tdb, "thickDrawItem") != NULL); if (tg->itemColor != NULL) { color = tg->itemColor(tg, bed, hvg); } else if (tg->colorShades) { adjustBedScoreGrayLevel(tdb, bed, scoreMin, scoreMax); color = tg->colorShades[grayInRange(bed->score, scoreMin, scoreMax)]; } /* Keep the item at least 4 pixels wide at all viewpoints */ if (thickDrawItem && (w < 4)) { x1 -= ((5-w) >> 1); w = 4; x2 = x1 + w; }
void loadOperon(struct track *tg) /* Load the items in one custom track - just move beds in * window... */ { struct linkedFeatures *lfList = NULL, *lf; struct bed *bed, *list = NULL; struct sqlConnection *conn = hAllocConn(database); struct sqlResult *sr; char **row; int rowOffset; sr = hRangeQuery(conn, tg->table, chromName, winStart, winEnd, NULL, &rowOffset); while ((row = sqlNextRow(sr)) != NULL) { bed = bedLoadN(row+rowOffset, 15); slAddHead(&list, bed); } sqlFreeResult(&sr); hFreeConn(&conn); slReverse(&list); for (bed = list; bed != NULL; bed = bed->next) { struct simpleFeature *sf; int i; lf = lfFromBed(bed); sf = lf->components; for (i = 0; i < bed->expCount; i++) { if (sf == NULL) break; sf->grayIx = grayInRange((int)(bed->expScores[i]),0,1000); sf = sf->next; } slAddHead(&lfList,lf); } tg->items = lfList; }
static int grayIxForCgap(double tpm) /* Return a grayIx based on the score. */ { int val = (int)ceil(tpm); return grayInRange(val, 0, 150); }