struct linkedFeatures *bedMungToLinkedFeatures(struct bed **pBed, struct trackDb *tdb, int fieldCount, int scoreMin, int scoreMax, boolean useItemRgb) /* Convert bed to a linkedFeature, destroying bed in the process. */ { struct bed *bed = *pBed; if (fieldCount < 12) bed8To12(bed); adjustBedScoreGrayLevel(tdb, bed, scoreMin, scoreMax); struct linkedFeatures *lf = lfFromBedExtra(bed, scoreMin, scoreMax); if (useItemRgb) { lf->extra = (void *)USE_ITEM_RGB; /* signal for coloring */ lf->filterColor=bed->itemRgb; } bedFree(pBed); return lf; }
static void wikiTrackLoadItems(struct track *tg) /* Load the items from the wikiTrack table */ { struct bed *bed; struct sqlConnection *wikiConn = wikiConnect(); struct sqlResult *sr; char **row; int rowOffset; char where[256]; struct linkedFeatures *lfList = NULL, *lf; int scoreMin = 0; int scoreMax = 99999; safef(where, ArraySize(where), "db='%s'", database); sr = hRangeQuery(wikiConn, tg->table, chromName, winStart, winEnd, where, &rowOffset); while ((row = sqlNextRow(sr)) != NULL) { struct wikiTrack *item = wikiTrackLoad(row); AllocVar(bed); bed->chrom = cloneString(item->chrom); bed->chromStart = item->chromStart; bed->chromEnd = item->chromEnd; bed->name = cloneString(item->name); bed->score = item->score; safecpy(bed->strand, sizeof(bed->strand), item->strand); bed->thickStart = item->chromStart; bed->thickEnd = item->chromEnd; bed->itemRgb = hexToDecimal(item->color); bed8To12(bed); lf = lfFromBedExtra(bed, scoreMin, scoreMax); lf->extra = (void *)USE_ITEM_RGB; /* signal for coloring */ lf->filterColor=bed->itemRgb; /* overload itemAttr fields to be able to pass id to hgc click box */ struct itemAttr *id; AllocVar(id); id->chromStart = item->id; lf->itemAttr = id; slAddHead(&lfList, lf); wikiTrackFree(&item); } sqlFreeResult(&sr); wikiDisconnect(&wikiConn); slSort(&lfList, linkedFeaturesCmp); /* read-only option 2012-06-25 */ if ((! wikiTrackReadOnly()) && wikiTrackEnabled(database, NULL)) { // add special item to allow creation of new entries AllocVar(bed); bed->chrom = chromName; bed->chromStart = winStart; bed->chromEnd = winEnd; bed->name = cloneString("Make new entry"); bed->score = 100; bed->strand[0] = ' '; /* no barbs when strand is unknown */ bed->thickStart = winStart; bed->thickEnd = winEnd; bed->itemRgb = 0xcc0000; bed8To12(bed); lf = lfFromBedExtra(bed, scoreMin, scoreMax); lf->extra = (void *)USE_ITEM_RGB; /* signal for coloring */ lf->filterColor=bed->itemRgb; slAddHead(&lfList, lf); } tg->items = lfList; } /* static void wikiTrackLoadItems(struct track *tg) */