dee575dd40edfb8115a977926ad5d5ccc591c114 kate Tue Jan 28 12:14:26 2014 -0800 Add some flexibility to Motif section display. refs #9092 diff --git src/hg/hgc/regMotif.c src/hg/hgc/regMotif.c index 3b43161..dc5cc9c 100644 --- src/hg/hgc/regMotif.c +++ src/hg/hgc/regMotif.c @@ -89,46 +89,43 @@ printProbRow(f, "T", motif->tProb, motif->columnCount); } struct dnaMotif *loadDnaMotif(char *motifName, char *motifTable) /* Load dnaMotif from table. */ { struct sqlConnection *conn = hAllocConn(database); char query[256]; struct dnaMotif *motif; sqlSafefFrag(query, sizeof query, "name = '%s'", motifName); motif = dnaMotifLoadWhere(conn, motifTable, query); hFreeConn(&conn); return motif; } - -void motifMultipleHitsSection(struct dnaSeq **seqs, int count, struct dnaMotif *motif) -/* Print out section about motif, possibly with mutliple occurrences. */ +void motifLogoAndMatrix(struct dnaSeq **seqs, int count, struct dnaMotif *motif) +/* Print out motif sequence logo and text (possibly with multiple occurences) */ { // Detect inconsistent motif/pwm tables and suppress confusing display if (motif != NULL) { if (seqs != NULL && motif->columnCount != seqs[0]->size) { warn("Motif seq length doesn't match PWM\n"); return; } } - #define MOTIF_HELP_PAGE "../goldenPath/help/hgRegMotifHelp.html" -webNewSection("Motif Sequence from Matching Strand"); 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("", 
         motif->columnCount, MOTIF_HELP_PAGE);
     printf("\n");
     }
 if (count > 0)
@@ -146,37 +143,54 @@
             // is there a library routine to get 1st, 2nd ...?
             printf("\n", i + 1);
         }
     }
 if (motif != NULL)
     {
     printf("");
     printConsensus(motif);
     printf("\n");
     dnaMotifPrintProbTable(motif, stdout);
     }
 printf("
Motif display help
", motif->columnCount); printf("", pngTn.forHtml); printf("
occurrence #%d
motif consensus
\n"); printf("
"); } +void motifMultipleHitsSection(struct dnaSeq **seqs, int count, struct dnaMotif *motif, char *title) +/* Print out section about motif, possibly with mutliple occurrences. */ +{ +// Detect inconsistent motif/pwm tables and suppress confusing display +if (motif != NULL) + { + if (seqs != NULL && motif->columnCount != seqs[0]->size) + { + warn("Motif seq length doesn't match PWM\n"); + return; + } + } +webNewSection(title); +motifLogoAndMatrix(seqs, count, motif); +} + void motifHitSection(struct dnaSeq *seq, struct dnaMotif *motif) /* Print out section about motif. */ { +static char *title = "Motif Sequence"; if(seq == NULL) - motifMultipleHitsSection(NULL, 0, motif); + motifMultipleHitsSection(NULL, 0, motif, title); else - motifMultipleHitsSection(&seq, 1, motif); + motifMultipleHitsSection(&seq, 1, motif, title); } void doTriangle(struct trackDb *tdb, char *item, char *motifTable) /* Display detailed info on a regulatory triangle item. */ { int start = cartInt(cart, "o"); struct dnaSeq *seq = NULL; struct dnaMotif *motif = loadDnaMotif(item, motifTable); char *table = tdb->table; int rowOffset = hOffsetPastBin(database, seqName, table); char query[256]; struct sqlResult *sr; char **row; struct bed *hit = NULL; struct sqlConnection *conn = hAllocConn(database);