void doGenePredPal(struct sqlConnection *conn) /* Output genePred protein alignment. */ { if (doGalaxy() && !cgiOptionalString(hgtaDoGalaxyQuery)) { sendParamsToGalaxy(hgtaDoPalOut, "submit"); return; } /* get rid of pesky cookies that would bring us back here */ cartRemove(cart, hgtaDoPal); cartRemove(cart, hgtaDoPalOut); if (anyIntersection() && intersectionIsBpWise()) errAbort("Can't do CDS FASTA output when bit-wise intersection is on. " "Please go back and select another output type, or clear the intersection."); checkNoGenomeDisabled(database, curTable); struct lm *lm = lmInit(64*1024); int fieldCount; struct bed *bedList = cookedBedsOnRegions(conn, curTable, getRegions(), lm, &fieldCount); //lmCleanup(&lm); textOpen(); int outCount = palOutPredsInBeds(conn, cart, bedList, curTable); /* Do some error diagnostics for user. */ if (outCount == 0) explainWhyNoResults(NULL); }
boolean userSettingsProcessForm(struct userSettings *us) /* Handle button press in userSettings form. * If this returns TRUE then form is finished processing * and you can call something to make the next page. */ { struct cart *cart = us->cart; char *command = cartString(cart, us->formVar); boolean retVal = TRUE; char *name = cartNonemptyString(cart, us->nameVar); command = trimSpaces(command); if (sameWord(command, "save") && name != NULL) { char *varName = settingsVarName(us->savePrefix, name); saveSettings(us, varName); freez(&varName); } else if (startsWith(command, "load") && name != NULL) { userSettingsUseSelected(us); } else if (startsWith("delete", command)) { char *which = cartOptionalString(cart, us->listDisplayVar); if (which != NULL) { char *varName = settingsVarName(us->savePrefix, which); cartRemove(cart, varName); userSettingsSaveForm(us); retVal = FALSE; } } cartRemove(cart, us->formVar); return retVal; }
void doGsLogin(struct sqlConnection *conn) /* Process user password post. * Log into GS * if successful save gsToken * else return to login page or to mainpage */ { char *user = cloneString(cartUsualString(cart, hgtaGsUser, NULL)); char *password = cloneString(cartUsualString(cart, hgtaGsPassword, NULL)); // do not leave them in the cart cartRemove(cart, hgtaGsUser); cartRemove(cart, hgtaGsPassword); if (!(user && password)) errAbort("expecting GenomeSpace user and password"); char *gsToken = getAuthorizationToken(user, password); if (gsToken) { cartSetString(cart, "gsToken", gsToken); } else { cartRemove(cart, "gsToken"); } cartSetString(cart, hgtaDoTopSubmit, "get output"); }
boolean checkGsReady() /* check that GS requirements are met */ { // check that the output file has been specified char *fileName = cartUsualString(cart, hgtaOutFileName, ""); if (sameString(fileName,"")) { cartRemove(cart, hgtaDoTopSubmit); showMissingOutputFileForm(); return FALSE; } // check login // is the GS login token in the cart? char *gsToken = cartUsualString(cart, "gsToken", NULL); if (!gsToken) { cartRemove(cart, hgtaDoTopSubmit); showGsLoginForm(); return FALSE; } else { // check if the token still valid char *temp = getGsPersonalDirectory(gsToken); if (!temp) { cartRemove(cart, hgtaDoTopSubmit); showGsLoginForm(); return FALSE; } freeMem(temp); } return TRUE; }
void doClearSetUserRegionsText(struct sqlConnection *conn) /* Respond to clear within user regions enter page. */ { char *fileName = userRegionsFileName(); if (fileName != NULL) remove(fileName); cartRemove(cart, hgtaEnteredUserRegions); cartRemove(cart, hgtaEnteredUserRegionFile); cartRemove(cart, hgtaUserRegionsFile); cartRemove(cart, hgtaRegionType); doSetUserRegions(conn); }
static void doDisconnectHub(struct cart *theCart) { char *id = cartOptionalString(cart, "hubId"); if (id != NULL) { char buffer[1024]; safef(buffer, sizeof buffer, "hgHubConnect.hub.%s", id); cartRemove(cart, buffer); } cartRemove(theCart, "hubId"); }
void doClearIdentifiers(struct sqlConnection *conn) /* Respond to clear identifiers button. */ { char *fileName; htmlOpen("Table Browser (Cleared Identifiers)"); fileName = identifierFileName(); if (fileName != NULL) remove(fileName); cartRemove(cart, hgtaIdentifierFile); cartRemove(cart, hgtaPastedIdentifiers); mainPageAfterOpen(conn); htmlClose(); }
void doClearUserRegions(struct sqlConnection *conn) /* Respond to clear user regions button. */ { char *fileName = userRegionsFileName(); htmlOpen("Table Browser (Cleared Region List)"); if (fileName != NULL) remove(fileName); cartRemove(cart, hgtaEnteredUserRegions); cartRemove(cart, hgtaEnteredUserRegionFile); cartRemove(cart, hgtaUserRegionsFile); cartRemove(cart, hgtaRegionType); mainPageAfterOpen(conn); htmlClose(); }
static void disconnectHubsSamePrefix(struct cart *cart, char *url) /* disconnect all the hubs with the same prefix */ { char *prefix = cloneString(url); char *ptr = strrchr(prefix, '/'); if (ptr == NULL) return; *ptr = 0; char query[2048]; sqlSafef(query, sizeof(query), "select id from %s where hubUrl like \"%s%%\"", getHubStatusTableName(), prefix); struct sqlConnection *conn = hConnectCentral(); struct sqlResult *sr = sqlGetResult(conn, query); char **row; while ((row = sqlNextRow(sr)) != NULL) { int id = sqlUnsigned(row[0]); char buffer[512]; safef(buffer, sizeof(buffer), "hgHubConnect.hub.%d", id); cartRemove(cart, buffer); } sqlFreeResult(&sr); hDisconnectCentral(&conn); }
static void hubConnectRemakeTrackHubVar(struct cart *cart) /* Remake trackHub cart variable if need be from various check box vars. */ { if (cartVarExists(cart, hgHubConnectRemakeTrackHub)) { struct slPair *hubVarList = cartVarsWithPrefix(cart, hgHubConnectHubVarPrefix); int prefixLength = strlen(hgHubConnectHubVarPrefix); struct dyString *trackHubs = dyStringNew(0); struct slPair *hubVar; boolean firstOne = TRUE; for (hubVar = hubVarList; hubVar != NULL; hubVar = hubVar->next) { if (cartBoolean(cart, hubVar->name)) { if (firstOne) firstOne = FALSE; else dyStringAppendC(trackHubs, ' '); dyStringAppend(trackHubs, hubVar->name + prefixLength); } } slPairFreeList(&hubVarList); cartSetString(cart, hubConnectTrackHubsVarName, trackHubs->string); dyStringFree(&trackHubs); cartRemove(cart, hgHubConnectRemakeTrackHub); } }
void doMiddle(struct cart *theCart) /* Set up pretty web display and save cart in global. */ { char *key = NULL; char *file = NULL; cart = theCart; key = cartOptionalString(cart, "key"); if (isValidKey(key)) { file = cartOptionalString(cart, "file"); if(NULL == file) { printIndexFile(); } else { printFile(file); } } else { cartWebStart(theCart, database, "SECURE CGI \n"); cartRemove(cart, "key"); printf("INVALID KEY\n"); cartWebEnd(); } }
void removeCartVars(struct cart *cart, char **vars, int varCount) /* Remove array of variables from cart. */ { int i; for (i=0; i<varCount; ++i) cartRemove(cart, vars[i]); }
void doAdvFilterKeyPasted(struct sqlConnection *conn, struct column *colList, struct column *col) /* Handle submission in key-paste in form. */ { char *pasteVarName = colVarName(col, keyWordPastedPrefix); char *pasteVal = trimSpaces(cartString(cart, pasteVarName)); char *keyVarName = advFilterName(col, "keyFile"); if (pasteVal == NULL || pasteVal[0] == 0) { /* If string is empty then clear cart variable. */ cartRemove(cart, keyVarName); } else { /* Else write variable to temp file and save temp * file name. */ struct tempName tn; FILE *f; makeTempName(&tn, "near", ".key"); f = mustOpen(tn.forCgi, "w"); mustWrite(f, pasteVal, strlen(pasteVal)); carefulClose(&f); cartSetString(cart, keyVarName, tn.forCgi); } cartRemovePrefix(cart, keyWordPastedPrefix); doAdvFilter(conn, colList); }
void doGetGreatOutput(void (*dispatch)()) { struct tempName tn; int saveStdout; FILE *f; trashDirFile(&tn, "great", cartSessionId(cart), ".bed"); f = fopen(tn.forCgi, "w"); /* We want to capture hgTables stdout output to a trash file * which will later be fetched by Great via URL. */ /* Workaround because stdout stream is not assignable on some operating systems */ fflush(stdout); saveStdout = dup(STDOUT_FILENO); dup2(fileno(f),STDOUT_FILENO); /* closes STDOUT before setting it again */ fclose(f); dispatch(); /* this writes to stdout */ /* restore stdout */ fflush(stdout); dup2(saveStdout ,STDOUT_FILENO); /* closes STDOUT before setting it back to saved descriptor */ close(saveStdout); cartRemove(cart, hgtaDoGreatOutput); htmlOpen("Table Browser integration with GREAT"); doSubmitToGreat(tn.forCgi); htmlClose(); }
void doAdvFilterKeyClear(struct sqlConnection *conn, struct column *colList, struct column *col) /* Handle upload keyword list button press in advanced filter form. */ { cartRemovePrefix(cart, keyWordClearPrefix); cartRemove(cart, advFilterName(col, "keyFile")); doAdvFilter(conn, colList); }
void doProbe(struct sqlConnection *conn) /* Put up probe info page. */ { int probeId = cartInt(cart, hgpDoProbe); int submissionSourceId = cartInt(cart, hgpSs); cartRemove(cart, hgpSs); probePage(conn, probeId, submissionSourceId); }
void doId(struct sqlConnection *conn) /* Set up Gene Pix on given ID. */ { int id = cartInt(cart, hgpDoId); struct slName *genes = visiGeneGeneName(conn, id); if (genes == NULL) { cartRemove(cart, hgpListSpec); cartRemove(cart, hgpId); } else { cartSetInt(cart, hgpId, id); cartSetString(cart, hgpListSpec, genes->name); } slFreeList(&genes); doDefault(conn, FALSE); }
char *userRegionsFileName() /* File name defined regions are in, or NULL if no such file. */ { char *fileName = cartOptionalString(cart, hgtaUserRegionsFile); char *db = cartOptionalString(cart, hgtaUserRegionsDb); if (db && !sameString(database, db)) return NULL; if (fileName == NULL) return NULL; if (fileExists(fileName)) return fileName; else { cartRemove(cart, hgtaUserRegionsFile); cartRemove(cart, hgtaRegionType); return NULL; } }
static char *checkForNew( struct cart *cart) /* see if the user just typed in a new hub url, return id if so */ { struct hubConnectStatus *hub; char *url = cartOptionalString(cart, hgHubDataClearText); if (url != NULL) disconnectHubsSamePrefix(cart, url); else url = cartOptionalString(cart, hgHubDataText); if (url == NULL) return NULL; trimSpaces(url); gNewHub = hub = getAndSetHubStatus( cart, url, TRUE); cartRemove(cart, hgHubDataClearText); cartRemove(cart, hgHubDataText); char *wantFirstDb = cartOptionalString(cart, hgHubDoFirstDb); char *newDatabase = NULL; if ((wantFirstDb != NULL) && (hub->trackHub != NULL)) newDatabase = hub->trackHub->defaultDb; else { // Check to see if the user specified an assembly within // an assembly hub. char *assemblyDb = cartOptionalString(cart, hgHubGenome); if (assemblyDb != NULL) { char buffer[512]; safef(buffer, sizeof buffer, "hub_%d_%s", hub->id, assemblyDb); newDatabase = cloneString(buffer); } } cartRemove(cart, hgHubDoFirstDb); cartRemove(cart, hgHubGenome); return newDatabase; }
boolean checkAndClear(char *cartVar) /* If cart var exists, clear it and return TRUE */ { if (cartVarExists(cart, cartVar)) { cartRemove(cart, cartVar); /* in case of errAbort */ return TRUE; } return FALSE; }
void doDefaultConfigure(struct sqlConnection *conn, struct column *colList) /* Do configuration starting with defaults. */ { struct column *col; for (col=colList; col != NULL; col = col->next) col->on = col->defaultOn; cartRemovePrefix(cart, colConfigPrefix); cartRemove(cart, colOrderVar); //restoreDefaultOrder(&colList); doConfigure(conn, colList); //, NULL); }
void hubDisconnect(struct cart *cart, char *url) /* drop the information about this url from the hubStatus table, and * the cart variable the references this hub */ { /* clear the hubStatus table */ unsigned id = hubClearStatus(url); /* remove the cart variable */ char buffer[1024]; safef(buffer, sizeof buffer, "hgHubConnect.hub.%d", id); cartRemove(cart, buffer); }
void copyCartVars(struct cart *cart, char **source, char **dest, int count) /* Copy from source to dest. */ { int i; for (i=0; i<count; ++i) { char *s = cartOptionalString(cart, source[i]); if (s != NULL) cartSetString(cart, dest[i], s); else cartRemove(cart, dest[i]); } }
static char *keyFileName(struct column *col) /* Return key file name for this column. Return * NULL if no key file. */ { char *fileName = advFilterVal(col, "keyFile"); if (fileName == NULL) return NULL; if (!fileExists(fileName)) { cartRemove(cart, advFilterName(col, "keyFile")); return NULL; } return fileName; }
char *identifierFileName() /* File name identifiers are in, or NULL if not for curTable or no such file. */ { char *fileName = cartOptionalString(cart, hgtaIdentifierFile); if (fileName == NULL) return NULL; if (! forCurTable()) return NULL; if (fileExists(fileName)) return fileName; else { cartRemove(cart, hgtaIdentifierFile); return NULL; } }
void configInitTrackList( int vis, char **pGroupTarget, struct track **pTrackList, struct track **pIdeoTrack, struct group **pGroupList ) { 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); if (trackHash == NULL) trackHash = makeGlobalTrackHash(trackList); // Subtrack settings must be removed when composite/view settings are updated parentChildCartCleanup(trackList,cart,oldVars); addDownloadOnlyTracks(database,&groupList,&trackList); /* 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); *pGroupTarget = groupTarget; *pTrackList = trackList; *pIdeoTrack = ideoTrack; *pGroupList = groupList; }
void displayData(struct sqlConnection *conn, struct column *colList) /* Display data in neighborhood of gene. */ { struct subjInfo *subjList = NULL; struct column *ordList = colList; struct column *ord = curOrder(ordList); if (ord == NULL) /* no columns are visible, go to back to configure page */ { doConfigure(conn, colList); return; } if (cartVarExists(cart, getTextVarName)) { subjList = getOrderedList(ord, colList, conn, BIGNUM); doGetText(conn, colList, subjList); } else if (cartVarExists(cart, getSeqVarName)) { subjList = getOrderedList(ord, colList, conn, BIGNUM); doGetSeq(conn, subjList, cartString(cart, getSeqHowVarName)); } else if (cartVarExists(cart, redirectName)) { subjList = getOrderedList(ord, colList, conn, BIGNUM); if (subjList) { cartRemove(cart, redirectName); } else /* if everything has been filtered out, we'll have to go back */ { hPrintf("No subject(s) found with the filtering conditions specified.<br>"); hPrintf("Click <a href=\"gisaidTable?gisaidTable.do.advFilter=filter+%c28now+on%c29\">here</a> to return to Select Subjects.<br>", '%', '%'); } } else { subjList = getOrderedList(ord, colList, conn, displayCount); doMainDisplay(conn, colList, subjList); } }
void lookupAdvFilterControls(struct column *col, struct sqlConnection *conn) /* Print out controls for advanced filter on lookup column. */ { char *fileName = advFilterVal(col, "keyFile"); hPrintf("%s search (including * and ? wildcards):", col->shortLabel); advFilterRemakeTextVar(col, "wild", 18); hPrintf("<BR>\n"); hPrintf("Include if "); advFilterAnyAllMenu(col, "logic", TRUE); hPrintf("words in search term match.<BR>"); if (!columnSetting(col, "noKeys", NULL)) { hPrintf("Limit to items (no wildcards) in list: "); advFilterKeyPasteButton(col); hPrintf(" "); advFilterKeyUploadButton(col); hPrintf(" "); if (fileName != NULL) { if (fileExists(fileName)) { int count = countQuotedWordsInFile(fileName); advFilterKeyClearButton(col); hPrintf("<BR>\n"); if (count == 1) hPrintf("(There is currently 1 item in the list.)"); else hPrintf("(There are currently %d items in the list.)", count); } else { cartRemove(cart, advFilterName(col, "keyFile")); } } } if (col->filterDropDown) showListOfFilterValues(col, conn); }
void submitUpload(struct sqlConnection *conn) /* Called when they've submitted from uploads page */ { char *urlText = cartUsualString(cart, hggUploadUrl, NULL); char *fileText = cartUsualString(cart, hggUploadFile, NULL); char *rawText = urlText; if (isNotEmpty(fileText)) rawText = fileText; int rawTextSize = strlen(rawText); struct errCatch *errCatch = errCatchNew(); cartWebStart(cart, database, "Data Upload Complete (%d bytes)", rawTextSize); hPrintf("<FORM ACTION=\"../cgi-bin/hgGenome\">"); cartSaveSession(cart); if (errCatchStart(errCatch)) trySubmitUpload(conn, rawText); errCatchFinish(&errCatch); cartRemove(cart, hggUploadFile); hPrintf("<CENTER>"); cgiMakeButton("submit", "OK"); hPrintf("</CENTER>"); hPrintf("</FORM>"); cartWebEnd(); }
void doOutSelectedFields(char *table, struct sqlConnection *conn) /* Put up select fields (for tab-separated output) page. */ { if (anySubtrackMerge(database, curTable)) errAbort("Can't do selected fields output when subtrack merge is on. " "Please go back and select another output type, or clear the subtrack merge."); else if (anyIntersection()) errAbort("Can't do selected fields output when intersection is on. " "Please go back and select another output type, or clear the intersection."); else { char *fsTable = cartOptionalString(cart, hgtaFieldSelectTable); char *dbTable = NULL; table = connectingTableForTrack(table); dbTable = getDbTable(database, table); /* Remove cart state if table has been changed: */ if (fsTable && ! sameString(fsTable, dbTable)) { cartRemovePrefix(cart, hgtaFieldSelectPrefix); cartRemove(cart, hgtaFieldSelectTable); } doBigSelectPage(database, table); } }