static void printParLink(struct bed *par) /* print one par link back to the browser */ { webPrintLinkCellStart(); printf("<A HREF=\"%s?db=%s&position=%s:%d-%d\">%s:%d-%d</A>", hgTracksName(), database, par->chrom, par->chromStart, par->chromEnd, par->chrom, par->chromStart+1, par->chromEnd); webPrintLinkCellEnd(); }
static void vcfRecordDetails(struct trackDb *tdb, struct vcfRecord *rec) /* Display the contents of a single line of VCF, assumed to be from seqName * (using seqName instead of rec->chrom because rec->chrom might lack "chr"). */ { printf("<B>Name:</B> %s<BR>\n", rec->name); // Since these are variants, if it looks like a dbSNP or dbVar ID, provide a link: if (regexMatch(rec->name, "^rs[0-9]+$")) { printf("<B>dbSNP:</B> "); printDbSnpRsUrl(rec->name, "%s", rec->name); puts("<BR>"); } else if (regexMatch(rec->name, "^[en]ss?v[0-9]+$")) { printf("<B>dbVar:</B> "); printf("<A HREF=\"http://www.ncbi.nlm.nih.gov/dbvar/variants/%s/\" " "TARGET=_BLANK>%s</A><BR>\n", rec->name, rec->name); } printCustomUrl(tdb, rec->name, TRUE); boolean hapClustEnabled = cartOrTdbBoolean(cart, tdb, VCF_HAP_ENABLED_VAR, TRUE); if (hapClustEnabled) { static char *formName = "vcfCfgHapCenter"; printf("<FORM NAME=\"%s\" ACTION=\"%s\">\n", formName, hgTracksName()); cartSaveSession(cart); vcfCfgHaplotypeCenter(cart, tdb, tdb->track, FALSE, rec->file, rec->name, seqName, rec->chromStart, formName); printf("</FORM>\n"); } char leftBase = rec->alleles[0][0]; unsigned int vcfStart = vcfRecordTrimIndelLeftBase(rec); boolean showLeftBase = (rec->chromStart == vcfStart+1); (void)vcfRecordTrimAllelesRight(rec); char *displayAls[rec->alleleCount]; makeDisplayAlleles(rec, showLeftBase, leftBase, 20, TRUE, FALSE, displayAls); printPosOnChrom(seqName, rec->chromStart, rec->chromEnd, NULL, FALSE, rec->name); printf("<B>Reference allele:</B> %s<BR>\n", displayAls[0]); vcfAltAlleleDetails(rec, displayAls); vcfQualDetails(rec); vcfFilterDetails(rec); vcfInfoDetails(rec); pgSnpCodingDetail(rec); makeDisplayAlleles(rec, showLeftBase, leftBase, 5, FALSE, TRUE, displayAls); vcfGenotypesDetails(rec, tdb, displayAls); }
void doTargetQuery(struct targetPcrServer *server, struct gfPcrInput *gpi, int maxSize, int minPerfect, int minGood) /* Send a query to a non-genomic target PCR server and print the results. */ { struct gfPcrOutput *gpoList; char seqDir[PATH_LEN]; splitPath(server->targetDb->seqFile, seqDir, NULL, NULL); if (endsWith("/", seqDir)) seqDir[strlen(seqDir) - 1] = '\0'; gpoList = gfPcrViaNet(server->host, server->port, seqDir, gpi, maxSize, minPerfect, minGood); if (gpoList != NULL) { struct gfPcrOutput *gpo; char urlFormat[2048]; printf("The sequences and coordinates shown below are from %s, " "not from the genome assembly. The links lead to the " "Genome Browser at the position of the entire target " "sequence.<BR>\n", server->targetDb->description); printf("<TT><PRE>"); for (gpo = gpoList; gpo != NULL; gpo = gpo->next) { /* Not used as a format here; we modify the name used for position: */ safef(urlFormat, sizeof(urlFormat), "%s?%s&db=%s&position=%s" "&hgPcrResult=pack", hgTracksName(), cartSidUrlString(cart), server->targetDb->db, pcrResultItemAccession(gpo->seqName)); if (gpo->strand == '-') printf("<EM>Warning: this amplification is on the reverse-" "complement of %s</EM>.\n", gpo->seqName); gfPcrOutputWriteOne(gpo, "fa", urlFormat, stdout); printf("\n"); } printf("</PRE></TT>"); writePcrResultTrack(gpoList, server->targetDb->db, server->targetDb->name); } else { printf("No matches to %s %s in %s", gpi->fPrimer, gpi->rPrimer, server->targetDb->description); } }
static void genePredPosPrint(struct column *col, struct genePos *gp, struct sqlConnection *conn) /* Print genome position with hyperlink to browser. */ { char *pos = col->cellVal(col, gp, conn); char *chrom; int start, end; hPrintf("<TD>"); if (pos == NULL) hPrintf("n/a"); else { char numBuf[32]; hgParseChromRange(database, pos, &chrom, &start, &end); sprintLongWithCommas(numBuf, (start+end+1)/2); hPrintf("<A HREF=\"%s?db=%s&position=%s&%s&%s=full\">", hgTracksName(), database, pos, cartSidUrlString(cart), genomeSetting("geneTable")); hPrintf("%s %s</A>", chrom, numBuf); freeMem(pos); } hPrintf("</TD>"); }
void doQuery(struct pcrServer *server, struct gfPcrInput *gpi, int maxSize, int minPerfect, int minGood) /* Send a query to a genomic assembly PCR server and print the results. */ { struct gfPcrOutput *gpoList = gfPcrViaNet(server->host, server->port, server->seqDir, gpi, maxSize, minPerfect, minGood); if (gpoList != NULL) { char urlFormat[2048]; safef(urlFormat, sizeof(urlFormat), "%s?%s&db=%s&position=%%s:%%d-%%d" "&hgPcrResult=pack", hgTracksName(), cartSidUrlString(cart), server->db); printf("<TT><PRE>"); gfPcrOutputWriteAll(gpoList, "fa", urlFormat, "stdout"); printf("</PRE></TT>"); writePcrResultTrack(gpoList, server->db, NULL); } else { printf("No matches to %s %s in %s %s", gpi->fPrimer, gpi->rPrimer, server->genome, server->description); } }
boolean doGetBedOrCt(struct sqlConnection *conn, boolean doCt, boolean doCtFile, boolean redirectToGb) /* Actually output bed or custom track. Return TRUE unless no results. */ { char *db = cloneString(database); char *table = curTable; struct hTableInfo *hti = getHti(db, table, conn); struct featureBits *fbList = NULL, *fbPtr; struct customTrack *ctNew = NULL; boolean doCtHdr = (cartUsualBoolean(cart, hgtaPrintCustomTrackHeaders, FALSE) || doCt || doCtFile); char *ctWigOutType = cartCgiUsualString(cart, hgtaCtWigOutType, outWigData); char *fbQual = fbOptionsToQualifier(); char fbTQ[128]; int fields = hTableInfoBedFieldCount(hti); boolean gotResults = FALSE; struct region *region, *regionList = getRegions(); boolean isBedGr = isBedGraph(curTable); boolean isBgWg = isBigWigTable(curTable); boolean needSubtrackMerge = anySubtrackMerge(database, curTable); boolean doDataPoints = FALSE; boolean isWig = isWiggle(database, table); struct wigAsciiData *wigDataList = NULL; struct dataVector *dataVectorList = NULL; boolean doRgb = bedItemRgb(hTrackDbForTrack(db, curTable)); if (!cartUsualBoolean(cart, hgtaDoGreatOutput, FALSE) && !doCt) { textOpen(); } if (cartUsualBoolean(cart, hgtaDoGreatOutput, FALSE)) fputs("#", stdout); if ((isWig || isBedGr || isBgWg) && sameString(outWigData, ctWigOutType)) doDataPoints = TRUE; for (region = regionList; region != NULL; region = region->next) { struct bed *bedList = NULL, *bed; struct lm *lm = lmInit(64*1024); struct dataVector *dv = NULL; if (isWig && doDataPoints) { if (needSubtrackMerge) { dv = wiggleDataVector(curTrack, curTable, conn, region); if (dv != NULL) slAddHead(&dataVectorList, dv); } else { int count = 0; struct wigAsciiData *wigData = NULL; struct wigAsciiData *asciiData; struct wigAsciiData *next; wigData = getWiggleAsData(conn, curTable, region); for (asciiData = wigData; asciiData; asciiData = next) { next = asciiData->next; if (asciiData->count) { slAddHead(&wigDataList, asciiData); ++count; } } slReverse(&wigDataList); } } else if (isBedGr && doDataPoints) { dv = bedGraphDataVector(curTable, conn, region); if (dv != NULL) slAddHead(&dataVectorList, dv); } else if (isBgWg && doDataPoints) { dv = bigWigDataVector(curTable, conn, region); if (dv != NULL) slAddHead(&dataVectorList, dv); } else if (isWig || isBgWg) { dv = wiggleDataVector(curTrack, curTable, conn, region); bedList = dataVectorToBedList(dv); dataVectorFree(&dv); } else if (isBedGr) { bedList = getBedGraphAsBed(conn, curTable, region); } else { bedList = cookedBedList(conn, curTable, region, lm, &fields); } /* this is a one-time only initial creation of the custom track * structure to receive the results. gotResults turns it off after * the first time. */ if (doCtHdr && !gotResults && ((bedList != NULL) || (wigDataList != NULL) || (dataVectorList != NULL))) { ctNew = beginCustomTrack(table, fields, doCt, (isWig || isBedGr || isBgWg), doDataPoints); } if (doDataPoints && (wigDataList || dataVectorList)) gotResults = TRUE; else { if ((fbQual == NULL) || (fbQual[0] == 0)) { for (bed = bedList; bed != NULL; bed = bed->next) { if (bed->name != NULL) { subChar(bed->name, ' ', '_'); } if (doCt) { struct bed *dupe = cloneBed(bed); /* Out of local memory. */ slAddHead(&ctNew->bedList, dupe); } else { if (doRgb) bedTabOutNitemRgb(bed, fields, stdout); else bedTabOutN(bed, fields, stdout); } gotResults = TRUE; } } else { safef(fbTQ, sizeof(fbTQ), "%s:%s", hti->rootName, fbQual); fbList = fbFromBed(db, fbTQ, hti, bedList, 0, 0, FALSE, FALSE); if (fields >= 6) fields = 6; else if (fields >= 4) fields = 4; else fields = 3; if (doCt && ctNew) { ctNew->fieldCount = fields; safef(ctNew->tdb->type, strlen(ctNew->tdb->type)+1, "bed %d", fields); } for (fbPtr=fbList; fbPtr != NULL; fbPtr=fbPtr->next) { if (fbPtr->name != NULL) { char *ptr = strchr(fbPtr->name, ' '); if (ptr != NULL) *ptr = 0; } if (doCt) { struct bed *fbBed = fbToBedOne(fbPtr); slAddHead(&ctNew->bedList, fbBed ); } else { if (fields >= 6) hPrintf("%s\t%d\t%d\t%s\t%d\t%c\n", fbPtr->chrom, fbPtr->start, fbPtr->end, fbPtr->name, 0, fbPtr->strand); else if (fields >= 4) hPrintf("%s\t%d\t%d\t%s\n", fbPtr->chrom, fbPtr->start, fbPtr->end, fbPtr->name); else hPrintf("%s\t%d\t%d\n", fbPtr->chrom, fbPtr->start, fbPtr->end); } gotResults = TRUE; } featureBitsFreeList(&fbList); } } bedList = NULL; lmCleanup(&lm); } if (!gotResults) { hPrintf(NO_RESULTS); } else if (doCt) { int wigDataSize = 0; /* Load existing custom tracks and add this new one: */ struct customTrack *ctList = getCustomTracks(); removeNamedCustom(&ctList, ctNew->tdb->table); if (doDataPoints) { if (needSubtrackMerge || isBedGr || isBgWg) { slReverse(&dataVectorList); wigDataSize = dataVectorWriteWigAscii(dataVectorList, ctNew->wigAscii, 0, NULL); // TODO: see if can make prettier wig output here that // doesn't necessarily have one value per base } else { struct wiggleDataStream *wds = NULL; /* create an otherwise empty wds so we can print out the list */ wds = wiggleDataStreamNew(); wds->ascii = wigDataList; wigDataSize = wds->asciiOut(wds, db, ctNew->wigAscii, TRUE, FALSE); #if defined(DEBUG) /* dbg */ /* allow file readability for debug */ chmod(ctNew->wigAscii, 0666); #endif wiggleDataStreamFree(&wds); } } else slReverse(&ctNew->bedList); slAddHead(&ctList, ctNew); /* Save the custom tracks out to file (overwrite the old file): */ customTracksSaveCart(db, cart, ctList); /* Put up redirect-to-browser page. */ if (redirectToGb) { char browserUrl[256]; char headerText[512]; int redirDelay = 3; safef(browserUrl, sizeof(browserUrl), "%s?%s&db=%s", hgTracksName(), cartSidUrlString(cart), database); safef(headerText, sizeof(headerText), "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"%d;URL=%s\">", redirDelay, browserUrl); webStartHeader(cart, database, headerText, "Table Browser: %s %s: %s", hOrganism(database), freezeName, "get custom track"); if (doDataPoints) { hPrintf("There are %d data points in custom track. ", wigDataSize); } else { hPrintf("There are %d items in custom track. ", slCount(ctNew->bedList)); } hPrintf("You will be automatically redirected to the genome browser in\n" "%d seconds, or you can \n" "<A HREF=\"%s\">click here to continue</A>.\n", redirDelay, browserUrl); } } else if (doDataPoints) { if (needSubtrackMerge || isBedGr || isBgWg) { slReverse(&dataVectorList); dataVectorWriteWigAscii(dataVectorList, "stdout", 0, NULL); } else { /* create an otherwise empty wds so we can print out the list */ struct wiggleDataStream *wds = NULL; wds = wiggleDataStreamNew(); wds->ascii = wigDataList; wds->asciiOut(wds, db, "stdout", TRUE, FALSE); wiggleDataStreamFree(&wds); } } return gotResults; }
void showAliPlaces(char *pslName, char *faName, char *database, enum gfType qType, enum gfType tType, char *organism, boolean feelingLucky) /* Show all the places that align. */ { struct lineFile *lf = pslFileOpen(pslName); struct psl *pslList = NULL, *psl; char *browserUrl = hgTracksName(); char *hgcUrl = hgcName(); char uiState[64]; char *vis; char unhideTrack[64]; char *sort = cartUsualString(cart, "sort", sortList[0]); char *output = cartUsualString(cart, "output", outputList[0]); boolean pslOut = startsWith("psl", output); boolean isStraightNuc = (qType == gftRna || qType == gftDna); int minThreshold = (isStraightNuc ? minMatchShown : 0); sprintf(uiState, "%s=%s", cartSessionVarName(), cartSessionId(cart)); /* If user has hidden BLAT track, add a setting that will unhide the track if user clicks on a browser link. */ vis = cartOptionalString(cart, "hgUserPsl"); if (vis != NULL && sameString(vis, "hide")) snprintf(unhideTrack, sizeof(unhideTrack), "&hgUserPsl=dense"); else unhideTrack[0] = 0; while ((psl = pslNext(lf)) != NULL) { if (psl->match >= minThreshold) slAddHead(&pslList, psl); } lineFileClose(&lf); if (pslList == NULL) { puts("<table><tr><td><hr>Sorry, no matches found<hr><td></tr></table>"); return; } if (sameString(sort, "query,start")) { slSort(&pslList, pslCmpQuery); } else if (sameString(sort, "query,score")) { slSort(&pslList, pslCmpQueryScore); } else if (sameString(sort, "score")) { slSort(&pslList, pslCmpScore); } else if (sameString(sort, "chrom,start")) { slSort(&pslList, pslCmpTargetStart); } else if (sameString(sort, "chrom,score")) { slSort(&pslList, pslCmpTargetScore); } else { slSort(&pslList, pslCmpQueryScore); } if(feelingLucky) { /* If we found something jump browser to there. */ if(slCount(pslList) > 0) printLuckyRedirect(browserUrl, pslList, database, pslName, faName, uiState, unhideTrack); /* Otherwise call ourselves again not feeling lucky to print empty results. */ else { cartWebStart(cart, database, "%s BLAT Results", trackHubSkipHubName(organism)); showAliPlaces(pslName, faName, database, qType, tType, organism, FALSE); cartWebEnd(); } } else if (pslOut) { printf("<TT><PRE>"); if (!sameString(output, "psl no header")) pslxWriteHead(stdout, qType, tType); for (psl = pslList; psl != NULL; psl = psl->next) pslTabOut(psl, stdout); printf("</PRE></TT>"); } else { printf("<H2>BLAT Search Results</H2>"); printf("<TT><PRE>"); printf(" ACTIONS QUERY SCORE START END QSIZE IDENTITY CHRO STRAND START END SPAN\n"); printf("---------------------------------------------------------------------------------------------------\n"); for (psl = pslList; psl != NULL; psl = psl->next) { printf("<A HREF=\"%s?position=%s:%d-%d&db=%s&ss=%s+%s&%s%s\">", browserUrl, psl->tName, psl->tStart + 1, psl->tEnd, database, pslName, faName, uiState, unhideTrack); printf("browser</A> "); printf("<A HREF=\"%s?o=%d&g=htcUserAli&i=%s+%s+%s&c=%s&l=%d&r=%d&db=%s&%s\">", hgcUrl, psl->tStart, pslName, cgiEncode(faName), psl->qName, psl->tName, psl->tStart, psl->tEnd, database, uiState); printf("details</A> "); printf("%-14s %5d %5d %5d %5d %5.1f%% %4s %2s %9d %9d %6d\n", psl->qName, pslScore(psl), psl->qStart+1, psl->qEnd, psl->qSize, 100.0 - pslCalcMilliBad(psl, TRUE) * 0.1, skipChr(psl->tName), psl->strand, psl->tStart+1, psl->tEnd, psl->tEnd - psl->tStart); } printf("</PRE></TT>"); } pslFreeList(&pslList); }
void doSearchTracks(struct group *groupList) { if (!advancedJavascriptFeaturesEnabled(cart)) { warn("Requires advanced javascript features."); return; } struct group *group; char *groups[128]; char *labels[128]; int numGroups = 1; groups[0] = ANYLABEL; labels[0] = ANYLABEL; char *currentTab = cartUsualString(cart, TRACK_SEARCH_CURRENT_TAB, "simpleTab"); char *nameSearch = cartOptionalString(cart, TRACK_SEARCH_ON_NAME); #ifdef TRACK_SEARCH_ON_TYPE char *typeSearch = cartOptionalString(cart, TRACK_SEARCH_ON_TYPE); #else///ifndef TRACK_SEARCH_ON_TYPE char *typeSearch = NULL; #endif///def TRACK_SEARCH_ON_TYPE char *descSearch; char *groupSearch = cartOptionalString(cart, TRACK_SEARCH_ON_GROUP); boolean doSearch = sameString(cartOptionalString(cart, TRACK_SEARCH), "Search") || cartUsualInt(cart, TRACK_SEARCH_PAGER, -1) >= 0; struct sqlConnection *conn = hAllocConn(database); boolean metaDbExists = sqlTableExists(conn, "metaDb"); int numMetadataSelects, tracksFound = 0; int numMetadataNonEmpty = 0; char **mdbVar = NULL; char **mdbVal = NULL; #ifdef ONE_FUNC struct hash *parents = newHash(4); #endif///def ONE_FUNC boolean simpleSearch; struct trix *trix; char trixFile[HDB_MAX_PATH_STRING]; char **descWords = NULL; int descWordCount = 0; boolean searchTermsExist = FALSE; int cols; char buf[512]; if(sameString(currentTab, "simpleTab")) { descSearch = cartOptionalString(cart, TRACK_SEARCH_SIMPLE); simpleSearch = TRUE; freez(&nameSearch); #ifdef TRACK_SEARCH_ON_TYPE freez(&typeSearch); #endif///def TRACK_SEARCH_ON_TYPE freez(&groupSearch); } else { descSearch = cartOptionalString(cart, TRACK_SEARCH_ON_DESCR); simpleSearch = FALSE; } if(descSearch) stripChar(descSearch, '"'); trackList = getTrackList(&groupList, -2); // global makeGlobalTrackHash(trackList); // NOTE: This is necessary when container cfg by '*' results in vis changes // This will handle composite/view override when subtrack specific vis exists, AND superTrack reshaping. parentChildCartCleanup(trackList,cart,oldVars); // Subtrack settings must be removed when composite/view settings are updated getSearchTrixFile(database, trixFile, sizeof(trixFile)); trix = trixOpen(trixFile); slSort(&groupList, gCmpGroup); for (group = groupList; group != NULL; group = group->next) { groupTrackListAddSuper(cart, group); if (group->trackList != NULL) { groups[numGroups] = cloneString(group->name); labels[numGroups] = cloneString(group->label); numGroups++; if (numGroups >= ArraySize(groups)) internalErr(); } } safef(buf, sizeof(buf),"Search for Tracks in the %s %s Assembly", organism, hFreezeFromDb(database)); webStartWrapperDetailedNoArgs(cart, database, "", buf, FALSE, FALSE, FALSE, FALSE); hPrintf("<div style='max-width:1080px;'>"); hPrintf("<form action='%s' name='%s' id='%s' method='get'>\n\n", hgTracksName(),TRACK_SEARCH_FORM,TRACK_SEARCH_FORM); cartSaveSession(cart); // Creates hidden var of hgsid to avoid bad voodoo safef(buf, sizeof(buf), "%lu", clock1()); cgiMakeHiddenVar("hgt_", buf); // timestamps page to avoid browser cache hPrintf("<input type='hidden' name='db' value='%s'>\n", database); hPrintf("<input type='hidden' name='%s' id='currentTab' value='%s'>\n", TRACK_SEARCH_CURRENT_TAB, currentTab); hPrintf("<input type='hidden' name='%s' value=''>\n",TRACK_SEARCH_DEL_ROW); hPrintf("<input type='hidden' name='%s' value=''>\n",TRACK_SEARCH_ADD_ROW); hPrintf("<input type='hidden' name='%s' value=''>\n",TRACK_SEARCH_PAGER); hPrintf("<div id='tabs' style='display:none; %s'>\n" "<ul>\n" "<li><a href='#simpleTab'><B style='font-size:.9em;font-family: arial, Geneva, Helvetica, san-serif;'>Search</B></a></li>\n" "<li><a href='#advancedTab'><B style='font-size:.9em;font-family: arial, Geneva, Helvetica, san-serif;'>Advanced</B></a></li>\n" "</ul>\n" "<div id='simpleTab' style='max-width:inherit;'>\n",cgiBrowser()==btIE?"width:1060px;":"max-width:inherit;"); hPrintf("<table style='width:100%%; font-size:.9em;'><tr><td colspan='2'>"); hPrintf("<input type='text' name='%s' id='simpleSearch' class='submitOnEnter' value='%s' style='max-width:1000px; width:100%%;' onkeyup='findTracksSearchButtonsEnable(true);'>\n", TRACK_SEARCH_SIMPLE,descSearch == NULL ? "" : descSearch); if (simpleSearch && descSearch) searchTermsExist = TRUE; hPrintf("</td></tr><td style='max-height:4px;'></td></tr></table>"); //hPrintf("</td></tr></table>"); hPrintf("<input type='submit' name='%s' id='searchSubmit' value='search' style='font-size:.8em;'>\n", TRACK_SEARCH); hPrintf("<input type='button' name='clear' value='clear' class='clear' style='font-size:.8em;' onclick='findTracksClear();'>\n"); hPrintf("<input type='submit' name='submit' value='cancel' class='cancel' style='font-size:.8em;'>\n"); hPrintf("</div>\n"); // Advanced tab hPrintf("<div id='advancedTab' style='width:inherit;'>\n" "<table cellSpacing=0 style='width:inherit; font-size:.9em;'>\n"); cols = 8; // Track Name contains hPrintf("<tr><td colspan=3></td>"); hPrintf("<td nowrap><b style='max-width:100px;'>Track Name:</b></td>"); hPrintf("<td align='right'>contains</td>\n"); hPrintf("<td colspan='%d'>", cols - 4); hPrintf("<input type='text' name='%s' id='nameSearch' class='submitOnEnter' value='%s' onkeyup='findTracksSearchButtonsEnable(true);' style='min-width:326px; font-size:.9em;'>", TRACK_SEARCH_ON_NAME, nameSearch == NULL ? "" : nameSearch); hPrintf("</td></tr>\n"); // Description contains hPrintf("<tr><td colspan=2></td><td align='right'>and </td>"); hPrintf("<td><b style='max-width:100px;'>Description:</b></td>"); hPrintf("<td align='right'>contains</td>\n"); hPrintf("<td colspan='%d'>", cols - 4); hPrintf("<input type='text' name='%s' id='descSearch' value='%s' class='submitOnEnter' onkeyup='findTracksSearchButtonsEnable(true);' style='max-width:536px; width:536px; font-size:.9em;'>", TRACK_SEARCH_ON_DESCR, descSearch == NULL ? "" : descSearch); hPrintf("</td></tr>\n"); if (!simpleSearch && descSearch) searchTermsExist = TRUE; hPrintf("<tr><td colspan=2></td><td align='right'>and </td>\n"); hPrintf("<td><b style='max-width:100px;'>Group:</b></td>"); hPrintf("<td align='right'>is</td>\n"); hPrintf("<td colspan='%d'>", cols - 4); cgiMakeDropListFull(TRACK_SEARCH_ON_GROUP, labels, groups, numGroups, groupSearch, "class='groupSearch' style='min-width:40%; font-size:.9em;'"); hPrintf("</td></tr>\n"); if (!simpleSearch && groupSearch) searchTermsExist = TRUE; #ifdef TRACK_SEARCH_ON_TYPE // Track Type is (drop down) hPrintf("<tr><td colspan=2></td><td align='right'>and </td>\n"); hPrintf("<td nowrap><b style='max-width:100px;'>Data Format:</b></td>"); hPrintf("<td align='right'>is</td>\n"); hPrintf("<td colspan='%d'>", cols - 4); char **formatTypes = NULL; char **formatLabels = NULL; int formatCount = getFormatTypes(&formatLabels, &formatTypes); cgiMakeDropListFull(TRACK_SEARCH_ON_TYPE, formatLabels, formatTypes, formatCount, typeSearch, "class='typeSearch' style='min-width:40%; font-size:.9em;'"); hPrintf("</td></tr>\n"); if (!simpleSearch && typeSearch) searchTermsExist = TRUE; #endif///def TRACK_SEARCH_ON_TYPE // Metadata selects require careful accounting if(metaDbExists) numMetadataSelects = printMdbSelects(conn, cart, simpleSearch, &mdbVar, &mdbVal, &numMetadataNonEmpty, cols); else numMetadataSelects = 0; hPrintf("</table>\n"); hPrintf("<input type='submit' name='%s' id='searchSubmit' value='search' style='font-size:.8em;'>\n", TRACK_SEARCH); hPrintf("<input type='button' name='clear' value='clear' class='clear' style='font-size:.8em;' onclick='findTracksClear();'>\n"); hPrintf("<input type='submit' name='submit' value='cancel' class='cancel' style='font-size:.8em;'>\n"); //hPrintf("<a target='_blank' href='../goldenPath/help/trackSearch.html'>help</a>\n"); hPrintf("</div>\n</div>\n"); hPrintf("</form>\n"); hPrintf("</div>"); // Restricts to max-width:1000px; if(descSearch != NULL && !strlen(descSearch)) descSearch = NULL; if(groupSearch != NULL && sameString(groupSearch, ANYLABEL)) groupSearch = NULL; if(typeSearch != NULL && sameString(typeSearch, ANYLABEL)) typeSearch = NULL; if(!isEmpty(descSearch)) { char *tmp = cloneString(descSearch); char *val = nextWord(&tmp); struct slName *el, *descList = NULL; int i; while (val != NULL) { slNameAddTail(&descList, val); descWordCount++; val = nextWord(&tmp); } descWords = needMem(sizeof(char *) * descWordCount); for(i = 0, el = descList; el != NULL; i++, el = el->next) descWords[i] = strLower(el->name); } if (doSearch && simpleSearch && descWordCount <= 0) doSearch = FALSE; if(doSearch) { // Now search struct slRef *tracks = NULL; if(simpleSearch) tracks = simpleSearchForTracksstruct(trix,descWords,descWordCount); else tracks = advancedSearchForTracks(conn,groupList,descWords,descWordCount,nameSearch,typeSearch,descSearch,groupSearch,numMetadataNonEmpty,numMetadataSelects,mdbVar,mdbVal); // Sort and Print results enum sortBy sortBy = cartUsualInt(cart,TRACK_SEARCH_SORT,sbRelevance); tracksFound = slCount(tracks); if(tracksFound > 1) findTracksSort(&tracks,simpleSearch,sortBy); displayFoundTracks(cart,tracks,tracksFound,sortBy); } hFreeConn(&conn); webNewSection("About Track Search"); if(metaDbExists) hPrintf("<p>Search for terms in track names, descriptions, groups, and ENCODE " "metadata. If multiple terms are entered, only tracks with all terms " "will be part of the results."); else hPrintf("<p>Search for terms in track descriptions, groups, and names. " "If multiple terms are entered, only tracks with all terms " "will be part of the results."); hPrintf("<BR><a target='_blank' href='../goldenPath/help/trackSearch.html'>more help</a></p>\n"); webEndSectionTables(); }
static void displayFoundTracks(struct cart *cart, struct slRef *tracks, int tracksFound,enum sortBy sortBy) // Routine for displaying found tracks { hPrintf("<div id='found' style='display:none;'>\n"); // This div allows the clear button to empty it if(tracksFound < 1) { hPrintf("<p>No tracks found</p>\n"); } else { struct hash *tdbHash = makeTrackHash(database, chromName); hPrintf("<form action='%s' name='%s' id='%s' method='post'>\n\n", hgTracksName(),SEARCH_RESULTS_FORM,SEARCH_RESULTS_FORM); cartSaveSession(cart); // Creates hidden var of hgsid to avoid bad voodoo int startFrom = 0; hPrintf("<table id='foundTracks'>\n"); // Opening view in browser button and foundTracks count #define ENOUGH_FOUND_TRACKS 10 if(tracksFound >= ENOUGH_FOUND_TRACKS) { hPrintf("<tr><td nowrap colspan=3>\n"); hPrintf("<INPUT TYPE=SUBMIT NAME='submit' VALUE='return to browser' class='viewBtn' style='font-size:.8em;'>"); hPrintf(" <FONT class='selCbCount'></font>\n"); startFrom = cartUsualInt(cart,TRACK_SEARCH_PAGER,0); if (startFrom > 0 && startFrom < tracksFound) { int countUp = 0; for(countUp=0; countUp < startFrom;countUp++) { if (slPopHead(&tracks) == NULL) // memory waste break; } } hPrintf("</td><td align='right' valign='bottom'>\n"); findTracksPageLinks(tracksFound,startFrom); hPrintf("</td></tr>\n"); } // Begin foundTracks table //hPrintf("<table id='foundTracks'><tr><td colspan='2'>\n"); hPrintf("<tr><td colspan='2'>\n"); hPrintf("</td><td align='right'>\n"); #define PM_BUTTON "<IMG height=18 width=18 onclick=\"return findTracksCheckAllWithWait(%s);\" id='btn_%s' src='../images/%s' title='%s all found tracks'>" hPrintf("</td></tr><tr bgcolor='#%s'><td>",HG_COL_HEADER); hPrintf(PM_BUTTON,"true", "plus_all", "add_sm.gif", "Select"); hPrintf(PM_BUTTON,"false","minus_all","remove_sm.gif","Unselect"); hPrintf("</td><td><b>Visibility</b></td><td colspan=2> <b>Track Name</b>\n"); // Sort options? if(tracksFound >= ENOUGH_FOUND_TRACKS) { hPrintf("<span style='float:right;'>Sort:"); cgiMakeOnClickRadioButton(TRACK_SEARCH_SORT, "0", (sortBy == sbRelevance),"onchange=\"findTracksSortNow(this);\""); hPrintf("by Relevance"); cgiMakeOnClickRadioButton(TRACK_SEARCH_SORT, "1", (sortBy == sbAbc), "onchange=\"findTracksSortNow(this);\""); hPrintf("Alphabetically"); cgiMakeOnClickRadioButton(TRACK_SEARCH_SORT, "2",(sortBy == sbHierarchy), "onchange=\"findTracksSortNow(this);\""); hPrintf("by Hierarchy </span>\n"); } hPrintf("</td></tr>\n"); // Set up json for js functionality struct dyString *jsonTdbVars = NULL; int trackCount=0; boolean containerTrackCount = 0; struct slRef *ptr; while((ptr = slPopHead(&tracks))) { if(++trackCount > MAX_FOUND_TRACKS) break; struct track *track = (struct track *) ptr->val; jsonTdbSettingsBuild(&jsonTdbVars, track, FALSE); // FALSE: No configuration from track search if (tdbIsFolder(track->tdb)) // supertrack hPrintf("<tr bgcolor='%s' valign='top' class='found'>\n","#EED5B7");//"#DEB887");//"#E6B426");//#FCECC0//COLOR_LTGREY);//COLOR_LTGREEN);//COLOR_TRACKLIST_LEVEL1); else if (tdbIsContainer(track->tdb)) hPrintf("<tr bgcolor='%s' valign='top' class='found'>\n",COLOR_TRACKLIST_LEVEL3); else hPrintf("<tr bgcolor='%s' valign='top' class='found'>\n",COLOR_TRACKLIST_LEVEL2); hPrintf("<td align='center'>\n"); // Determine visibility and checked state track->visibility = tdbVisLimitedByAncestors(cart, track->tdb, TRUE, TRUE); boolean checked = ( track->visibility != tvHide ); if(tdbIsContainerChild(track->tdb)) { checked = fourStateVisible(subtrackFourStateChecked(track->tdb,cart)); // Don't need all 4 states here. Visible=checked&&enabled checked = (checked && ( track->visibility != tvHide )); // Checked is only if subtrack level vis is also set! } // Setup the check box #define CB_HIDDEN_VAR "<INPUT TYPE=HIDDEN disabled=true NAME='%s_sel' VALUE='%s'>" if (tdbIsContainerChild(track->tdb) || tdbIsFolderContent(track->tdb)) // subtracks and folder children get "_sel" var. ("_sel" var is temporary on folder children) hPrintf(CB_HIDDEN_VAR,track->track,checked?"1":CART_VAR_EMPTY); #define CB_SEEN "<INPUT TYPE=CHECKBOX id='%s_sel_id' VALUE='on' class='selCb' onclick='findTracksClickedOne(this,true);'%s>" hPrintf(CB_SEEN,track->track,(checked?" CHECKED":"")); hPrintf("</td><td>\n"); // Setup the visibility drop down #define VIS_HIDDEN_VAR "<INPUT TYPE=HIDDEN disabled=true NAME='%s' VALUE='%s'>" hPrintf(VIS_HIDDEN_VAR,track->track,CART_VAR_EMPTY); // All tracks get vis hidden var char extra[512]; if (tdbIsFolder(track->tdb)) { safef(extra,sizeof(extra),"id='%s_id' onchange='findTracksChangeVis(this)'",track->track); hideShowDropDownWithClassAndExtra(track->track, (track->visibility != tvHide), "normalText visDD",extra); } else { safef(extra,sizeof(extra),"id='%s_id' onchange='findTracksChangeVis(this)'",track->track); hTvDropDownClassWithJavascript(NULL, track->visibility,track->canPack,"normalText seenVis",extra); } // If this is a container track, allow configuring... if (tdbIsContainer(track->tdb) || tdbIsFolder(track->tdb)) { containerTrackCount++; hPrintf(" <a href='hgTrackUi?db=%s&g=%s&%s=Search' title='Configure this container track...'><IMG SRC='../images/folderWrench.png'></a> ",database,track->track,TRACK_SEARCH); } hPrintf("</td>\n"); // shortLabel has description popup and longLabel has "..." metadata hPrintf("<td><a target='_top' onclick=\"hgTrackUiPopUp('%s',true); return false;\" href='%s' title='Display track details'>%s</a></td>\n", track->track, trackUrl(track->track, NULL), track->shortLabel); hPrintf("<td>%s", track->longLabel); compositeMetadataToggle(database, track->tdb, "...", TRUE, FALSE, tdbHash); hPrintf("</td></tr>\n"); } //hPrintf("</table>\n"); // Closing view in browser button and foundTracks count hPrintf("<tr><td nowrap colspan=3>"); hPrintf("<INPUT TYPE=SUBMIT NAME='submit' VALUE='Return to Browser' class='viewBtn' style='font-size:.8em;'>"); hPrintf(" <FONT class='selCbCount'></font>"); if(tracksFound >= ENOUGH_FOUND_TRACKS) { hPrintf("</td><td align='right' valign='top'>\n"); findTracksPageLinks(tracksFound,startFrom); hPrintf("</td></tr>\n"); } hPrintf("</table>\n"); if(containerTrackCount > 0) hPrintf("<BR><IMG SRC='../images/folderWrench.png'> Tracks so marked are containers which group related data tracks. Containers may need additional configuration (by clicking on the <IMG SRC='../images/folderWrench.png'> icon) before they can be viewed in the browser.<BR>\n"); //hPrintf("* Tracks so marked are containers which group related data tracks. These may not be visible unless further configuration is done. Click on the * to configure these.<BR><BR>\n"); hPrintf("\n</form>\n"); // be done with json hWrites(jsonTdbSettingsUse(&jsonTdbVars)); } #ifdef OMIT if(!doSearch) { hPrintf("<p><b>Recently Done</b><ul>\n" "<li>Can now page through found tracks 100 at a time.</li>" "<li>Added <IMG SRC='../images/folderWrench.png'> icon for contqainers with a configuration link. Is this okay?</li>" "<li>SuperTracks can now be found.</li>" "<li>Configuration of superTrack children's vis should result in proper superTrack reshaping. (This is really an hgTrackUi feature.)</li>" "<li>Added sort toggle: Relevance, Alphabetically or by Hierarchy.</li>" "<li>Composite/view visibilites in hgTrackUi get reshaped to reflect found/selected subtracks. (In demo1: only default state composites; demo2: all composites.)</li>" "<li>Non-data 'container' tracks (composites and supertracks) have '*' to mark them, and can be configured before displaying. Better suggestions?</li>" "</ul></p>" "<p><b>Suggested improvments:</b><ul>\n" "<li>The metadata values will not be white-listed, but it would be nice to have more descriptive text for them. A short label added to cv.ra?</li>" "<li>Look and feel of found track list (here) and composite subtrack list (hgTrackUi) should converge. Jim suggests look and feel of hgTracks 'Configure Tracks...' list instead.</li>" "<li>Drop-down list of terms (cells, antibodies, etc.) should be multi-select with checkBoxes as seen in filterComposites. Perhaps saved for v2.0.</li>" "</ul></p>\n"); } #endif///def OMIT hPrintf("</div>"); // This div allows the clear button to empty it }
void configMultiRegionPage() /* Do multi-region config page after setting track visibility. If vis is -2, then visibility * is unchanged. If -1 then set visibility to default, otherwise it should * be tvHide, tvDense, etc. */ { char *groupTarget; struct track *trackList; struct track *ideoTrack; struct group *groupList; int vis = -2; configInitTrackList(vis, &groupTarget, &trackList, &ideoTrack, &groupList); hPrintf("<FORM ACTION=\"%s\" NAME=\"mainForm\" METHOD=%s>\n", hgTracksName(), cartUsualString(cart, "formMethod", "POST")); webStartWrapperDetailedNoArgs(cart, database, "", "", FALSE, FALSE, FALSE, FALSE); cartSaveSession(cart); hPrintf("<BR>\n"); hTableStart(); virtModeType = cartUsualString(cart, "virtModeType", virtModeType); hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "default", sameWord("default", virtModeType)); hPrintf("</TD><TD>"); hPrintf("Exit multi-region mode"); hPrintf("</TD></TR>\n"); struct sqlConnection *conn = NULL; if (!trackHubDatabase(database)) // no db conn for assembly hubs conn = hAllocConn(database); // Do we have a gene table for exonMostly? findBestEMGeneTable(trackList); if (emGeneTable) { hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "exonMostly", sameWord("exonMostly", virtModeType)); hPrintf("</TD><TD>"); hPrintf("Show exons using %s. Use padding of: ", emGeneTrack->shortLabel); hIntVar("emPadding", cartUsualInt(cart, "emPadding", emPadding), 3); hPrintf(" bases."); hPrintf("</TD></TR>\n"); } if (emGeneTable) { hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "geneMostly", sameWord("geneMostly", virtModeType)); hPrintf("</TD><TD>"); hPrintf("Show genes using %s. Use padding of: ", emGeneTrack->shortLabel); hIntVar("gmPadding", cartUsualInt(cart, "gmPadding", gmPadding), 3); hPrintf(" bases."); hPrintf("</TD></TR>\n"); } /* obsolete if (conn && sqlTableExists(conn,"knownCanonical")) { hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "kcGenes", sameWord("kcGenes", virtModeType)); hPrintf("</TD><TD>"); hPrintf("Show gene regions genome-wide."); hPrintf("</TD></TR>\n"); } */ hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "customUrl", sameWord("customUrl", virtModeType)); hPrintf("</TD><TD>"); hPrintf("Enter Custom regions as BED, or a URL to them:<br>"); multiRegionsBedUrl = cartUsualString(cart, "multiRegionsBedUrl", multiRegionsBedUrl); struct dyString *dyMultiRegionsBedInput = dyStringNew(256); if (strstr(multiRegionsBedUrl,"://")) { dyStringAppend(dyMultiRegionsBedInput, multiRegionsBedUrl); } else { if (fileExists(multiRegionsBedUrl)) { struct lineFile *lf = lineFileMayOpen(multiRegionsBedUrl, TRUE); char *line; int lineSize; while (lineFileNext(lf, &line, &lineSize)) { dyStringPrintf(dyMultiRegionsBedInput, "%s\n", line); } lineFileClose(&lf); } } hPrintf("<TEXTAREA NAME='multiRegionsBedInput' ID='multiRegionsBedInput' rows='4' cols='58' style='white-space: pre;'>%s</TEXTAREA>", dyMultiRegionsBedInput->string); hPrintf("</TD></TR>\n"); /* The AllChroms option will be released in future if (emGeneTable && sqlTableExists(conn, emGeneTable)) { hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "singleTrans", sameWord("singleTrans", virtModeType)); hPrintf("</TD><TD>"); hPrintf("Show only one transcript using an ID from %s : ", emGeneTrack->shortLabel); char *trans = cartUsualString(cart, "singleTransId", singleTransId); char sql[1024]; sqlSafef(sql, sizeof sql, "select name from %s where name='%s'", emGeneTable, trans); char *result = sqlQuickString(conn, sql); if (!result) { sqlSafef(sql, sizeof sql, "select name from %s limit 1", emGeneTable); trans = sqlQuickString(conn, sql); } hTextVar("singleTransId", trans, 20); hPrintf("</TD></TR>\n"); } */ if (conn) { boolean altLocExists = sqlTableExists(conn, "altLocations"); boolean fixLocExists = sqlTableExists(conn, "fixLocations"); if (altLocExists || fixLocExists) { hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "singleAltHaplo", sameWord("singleAltHaplo", virtModeType)); hPrintf("</TD><TD>"); hPrintf("Show one alternate haplotype"); if (fixLocExists) hPrintf(" or fix patch"); hPrintf(", placed on its chromosome, using ID: "); char *haplo = cartUsualString(cart, "singleAltHaploId", singleAltHaploId); char *foundHaplo = NULL; char sql[1024]; if (altLocExists) { sqlSafef(sql, sizeof sql, "select name from altLocations where name rlike '^%s(:[0-9-]+)?'", haplo); foundHaplo = sqlQuickString(conn, sql); } if (!foundHaplo && fixLocExists) { sqlSafef(sql, sizeof sql, "select name from fixLocations where name rlike '^%s(:[0-9-]+)?'", haplo); foundHaplo = sqlQuickString(conn, sql); } if (!foundHaplo) { if (altLocExists) sqlSafef(sql, sizeof sql, "select name from altLocations limit 1"); else sqlSafef(sql, sizeof sql, "select name from fixLocations limit 1"); haplo = sqlQuickString(conn, sql); chopSuffixAt(haplo, ':'); } hTextVar("singleAltHaploId", haplo, 60); hPrintf("</TD></TR>\n"); } } /* disable demo for now if (sameString(database,"hg19") || sameString(database, "hg38")) { hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "demo1", sameWord("demo1", virtModeType)); hPrintf("</TD><TD>"); hPrintf("demo1 two windows on two chroms (default pos on chr21, and same loc on chr22)"); hPrintf("</TD></TR>\n"); } */ /* Disabled for now hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "demo2", sameWord("demo2", virtModeType)); hPrintf("</TD><TD>"); hPrintf("demo2 multiple "); hIntVar("demo2NumWindows", cartUsualInt(cart, "demo2NumWindows", demo2NumWindows), 3); hPrintf(" windows on one chrom chr21 def posn, window size "); hIntVar("demo2WindowSize", cartUsualInt(cart, "demo2WindowSize", demo2WindowSize), 3); hPrintf(" and step size "); hIntVar("demo2StepSize", cartUsualInt(cart, "demo2StepSize", demo2StepSize), 3); hPrintf(" exon-like"); hPrintf("</TD></TR>\n"); */ /* The AllChroms option will be released in future if (conn) // requires chromInfo from database. { // TODO allow it to use assembly hubs via trackHubAllChromInfo() ? hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "allChroms", sameWord("allChroms", virtModeType)); hPrintf("</TD><TD>"); hPrintf("<br>Show all chromosomes.<br><span style='color:red'>Warning:</span> Turn off all tracks except bigBed, bigWig, and very sparse tracks.<br>Press Hide All to hide all tracks."); hPrintf("</TD></TR>\n"); } */ /* Disabled for now hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "demo4", sameWord("demo4", virtModeType)); hPrintf("</TD><TD>"); hPrintf("demo4 multiple (311) windows showing exons from TITIN gene uc031rqd.1."); hPrintf("</TD></TR>\n"); */ /* Disabled for now hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "demo5", sameWord("demo5", virtModeType)); hPrintf("</TD><TD>"); hPrintf("demo5 alt locus on hg38. Shows alt chrom surrounded by regions of same size from reference genome."); hPrintf("</TD></TR>\n"); */ /* Disabled for now hPrintf("<TR><TD>"); cgiMakeRadioButton("virtModeType", "demo6", sameWord("demo6", virtModeType)); hPrintf("</TD><TD>"); hPrintf("demo6 shows zoomed in exon-exon junction from SOD1 gene, between exon1 and exon2."); hPrintf("</TD></TR>\n"); */ hTableEnd(); hPrintf("<BR>\n"); hPrintf("<TABLE style=\"border:0px; \">\n"); hPrintf("<TR><TD>"); hCheckBox("emAltHighlight", cartUsualBoolean(cart, "emAltHighlight", FALSE)); hPrintf("</TD><TD>"); hPrintf("Highlight alternating regions in multi-region view"); hPrintf("</TD></TR>\n"); hPrintf("</TABLE>\n"); hPrintf("<BR>\n"); hPrintf("<TABLE style=\"border:0px;width:650px \">\n"); hPrintf("<TR><TD>"); cgiMakeButton("topSubmit", "submit"); hPrintf("</TD><TD align=right>"); hPrintf("<A HREF=\"../goldenPath/help/multiRegionHelp.html\" target=_blank>Help</A>\n"); hPrintf("</TD></TR>\n"); hPrintf("</TABLE>\n"); hFreeConn(&conn); cgiDown(0.9); freez(&groupTarget); webEndSectionTables(); hPrintf("</FORM>"); }
void configPageSetTrackVis(int vis) /* Do config page after setting track visibility. If vis is -2, then visibility * is unchanged. If -1 then set visibility to default, otherwise it should * be tvHide, tvDense, etc. */ { char *groupTarget; struct track *trackList; struct track *ideoTrack; struct group *groupList; configInitTrackList(vis, &groupTarget, &trackList, &ideoTrack, &groupList); struct dyString *title = dyStringNew(0); dyStringPrintf(title, "Configure Image"); hPrintf("<FORM ACTION=\"%s\" NAME=\"mainForm\" METHOD=%s>\n", hgTracksName(), cartUsualString(cart, "formMethod", "POST")); webStartWrapperDetailedNoArgs(cart, database, "", title->string, FALSE, FALSE, FALSE, FALSE); cartSaveSession(cart); hPrintf("<INPUT TYPE=HIDDEN NAME=\"hgTracksConfigPage\" VALUE=\"\">"); /* do not want all the submit buttons named the same thing, this one is: */ cgiMakeButton("topSubmit", "submit"); // 3 column table hPrintf("<TABLE style=\"border:0px; \">\n"); hPrintf("<TR><TD>image width:"); hPrintf("<TD style=\"text-align: right\">"); hIntVar("pix", tl.picWidth, 4); hPrintf("<TD>pixels</TR>"); hPrintf("<TR><TD>label area width:"); hPrintf("<TD style=\"text-align: right\">"); hIntVar("hgt.labelWidth", leftLabelWidthChars, 2); hPrintf("<TD>characters<TD></TR>"); hPrintf("<TR><TD>text size:"); hPrintf("<TD style=\"text-align: right\">"); textSizeDropDown(); hPrintf("</TD>"); if (trackLayoutInclFontExtras()) { hPrintf("<TD>"); char *defaultStyle = cartUsualString(cart, "fontType", "medium"); cartMakeRadioButton(cart, "fontType", "medium", defaultStyle); hPrintf(" medium "); cartMakeRadioButton(cart, "fontType", "fixed", defaultStyle); hPrintf(" fixed "); cartMakeRadioButton(cart, "fontType", "bold", defaultStyle); hPrintf(" bold "); hPrintf(" "); hPrintf("</TD>"); } hPrintf("</TR>"); themeDropDown(cart); hTableStart(); if (ideoTrack != NULL) { hPrintf("<TR><TD>"); hCheckBox("ideogram", cartUsualBoolean(cart, "ideogram", TRUE)); hPrintf("</TD><TD>"); hPrintf("Display chromosome ideogram above main graphic"); hPrintf("</TD></TR>\n"); } hPrintf("<TR><TD>"); hCheckBox("guidelines", cartUsualBoolean(cart, "guidelines", TRUE)); hPrintf("</TD><TD>"); hPrintf("Show light blue vertical guidelines, or light red vertical window separators in multi-region view"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("leftLabels", cartUsualBoolean(cart, "leftLabels", TRUE)); hPrintf("</TD><TD>"); hPrintf("Display labels to the left of items in tracks"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("centerLabels", cartUsualBoolean(cart, "centerLabels", TRUE)); hPrintf("</TD><TD>"); hPrintf("Display description above each track"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("trackControlsOnMain", cartUsualBoolean(cart, "trackControlsOnMain", TRUE)); hPrintf("</TD><TD>"); hPrintf("Show track controls under main graphic"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("nextItemArrows", cartUsualBoolean(cart, "nextItemArrows", FALSE)); hPrintf("</TD><TD>"); hPrintf("Next/previous item navigation"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("nextExonArrows", cartUsualBoolean(cart, "nextExonArrows", TRUE)); hPrintf("</TD><TD>"); hPrintf("Next/previous exon navigation"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("exonNumbers", cartUsualBoolean(cart, "exonNumbers", TRUE)); hPrintf("</TD><TD>"); hPrintf("Show exon numbers"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("enableHighlightingDialog", cartUsualBoolean(cart, "enableHighlightingDialog", TRUE)); hPrintf("</TD><TD>"); hPrintf("Enable highlight with drag-and-select " "(if unchecked, drag-and-select always zooms to selection)"); hPrintf("</TD></TR>\n"); hTableEnd(); cgiDown(0.9); char buf[256]; char *freeze = hFreezeFromDb(database); if (freeze == NULL) safef(buf, sizeof buf, "Configure Tracks on %s %s: %s", organization, browserName, trackHubSkipHubName(organism)); else if (stringIn(database, freeze)) safef(buf, sizeof buf, "Configure Tracks on %s %s: %s %s", organization, browserName, trackHubSkipHubName(organism), freeze); else safef(buf, sizeof buf, "Configure Tracks on %s %s: %s %s (%s)", organization, browserName, trackHubSkipHubName(organism), freeze, trackHubSkipHubName(database)); webNewSection("%s",buf); hPrintf("Tracks: "); if (isSearchTracksSupported(database,cart)) { cgiMakeButtonWithMsg(TRACK_SEARCH, TRACK_SEARCH_BUTTON,TRACK_SEARCH_HINT); hPrintf(" "); } cgiMakeButtonWithMsg(configHideAll, "hide all","Hide all tracks in this genome assembly"); hPrintf(" "); cgiMakeButtonWithMsg(configShowAll, "show all","Show all tracks in this genome assembly"); hPrintf(" "); cgiMakeButtonWithMsg(configDefaultAll, "default","Display only default tracks"); hPrintf(" Groups: "); hButtonWithOnClick("hgt.collapseGroups", "collapse all", "Collapse all track groups", "return vis.expandAllGroups(false)"); hPrintf(" "); hButtonWithOnClick("hgt.expandGroups", "expand all", "Expand all track groups", "return vis.expandAllGroups(true)"); hPrintf("<div style='margin-top:.2em; margin-bottom:.9em;'>Control track and group visibility " "more selectively below.</div>"); trackConfig(trackList, groupList, groupTarget, vis); dyStringFree(&title); freez(&groupTarget); webEndSectionTables(); hPrintf("</FORM>"); }
static void trackConfig(struct track *trackList, struct group *groupList, char *groupTarget, int changeVis) /* Put up track configurations. If groupTarget is * NULL then set visibility for tracks in all groups. Otherwise, * just set it for the given group. If vis is -2, then visibility is * unchanged. If -1 then set visibility to default, otherwise it should * be tvHide, tvDense, etc. */ { #ifdef PRIORITY_CHANGES_IN_CONFIG_UI char pname[512]; char gname[512]; #endif///def PRIORITY_CHANGES_IN_CONFIG_UI struct group *group; boolean showedRuler = FALSE; setRulerMode(); changeTrackVis(groupList, groupTarget, changeVis); /* Set up ruler mode according to changeVis. */ #ifdef BOB_DOESNT_LIKE if (changeVis != -2) { if (groupTarget == NULL || (groupList != NULL && sameString(groupTarget, groupList->name))) { if (changeVis == -1) rulerMode = tvFull; else rulerMode = changeVis; } } #endif /* BOB_DOESNT_LIKE */ jsInit(); cgiMakeHiddenVar(configGroupTarget, "none"); boolean isFirstNotCtGroup = TRUE; for (group = groupList; group != NULL; group = group->next) { struct trackRef *tr; if (group->trackList == NULL) continue; /* check if group section should be displayed */ char *otherState; char *indicator; char *indicatorImg; boolean isOpen = !isCollapsedGroup(group); collapseGroupGoodies(isOpen, FALSE, &indicatorImg, &indicator, &otherState); hTableStart(); hPrintf("<TR NOWRAP>"); hPrintf("<TH NOWRAP align=\"left\" colspan=3 BGCOLOR=#536ED3>"); hPrintf("\n<A NAME='%sGroup'></A>",group->name); hPrintf("<input type=hidden name='%s' id='%s' value=%d>", collapseGroupVar(group->name),collapseGroupVar(group->name), (isOpen?0:1)); hPrintf("<A HREF='%s?%s&%s=%s#%sGroup' class='bigBlue'><IMG height=22 width=22 onclick=\"return toggleTrackGroupVisibility(this,'%s');\" id='%s_button' src='%s' alt='%s' class='bigBlue' title='%s this group'></A> ", hgTracksName(), cartSidUrlString(cart),collapseGroupVar(group->name), otherState, group->name, group->name, group->name, indicatorImg, indicator,isOpen?"Collapse":"Expand"); hPrintf("<B> %s</B> ", wrapWhiteFont(group->label)); hPrintf(" "); hPrintf("<INPUT TYPE=SUBMIT NAME=\"%s\" VALUE=\"%s\" " "onClick=\"document.mainForm.%s.value='%s'; %s\" title='Hide all tracks in this groups'>", configHideAll, "hide all", configGroupTarget, group->name, jsSetVerticalPosition("mainForm")); hPrintf(" "); hPrintf("<INPUT TYPE=SUBMIT NAME=\"%s\" VALUE=\"%s\" " "onClick=\"document.mainForm.%s.value='%s'; %s\" title='Show all tracks in this groups'>", configShowAll, "show all", configGroupTarget, group->name, jsSetVerticalPosition("mainForm")); hPrintf(" "); hPrintf("<INPUT TYPE=SUBMIT NAME=\"%s\" VALUE=\"%s\" " "onClick=\"document.mainForm.%s.value='%s'; %s\" title='Show default tracks in this group'>", configDefaultAll, "default", configGroupTarget, group->name, jsSetVerticalPosition("mainForm")); hPrintf(" "); /* do not want all the submit buttons named the same. It is * confusing to the javascript submit() function. */ char submitName[256]; safef(submitName, sizeof(submitName), "%sSubmit", group->name); cgiMakeButtonWithMsg(submitName, "submit","Submit your selections and view them in the browser"); #ifdef PRIORITY_CHANGES_IN_CONFIG_UI if (withPriorityOverride) { hPrintf(" "); hPrintf(" "); hPrintf(" "); hPrintf("%s", wrapWhiteFont("Group Order: ")); } #endif///def PRIORITY_CHANGES_IN_CONFIG_UI hPrintf("</TH>\n"); #ifdef PRIORITY_CHANGES_IN_CONFIG_UI if (withPriorityOverride) { hPrintf("<TH>\n"); safef(pname, sizeof(pname), "%s.priority",group->name); hDoubleVar(pname, (double)group->priority, 4); hPrintf("</TH>\n"); if (isOpen) hPrintf("<TH align=CENTER BGCOLOR=#536ED3><B> %s</B></TH> ", wrapWhiteFont("Group")); hPrintf("\n"); } #endif///def PRIORITY_CHANGES_IN_CONFIG_UI hPrintf("</TR>\n"); /* First non-CT group gets ruler. */ if (!showedRuler && isFirstNotCtGroup && differentString(group->name, "user")) { showedRuler = TRUE; hPrintf("<TR %sid='%s-0'>",(isOpen ? "" : "style='display: none'"), group->name); hPrintf("<TD>"); hPrintf("<A HREF=\"%s?%s=%u&c=%s&g=%s&hgTracksConfigPage=configure\">", hgTrackUiName(), cartSessionVarName(), cartSessionId(cart), chromName, RULER_TRACK_NAME); hPrintf("%s</A>", RULER_TRACK_LABEL); hPrintf("</TD>"); hPrintf("<TD>"); hTvDropDownClass("ruler", rulerMode, FALSE, rulerMode ? "normalText" : "hiddenText"); hPrintf("</TD>"); hPrintf("<TD>"); hPrintf("Chromosome position in bases. (Clicks here zoom in 3x)"); hPrintf("</TD>"); #ifdef PRIORITY_CHANGES_IN_CONFIG_UI if (withPriorityOverride) { hPrintf("<TD>"); hPrintf("</TD>"); hPrintf("<TD>"); hPrintf("</TD>"); } #endif///def PRIORITY_CHANGES_IN_CONFIG_UI hPrintf("</TR>\n"); } if (differentString(group->name, "user")) isFirstNotCtGroup = FALSE; /* Scan track list to determine which supertracks have visible member * tracks, and to insert a track in the list for the supertrack. * Sort tracks and supertracks together by priority */ groupTrackListAddSuper(cart, group); if (!withPriorityOverride) { /* sort hierarchically by priority, considering supertracks */ struct trackRef *refList = NULL, *ref; for (tr = group->trackList; tr != NULL; tr = tr->next) { struct track *track = tr->track; if (tdbIsSuperTrackChild(track->tdb)) /* ignore supertrack member tracks till supertrack is found */ continue; AllocVar(ref); ref->track = track; slAddTail(&refList, ref); if (tdbIsSuper(track->tdb)) { struct trackRef *tr2; for (tr2 = group->trackList; tr2 != NULL; tr2 = tr2->next) { char *parent = tr2->track->tdb->parentName; if (parent && sameString(parent, track->track)) { AllocVar(ref); ref->track = tr2->track; slAddTail(&refList, ref); } } } } group->trackList = refList; } /* Loop through this group and display */ int rowCount=1; for (tr = group->trackList; tr != NULL; tr = tr->next) { struct track *track = tr->track; struct trackDb *tdb = track->tdb; hPrintf("<TR %sid='%s-%d'>",(isOpen ? "" : "style='display: none'"),group->name, rowCount++); hPrintf("<TD NOWRAP>"); if (tdbIsSuperTrackChild(tdb)) /* indent members of a supertrack */ hPrintf(" "); // Print an icon before the title when one is defined hPrintPennantIcon(track->tdb); if (track->hasUi) hPrintf("<A %s%s%s HREF=\"%s?%s=%u&g=%s&hgTracksConfigPage=configure\">", tdb->parent ? "TITLE=\"Part of super track: " : "", tdb->parent ? tdb->parent->shortLabel : "", tdb->parent ? "...\"" : "", hgTrackUiName(), cartSessionVarName(), cartSessionId(cart), track->track); hPrintf(" %s", track->shortLabel); if (tdbIsSuper(track->tdb)) hPrintf("..."); if (track->hasUi) hPrintf("</A>"); hPrintf("</TD>"); hPrintf("<TD NOWRAP>"); if (tdbIsSuperTrackChild(tdb)) /* indent members of a supertrack */ hPrintf(" "); /* If track is not on this chrom print an informational message for the user. */ if (hTrackOnChrom(track->tdb, chromName)) { if (tdbIsSuper(track->tdb)) { /* supertrack dropdown is hide/show */ superTrackDropDown(cart, track->tdb, 1); } else { /* check for option of limiting visibility to one mode */ hTvDropDownClassVisOnly(track->track, track->visibility, track->canPack, (track->visibility == tvHide) ? "hiddenText" : "normalText", trackDbSetting(track->tdb, "onlyVisibility")); } } else hPrintf("[No data-%s]", chromName); hPrintf("</TD>"); hPrintf("<TD NOWRAP>"); hPrintf("%s", track->longLabel); hPrintf("</TD>"); #ifdef PRIORITY_CHANGES_IN_CONFIG_UI if (withPriorityOverride) { hPrintf("<TD>"); safef(pname, sizeof(pname), "%s.priority",track->track); hDoubleVar(pname, (double)track->priority, 4); hPrintf("</TD>"); hPrintf("<TD>\n"); /* suppress group pull-down for supertrack members */ if (tdbIsSuperTrackChild(track->tdb)) hPrintf(" "); else { safef(gname, sizeof(gname), "%s.group",track->track); printGroupListHtml(gname, groupList, track->groupName); } hPrintf("</TD>"); } #endif///def PRIORITY_CHANGES_IN_CONFIG_UI hPrintf("</TR>\n"); } hTableEnd(); hPrintf("<BR>"); } }
void configPageSetTrackVis(int vis) /* Do config page after setting track visibility. If vis is -2, then visibility * is unchanged. If -1 then set visibility to default, otherwise it should * be tvHide, tvDense, etc. */ { struct dyString *title = dyStringNew(0); char *groupTarget = NULL; struct track *trackList = NULL; struct track *ideoTrack = NULL; struct group *groupList = NULL; withPriorityOverride = cartUsualBoolean(cart, configPriorityOverride, FALSE); /* Get track list and group them. */ ctList = customTracksParseCart(database, cart, &browserLines, &ctFileName); trackList = getTrackList(&groupList, vis); /* The ideogram for some reason is considered a track. * We don't really want to process it as one though, so * we see if it's there, and if necessary remove it. */ ideoTrack = chromIdeoTrack(trackList); if (ideoTrack != NULL) removeTrackFromGroup(ideoTrack); /* Fetch group to change on if any from CGI, * and remove var so it doesn't get used again. */ groupTarget = cloneString(cartUsualString(cart, configGroupTarget, "")); cartRemove(cart, configGroupTarget); if (sameString(groupTarget, "none")) freez(&groupTarget); dyStringPrintf(title, "Configure Image"); hPrintf("<FORM ACTION=\"%s\" NAME=\"mainForm\" METHOD=%s>\n", hgTracksName(), cartUsualString(cart, "formMethod", "POST")); webStartWrapperDetailedNoArgs(cart, database, "", title->string, FALSE, FALSE, FALSE, FALSE); cartSaveSession(cart); hPrintf("<INPUT TYPE=HIDDEN NAME=\"hgTracksConfigPage\" VALUE=\"\">"); /* do not want all the submit buttons named the same thing, this one is: */ cgiMakeButton("topSubmit", "submit"); // 3 column table hPrintf("<TABLE style=\"border:0px; \">\n"); hPrintf("<TR><TD>image width:"); hPrintf("<TD style=\"text-align: right\">"); hIntVar("pix", tl.picWidth, 4); hPrintf("<TD>pixels</TR>"); hPrintf("<TR><TD>label area width:"); hPrintf("<TD style=\"text-align: right\">"); hIntVar("hgt.labelWidth", leftLabelWidthChars, 2); hPrintf("<TD>characters<TD></TR>"); hPrintf("<TR><TD>text size:"); hPrintf("<TD style=\"text-align: right\">"); textSizeDropDown(); hPrintf("<TD>"); if (trackLayoutInclFontExtras()) { char *defaultStyle = cartUsualString(cart, "fontType", "medium"); cartMakeRadioButton(cart, "fontType", "medium", defaultStyle); hPrintf(" medium "); cartMakeRadioButton(cart, "fontType", "fixed", defaultStyle); hPrintf(" fixed "); cartMakeRadioButton(cart, "fontType", "bold", defaultStyle); hPrintf(" bold "); hPrintf(" "); } hPrintf("<TR><BR>"); hTableStart(); if (ideoTrack != NULL) { hPrintf("<TR><TD>"); hCheckBox("ideogram", cartUsualBoolean(cart, "ideogram", TRUE)); hPrintf("</TD><TD>"); hPrintf("Display chromosome ideogram above main graphic"); hPrintf("</TD></TR>\n"); } hPrintf("<TR><TD>"); hCheckBox("guidelines", cartUsualBoolean(cart, "guidelines", TRUE)); hPrintf("</TD><TD>"); hPrintf("Show light blue vertical guidelines"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("leftLabels", cartUsualBoolean(cart, "leftLabels", TRUE)); hPrintf("</TD><TD>"); hPrintf("Display labels to the left of items in tracks"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("centerLabels", cartUsualBoolean(cart, "centerLabels", TRUE)); hPrintf("</TD><TD>"); hPrintf("Display description above each track"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("trackControlsOnMain", cartUsualBoolean(cart, "trackControlsOnMain", TRUE)); hPrintf("</TD><TD>"); hPrintf("Show track controls under main graphic"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("nextItemArrows", cartUsualBoolean(cart, "nextItemArrows", FALSE)); hPrintf("</TD><TD>"); hPrintf("Next/previous item navigation"); hPrintf("</TD></TR>\n"); hPrintf("<TR><TD>"); hCheckBox("nextExonArrows", cartUsualBoolean(cart, "nextExonArrows", TRUE)); hPrintf("</TD><TD>"); hPrintf("Next/previous exon navigation"); hPrintf("</TD></TR>\n"); #ifdef PRIORITY_CHANGES_IN_CONFIG_UI hPrintf("<TR><TD>"); char *javascript="onClick=\"document.mainForm.hgTracksConfigPage.value='configure';document.mainForm.submit();\""; hCheckBoxJS(configPriorityOverride, cartUsualBoolean(cart, configPriorityOverride , FALSE), javascript); hPrintf("</TD><TD>"); hPrintf("Enable track re-ordering"); hPrintf("</TD></TR>\n"); #endif///def PRIORITY_CHANGES_IN_CONFIG_UI hPrintf("<TR><TD>"); hCheckBox("enableAdvancedJavascript", advancedJavascriptFeaturesEnabled(cart)); hPrintf("</TD><TD>"); hPrintf("Enable advanced javascript features"); hPrintf("</TD></TR>\n"); hTableEnd(); char *freeze = hFreezeFromDb(database); char buf[128]; if (stringIn(database, freeze)) safef(buf, sizeof buf, "Configure Tracks on %s %s: %s %s", organization, browserName, organism, freeze); else safef(buf, sizeof buf, "Configure Tracks on %s %s: %s %s (%s)", organization, browserName, organism, freeze, database); webNewSection(buf); hPrintf("Tracks: "); if(isSearchTracksSupported(database,cart)) { cgiMakeButtonWithMsg(TRACK_SEARCH, TRACK_SEARCH_BUTTON,TRACK_SEARCH_HINT); hPrintf(" "); } cgiMakeButtonWithMsg(configHideAll, "hide all","Hide all tracks in this genome assembly"); hPrintf(" "); cgiMakeButtonWithMsg(configShowAll, "show all","Show all tracks in this genome assembly"); hPrintf(" "); cgiMakeButtonWithMsg(configDefaultAll, "default","Display only default tracks"); hPrintf(" Groups: "); hButtonWithOnClick("hgt.collapseGroups", "collapse all", "Collapse all track groups", "return setAllTrackGroupVisibility(false)"); hPrintf(" "); hButtonWithOnClick("hgt.expandGroups", "expand all", "Expand all track groups", "return setAllTrackGroupVisibility(true)"); hPrintf("<P STYLE=\"margin-top:5;\">Control track and group visibility more selectively below.<P>"); trackConfig(trackList, groupList, groupTarget, vis); dyStringFree(&title); freez(&groupTarget); webEndSectionTables(); hPrintf("</FORM>"); }
void doSearchTracks(struct group *groupList) { webIncludeResourceFile("ui.dropdownchecklist.css"); jsIncludeFile("ui.dropdownchecklist.js",NULL); // This line is needed to get the multi-selects initialized jsIncludeFile("ddcl.js",NULL); struct group *group; char *groups[128]; char *labels[128]; int numGroups = 1; groups[0] = ANYLABEL; labels[0] = ANYLABEL; char *nameSearch = cartOptionalString(cart, TRACK_SEARCH_ON_NAME); char *typeSearch = cartUsualString( cart, TRACK_SEARCH_ON_TYPE,ANYLABEL); char *simpleEntry = cartOptionalString(cart, TRACK_SEARCH_SIMPLE); char *descSearch = cartOptionalString(cart, TRACK_SEARCH_ON_DESCR); char *groupSearch = cartUsualString( cart, TRACK_SEARCH_ON_GROUP,ANYLABEL); boolean doSearch = sameString(cartOptionalString(cart, TRACK_SEARCH), "Search") || cartUsualInt(cart, TRACK_SEARCH_PAGER, -1) >= 0; struct sqlConnection *conn = hAllocConn(database); boolean metaDbExists = sqlTableExists(conn, "metaDb"); int tracksFound = 0; boolean searchTermsExist = FALSE; int cols; char buf[512]; char *currentTab = cartUsualString(cart, TRACK_SEARCH_CURRENT_TAB, "simpleTab"); enum searchTab selectedTab = (sameString(currentTab, "advancedTab") ? advancedTab : simpleTab); // NOTE: could support quotes in simple tab by detecting quotes and choosing // to use doesNameMatch() || doesDescriptionMatch() if (selectedTab == simpleTab && !isEmpty(simpleEntry)) stripChar(simpleEntry, '"'); trackList = getTrackList(&groupList, -2); // global makeGlobalTrackHash(trackList); // NOTE: This is necessary when container cfg by '*' results in vis changes // This will handle composite/view override when subtrack specific vis exists, // AND superTrack reshaping. // Subtrack settings must be removed when composite/view settings are updated parentChildCartCleanup(trackList,cart,oldVars); slSort(&groupList, gCmpGroup); for (group = groupList; group != NULL; group = group->next) { groupTrackListAddSuper(cart, group); if (group->trackList != NULL) { groups[numGroups] = cloneString(group->name); labels[numGroups] = cloneString(group->label); numGroups++; if (numGroups >= ArraySize(groups)) internalErr(); } } safef(buf, sizeof(buf),"Search for Tracks in the %s %s Assembly", organism, hFreezeFromDb(database)); webStartWrapperDetailedNoArgs(cart, database, "", buf, FALSE, FALSE, FALSE, FALSE); hPrintf("<div style='max-width:1080px;'>"); hPrintf("<form action='%s' name='%s' id='%s' method='get'>\n\n", hgTracksName(),TRACK_SEARCH_FORM,TRACK_SEARCH_FORM); cartSaveSession(cart); // Creates hidden var of hgsid to avoid bad voodoo safef(buf, sizeof(buf), "%lu", clock1()); cgiMakeHiddenVar("hgt_", buf); // timestamps page to avoid browser cache hPrintf("<input type='hidden' name='db' value='%s'>\n", database); hPrintf("<input type='hidden' name='%s' id='currentTab' value='%s'>\n", TRACK_SEARCH_CURRENT_TAB, currentTab); hPrintf("<input type='hidden' name='%s' value=''>\n",TRACK_SEARCH_DEL_ROW); hPrintf("<input type='hidden' name='%s' value=''>\n",TRACK_SEARCH_ADD_ROW); hPrintf("<input type='hidden' name='%s' value=''>\n",TRACK_SEARCH_PAGER); hPrintf("<div id='tabs' style='display:none; %s'>\n<ul>\n<li><a href='#simpleTab'>" "<B style='font-size:.9em;font-family: arial, Geneva, Helvetica, san-serif;'>Search</B>" "</a></li>\n<li><a href='#advancedTab'>" "<B style='font-size:.9em;font-family: arial, Geneva, Helvetica, san-serif;'>Advanced</B>" "</a></li>\n</ul>\n<div id='simpleTab' style='max-width:inherit;'>\n", cgiBrowser()==btIE?"width:1060px;":"max-width:inherit;"); hPrintf("<table id='simpleTable' style='width:100%%; font-size:.9em;'><tr><td colspan='2'>"); hPrintf("<input type='text' name='%s' id='simpleSearch' class='submitOnEnter' value='%s' " "style='max-width:1000px; width:100%%;' onkeyup='findTracks.searchButtonsEnable(true);'>\n", TRACK_SEARCH_SIMPLE,simpleEntry == NULL ? "" : simpleEntry); if (selectedTab==simpleTab && simpleEntry) searchTermsExist = TRUE; hPrintf("</td></tr><td style='max-height:4px;'></td></tr></table>"); //hPrintf("</td></tr></table>"); hPrintf("<input type='submit' name='%s' id='searchSubmit' value='search' " "style='font-size:.8em;'>\n", TRACK_SEARCH); hPrintf("<input type='button' name='clear' value='clear' class='clear' " "style='font-size:.8em;' onclick='findTracks.clear();'>\n"); hPrintf("<input type='submit' name='submit' value='cancel' class='cancel' " "style='font-size:.8em;'>\n"); hPrintf("</div>\n"); // Advanced tab hPrintf("<div id='advancedTab' style='width:inherit;'>\n" "<table id='advancedTable' cellSpacing=0 style='width:inherit; font-size:.9em;'>\n"); cols = 8; // Track Name contains hPrintf("<tr><td colspan=3></td>"); hPrintf("<td nowrap><b style='max-width:100px;'>Track Name:</b></td>"); hPrintf("<td align='right'>contains</td>\n"); hPrintf("<td colspan='%d'>", cols - 4); hPrintf("<input type='text' name='%s' id='nameSearch' class='submitOnEnter' value='%s' " "onkeyup='findTracks.searchButtonsEnable(true);' style='min-width:326px; font-size:.9em;'>", TRACK_SEARCH_ON_NAME, nameSearch == NULL ? "" : nameSearch); hPrintf("</td></tr>\n"); // Description contains hPrintf("<tr><td colspan=2></td><td align='right'>and </td>"); hPrintf("<td><b style='max-width:100px;'>Description:</b></td>"); hPrintf("<td align='right'>contains</td>\n"); hPrintf("<td colspan='%d'>", cols - 4); hPrintf("<input type='text' name='%s' id='descSearch' value='%s' class='submitOnEnter' " "onkeyup='findTracks.searchButtonsEnable(true);' " "style='max-width:536px; width:536px; font-size:.9em;'>", TRACK_SEARCH_ON_DESCR, descSearch == NULL ? "" : descSearch); hPrintf("</td></tr>\n"); if (selectedTab==advancedTab && !isEmpty(descSearch)) searchTermsExist = TRUE; hPrintf("<tr><td colspan=2></td><td align='right'>and </td>\n"); hPrintf("<td><b style='max-width:100px;'>Group:</b></td>"); hPrintf("<td align='right'>is</td>\n"); hPrintf("<td colspan='%d'>", cols - 4); cgiMakeDropListFull(TRACK_SEARCH_ON_GROUP, labels, groups, numGroups, groupSearch, "class='groupSearch' style='min-width:40%; font-size:.9em;'"); hPrintf("</td></tr>\n"); if (selectedTab==advancedTab && !isEmpty(groupSearch) && !sameString(groupSearch,ANYLABEL)) searchTermsExist = TRUE; // Track Type is (drop down) hPrintf("<tr><td colspan=2></td><td align='right'>and </td>\n"); hPrintf("<td nowrap><b style='max-width:100px;'>Data Format:</b></td>"); hPrintf("<td align='right'>is</td>\n"); hPrintf("<td colspan='%d'>", cols - 4); char **formatTypes = NULL; char **formatLabels = NULL; int formatCount = getFormatTypes(&formatLabels, &formatTypes); cgiMakeDropListFull(TRACK_SEARCH_ON_TYPE, formatLabels, formatTypes, formatCount, typeSearch, "class='typeSearch' style='min-width:40%; font-size:.9em;'"); hPrintf("</td></tr>\n"); if (selectedTab==advancedTab && !isEmpty(typeSearch) && !sameString(typeSearch,ANYLABEL)) searchTermsExist = TRUE; // mdb selects struct slPair *mdbSelects = NULL; if (metaDbExists) { struct slPair *mdbVars = mdbVarsSearchable(conn,TRUE,FALSE); // Tables but not file only objects mdbSelects = mdbSelectPairs(cart, mdbVars); char *output = mdbSelectsHtmlRows(conn,mdbSelects,mdbVars,cols,FALSE); // not a fileSearch if (output) { puts(output); freeMem(output); } slPairFreeList(&mdbVars); } hPrintf("</table>\n"); hPrintf("<input type='submit' name='%s' id='searchSubmit' value='search' " "style='font-size:.8em;'>\n", TRACK_SEARCH); hPrintf("<input type='button' name='clear' value='clear' class='clear' " "style='font-size:.8em;' onclick='findTracks.clear();'>\n"); hPrintf("<input type='submit' name='submit' value='cancel' class='cancel' " "style='font-size:.8em;'>\n"); //hPrintf("<a target='_blank' href='../goldenPath/help/trackSearch.html'>help</a>\n"); hPrintf("</div>\n"); hPrintf("</div>\n"); hPrintf("</form>\n"); hPrintf("</div>"); // Restricts to max-width:1000px; cgiDown(0.8); if (measureTiming) measureTime("Rendered tabs"); if (doSearch) { // Now search struct slRef *tracks = NULL; if (selectedTab==simpleTab && !isEmpty(simpleEntry)) tracks = simpleSearchForTracksstruct(simpleEntry); else if (selectedTab==advancedTab) tracks = advancedSearchForTracks(conn,groupList,nameSearch,typeSearch,descSearch, groupSearch,mdbSelects); if (measureTiming) measureTime("Searched for tracks"); // Sort and Print results if (selectedTab!=filesTab) { enum sortBy sortBy = cartUsualInt(cart,TRACK_SEARCH_SORT,sbRelevance); tracksFound = slCount(tracks); if (tracksFound > 1) findTracksSort(&tracks,sortBy); displayFoundTracks(cart,tracks,tracksFound,sortBy); if (measureTiming) measureTime("Displayed found tracks"); } slPairFreeList(&mdbSelects); } hFreeConn(&conn); webNewSection("About Track Search"); if (metaDbExists) hPrintf("<p>Search for terms in track names, descriptions, groups, and ENCODE " "metadata. If multiple terms are entered, only tracks with all terms " "will be part of the results."); else hPrintf("<p>Search for terms in track descriptions, groups, and names. " "If multiple terms are entered, only tracks with all terms " "will be part of the results."); hPrintf("<BR><a target='_blank' href='../goldenPath/help/trackSearch.html'>more help</a></p>\n"); webEndSectionTables(); }
static void displayFoundTracks(struct cart *cart, struct slRef *tracks, int tracksFound, enum sortBy sortBy) // Routine for displaying found tracks { hPrintf("<div id='found' style='display:none;'>\n"); // This div is emptied with 'clear' button if (tracksFound < 1) { hPrintf("<p>No tracks found</p>\n"); } else { hPrintf("<form action='%s' name='%s' id='%s' method='post'>\n\n", hgTracksName(),SEARCH_RESULTS_FORM,SEARCH_RESULTS_FORM); cartSaveSession(cart); // Creates hidden var of hgsid to avoid bad voodoo int startFrom = 0; hPrintf("<table id='foundTracks'>\n"); // Opening view in browser button and foundTracks count #define ENOUGH_FOUND_TRACKS 10 if (tracksFound >= ENOUGH_FOUND_TRACKS) { hPrintf("<tr><td nowrap colspan=3>\n"); hPrintf("<INPUT TYPE=SUBMIT NAME='submit' VALUE='return to browser' class='viewBtn' " "style='font-size:.8em;'>"); hPrintf(" <span class='selCbCount'></span>\n"); startFrom = cartUsualInt(cart,TRACK_SEARCH_PAGER,0); if (startFrom > 0 && startFrom < tracksFound) { int countUp = 0; for (countUp=0; countUp < startFrom;countUp++) { if (slPopHead(&tracks) == NULL) // memory waste break; } } hPrintf("</td><td align='right' valign='bottom'>\n"); findTracksPageLinks(tracksFound,startFrom); hPrintf("</td></tr>\n"); } // Begin foundTracks table //hPrintf("<table id='foundTracks'><tr><td colspan='2'>\n"); hPrintf("<tr><td colspan='2'>\n"); hPrintf("</td><td align='right'>\n"); hPrintf("</td></tr><tr bgcolor='#%s'><td>",HG_COL_HEADER); #define PM_BUTTON \ "<IMG height=18 width=18 onclick=\"return findTracks.checkAllWithWait(%s);\" " \ "id='btn_%s' src='../images/%s' title='%s all found tracks'>" hPrintf(PM_BUTTON,"true", "plus_all", "add_sm.gif", "Select"); hPrintf(PM_BUTTON,"false","minus_all","remove_sm.gif","Unselect"); hPrintf("</td><td><b>Visibility</b></td><td colspan=2> <b>Track Name</b>\n"); // Sort options? if (tracksFound >= ENOUGH_FOUND_TRACKS) { hPrintf("<span style='float:right;'>Sort:"); cgiMakeOnClickRadioButton(TRACK_SEARCH_SORT, "0", (sortBy == sbRelevance), "onclick=\"findTracks.sortNow(this);\""); hPrintf("by Relevance"); cgiMakeOnClickRadioButton(TRACK_SEARCH_SORT, "1", (sortBy == sbAbc), "onclick=\"findTracks.sortNow(this);\""); hPrintf("Alphabetically"); cgiMakeOnClickRadioButton(TRACK_SEARCH_SORT, "2",(sortBy == sbHierarchy), "onclick=\"findTracks.sortNow(this);\""); hPrintf("by Hierarchy </span>\n"); } hPrintf("</td></tr>\n"); // Set up json for js functionality struct jsonElement *jsonTdbVars = newJsonObject(newHash(8)); int trackCount=0; boolean containerTrackCount = 0; struct slRef *ptr; while((ptr = slPopHead(&tracks))) { if (++trackCount > MAX_FOUND_TRACKS) break; struct track *track = (struct track *) ptr->val; jsonTdbSettingsBuild(jsonTdbVars, track, FALSE); // FALSE: No config from track search if (tdbIsFolder(track->tdb)) // supertrack hPrintf("<tr class='bgLevel4' valign='top' class='found'>\n"); else if (tdbIsContainer(track->tdb)) hPrintf("<tr class='bgLevel3' valign='top' class='found'>\n"); else hPrintf("<tr class='bgLevel2' valign='top' class='found'>\n"); hPrintf("<td align='center'>\n"); // Determine visibility and checked state track->visibility = tdbVisLimitedByAncestors(cart, track->tdb, TRUE, TRUE); boolean checked = ( track->visibility != tvHide ); if (tdbIsContainerChild(track->tdb)) { // Don't need all 4 states here. Visible=checked&&enabled checked = fourStateVisible(subtrackFourStateChecked(track->tdb,cart)); // Checked is only if subtrack level vis is also set! checked = (checked && ( track->visibility != tvHide )); } // Setup the check box #define CB_HIDDEN_VAR "<INPUT TYPE=HIDDEN disabled=true NAME='%s_sel' VALUE='%s'>" // subtracks and folder children get "_sel" var. ("_sel" var is temp on folder children) if (tdbIsContainerChild(track->tdb) || tdbIsFolderContent(track->tdb)) hPrintf(CB_HIDDEN_VAR,track->track,checked?"1":CART_VAR_EMPTY); #define CB_SEEN "<INPUT TYPE=CHECKBOX id='%s_sel_id' VALUE='on' class='selCb' " \ "onclick='findTracks.clickedOne(this,true);'%s>" hPrintf(CB_SEEN,track->track,(checked?" CHECKED":"")); hPrintf("</td><td>\n"); // Setup the visibility drop down #define VIS_HIDDEN_VAR "<INPUT TYPE=HIDDEN disabled=true NAME='%s' VALUE='%s'>" hPrintf(VIS_HIDDEN_VAR,track->track,CART_VAR_EMPTY); // All tracks get vis hidden var char extra[512]; if (tdbIsFolder(track->tdb)) { safef(extra,sizeof(extra),"id='%s_id' onchange='findTracks.changeVis(this)'", track->track); hideShowDropDownWithClassAndExtra(track->track, (track->visibility != tvHide), "normalText visDD",extra); } else { safef(extra,sizeof(extra),"id='%s_id' onchange='findTracks.changeVis(this)'", track->track); hTvDropDownClassWithJavascript(NULL, track->visibility,track->canPack, "normalText seenVis",extra); } // If this is a container track, allow configuring... if (tdbIsContainer(track->tdb) || tdbIsFolder(track->tdb)) { containerTrackCount++; // Using onclick ensures return to search tracks on submit hPrintf(" <IMG SRC='../images/folderWrench.png' style='cursor:pointer;' " "title='Configure this track container...' " "onclick='findTracks.configSet(\"%s\");'> ", track->track); } //#define SHOW_PARENT_FOLDER #ifdef SHOW_PARENT_FOLDER else if (tdbIsContainerChild(track->tdb) || tdbIsFolderContent(track->tdb)) { struct trackDb *parentTdb = tdbIsContainerChild(track->tdb) ? tdbGetContainer(track->tdb) : tdbGetImmediateFolder(track->tdb); if (parentTdb != NULL) // Using href will not return to search tracks on submit hPrintf(" <A HREF='../cgi-bin/hgTrackUi?g=%s'><IMG SRC='../images/folderC.png'" " title='Navigate to parent container...'></A> ", parentTdb->track); } #endif///def SHOW_PARENT_FOLDER hPrintf("</td>\n"); // shortLabel has description popup and longLabel has "..." metadata hPrintf("<td><a target='_top' onclick=\"popUp.hgTrackUi('%s',true); return false;\" " "href='%s' title='Display track details'>%s</a></td>\n", track->track, trackUrl(track->track, NULL), track->shortLabel); hPrintf("<td>%s", track->longLabel); compositeMetadataToggle(database, track->tdb, NULL, TRUE, FALSE); hPrintf("</td></tr>\n"); } //hPrintf("</table>\n"); // Closing view in browser button and foundTracks count hPrintf("<tr><td nowrap colspan=3>"); hPrintf("<INPUT TYPE=SUBMIT NAME='submit' VALUE='Return to Browser' class='viewBtn' " "style='font-size:.8em;'>"); hPrintf(" <span class='selCbCount'></span>"); if (tracksFound >= ENOUGH_FOUND_TRACKS) { hPrintf("</td><td align='right' valign='top'>\n"); findTracksPageLinks(tracksFound,startFrom); hPrintf("</td></tr>\n"); } hPrintf("</table>\n"); if (containerTrackCount > 0) hPrintf("<BR><IMG SRC='../images/folderWrench.png'> Tracks so marked are containers " "which group related data tracks. Containers may need additional configuration " "(by clicking on the <IMG SRC='../images/folderWrench.png'> icon) before they can " "be viewed in the browser.<BR>\n"); //hPrintf("* Tracks so marked are containers which group related data tracks. These may " // "not be visible unless further configuration is done. Click on the * to " // "configure these.<BR><BR>\n"); hPrintf("\n</form>\n"); // be done with json jsonTdbSettingsUse(jsonTdbVars); } hPrintf("</div>"); // This div allows the clear button to empty it }