08e4ee4ee040fe5296616615c6f4ddb73987e2b9 braney Thu May 23 16:18:42 2013 -0700 add some blue bars for duplications in HAL snakes diff --git src/hg/hgTracks/snakeTrack.c src/hg/hgTracks/snakeTrack.c index 05cffbd..04688dc 100644 --- src/hg/hgTracks/snakeTrack.c +++ src/hg/hgTracks/snakeTrack.c @@ -439,33 +439,35 @@ y += tg->itemHeight(tg, item); } } static void packSnakeDrawAt(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 linkedFeatures *lf = (struct linkedFeatures *)item; calcPackSnake(tg, item); if (lf->components == NULL) return; +#ifdef USE_HAL +boolean isHalSnake = lf->isHalSnake; +#else boolean isHalSnake = FALSE; -if (lf->original == (void *)1) - isHalSnake = TRUE; +#endif struct snakeFeature *sf = (struct snakeFeature *)lf->components, *prevSf = NULL; int s = tg->itemStart(tg, item); int sClp = (s < winStart) ? winStart : s; int x1 = round((sClp - winStart)*scale) + xOff; int textX = x1; int yOff = y; //boolean withLabels = (withLeftLabels && (vis == tvFull) && !tg->drawName); unsigned labelColor = MG_BLACK; // draw the labels (this code needs a clean up ) if (0)//withLabels) { char *name = tg->itemName(tg, item); int nameWidth = mgFontStringWidth(font, name); @@ -500,30 +502,51 @@ hvGfxUnclip(hvgSide); hvGfxSetClip(hvgSide, insideX, yOff, insideWidth, tg->height); } else { if(drawNameInverted) { hvGfxBox(hvg, textX - 1, y, nameWidth+1, tg->heightPer-1, color); hvGfxTextRight(hvg, textX, y, nameWidth, tg->heightPer, MG_WHITE, font, name); } else hvGfxTextRight(hvg, textX, y, nameWidth, tg->heightPer, labelColor, font, name); } } +#ifdef USE_HAL +// let's draw some blue bars for the duplications +struct hal_target_dupe_list_t* dupeList = lf->dupeList; + +for(; dupeList ; dupeList = dupeList->next) + { + struct hal_target_range_t *range = dupeList->tRange; + for(; range; range = range->next) + { + int s = range->tStart; + int e = range->tStart + range->size; + int sClp = (s < winStart) ? winStart : s; + int eClp = (e > winEnd) ? winEnd : e; + int x1 = round((sClp - winStart)*scale) + xOff; + int x2 = round((eClp - winStart)*scale) + xOff; + hvGfxLine(hvg, x1, y , x2, y , MG_BLUE); + } + } +y+=2; +#endif + // now we're going to draw the boxes s = sf->start; int lastE = -1; int lastS = -1; int offY = y; int lineHeight = tg->lineHeight ; int tStart, tEnd, qStart; int qs, qe; int heightPer = tg->heightPer; int lastX = -1,lastY = y; int lastQEnd = 0; int lastLevel = -1; int e; qe = lastQEnd = 0; @@ -943,39 +966,54 @@ { printf("<br> %ld : %ld\n", range->tStart, range->size); } } #endif while (cur) { struct hashEl* hel; //safef(buffer, sizeof buffer, "%s.%c", cur->qChrom,cur->strand); safef(buffer, sizeof buffer, "%s", cur->qChrom); if ((hel = hashLookup(qChromHash, buffer)) == NULL) { AllocVar(lf); - lf->original = (void *)1; + lf->isHalSnake = TRUE; slAddHead(&lfList, lf); lf->start = 0; lf->end = 1000000000; lf->grayIx = maxShade; lf->name = cloneString(buffer); lf->extra = cloneString(buffer); lf->orientation = (cur->strand == '+') ? 1 : -1; hashAdd(qChromHash, lf->name, lf); + + // now figure out where the blue bars go + struct hal_target_dupe_list_t* targetDupeBlocks = head->targetDupeBlocks; + + for(;targetDupeBlocks; targetDupeBlocks = targetDupeBlocks->next) + { + if (sameString(targetDupeBlocks->qChrom, cur->qChrom)) + { + struct hal_target_dupe_list_t* dupeList; + AllocVar(dupeList); + *dupeList = *targetDupeBlocks; + slAddHead(&lf->dupeList, dupeList); + // TODO: should clone the target_range structures + } + } } else { lf = hel->val; } struct snakeFeature *sf; AllocVar(sf); slAddHead(&lf->components, sf); sf->start = cur->tStart; sf->end = cur->tStart + cur->size; sf->qStart = cur->qStart; sf->qEnd = cur->qStart + cur->size; sf->orientation = (cur->strand == '+') ? 1 : -1;