41e92aca41621f3fe3c5caf951261db487875dc8 larrym Fri May 4 15:59:07 2012 -0700 refactor menu bar code into a new file to get ready for new menu bar design (#5245) diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index 16e8e81..fc59817 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -35,31 +35,30 @@ #include "cutterTrack.h" #include "wikiTrack.h" #include "ctgPos.h" #include "bed.h" #include "bigBed.h" #include "bigWig.h" #include "bedCart.h" #include "udc.h" #include "customTrack.h" #include "trackHub.h" #include "hubConnect.h" #include "cytoBand.h" #include "ensFace.h" #include "liftOver.h" #include "pcrResult.h" -#include "wikiLink.h" #include "jsHelper.h" #include "mafTrack.h" #include "hgConfig.h" #include "encode.h" #include "agpFrag.h" #include "imageV2.h" #include "suggest.h" #include "search.h" #include "errCatch.h" /* Other than submit and Submit all these vars should start with hgt. * to avoid weeding things out of other program's namespaces. * Because the browser is a central program, most of it's cart * variables are not hgt. qualified. It's a good idea if other @@ -2608,99 +2607,30 @@ winBaseCount = winEnd - winStart; insideWidth = tl.picWidth-gfxBorder-insideX; } imgBoxFree(&theImgBox); } else { char *titleAttr = "title='click or drag mouse in base position track to zoom in'"; hPrintf("
\n"); } flatTracksFree(&flatTracks); } -static void appendLink(struct hotLink **links, char *url, char *name, char *id) -{ -// append to list of links for later printing and/or communication with javascript client -struct hotLink *link; -AllocVar(link); -link->name = cloneString(name); -link->url = cloneString(url); -link->id = cloneString(id); -slAddTail(links, link); -} - -static void printEnsemblAnchor(char *database, char* archive, - char *chrName, int start, int end, struct hotLink **links) -/* Print anchor to Ensembl display on same window. */ -{ -char *scientificName = hScientificName(database); -char *dir = ensOrgNameFromScientificName(scientificName); -struct dyString *ensUrl; -char *name; -int localStart, localEnd; - -name = chrName; - -if (sameWord(scientificName, "Takifugu rubripes")) - { - /* for Fugu, must give scaffold, not chr coordinates */ - /* Also, must give "chrom" as "scaffold_N", name below. */ - if (differentWord(chromName,"chrM") && - !hScaffoldPos(database, chromName, winStart, winEnd, - &name, &localStart, &localEnd)) - /* position doesn't appear on Ensembl browser. - * Ensembl doesn't show scaffolds < 2K */ - return; - } -else if (sameWord(scientificName, "Gasterosteus aculeatus")) - { - if (differentWord("chrM", chrName)) - { - char *fixupName = replaceChars(chrName, "chr", "group"); - name = fixupName; - } - } -else if (sameWord(scientificName, "Ciona intestinalis")) - { - if (stringIn("chr0", chrName)) - { - char *fixupName = replaceChars(chrName, "chr0", "chr"); - name = fixupName; - } - } -else if (sameWord(scientificName, "Saccharomyces cerevisiae")) - { - if (stringIn("2micron", chrName)) - { - char *fixupName = replaceChars(chrName, "2micron", "2-micron"); - name = fixupName; - } - } - -if (sameWord(chrName, "chrM")) - name = "chrMt"; -ensUrl = ensContigViewUrl(database, dir, name, seqBaseCount, start+1, end, archive); -appendLink(links, ensUrl->string, "Ensembl", "ensemblLink"); -/* NOTE: you can not freeMem(dir) because sometimes it is a literal - * constant */ -freeMem(scientificName); -dyStringFree(&ensUrl); -} - void makeHgGenomeTrackVisible(struct track *track) /* This turns on a track clicked from hgGenome, even if it was previously */ /* hidden manually and there are cart vars to support that. */ { struct hashEl *hels; struct hashEl *hel; char prefix[SMALLBUF]; /* First check if the click was from hgGenome. If not, leave. */ /* get the names of the tracks in the cart */ safef(prefix, sizeof(prefix), "%s_", hggGraphPrefix); hels = cartFindPrefix(cart, prefix); /* loop through them and compare them to the track passed into this */ /* function. */ for (hel = hels; hel != NULL; hel = hel->next) { @@ -3459,394 +3389,30 @@ hubUpdateStatus(NULL, hub); errCatchFree(&errCatch); } } hubConnectStatusFreeList(&hubList); } boolean restrictionEnzymesOk() /* Check to see if it's OK to do restriction enzymes. */ { return (sqlDatabaseExists("hgFixed") && hTableExists("hgFixed", "cutters") && hTableExists("hgFixed", "rebaseRefs") && hTableExists("hgFixed", "rebaseCompanies")); } -static void fr2ScaffoldEnsemblLink(char *archive, struct hotLink **links) -/* print out Ensembl link to appropriate scaffold there */ -{ -struct sqlConnection *conn = hAllocConn(database); -struct sqlResult *sr = NULL; -char **row = NULL; -char query[256]; -safef(query, sizeof(query), -"select * from chrUn_gold where chrom = '%s' and chromStart<%u and chromEnd>%u", -chromName, winEnd, winStart); -sr = sqlGetResult(conn, query); - -int itemCount = 0; -struct agpFrag *agpItem = NULL; -while ((row = sqlNextRow(sr)) != NULL) - { - agpFragFree(&agpItem); // if there is a second one - agpItem = agpFragLoad(row+1); - ++itemCount; - if (itemCount > 1) - break; - } -sqlFreeResult(&sr); -hFreeConn(&conn); -if (1 == itemCount) - { // verify *entirely* within single contig - if ((winEnd <= agpItem->chromEnd) && - (winStart >= agpItem->chromStart)) - { - int agpStart = winStart - agpItem->chromStart; - int agpEnd = agpStart + winEnd - winStart; - hPuts(""); - printEnsemblAnchor(database, archive, agpItem->frag, - agpStart, agpEnd, links); - hPrintf("%s", "Ensembl"); - } - } -agpFragFree(&agpItem); // the one we maybe used -} - -void hotLinks() -/* Put up the hot links bar. */ -{ -boolean gotBlat = hIsBlatIndexedDatabase(database); -struct dyString *uiVars = uiStateUrlPart(NULL); -char *orgEnc = cgiEncode(organism); -boolean psOutput = cgiVarExists("hgt.psOutput"); -struct hotLink *link, *links = NULL; - -hPrintf("
\n"); -hPrintf("\n"); -hPrintf(""); -hPuts("
\n"); -hPrintf("", - orgEnc, database, cartSessionVarName(), cartSessionId(cart)); - -if (hIsGisaidServer()) - { - /* disable hgGateway for gisaid for now */ - //hPrintf("", orgEnc, database); - hPrintf( - "", - '%', '%', - cartSessionVarName(), - cartSessionId(cart), - "Select Subjects"); - } -else -if (hIsGsidServer()) - { - hPrintf("", orgEnc, database); - hPrintf( - "", - '%', '%', "Select Subjects"); - } -else - { - hPrintf("", orgEnc, database, cartSessionVarName(), cartSessionId(cart)); - } -if (psOutput) - { - hPrintf("", orgEnc, database, cartSessionVarName(), cartSessionId(cart)); - } -if (gotBlat) - { - hPrintf("", uiVars->string); - } -if (hIsGisaidServer()) - { - hPrintf("", - database, - cartSessionVarName(), - cartSessionId(cart), - "Table View"); - } -else if (hIsGsidServer()) - { - hPrintf("", - database, "Table View"); - } -else - { - /* disable TB for CGB servers */ - if (!hIsCgbServer()) - { - hPrintf("", - database, cartSessionVarName(), cartSessionId(cart), - "Tables"); - } - } - -if (hgNearOk(database)) - { - hPrintf("", - uiVars->string, "Gene Sorter"); - } -if (hgPcrOk(database)) - { - hPrintf("", uiVars->string); - } -if (!psOutput) - { - hPrintf("", hgcNameAndSettings(), - winStart, chromName, winStart, winEnd, database, uiVars->string, "DNA"); - } - -if (!psOutput) - { - /* disable Convert function for CGB servers for the time being */ - if (!hIsCgbServer()) - if (liftOverChainForDb(database) != NULL) - { - hPrintf(""); - } - } - -if (!psOutput) - { - hPrintf("",cartSessionVarName(), - cartSessionId(cart), "PS/PDF"); - } - -if (!psOutput) - { - if (wikiLinkEnabled()) - { - printf("", - cartSessionVarName(), cartSessionId(cart)); - } - } - -char ensVersionString[256]; -char ensDateReference[256]; -ensGeneTrackVersion(database, ensVersionString, ensDateReference, - sizeof(ensVersionString)); - -if (!psOutput) - { - if (differentWord(database,"susScr2")) - { - /* Print Ensembl anchor for latest assembly of organisms we have - * supported by Ensembl == if versionString from trackVersion exists */ - if (sameWord(database,"hg19")) - { - printEnsemblAnchor(database, NULL, chromName, winStart, winEnd, &links); - } - else if (sameWord(database,"hg18")) - { - printEnsemblAnchor(database, "ncbi36", chromName, winStart, winEnd, &links); - } - else if (sameWord(database,"oryCun2") || sameWord(database,"anoCar2") || sameWord(database,"calJac3")) - { - printEnsemblAnchor(database, NULL, chromName, winStart, winEnd, &links); - } - else if (ensVersionString[0]) - { - char *archive = NULL; - if (ensDateReference[0] && differentWord("current", ensDateReference)) - archive = cloneString(ensDateReference); - /* Can we perhaps map from a UCSC random chrom to an Ensembl contig ? */ - if (isUnknownChrom(database, chromName)) - { - // which table to check - char *ctgPos = "ctgPos"; - - if (sameWord(database,"fr2")) - fr2ScaffoldEnsemblLink(archive, &links); - else if (hTableExists(database, UCSC_TO_ENSEMBL)) - printEnsemblAnchor(database, archive, chromName, winStart, winEnd, &links); - else if (hTableExists(database, ctgPos)) - /* see if we are entirely within a single contig */ - { - struct sqlConnection *conn = hAllocConn(database); - struct sqlResult *sr = NULL; - char **row = NULL; - char query[256]; - safef(query, sizeof(query), - "select * from %s where chrom = '%s' and chromStart<%u and chromEnd>%u", - ctgPos, chromName, winEnd, winStart); - sr = sqlGetResult(conn, query); - - int itemCount = 0; - struct ctgPos *ctgItem = NULL; - while ((row = sqlNextRow(sr)) != NULL) - { - ctgPosFree(&ctgItem); // if there is a second one - ctgItem = ctgPosLoad(row); - ++itemCount; - if (itemCount > 1) - break; - } - sqlFreeResult(&sr); - hFreeConn(&conn); - if (1 == itemCount) - { // verify *entirely* within single contig - if ((winEnd <= ctgItem->chromEnd) && - (winStart >= ctgItem->chromStart)) - { - int ctgStart = winStart - ctgItem->chromStart; - int ctgEnd = ctgStart + winEnd - winStart; - printEnsemblAnchor(database, archive, ctgItem->contig, - ctgStart, ctgEnd, &links); - } - } - ctgPosFree(&ctgItem); // the one we maybe used - } - } - else - { - printEnsemblAnchor(database, archive, chromName, winStart, winEnd, &links); - } - } - } - } - -if (!psOutput) - { - char buf[2056]; - /* Print NCBI MapView anchor */ - if (sameString(database, "hg18")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=9606&build=previous&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (sameString(database, "hg19")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=9606&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (sameString(database, "mm8")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=10090&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (sameString(database, "danRer2")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=7955&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (sameString(database, "galGal3")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=9031&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (sameString(database, "canFam2")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=9615&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (sameString(database, "rheMac2")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=9544&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (sameString(database, "panTro2")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=9598&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (sameString(database, "anoGam1")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=7165&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (sameString(database, "bosTau6")) - { - safef(buf, sizeof(buf), "http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=9913&CHR=%s&BEG=%d&END=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "NCBI", "ncbiLink"); - } - if (startsWith("oryLat", database)) - { - safef(buf, sizeof(buf), "http://medaka.utgenome.org/browser_ens_jump.php?revision=version1.0&chr=chromosome%s&start=%d&end=%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "UTGB", "medakaLink"); - } - if (sameString(database, "cb3")) - { - safef(buf, sizeof(buf), "http://www.wormbase.org/db/seq/gbrowse/briggsae?name=%s:%d-%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "WormBase", "wormbaseLink"); - } - if (sameString(database, "cb4")) - { - safef(buf, sizeof(buf), "http://www.wormbase.org/db/gb2/gbrowse/c_briggsae?name=%s:%d-%d", - chromName, winStart+1, winEnd); - appendLink(&links, buf, "WormBase", "wormbaseLink"); - } - if (sameString(database, "ce10")) - { - safef(buf, sizeof(buf), "http://www.wormbase.org/db/gb2/gbrowse/c_elegans?name=%s:%d-%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "WormBase", "wormbaseLink"); - } - if (sameString(database, "ce4")) - { - safef(buf, sizeof(buf), "http://ws170.wormbase.org/db/seq/gbrowse/wormbase?name=%s:%d-%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "WormBase", "wormbaseLink"); - } - if (sameString(database, "ce2")) - { - safef(buf, sizeof(buf), "http://ws120.wormbase.org/db/seq/gbrowse/wormbase?name=%s:%d-%d", - skipChr(chromName), winStart+1, winEnd); - appendLink(&links, buf, "WormBase", "wormbaseLink"); - } - } - -for(link = links; link != NULL; link = link->next) - hPrintf("\n", link->url, link->id, link->name); - -if (hIsGisaidServer()) - { - //hPrintf("\n", "Help"); - hPrintf("\n", "Help"); - } -else -if (hIsGsidServer()) - { - hPrintf("\n", "Help"); - } -else - { - hPrintf("\n", "Help"); - } - -hPuts("
Home    Sequence View Gateway    %s    Sequence View Gateway    %s    Genomes    Genome Browser    Blat    %s    %s    %s    %s    PCR    " - "%s    string, database); - hPrintf("\" class=\"topbar\">Convert    %s    Session    %s    %s    %s    %s    %s   
"); -hPuts("
\n"); -} - static void setSuperTrackHasVisibleMembers(struct trackDb *tdb) /* Determine if any member tracks are visible -- currently * recording this in the parent's visibility setting */ { tdb->visibility = tvDense; } boolean superTrackHasVisibleMembers(struct trackDb *tdb) /* Determine if any member tracks are visible -- currently * recording this in the parent's visibility setting */ { if (!tdbIsSuper(tdb)) return FALSE; return (tdb->visibility != tvHide); } @@ -4874,31 +4440,31 @@ { ideoTrack->limitedVisSet = TRUE; ideoTrack->limitedVis = tvHide; /* Don't draw in main gif. */ } makeActiveImage(trackList, psOutput); fflush(stdout); return; // bail out b/c we are done } if (!hideControls) { /* set white-space to nowrap to prevent buttons from wrapping when screen is * narrow */ hPrintf("
\n"); - hotLinks(); + menuBar(); /* Show title . */ freezeName = hFreezeFromDb(database); if(freezeName == NULL) freezeName = "Unknown"; hPrintf(""); if (startsWith("zoo",database) ) { hPrintf("%s %s on %s June 2002 Assembly %s target1", organization, browserName, organism, freezeName); } else { if (sameString(organism, "Archaea")) { @@ -5482,31 +5048,31 @@ int ret = round(x*guideBases); return (ret == 0) ? 1 : ret; } void handlePostscript() /* Deal with Postscript output. */ { struct tempName psTn, ideoPsTn; char *pdfFile = NULL, *ideoPdfFile = NULL; ZeroVar(&ideoPsTn); trashDirFile(&psTn, "hgt", "hgt", ".eps"); if(!trackImgOnly) { - hotLinks(); + menuBar(); printf("

PDF Output

\n"); printf("PDF images can be printed with Acrobat Reader " "and edited by many drawing programs such as Adobe " "Illustrator or Inkscape.
"); } doTrackForm(psTn.forCgi, &ideoPsTn); pdfFile = convertEpsToPdf(psTn.forCgi); if (strlen(ideoPsTn.forCgi)) ideoPdfFile = convertEpsToPdf(ideoPsTn.forCgi); if(pdfFile != NULL) { printf("