cc5381e539ecba5b07109b194acf1d76b0c8f641 braney Thu Jul 23 06:22:48 2026 -0700 Guard hDbForTaxon() callers against curated hub (GenArk) db names. hDbForTaxon() can now return a GenArk-only assembly with no real SQL database, which would abort in sqlConnect()/"use "/cross-db sqlTableExists(). Treat a hubConnectIsCurated() db as no usable native db in uniProtAccToDb(), bacProbeInfo(), and getKnownGeneUrl(). refs #37909 diff --git src/hg/visiGene/hgVisiGene/probePage.c src/hg/visiGene/hgVisiGene/probePage.c index 6c132367289..906608f8af4 100644 --- src/hg/visiGene/hgVisiGene/probePage.c +++ src/hg/visiGene/hgVisiGene/probePage.c @@ -1,224 +1,231 @@ /* probePage - put up page of info on probe. */ /* Copyright (C) 2013 The Regents of the University of California * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */ #include "common.h" #include "hash.h" #include "dystring.h" #include "jksql.h" #include "cart.h" #include "htmshell.h" #include "dnautil.h" #include "web.h" #include "hdb.h" +#include "hubConnect.h" #include "visiGene.h" #include "hgVisiGene.h" #include "probePage.h" static char *orgName(struct sqlConnection *conn, int taxon) /* Return organism name associated with taxon. */ { char *binomial; char query[256]; sqlSafef(query, sizeof(query), "select binomial from uniProt.taxon where id=%d", taxon); binomial = sqlQuickString(conn, query); return shortOrgName(binomial); } static void labeledText(char *label, char *text) /* Print out labeled text */ { printf("%s: %s ", label, naForEmpty(text)); } static void labeledResult(char *label, struct sqlConnection *conn, char *query) /* Put up labeled query result. */ { labeledText(label, sqlQuickString(conn, query)); } static void rnaProbeInfo(struct sqlConnection *conn, int probeId) /* Print out info on RNA/DNA based probe */ { char query[256]; char *seq; printf("
\n"); sqlSafef(query, sizeof(query), "select fPrimer from probe where id=%d", probeId); labeledResult("forward primer", conn, query); printf("
\n"); sqlSafef(query, sizeof(query), "select rPrimer from probe where id=%d", probeId); labeledResult("reverse primer", conn, query); printf("
\n"); sqlSafef(query, sizeof(query), "select seq from probe where id=%d", probeId); seq = naForEmpty(sqlQuickString(conn, query)); printf("
sequence:\n"); if (sameWord(seq, "n/a")) printf("%s
", seq); else { printf("
");
     writeSeqWithBreaks(stdout, seq, strlen(seq), 60);
     printf("
"); } } static void bacProbeInfo(struct sqlConnection *conn, int probeId, int taxon) /* Print out information about BAC probe. */ { char query[256]; int bacId; char *name = NULL; char *genomeDb = hDbForTaxon(taxon); boolean gotMapping = FALSE; +/* hDbForTaxon may return a curated hub (GenArk) assembly with no real SQL + * database; genomeDb is passed to sqlConnect() below, which would abort on a + * hub db name. Treat it as no usable native db. */ +if (genomeDb != NULL && hubConnectIsCurated(genomeDb)) + genomeDb = NULL; + /* Start new line. */ printf("
\n"); /* Lookup bacId and print name associated with it. */ sqlSafef(query, sizeof(query), "select bac from probe where id=%d", probeId); bacId = sqlQuickNum(conn, query); if (bacId != 0) { sqlSafef(query, sizeof(query), "select name from bac where id=%d", bacId); name = sqlQuickString(conn, query); } /* Find where bac lands in genome and print hyperlink to genome browser. */ if (genomeDb != NULL && name != NULL && name[0] != 0) { struct sqlConnection *gConn = sqlConnect(genomeDb); if (sqlTableExists(gConn, "bacEndPairs")) { char query[256]; int count; sqlSafef(query, sizeof(query), "select count(*) from bacEndPairs where name = '%s'", name); count = sqlQuickNum(gConn, query); if (count > 0) gotMapping = TRUE; } sqlDisconnect(&gConn); } /* Print out BAC name, hyperlinked to genome browser if possible. */ printf("BAC name: "); if (gotMapping) { printf(""); } printf("%s", naForEmpty(name)); if (gotMapping) printf(""); } static void antibodyProbeInfo(struct sqlConnection *conn, int probeId, int submissionSourceId) /* Print out info on antibody based probe */ { char query[256]; int abId; int taxon; char *species = "n/a"; char *abUrl = NULL; /* Lookup antibody id and taxon. */ sqlSafef(query, sizeof(query), "select antibody from probe where id=%d", probeId); abId = sqlQuickNum(conn, query); sqlSafef(query, sizeof(query), "select taxon from antibody where id=%d", abId); taxon = sqlQuickNum(conn, query); sqlSafef(query, sizeof(query), "select name from antibody where id=%d", abId); labeledResult("name", conn, query); if (taxon != 0) species = orgName(conn, taxon); labeledText("species", species); printf("
\n"); sqlSafef(query, sizeof(query), "select description from antibody where id=%d", abId); labeledResult("description", conn, query); printf("
\n"); sqlSafef(query, sizeof(query), "select abUrl from submissionSource where id=%d", submissionSourceId); abUrl = sqlQuickString(conn, query); if (abUrl != NULL && abUrl[0] != 0) { char *abSubmitId = NULL; sqlSafef(query, sizeof(query), "select abSubmitId from antibodySource" " where antibody=%d and submissionSource=%d", abId, submissionSourceId); abSubmitId = sqlQuickString(conn, query); if (abSubmitId != NULL && abSubmitId[0] != 0) { printf("source: "); printf("%s ", "MGI"); freez(&abSubmitId); } } freez(&abUrl); } void probePage(struct sqlConnection *conn, int probeId, int submissionSourceId) /* Put up a page of info on probe. */ { char query[256]; int geneId, taxon; char *probeType; webStartWrapperDetailedNoArgs(cart, NULL, "", "Probe Information", FALSE, FALSE, FALSE, TRUE); /* Get gene ID. */ sqlSafef(query, sizeof(query), "select gene from probe where id=%d", probeId); geneId = sqlQuickNum(conn, query); /* Print gene symbol. */ sqlSafef(query, sizeof(query), "select name from gene where id=%d", geneId); labeledResult("gene symbol", conn, query); /* Print organism. */ sqlSafef(query, sizeof(query), "select taxon from gene where id=%d", geneId); taxon = sqlQuickNum(conn, query); labeledText("organism", orgName(conn, taxon)); /* Print synonyms if any. */ sqlSafef(query, sizeof(query), "select name from geneSynonym where gene=%d", geneId); printf("synonyms: %s
\n", makeCommaSpacedList(sqlQuickList(conn, query))); /* Print refSeq, genbank, uniProt */ sqlSafef(query, sizeof(query), "select refSeq from gene where id=%d", geneId); labeledResult("RefSeq", conn, query); sqlSafef(query, sizeof(query), "select genbank from gene where id=%d", geneId); labeledResult("GenBank", conn, query); sqlSafef(query, sizeof(query), "select uniProt from gene where id=%d", geneId); labeledResult("UniProt", conn, query); /* Now print probe information. */ sqlSafef(query, sizeof(query), "select probeType.name from probe,probeType " "where probe.id = %d and probe.probeType = probeType.id" , probeId); probeType = sqlQuickString(conn, query); labeledText("probe type", probeType); if (sameWord(probeType, "antibody")) antibodyProbeInfo(conn, probeId, submissionSourceId); else if (sameWord(probeType, "BAC")) bacProbeInfo(conn, probeId, taxon); else rnaProbeInfo(conn, probeId); webEnd(); }