4e5e4b111651337ddd7d36320f1f667d6c035788
kate
Tue Jan 28 14:46:42 2014 -0800
1. Bug fix: need section on details page for peak clusters lacking motif. 2. Some code simplification. refs #9092
diff --git src/hg/hgc/peakClusters.c src/hg/hgc/peakClusters.c
index 568ef28..e07fdf6 100644
--- src/hg/hgc/peakClusters.c
+++ src/hg/hgc/peakClusters.c
@@ -414,63 +414,65 @@
if ((row = sqlNextRow(sr)) != NULL)
#else
while ((row = sqlNextRow(sr)) != NULL)
#endif
{
struct bed6FloatScore *hit = NULL;
AllocVar(hit);
hit->chromStart = sqlUnsigned(row[rowOffset + 1]);
hit->chromEnd = sqlUnsigned(row[rowOffset + 2]);
hit->score = sqlFloat(row[rowOffset + 4]);
hit->strand[0] = row[rowOffset + 5][0];
slAddHead(&hits, hit);
}
sqlFreeResult(&sr);
}
-int hitCount = 0;
-if (hits != NULL)
+if (hits == NULL)
{
- hitCount = slCount(hits);
+ // Maintain table layout
+ webNewEmptySection();
+ return;
+ }
+
+int hitCount = 0;
if (motifPwmTable != NULL && sqlTableExists(conn, motifPwmTable))
{
motif = loadDnaMotif(motifName, motifPwmTable);
}
- }
-if (motif != NULL && hits != NULL)
- {
struct bed6FloatScore *hit = NULL;
int i;
seqs = needMem(sizeof(struct dnaSeq *) * slCount(hits));
char posLink[1024];
+hitCount = slCount(hits);
+
+webNewSection("Canonical Motif in Cluster");
#ifdef SHOW_MAX_SCORE
float maxScore = -1;
sqlSafef(query, sizeof(query),
"select max(score) from %s where name = '%s'", motifTable, motifName);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
if(!isEmpty(row[0]))
{
maxScore = sqlFloat(row[0]);
}
}
sqlFreeResult(&sr);
#endif
- //puts("
");
- webNewSection("Canonical Motif in Cluster");
for (hit = hits, i = 0; hit != NULL; hit = hit->next, i++)
{
struct dnaSeq *seq = hDnaFromSeq(database,
seqName, hit->chromStart, hit->chromEnd, dnaLower);
if(hit->strand[0] == '-')
reverseComplement(seq->dna, seq->size);
seqs[i] = seq;
// TODO: move to hgc.c (with other pos printers)
safef(posLink, sizeof(posLink),"%s:%d-%d",
hgTracksPathAndSettings(), database,
cluster->chrom, hit->chromStart+1, hit->chromEnd,
cluster->chrom, hit->chromStart+1, hit->chromEnd);
printf("Motif Name: %s
\n", motifName);
printf("Motif Score");
if (hitCount > 1)
@@ -483,32 +485,31 @@
printf(": %.2f at %s on %c strand
",
hit->score, posLink, (int)hit->strand[0]);
#endif
}
else
{
#ifdef SHOW_MAX_SCORE
printf(": %.2f (%s max: %.2f)
\n", hit->score, cluster->name, maxScore);
#else
printf(": %.2f
\n", hit->score);
#endif
printf("Motif Position: %s
\n", posLink);
printf("Motif Strand: %c
\n", (int)hit->strand[0]);
}
}
- }
-if (seqs != NULL)
+if (seqs != NULL && motif != NULL)
{
motifLogoAndMatrix(seqs, hitCount, motif);
}
}
void doFactorSource(struct sqlConnection *conn, struct trackDb *tdb, char *item, int start)
/* Display detailed info about a cluster of TFBS peaks from other tracks. */
{
int rowOffset = hOffsetPastBin(database, seqName, tdb->table);
char **row;
struct sqlResult *sr;
char query[256];
sqlSafef(query, sizeof(query),
"select * from %s where name = '%s' and chrom = '%s' and chromStart = %d",
@@ -548,42 +549,42 @@
* some other way. We'll do this by one of two techniques. */
char *inputTableFieldDisplay = trackDbSetting(tdb, "inputTableFieldDisplay");
if (inputTableFieldDisplay != NULL)
{
struct slName *fieldList = stringToSlNames(inputTableFieldDisplay);
char *vocab = trackDbSetting(tdb, "controlledVocabulary");
/* In a new section put up list of hits. */
webNewSection("Assays for %s in Cluster", cluster->name);
webPrintLinkTableStart();
printClusterTableHeader(fieldList, TRUE, FALSE, TRUE);
printFactorSourceTableHits(cluster, conn, sourceTable,
inputTrackTable, fieldList, FALSE, vocab);
webPrintLinkTableEnd();
- webNewSectionHeaderStart();
+ webNewSectionHeaderStart(TRUE);
char sectionTitle[128];
safef(sectionTitle,
sizeof(sectionTitle),"Assays for %s Without Hits in Cluster", cluster->name);
jsBeginCollapsibleSectionOldStyle(cart, tdb->track, "cellNoHits", sectionTitle, FALSE);
webNewSectionHeaderEnd();
webPrintLinkTableStart();
printClusterTableHeader(fieldList, TRUE, FALSE, FALSE);
printFactorSourceTableHits(cluster, conn, sourceTable,
inputTrackTable, fieldList, TRUE, vocab);
webPrintLinkTableEnd();
jsEndCollapsibleSection();
}
else
{
errAbort("Missing required trackDb setting %s for track %s",
"inputTableFieldDisplay", tdb->track);
}
-webNewSectionHeaderStart();
+webNewSectionHeaderStart(TRUE);
jsBeginCollapsibleSectionOldStyle(cart, tdb->track, "cellSources", "Cell Abbreviations", FALSE);
webNewSectionHeaderEnd();
hPrintFactorSourceAbbrevTable(conn, tdb);
jsEndCollapsibleSection();
doClusterMotifDetails(conn, tdb, cluster);
}