b9a0bfaebcc2131ee89041aefc68c3646b69ad13 fanhsu Thu May 5 10:14:38 2011 -0700 Added link to Jakob's lab mirror site page which has Java applet with more viewing options. diff --git src/hg/hgc/rnaFoldClick.c src/hg/hgc/rnaFoldClick.c index 5bf87f5..6526ef5 100644 --- src/hg/hgc/rnaFoldClick.c +++ src/hg/hgc/rnaFoldClick.c @@ -1,401 +1,409 @@ /* Handle details pages for rna fold (evofold) tracks. */ #include "common.h" #include "jksql.h" #include "hgMaf.h" #include "maf.h" #include "cart.h" #include "hgc.h" #include "hCommon.h" #include "hgColors.h" #include "obscure.h" #include "customTrack.h" #include "htmshell.h" #include "rnautil.h" #include "rnaSecStr.h" #include "memalloc.h" static char const rcsid[] = "$Id: rnaFoldClick.c,v 1.9 2010/05/11 01:43:29 kent Exp $"; /* Taken from hgc.c (should probably be in hgc.h)*/ #define RED 0xFF0000 #define GREEN 0x00FF00 #define BLUE 0x0000FF #define BLACK 0x000000 #define CYAN 0x00FFFF #define GRAY 0xcccccc #define LTGRAY 0x999999 #define ORANGE 0xDD6600 #define MAGENTA 0xFF00FF #define LTPURPLE 0x9966CC #define SCORE_SHADES_COUNT 10 void printRfamUrl(char *itemName) /* Print a link to the Rfam entry corresponding to the item. */ { char *query = cloneString(itemName); char *end = strchr(query, '.'); if (!end) return; else *end = 0; printf("
", itemName); freeMem(query); } void doubleArray2binArray(double *scores, int size, double minScore, double maxScore, int *binArray, int binCount) /* Will assign a bin to each score in 'scores' and store it in 'binArray' */ { int i; for (i = 0; i < size; i++) binArray[i] = assignBin(scores[i], minScore, maxScore, binCount); } void htmlColorPrintString(FILE *f, char *s, int *colorFormat, int *colors, int L) /* Prints s to f wrapping characters in html tags for coloring * according to colorFormat and colors. colorFormat must be of same * length as s. Each position of colorFormat defines which of the * colors to use. Use 0 for default color. If L is non-NULL it * defines a mximum length to print.*/ { int i; if (!L || (L && strlen(s)"); for (lineStart = 0; lineStart < maf->textSize; lineStart = lineEnd) { int size; lineEnd = lineStart + lineSize; if (lineEnd >= maf->textSize) lineEnd = maf->textSize; size = lineEnd - lineStart; fprintf(f, "%-*s %.*s\n", srcChars, positionTag, lineSize, adjPosString + lineStart); for (mc = maf->components, i = 0; mc != NULL; mc = mc->next, i++) { fprintf(f, "%-*s ", srcChars, mc->src); htmlColorPrintString(f, mc->text + lineStart, mafColorFormats[i] + lineStart, mafColors, lineSize); fprintf(f, "\n"); } fprintf(f, "%-*s %.*s\n", srcChars, foldTag, lineSize, adjFold + lineStart); fprintf(f, "%-*s %.*s\n", srcChars, pairSymbolsTag, lineSize, pairSymbols + lineStart); if (scores) { fprintf(f, "%-*s ", srcChars, scoresTag); htmlColorPrintString(f, scoreString + lineStart, scoreColorFormat + lineStart, scoreColors, lineSize); fprintf(f, "\n"); } fprintf(f, "\n"); } fprintf(f, ""); /* clean up*/ freeMem(posString); freeMem(adjPosString); freeMem(adjFold); freeMem(pairSymbols); if (scores) { freeMem(scoreString); freeMem(scoreColorFormat); } for (i = 0; i < N; i++) freeMem(mafColorFormats[i]); freeMem(mafColorFormats); } void mafAndFoldLegend(FILE *f) /* Print legend for the maf and fold section */ { char *s = "0123456789"; int colorFormat[] = {0,1,2,3,4,5,6,7,8,9}; int colors[] = {0x999999,0x888888,0x777777,0x666666,0x555555,0x444444,0x333333,0x222222,0x111111,0x000000}; fprintf(f, "
GRAY: | Not part of annotated pair, no substitution. |
LT. PURPLE: | Not part of annotated pair, substitution. |
BLACK: | Compatible with annotated pair, no substitutions. |
BLUE: | Compatible with annotated pair, single substitution. |
GREEN: | Compatible with annotated pair, double substitution. |
RED: | Not compatible with annotated pair, single substitution. |
ORANGE: | Not compatible with annotated pair, double substitution. |
MAGENTA: | Not compatible with annotated pair, involves gap. |
The UCSC Genome Browser mirror site at the Molecular Diagnostic Laboratory (MDL) at Aarhus University Hospital Skejby in Denmark offers a VARNA Java applet to view the above RNA structure with more options, "); +printf("chromStart, item->chromEnd, cgiEncode(item->name)); +printf("\" TARGET=_blank>%s
", "click here to go to moma.ki.au.dk/genome-mirror."); } void doRnaSecStr(struct trackDb *tdb, char *itemName) /* Handle click on rnaSecStr type elements. */ { char *table = tdb->table; struct sqlConnection *conn = hAllocConn(database); struct sqlResult *sr; struct rnaSecStr *item; char extraWhere[256]; char **row; int rowOffset = 0; char *mafTrack = trackDbRequiredSetting(tdb, "mafTrack"); int start = cartInt(cart, "o"); struct mafAli *maf; char option[128]; char *speciesOrder = NULL; /* print header */ genericHeader(tdb, itemName); /* printRfamUrl(itemName); */ genericBedClick(conn, tdb, itemName, start, 6); htmlHorizontalLine(); /* get the rnaSecStr and maf from db */ sprintf(extraWhere, "chromStart = %d and name = '%s'", start, itemName); sr = hExtendedChromQuery(conn, table, seqName, extraWhere, FALSE, NULL, &rowOffset); row = sqlNextRow(sr); item = rnaSecStrLoad(row + rowOffset); maf = mafFromRnaSecStrItem(mafTrack, item); /* order maf by species */ safef(option, sizeof(option), "%s.speciesOrder", tdb->track); speciesOrder = cartUsualString(cart, option, NULL); if (speciesOrder == NULL) speciesOrder = trackDbSetting(tdb, "speciesOrder"); if (speciesOrder) mafSortBySpeciesOrder(maf, speciesOrder); mafAndFoldHeader(stdout); htmlPrintMafAndFold(stdout, maf, item->secStr, item->conf, 100); mafAndFoldLegend(stdout); -/* Draw structure */ +/* Draw structure for evoFold */ +if (sameWord(tdb->table, "evofold")) + { htmlHorizontalLine(); htmlPrintSecStrDrawing(stdout, item); + } /* track specific html */ printTrackHtml(tdb); /* clean up */ mafAliFree(&maf); rnaSecStrFree(&item); sqlFreeResult(&sr); hFreeConn(&conn); }