351a9774974f537cc705ee9771bb61adc61980b6 larrym Tue Jun 8 18:31:13 2010 +0000 make motifHitSection and loadDnaMotif public; use a table for motif section to avoid problem where bases in image and text did not line up; fix typo (occurence => occurrence) diff --git src/hg/hgc/regMotif.c src/hg/hgc/regMotif.c index 618b353..ddcda99 100644 --- src/hg/hgc/regMotif.c +++ src/hg/hgc/regMotif.c @@ -21,13 +21,12 @@ #include "flyreg.h" #include "flyreg2.h" -static void printSpacedDna(char *dna, int size) -/* Print string with spaces between each letter. */ +static void printDnaCells(char *dna, int size) +/* Print string with each letter in a separate cell. */ { int i; -printf(" "); for (i=0; i%c", dna[i]); } static void printConsensus(struct dnaMotif *motif) @@ -37,7 +36,6 @@ int i, size = motif->columnCount; char c; float best; -printf(" "); for (i=0; itProb[i]; c = 't'; } - printf(" "); + printf(""); if (best >= 0.90) printf("%c", toupper(c)); else if (best >= 0.75) @@ -68,11 +66,30 @@ printf("%c", tolower(c)); else printf("."); - printf(" "); + printf(""); } } -static struct dnaMotif *loadDnaMotif(char *motifName, char *motifTable) +static void printProbRow(FILE *f, char *label, float *p, int pCount) +/* Print one row of a probability profile. */ +{ +int i; +fprintf(f, "%s", label); +for (i=0; i < pCount; ++i) + fprintf(f, "%5.2f", p[i]); +printf("\n"); +} + +static void dnaMotifPrintProbTable(struct dnaMotif *motif, FILE *f) +/* Print DNA motif probabilities. */ +{ +printProbRow(f, "A", motif->aProb, motif->columnCount); +printProbRow(f, "C", motif->cProb, motif->columnCount); +printProbRow(f, "G", motif->gProb, motif->columnCount); +printProbRow(f, "T", motif->tProb, motif->columnCount); +} + +struct dnaMotif *loadDnaMotif(char *motifName, char *motifTable) /* Load dnaMotif from table. */ { struct sqlConnection *conn = hAllocConn(database); @@ -85,33 +102,37 @@ } -static void motifHitSection(struct dnaSeq *seq, struct dnaMotif *motif) +void motifHitSection(struct dnaSeq *seq, struct dnaMotif *motif) /* Print out section about motif. */ { webNewSection("Motif:"); -printf("
");
+printf("
\n");
+printf("\n");
 if (motif != NULL)
     {
     struct tempName pngTn;
     dnaMotifMakeProbabalistic(motif);
     makeTempName(&pngTn, "logo", ".png");
     dnaMotifToLogoPng(motif, 47, 140, NULL, "../trash", pngTn.forCgi);
-    printf("   ");
+    printf("\n");
     }
 if (seq != NULL)
     {
+    printf("");
     touppers(seq->dna);
-    printSpacedDna(seq->dna, seq->size);
-    printf("this occurence\n");
+    printDnaCells(seq->dna, seq->size);
+    printf("\n");
     }
 if (motif != NULL)
     {
+    printf("");
     printConsensus(motif);
-    printf("motif consensus\n");
-    dnaMotifPrintProb(motif, stdout);
+    printf("\n");
+    dnaMotifPrintProbTable(motif, stdout);
     }
+printf("
", seq->size); printf("", pngTn.forHtml); - printf("\n"); + printf("
this occurrence
motif consensus
\n"); printf("
"); }