202cf2b9d3c629e1173721773e19e36a57ba91bf fanhsu Fri Aug 26 10:08:34 2011 -0700 Add organism name for EvoFold V2. diff --git src/hg/hgc/rnaFoldClick.c src/hg/hgc/rnaFoldClick.c index 7e7f01b..c3f6357 100644 --- src/hg/hgc/rnaFoldClick.c +++ src/hg/hgc/rnaFoldClick.c @@ -138,30 +138,56 @@ * markCompensatoryMutations function.*/ { int *mafColors; AllocArray(*p2mafColors, 8); mafColors = *p2mafColors; mafColors[0] = LTGRAY; /* not pairing */ mafColors[1] = LTPURPLE; /* not pairing, substitution */ mafColors[2] = BLACK; /* compatible with pairing */ mafColors[3] = BLUE; /* compatible with pairing, single substitution */ mafColors[4] = GREEN; /* compensatory change */ mafColors[5] = RED; /* not compatible with fold, single subs */ mafColors[6] = ORANGE; /* not compatible with fold, double subs */ mafColors[7] = MAGENTA; /* not compatible with fold, involves indel */ } +char *hDbOrganism(char *databaseIn) +/* Function to get organism from the genome db */ +{ +struct sqlConnection *connCentral = hConnectCentral(); +char buf[256]; +char query[256]; +char *res; +char *database; +char *chp; + +database = strdup(databaseIn); + +// process special case like "hg19.chr21" +chp = strstr(database, "."); +if (chp != NULL) + { + *chp = '\0'; + } + +safef(query, sizeof(query), "select organism from dbDb where name = '%s'", database); +res = strdup(sqlQuickQuery(connCentral, query, buf, sizeof(buf))); +hDisconnectCentral(&connCentral); +return res; +} + + void htmlPrintMafAndFold(FILE *f, struct mafAli *maf, char *fold, double *scores, int lineSize) /* HTML pretty print maf and fold to f. If scores is non-null then * scores are indicated below alignemnt.*/ { struct mafComp *mc; int i, N, lineStart, lineEnd; int *pairList = NULL; int *mafColors = NULL; int **mafColorFormats = NULL; int *scoreColorFormat = NULL; int scoreColors[] = {0x999999,0x888888,0x777777,0x666666,0x555555,0x444444,0x333333,0x222222,0x111111,0x000000}; char *scoreString = 0; char *pairSymbols; char *posString, *adjPosString; char *adjFold; @@ -196,48 +222,50 @@ /* Make a symbol string indicating pairing partner */ pairSymbols = (char *) needMem(refLength + 1); mkPairPartnerSymbols(pairList, pairSymbols, refLength); /* Make the score string and its colorFormat */ if (scores) { scoreString = mkScoreString(scores, foldLength, referenceText); scoreColorFormat = mkScoreColorFormat(scores, foldLength, referenceText); } /* Find max. length of source (species) field. */ for (mc = maf->components; mc != NULL; mc = mc->next) { - int len = strlen(mc->src); + int len = strlen(mc->src)+strlen(hDbOrganism(mc->src)) + 1; if (srcChars < len) srcChars = len; } /* Pretty print maf and fold */ fprintf(f, "
");
 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++)
         {
-	fprintf(f, "%-*s ", srcChars, mc->src);
+	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, "
");