static void cytoBandDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y, double scale, MgFont *font, Color color, enum trackVisibility vis) /* Draw cytoBand items. */ { struct cytoBand *band = item; int heightPer = tg->heightPer; int x1,x2,w; x1 = round((double)((int)tg->itemStart(tg,band) - winStart)*scale) + xOff; x2 = round((double)((int)tg->itemEnd(tg,band) - winStart)*scale) + xOff; /* Clip here so that text will tend to be more visible... */ if (x1 < xOff) x1 = xOff; if (x2 > insideX + insideWidth) x2 = insideX + insideWidth; w = x2-x1; if (w < 1) w = 1; hCytoBandDrawAt(band, hvg, x1, y, w, heightPer, hCytoBandDbIsDmel(database), font, mgFontPixelHeight(font), tg->ixColor, tg->ixAltColor, shadesOfGray, maxShade); if(tg->mapsSelf) tg->mapItem(tg, hvg, band, band->name, band->name, band->chromStart, band->chromEnd, x1, y, w, heightPer); else mapBoxHc(hvg, band->chromStart, band->chromEnd, x1,y,w,heightPer, tg->track, band->name, band->name); }
void chkGlue(char *bacAcc, char *finBac, char *unfinBac, char *gluedBac, int trim, char *repeatMask) /* Display glued and unglued form of BAC. */ { int trackCount = 1; int pixWidth, pixHeight; int x, y; struct memGfx *mg; struct tempName gifTn, mapTn; FILE *mapFile; printf("See picture at bottom for overview of where contigs align.\n\n"); /* Figure out basic dimensions and allocate picture. */ font = mgSmallFont(); trackWidth = 700; trackHeight = mgFontPixelHeight(font) + 4; pixWidth = trackWidth + 2*border; pixHeight = trackCount * (trackHeight+border) + border; x = y = border; mg = mgNew(pixWidth, pixHeight); mgClearPixels(mg); makeBlockColors(mg); /* Create map file. */ makeTempName(&mapTn, "glu", ".map"); mapFile = mustOpen(mapTn.forCgi, "wb"); mapWriteHead(mapFile, pixWidth, pixHeight, bacAcc, trim, repeatMask); /* Write out tracks onto picture. */ aliTrack(bacAcc, finBac, unfinBac, mg, x, y, mapFile, trim, repeatMask); /* Save pic and tell html file about it. */ makeTempName(&gifTn, "glu", ".gif"); mgSaveGif(mg, gifTn.forCgi); printf("<INPUT TYPE=HIDDEN NAME=map VALUE=\"%s\">\n", mapTn.forCgi); printf( "<P><INPUT TYPE=IMAGE SRC = \"%s\" BORDER=1 WIDTH=%d HEIGHT=%d NAME = \"clickMe\" ALIGN=BOTTOM><BR>\n", gifTn.forHtml, pixWidth, pixHeight); printf("Click on contig for detailed alignment\n"); /* Write end of map */ mapWriteBox(mapFile, mtNone, 0, 0, pixWidth, pixHeight, NULL, 0, 0, 0, 0, 0); mapWriteBox(mapFile, mtEnd, 0, 0, pixWidth, pixHeight, NULL, 0, 0, 0, 0, 0); /* Clean up. */ fclose(mapFile); mgFree(&mg); }
void genoLayDrawChromLabels(struct genoLay *gl, struct hvGfx *hvg, int color) /* Draw chromosomes labels in image */ { struct slRef *ref; struct genoLayChrom *chrom; int pixelHeight = mgFontPixelHeight(gl->font); if (gl->allOneLine) { int yOffset = gl->chromOffsetY + gl->chromHeight + 1; for (ref = gl->bottomList; ref != NULL; ref = ref->next) { chrom = ref->val; hvGfxTextCentered(hvg, chrom->x, yOffset, chrom->width, pixelHeight, color, gl->font, chrom->shortName); } } else { int yOffset = gl->chromOffsetY + gl->chromHeight - pixelHeight; /* Draw chromosome labels. */ for (ref = gl->leftList; ref != NULL; ref = ref->next) leftLabel(hvg, gl, ref->val, yOffset, pixelHeight, color); for (ref = gl->rightList; ref != NULL; ref = ref->next) rightLabel(hvg, gl, ref->val, yOffset, pixelHeight, color); for (ref = gl->bottomList; ref != NULL; ref = ref->next) { chrom = ref->val; if (ref == gl->bottomList) leftLabel(hvg, gl, chrom, yOffset, pixelHeight, color); else if (ref->next == NULL) rightLabel(hvg, gl, chrom, yOffset, pixelHeight, color); else midLabel(hvg, gl, chrom, yOffset, pixelHeight, color); } } }
void genoLayDrawBandedChroms(struct genoLay *gl, struct hvGfx *hvg, char *db, struct sqlConnection *conn, Color *shadesOfGray, int maxShade, int defaultColor) /* Draw chromosomes with centromere and band glyphs. * Get the band data from the database. If the data isn't * there then draw simple chroms in default color instead */ { char *bandTable = "cytoBandIdeo"; int yOffset = gl->chromOffsetY; genoLayDrawSimpleChroms(gl, hvg, defaultColor); if (sqlTableExists(conn, bandTable) && !gl->allOneLine) { int centromereColor = hCytoBandCentromereColor(hvg); double pixelsPerBase = 1.0/gl->basesPerPixel; int height = gl->chromHeight; int innerHeight = gl->chromHeight-2; struct genoLayChrom *chrom; boolean isDmel = hCytoBandDbIsDmel(db); boolean bColor = hvGfxFindColorIx(hvg, 200, 150, 150); int fontPixelHeight = mgFontPixelHeight(gl->font); for (chrom = gl->chromList; chrom != NULL; chrom = chrom->next) { boolean gotAny = FALSE; struct sqlResult *sr; char **row; char query[256]; int cenX1=BIGNUM, cenX2=0; int y = chrom->y + yOffset; /* Fetch bands from database and draw them. */ safef(query, sizeof(query), "select * from %s where chrom='%s'", bandTable, chrom->fullName); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { struct cytoBand band; int x1, x2; cytoBandStaticLoad(row, &band); x1 = pixelsPerBase*band.chromStart; x2 = pixelsPerBase*band.chromEnd; if (sameString(band.gieStain, "acen")) { /* Centromere is represented as two adjacent bands. * We'll just record the extents of it here, and draw it * in one piece later. */ if (x1 < cenX1) cenX1 = x1; if (x2 > cenX2) cenX2 = x2; } else { /* Draw band */ hCytoBandDrawAt(&band, hvg, x1+chrom->x, y+1, x2-x1, innerHeight, isDmel, gl->font, fontPixelHeight, MG_BLACK, bColor, shadesOfGray, maxShade); gotAny = TRUE; } } sqlFreeResult(&sr); /* Draw box around chromosome */ hvGfxBox(hvg, chrom->x, y, chrom->width, 1, MG_BLACK); hvGfxBox(hvg, chrom->x, y+height-1, chrom->width, 1, MG_BLACK); hvGfxBox(hvg, chrom->x, y, 1, height, MG_BLACK); hvGfxBox(hvg, chrom->x+chrom->width-1, y, 1, height, MG_BLACK); /* Draw centromere if we found one. */ if (cenX2 > cenX1) { hCytoBandDrawCentromere(hvg, cenX1+chrom->x, y, cenX2-cenX1, height, MG_WHITE, centromereColor); } } } }