7a89988d6fd56140fd0b43c0f60430a210c24570 braney Thu May 19 16:41:30 2016 -0700 connecting things up for the long-range interaction display. diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c index c6abaee..a96ecbb 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -1,22 +1,23 @@ /* hgc - Human Genome Click processor - gets called when user clicks * on something in human tracks display. */ /* Copyright (C) 2014 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" +#include #include "obscure.h" #include "hCommon.h" #include "hash.h" #include "binRange.h" #include "bits.h" #include "memgfx.h" #include "hvGfx.h" #include "portable.h" #include "regexHelper.h" #include "errAbort.h" #include "dystring.h" #include "nib.h" #include "cheapcgi.h" #include "htmshell.h" #include "cart.h" @@ -237,30 +238,33 @@ #include "lsSnpPdbChimera.h" #include "mammalPsg.h" #include "net.h" #include "jsHelper.h" #include "virusClick.h" #include "gwasCatalog.h" #include "parClick.h" #include "mdb.h" #include "yaleGencodeAssoc.h" #include "itemDetailsHtml.h" #include "trackVersion.h" #include "numtsClick.h" #include "geneReviewsClick.h" #include "bigBed.h" #include "bigPsl.h" +#include "bedTabix.h" +#include "longRange.h" +#include "hmmstats.h" static char *rootDir = "hgcData"; #define LINESIZE 70 /* size of lines in comp seq feature */ struct cart *cart; /* User's settings. */ char *seqName; /* Name of sequence we're working on. */ int winStart, winEnd; /* Bounds of sequence. */ char *database; /* Name of mySQL database. */ char *organism; /* Colloquial name of organism. */ char *genome; /* common name, e.g. Mouse, Human */ char *scientificName; /* Scientific name of organism. */ struct hash *trackHash; /* A hash of all tracks - trackDb valued */ @@ -3904,30 +3908,79 @@ static void genericContainerClick(struct sqlConnection *conn, char *containerType, struct trackDb *tdb, char *item, char *itemForUrl) /* Print page for container of some sort. */ { if (sameString(containerType, "multiWig")) { errAbort("It's suprising that multiWig container gets to hgc. It should go to hgTrackUi."); } else { errAbort("Unrecognized container type %s for %s", containerType, tdb->track); } } + +static void doLongTabix(struct trackDb *tdb, char *item) +{ +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); +double min = DBL_MAX, max = -DBL_MAX; +double total = 0, average; +unsigned count = 0; +double sumSquares = 0; + +for(longRange = longRangeList; longRange; longRange = longRange->next) + { + if (longRange->id == itemNum) + { + ourLongRange = longRange; + } + if (longRange->score < min) + min = longRange->score; + if (longRange->score > max) + max = longRange->score; + total += longRange->score; + sumSquares += longRange->score * longRange->score; + + count++; + } +average = total/count; +double stdDev = calcStdFromSums(total, sumSquares, count); + + +if (ourLongRange == NULL) + errAbort("cannot find long range item with id %d\n", itemNum); + +printf("Item you clicked on:
\n"); +printf("Score: %g
\n", ourLongRange->score); +printf("ID: %u
\n", ourLongRange->id); +//printf("Link to other block
\n", otherChrom, s, e); + +printf("
All items in window:\n"); +printf("
Min: %g
Max: %g
Average: %g
Count: %d
Total: %g
StDev: %g\n", min,max,average,count, total, stdDev); + +} + void genericClickHandlerPlus( struct trackDb *tdb, char *item, char *itemForUrl, char *plus) /* Put up generic track info, with additional text appended after item. */ { char *dupe, *type, *words[16], *headerItem; int wordCount; int start = cartInt(cart, "o"); int end = cartInt(cart, "t"); struct sqlConnection *conn = NULL; char *imagePath = trackDbSetting(tdb, ITEM_IMAGE_PATH); char *container = trackDbSetting(tdb, "container"); if (!trackHubDatabase(database)) conn = hAllocConnTrack(database, tdb); if (itemForUrl == NULL) @@ -4104,30 +4157,32 @@ doBedDetail(tdb, NULL, item); } else if (sameString(type, "interaction") ) { int num = 12; genericBedClick(conn, tdb, item, start, num); } else if (startsWith("gvf", type)) { doGvf(tdb, item); } #ifdef USE_BAM else if (sameString(type, "bam")) doBamDetails(tdb, item); #endif // USE_BAM + else if ( startsWith("longTabix", type)) + doLongTabix(tdb, item); } if (imagePath) { char *bigImagePath = trackDbSettingClosestToHome(tdb, ITEM_BIG_IMAGE_PATH); char *bothWords[2]; int shouldBeTwo = chopLine(imagePath, bothWords); if (shouldBeTwo != 2) errAbort("itemImagePath setting for %s track incorrect. Needs to be \"itemImagePath \".", tdb->track); printf("


\n", bothWords[0], item, bothWords[1]); shouldBeTwo = chopLine(bigImagePath, bothWords); if (shouldBeTwo != 2) errAbort("bigItemImagePath setting for %s track incorrect. Needs to be \"itemImagePath \".", tdb->track); printf("Download Original Image
\n", bothWords[0], item, bothWords[1]); } @@ -20726,30 +20781,32 @@ int end = cartInt(cart, "t"); char *item = cartString(cart, "i"); char *type; fileName = nextWord(&fileItem); for (ct = ctList; ct != NULL; ct = ct->next) if (sameString(trackId, ct->tdb->track)) break; if (ct == NULL) errAbort("Couldn't find '%s' in '%s'", trackId, fileName); type = ct->tdb->type; cartWebStart(cart, database, "Custom Track: %s", ct->tdb->shortLabel); itemName = skipLeadingSpaces(fileItem); printf("

%s

\n", ct->tdb->longLabel); if (sameWord(type, "array")) doExpRatio(ct->tdb, fileItem, ct); +else if ( startsWith( "longTabix", type)) + doLongTabix(ct->tdb, item); else if (sameWord(type, "encodePeak")) doEncodePeak(ct->tdb, ct, fileName); else if (sameWord(type, "bigWig")) bigWigCustomClick(ct->tdb); else if (sameWord(type, "bigChain")) genericChainClick(NULL, ct->tdb, item, start, "seq"); else if (sameWord(type, "bigPsl")) genericBigPslClick(NULL, ct->tdb, item, start, end); else if (sameWord(type, "bigMaf")) genericMafClick(NULL, ct->tdb, item, start); else if (sameWord(type, "bigBed") || sameWord(type, "bigGenePred")) bigBedCustomClick(ct->tdb); #ifdef USE_BAM else if (sameWord(type, "bam")) doBamDetails(ct->tdb, itemName);