fa8c6c2c8140538f014381e43421163cc6c7eb98
kate
Wed Jan 31 15:22:00 2018 -0800
Flesh out details page for interact track. refs #17512
diff --git src/hg/hgc/interactClick.c src/hg/hgc/interactClick.c
index b4ab8c7..14e8bb4 100644
--- src/hg/hgc/interactClick.c
+++ src/hg/hgc/interactClick.c
@@ -1,155 +1,88 @@
/* Details page for interact type tracks */
/* Copyright (C) 2018 The Regents of the University of California
* See README in this or parent directory for licensing information. */
#include "common.h"
+#include "obscure.h"
#include "hdb.h"
#include "hgc.h"
#include "interact.h"
#include "interactUi.h"
static struct interact *getInteract(char *item, char *chrom, int start, int end, char *table)
/* Retrieve this item from track table
* TODO: Hubbify */
{
struct sqlConnection *conn = hAllocConn(database);
struct interact *inters = NULL, *inter;
char **row;
int offset;
char where[512];
sqlSafefFrag(where, sizeof(where), "name='%s'", item);
struct sqlResult *sr = hRangeQuery(conn, table, chrom, start, end, where, &offset);
while ((row = sqlNextRow(sr)) != NULL)
{
inter = interactLoad(row+offset);
slAddHead(&inters, inter);
}
slReverse(&inters);
sqlFreeResult(&sr);
hFreeConn(&conn);
return inters;
}
void doInteractDetails(struct trackDb *tdb, char *item)
/* Details of interaction item */
{
char *chrom = cartString(cart, "c");
int start = cartInt(cart, "o");
int end = cartInt(cart, "t");
// TODO: hubbify
struct interact *inter = getInteract(item, chrom, start, end, tdb->table);
if (inter == NULL)
errAbort("Can't find interaction '%s'", item);
genericHeader(tdb, item);
-printf("Source: %s %s:%d-%d
\n",
- inter->sourceName, inter->sourceChrom, inter->sourceStart, inter->sourceEnd);
-printf("Target: %s %s:%d-%d
\n",
- inter->targetName, inter->targetChrom, inter->targetStart, inter->targetEnd);
-}
-
-#ifdef FOO
-static void doLongTabix(struct trackDb *tdb, char *item)
-/* Handle a click on a long range interaction */
-{
-char *bigDataUrl = hashFindVal(tdb->settingsHash, "bigDataUrl");
-struct bedTabixFile *btf = bedTabixFileMayOpen(bigDataUrl, NULL, 0, 0);
-char *chromName = cartString(cart, "c");
-struct bed *list = bedTabixReadBeds(btf, chromName, winStart, winEnd, bedLoad5);
-bedTabixFileClose(&btf);
-unsigned maxWidth;
-struct longRange *longRangeList = parseLongTabix(list, &maxWidth, 0);
-struct longRange *longRange, *ourLongRange = NULL;
-unsigned itemNum = sqlUnsigned(item);
-unsigned count = slCount(longRangeList);
-double *doubleArray;
-
-AllocArray(doubleArray, count);
-
-int ii = 0;
-for(longRange = longRangeList; longRange; longRange = longRange->next, ii++)
- {
- if (longRange->id == itemNum)
- {
- ourLongRange = longRange;
- }
- doubleArray[ii] = longRange->score;
- }
-
-if (ourLongRange == NULL)
- errAbort("cannot find long range item with id %d\n", itemNum);
-printf("Item you clicked on:
\n");
-printf(" ID: %u
\n", ourLongRange->id);
-if (!ourLongRange->hasColor)
- // if there's color, then there's no score in this format
- printf("Score: %g
\n", ourLongRange->score);
-
-unsigned padding = (ourLongRange->e - ourLongRange->s) / 10;
-int s = ourLongRange->s - padding;
-int e = ourLongRange->e + padding;
-if (s < 0 )
- s = 0;
-int chromSize = hChromSize(database, seqName);
-if (e > chromSize)
- e = chromSize;
-
-char sStartPosBuf[1024], sEndPosBuf[1024];
-char eStartPosBuf[1024], eEndPosBuf[1024];
-// FIXME: longRange should store region starts, not centers
-sprintLongWithCommas(sStartPosBuf, ourLongRange->s - ourLongRange->sw/2 + 1);
-sprintLongWithCommas(sEndPosBuf, ourLongRange->s + ourLongRange->sw/2 + 1);
-sprintLongWithCommas(eStartPosBuf, ourLongRange->e - ourLongRange->ew/2 + 1);
-sprintLongWithCommas(eEndPosBuf, ourLongRange->e + ourLongRange->ew/2 + 1);
-char sWidthBuf[1024], eWidthBuf[1024];
-char regionWidthBuf[1024];
-sprintLongWithCommas(sWidthBuf, ourLongRange->sw);
-sprintLongWithCommas(eWidthBuf, ourLongRange->ew);
-sprintLongWithCommas(regionWidthBuf, ourLongRange->ew + ourLongRange->e - ourLongRange->s);
-
-if (differentString(ourLongRange->sChrom, ourLongRange->eChrom))
- {
- printf("Current region: ");
- printf("%s:%s-%s (%s bp)
\n",
- ourLongRange->sChrom, sStartPosBuf, sEndPosBuf,
- ourLongRange->sChrom, sStartPosBuf,sEndPosBuf, sWidthBuf);
- printf("Paired region: ");
- printf("%s:%s-%s (%s bp)
\n",
- ourLongRange->eChrom, eStartPosBuf, eEndPosBuf,
- ourLongRange->eChrom, eStartPosBuf, eEndPosBuf, eWidthBuf);
- }
+char startBuf[1024], endBuf[1024], sizeBuf[1024];
+if (isNotEmpty(inter->name))
+ printf("Interaction name: %s
\n", inter->name);
+printf("Interaction region: ");
+if (interactOtherChrom(inter))
+ printf("across chromosomes
");
else
{
- printf("Lower region: ");
- printf("%s:%s-%s (%s bp)
\n",
- ourLongRange->sChrom, sStartPosBuf,sEndPosBuf,
- ourLongRange->sChrom, sStartPosBuf,sEndPosBuf, sWidthBuf);
- printf("Upper region: ");
- printf("%s:%s-%s (%s bp)
\n",
- ourLongRange->eChrom, eStartPosBuf, eEndPosBuf,
- ourLongRange->eChrom, eStartPosBuf, eEndPosBuf, eWidthBuf);
- printf("Interaction region: ");
- printf("%s:%s-%s (%s bp)
\n",
- ourLongRange->eChrom, sStartPosBuf, eEndPosBuf,
- ourLongRange->eChrom, sStartPosBuf, eEndPosBuf, regionWidthBuf);
+ sprintLongWithCommas(startBuf, inter->chromStart+1);
+ sprintLongWithCommas(endBuf, inter->chromEnd);
+ sprintLongWithCommas(sizeBuf, inter->chromEnd - inter->chromStart);
+ printf("%s:%s-%s",
+ inter->chrom, inter->chromStart, inter->chromEnd,
+ inter->chrom, startBuf, endBuf);
+ printf(" %s bp
\n", sizeBuf);
}
-if (ourLongRange->hasColor)
- return;
+printf("Score: %d
\n", inter->score);
+printf("Value: %0.3f
\n", inter->value);
+if (isNotEmpty(inter->exp))
+ printf("Experiment: %s
\n", inter->exp);
+puts("
");
-struct aveStats *as = aveStatsCalc(doubleArray, count);
-printf("
Statistics on the scores of all items in window (go to track controls to set minimum score to display):\n");
-
-printf("
Q1 | %f |
median | %f |
Q3 | %f |
average | %f |
min | %f |
max | %f |
count | %d |
total | %f |
standard deviation | %f |