e70152e44cc66cc599ff6b699eb8adc07f3e656a kent Sat May 24 21:09:34 2014 -0700 Adding Copyright NNNN Regents of the University of California to all files I believe with reasonable certainty were developed under UCSC employ or as part of Genome Browser copyright assignment. diff --git src/hg/hgc/rnaFoldClick.c src/hg/hgc/rnaFoldClick.c index b76a120..6da4a60 100644 --- src/hg/hgc/rnaFoldClick.c +++ src/hg/hgc/rnaFoldClick.c @@ -1,505 +1,508 @@ /* Handle details pages for rna fold (evofold) tracks. */ +/* Copyright (C) 2013 The Regents of the University of California + * See README in this or parent directory for licensing information. */ + #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" /* 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; char buf[256]; 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++) { safef(buf, sizeof(buf), "%s/%s", mc->src, hDbOrganism(mc->src)); fprintf(f, "%-*s ", srcChars, buf); 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("chrom, item->chromStart, item->chromEnd, item->chromStart, item->chromEnd, cgiEncode(item->name)); // c, l and r are needed because mirror may have no cart for us. Not actually used, however. printf("\" TARGET=_blank>%s.", "click here to go to genome-mirror.moma.ki.au.dk"); fprintf(f," NOTE: some operating system/browser combinations require "); fprintf(f," the latest version of Java for this to work properly.
"); } void htmlPrintSecStrEvofoldV2Drawing(FILE *f, struct rnaSecStr *item) { char fileName[512]; struct dnaSeq *seq; seq = hChromSeq(database, item->chrom, item->chromStart, item->chromEnd); touppers(seq->dna); if (item->strand[0] == '-') reverseComplement(seq->dna, seq->size); memSwapChar(seq->dna, seq->size, 'T', 'U'); safef(fileName, sizeof(fileName), "/gbdb/%s/evoFoldV2/%s/%s.png", database, item->chrom, item->name); if (fileExists(fileName)) { fprintf(f, "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("chrom, item->chromStart, item->chromEnd, item->chromStart, item->chromEnd, cgiEncode(item->name)); // c, l and r are needed because mirror may have no cart for us. Not actually used, however. printf("\" TARGET=_blank>%s.", "click here to go to genome-mirror.moma.ki.au.dk"); fprintf(f," NOTE: some operating system/browser combinations require "); fprintf(f," the latest version of Java for this to work properly.
"); } 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 for evoFold */ if (sameWord(tdb->table, "evofold")) { htmlHorizontalLine(); htmlPrintSecStrEvofoldDrawing(stdout, item); } /* Draw structure for evoFoldV2 */ if (sameWord(tdb->table, "evofoldV2")) { htmlHorizontalLine(); htmlPrintSecStrEvofoldV2Drawing(stdout, item); } /* track specific html */ printTrackHtml(tdb); /* clean up */ mafAliFree(&maf); rnaSecStrFree(&item); sqlFreeResult(&sr); hFreeConn(&conn); }