src/hg/hgc/bigBedClick.c 1.5
1.5 2009/05/28 16:49:28 mikep
show seq1,seq2 columns (non-standard bed cols 7+8) for pairedTagAlign. This is not very nice way to deal with it, asking Jim for other suggestion.
Index: src/hg/hgc/bigBedClick.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgc/bigBedClick.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -b -B -U 1000000 -r1.4 -r1.5
--- src/hg/hgc/bigBedClick.c 28 May 2009 15:30:40 -0000 1.4
+++ src/hg/hgc/bigBedClick.c 28 May 2009 16:49:28 -0000 1.5
@@ -1,104 +1,113 @@
/* Handle details pages for wiggle tracks. */
#include "common.h"
#include "wiggle.h"
#include "cart.h"
#include "hgc.h"
#include "hCommon.h"
#include "hgColors.h"
#include "bigBed.h"
+#include "hui.h"
static char const rcsid[] = "$Id$";
static void bigBedClick(char *fileName, struct trackDb *tdb,
char *item, int start, int bedSize)
/* Handle click in generic bigBed track. */
{
char *chrom = cartString(cart, "c");
/* Open BigWig file and get interval list. */
struct bbiFile *bbi = bigBedFileOpen(fileName);
struct lm *lm = lmInit(0);
struct bigBedInterval *bbList = bigBedIntervalQuery(bbi, chrom, winStart, winEnd, 0, lm);
/* Get bedSize if it's not already defined. */
if (bedSize == 0)
bedSize = bbi->definedFieldCount;
/* Find particular item in list - matching start, and item if possible. */
struct bigBedInterval *bbMatch = NULL, *bb;
for (bb = bbList; bb != NULL; bb = bb->next)
{
if (bb->start == start)
{
if (bedSize > 3)
{
char *name = cloneFirstWordInLine(bb->rest);
boolean match = sameString(name, item);
freez(&name);
if (match)
{
bbMatch = bb;
break;
}
}
else
{
bbMatch = bb;
break;
}
}
}
if (bbMatch != NULL)
{
- char *fields[bedSize];
+ int extraFields = 0;
+ // check for seq1 and seq2 in columns 7+8 (eg, pairedTagAlign)
+ char *setting = trackDbSetting(tdb, BASE_COLOR_USE_SEQUENCE);
+ if (bedSize == 6 && setting && sameString(setting, "seq1Seq2"))
+ extraFields = 2;
+ char *fields[bedSize+extraFields];
char startBuf[16], endBuf[16];
char *rest = cloneString(bbMatch->rest);
- int bbFieldCount = bigBedIntervalToRow(bbMatch, chrom, startBuf, endBuf, fields, bedSize);
- if (bbFieldCount != bedSize)
+ int bbFieldCount = bigBedIntervalToRow(bbMatch, chrom, startBuf, endBuf, fields, bedSize+extraFields);
+ if (bbFieldCount != bedSize+extraFields)
{
errAbort("Disagreement between trackDb field count (%d) and %s fieldCount (%d)",
bedSize, fileName, bbFieldCount);
}
struct bed *bed = bedLoadN(fields, bedSize);
bedPrintPos(bed, bedSize, tdb);
- if (bedSize > 6) // we have more fields to print
+ // display seq1 and seq2
+ if (bedSize+extraFields == 8 && setting && sameString(setting, "seq1Seq2"))
+ printf("<table><tr><th>Sequence 1</th><th>Sequence 2</th></tr><tr><td> %s </td><td> %s </td></tr></table>", fields[6], fields[7]);
+ else if (bedSize+extraFields > 6) // we have more fields to print
printf("Full bed record:<BR><PRE><TT>%s\t%u\t%u\t%s\n</TT></PRE>\n",
chrom, bb->start, bb->end, rest);
}
else
{
printf("No item %s starting at %d\n", emptyForNull(item), start);
}
lmCleanup(&lm);
bbiFileClose(&bbi);
}
void genericBigBedClick(struct sqlConnection *conn, struct trackDb *tdb,
char *item, int start, int bedSize)
/* Handle click in generic bigBed track. */
{
char query[256];
safef(query, sizeof(query), "select fileName from %s", tdb->tableName);
char *fileName = sqlQuickString(conn, query);
if (fileName == NULL)
errAbort("Missing fileName in %s table", tdb->tableName);
bigBedClick(fileName, tdb, item, start, bedSize);
}
void bigBedCustomClick(struct trackDb *tdb)
/* Display details for BigWig custom tracks. */
{
char *fileName = trackDbSetting(tdb, "dataUrl");
char *item = cartOptionalString(cart, "i");
int start = cartInt(cart, "o");
uglyf("fileName=%s, item=%s, start=%d<BR>\n", fileName, item, start);
struct bbiFile *bbi = bigBedFileOpen(fileName);
uglyf("bbi->fieldCount = %d, ->definedFieldCount=%d<BR>\n", bbi->fieldCount, bbi->definedFieldCount);
bigBedClick(fileName, tdb, item, start, 0);
#ifdef SOON
#endif
}