7def57860cd7a395af34b06ff0fe04e32a7f3e97 markd Thu Feb 25 13:58:01 2021 -0800 don't attempt to connect to database for blat results from user input, including hubs diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c index 0be5bb97..51e209c 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -7607,57 +7607,48 @@ printf("RNA sequence not found: '%s'", acc); } else { if (startsWith("xeno", aliTable)) showSomeAlignment(psl, rnaSeq, gftDnaX, 0, rnaSeq->size, NULL, cdsStart, cdsEnd); else showSomeAlignment(psl, rnaSeq, gftDna, 0, rnaSeq->size, NULL, cdsStart, cdsEnd); } hFreeConn(&conn); } void htcCdnaAliInWindow(char *acc) /* Show part of alignment in browser window for accession. */ { -char query[256]; -char table[64]; -struct sqlConnection *conn; -struct sqlResult *sr; -char **row; struct psl *wholePsl, *partPsl; struct dnaSeq *rnaSeq; char *aliTable; int start; unsigned int cdsStart = 0, cdsEnd = 0; -boolean hasBin; char accChopped[512] ; safef(accChopped, sizeof(accChopped), "%s",acc); chopSuffix(accChopped); /* Get some environment vars. */ aliTable = cartString(cart, "aliTable"); start = cartInt(cart, "o"); char *accForTitle = startsWith("ncbiRefSeq", aliTable) ? acc : accChopped; char title[1024]; safef(title, sizeof title, "%s vs Genomic [%s]", accForTitle, aliTable); htmlFramesetStart(title); -conn = hAllocConn(database); -getCdsStartAndStop(conn, acc, aliTable, &cdsStart, &cdsEnd); - if (startsWith("user", aliTable)) { char *pslName, *faName, *qName; struct lineFile *lf; bioSeq *oSeqList = NULL, *oSeq = NULL; struct psl *psl; int start; enum gfType tt, qt; boolean isProt; char *ss = cartOptionalString(cart, "ss"); if ((ss != NULL) && !ssFilesExist(ss)) { ss = NULL; cartRemove(cart, "ss"); @@ -7693,78 +7684,85 @@ errAbort("Couldn't find alignment at %s:%d", seqName, start); oSeqList = faReadAllSeq(faName, !isProt); for (oSeq = oSeqList; oSeq != NULL; oSeq = oSeq->next) { if (sameString(oSeq->name, qName)) break; } if (oSeq == NULL) errAbort("%s is in %s but not in %s. Internal error.", qName, pslName, faName); wholePsl = psl; rnaSeq = oSeq; } else { /* Look up alignments in database */ + struct sqlConnection *conn = hAllocConn(database); + getCdsStartAndStop(conn, acc, aliTable, &cdsStart, &cdsEnd); + + char table[64]; + boolean hasBin; if (!hFindSplitTable(database, seqName, aliTable, table, sizeof table, &hasBin)) errAbort("aliTable %s not found", aliTable); + char query[256]; sqlSafef(query, sizeof(query), "select * from %s where qName = '%s' and tName=\"%s\" and tStart=%d", table, acc, seqName, start); - sr = sqlGetResult(conn, query); + struct sqlResult *sr = sqlGetResult(conn, query); + char **row; if ((row = sqlNextRow(sr)) == NULL) errAbort("Couldn't find alignment for %s at %d", acc, start); wholePsl = pslLoad(row+hasBin); sqlFreeResult(&sr); if (startsWith("ucscRetroAli", aliTable) || startsWith("retroMrnaAli", aliTable) || sameString("pseudoMrna", aliTable) || startsWith("altSeqLiftOverPsl", aliTable) || startsWith("fixSeqLiftOverPsl", aliTable) || startsWith("ncbiRefSeqPsl", aliTable)) { rnaSeq = getBaseColorSequence(acc, aliTable); } else if (sameString("HInvGeneMrna", aliTable)) { /* get RNA accession for the gene id in the alignment */ sqlSafef(query, sizeof(query), "select mrnaAcc from HInv where geneId='%s'", acc); rnaSeq = hRnaSeq(database, sqlQuickString(conn, query)); } else { char *cdnaTable = NULL; struct trackDb *tdb = hashFindVal(trackHash, aliTable); if (tdb != NULL) cdnaTable = trackDbSetting(tdb, "cdnaTable"); if (isNotEmpty(cdnaTable) && hTableExists(database, cdnaTable)) rnaSeq = hGenBankGetMrna(database, acc, cdnaTable); else rnaSeq = hRnaSeq(database, acc); } + hFreeConn(&conn); } /* Get partial psl for part of alignment in browser window: */ if (wholePsl->tStart >= winStart && wholePsl->tEnd <= winEnd) partPsl = wholePsl; else partPsl = pslTrimToTargetRange(wholePsl, winStart, winEnd); if (startsWith("xeno", aliTable)) errAbort("htcCdnaAliInWindow does not support translated alignments."); else showSomePartialDnaAlignment(partPsl, wholePsl, rnaSeq, NULL, cdsStart, cdsEnd); -hFreeConn(&conn); } void htcChainAli(char *item) /* Draw detailed alignment representation of a chain. */ { struct chain *chain; struct psl *fatPsl, *psl = NULL; int id = atoi(item); char *track = cartString(cart, "o"); char *type = trackTypeInfo(track); char *typeWords[2]; char *otherDb = NULL, *org = NULL, *otherOrg = NULL; struct dnaSeq *qSeq = NULL; char name[128];