feeb6019339b80b90124476e6303e8dffb0f5f0b markd Sat Oct 29 14:59:04 2022 -0700 Compute versione table names rather then get them from trackDb. I have no idea why I did it this way, but it causes problems because a table was missing diff --git src/hg/hgc/gencodeClick.c src/hg/hgc/gencodeClick.c index 10e02c5..948f754 100644 --- src/hg/hgc/gencodeClick.c +++ src/hg/hgc/gencodeClick.c @@ -58,47 +58,49 @@ static char *apprisHomeUrl = "https://appris.bioinfo.cnio.es/#/"; static char *apprisGeneUrl = "https://appris.bioinfo.cnio.es/#/database/id/%s/%s?sc=ensembl"; static char* UNKNOWN = "unknown"; static char *getBaseAcc(char *acc, char *accBuf, int accBufSize) /* get the accession with version number dropped. */ { safecpy(accBuf, accBufSize, acc); char *dot = strchr(accBuf, '.'); if (dot != NULL) *dot = '\0'; return accBuf; } -static bool haveGencodeTable(struct trackDb *tdb, char *tableBase) -/* determine if table is in settings and thus in this gencode release */ +static char* getGencodeVersion(struct trackDb *tdb) +/* get the GENCODE version */ { -return trackDbSetting(tdb, tableBase) != NULL; +return trackDbRequiredSetting(tdb, "wgEncodeGencodeVersion"); } static char *getGencodeTable(struct trackDb *tdb, char *tableBase) -/* get a table name from the settings. */ +/* Return the table name with the version attached. This just leaks the memory + * and lets exit() clean up. It is tiny */ { -return trackDbRequiredSetting(tdb, tableBase); +char table[64]; +safef(table, sizeof(table), "%sV%s", tableBase, getGencodeVersion(tdb)); +return cloneString(table); } -static char* getGencodeVersion(struct trackDb *tdb) -/* get the GENCODE version or NULL for < V7, which is not supported - * by this module. */ +static bool haveGencodeTable(struct sqlConnection *conn, struct trackDb *tdb, char *tableBase) +/* determine if a gencode table exists; it might be option or not in older releases */ { -return trackDbSetting(tdb, "wgEncodeGencodeVersion"); +return sqlTableExists(conn, getGencodeTable(tdb, tableBase)); } static boolean isGrcH37Native(struct trackDb *tdb) /* Is this GENCODE GRCh37 native build, which requires a different Ensembl site. */ { // check for non-lifted GENCODE on GRCh37/hg19 if (sameString(database, "hg19")) return stringIn("lift37", getGencodeVersion(tdb)) == NULL; else return FALSE; } static boolean isFakeGeneSymbol(char* sym) /* is this a static gene symbol? */ { @@ -830,46 +832,46 @@ printf(""); } printf("\n"); rowCnt++; } printf("\n"); } static void doGencodeGeneTrack(struct trackDb *tdb, char *gencodeId, struct sqlConnection *conn, struct genePred *transAnno) /* Process click on a GENCODE gene annotation track. */ { struct wgEncodeGencodeAttrs *transAttrs = transAttrsLoad(tdb, conn, gencodeId); char *gencodeGeneId = transAttrs->geneId; struct wgEncodeGencodeGeneSource *geneSource = metaDataLoad(tdb, conn, gencodeGeneId, "wgEncodeGencodeGeneSource", "geneId", sqlQuerySingle, (sqlLoadFunc)wgEncodeGencodeGeneSourceLoad); struct wgEncodeGencodeTranscriptSource *transcriptSource = metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodeTranscriptSource", "transcriptId", sqlQuerySingle, (sqlLoadFunc)wgEncodeGencodeTranscriptSourceLoad); -bool haveRemarks = haveGencodeTable(tdb, "wgEncodeGencodeAnnotationRemark"); +bool haveRemarks = haveGencodeTable(conn, tdb, "wgEncodeGencodeAnnotationRemark"); struct wgEncodeGencodeAnnotationRemark *remarks = haveRemarks ? metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodeAnnotationRemark", "transcriptId", 0, (sqlLoadFunc)wgEncodeGencodeAnnotationRemarkLoad) : NULL; struct wgEncodeGencodePdb *pdbs = metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodePdb", "transcriptId", sqlQueryMulti, (sqlLoadFunc)wgEncodeGencodePdbLoad); struct wgEncodeGencodePubMed *pubMeds = metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodePubMed", "transcriptId", sqlQueryMulti, (sqlLoadFunc)wgEncodeGencodePubMedLoad); -bool haveEntrezGene = haveGencodeTable(tdb, "wgEncodeGencodeEntrezGene"); +bool haveEntrezGene = haveGencodeTable(conn, tdb, "wgEncodeGencodeEntrezGene"); struct wgEncodeGencodeEntrezGene *entrezGenes = haveEntrezGene ? metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodeEntrezGene", "transcriptId", sqlQueryMulti, (sqlLoadFunc)wgEncodeGencodeEntrezGeneLoad) : NULL; struct wgEncodeGencodeRefSeq *refSeqs = metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodeRefSeq", "transcriptId", sqlQueryMulti, (sqlLoadFunc)wgEncodeGencodeRefSeqLoad); struct wgEncodeGencodeTag *tags = metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodeTag", "transcriptId", sqlQueryMulti, (sqlLoadFunc)wgEncodeGencodeTagLoad); struct wgEncodeGencodeTranscriptSupport *transcriptSupports = metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodeTranscriptSupport", "transcriptId", sqlQueryMulti, (sqlLoadFunc)wgEncodeGencodeTranscriptSupportLoad); struct wgEncodeGencodeExonSupport *exonSupports = NULL; // exonSupports not available in back mapped GENCODE releases -if (haveGencodeTable(tdb, "wgEncodeGencodeExonSupport")) +if (haveGencodeTable(conn, tdb, "wgEncodeGencodeExonSupport")) exonSupports = metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodeExonSupport", "transcriptId", sqlQueryMulti, (sqlLoadFunc)wgEncodeGencodeExonSupportLoad); struct wgEncodeGencodeUniProt *uniProts = metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodeUniProt", "transcriptId", sqlQueryMulti, (sqlLoadFunc)wgEncodeGencodeUniProtLoad); slSort(&uniProts, uniProtDatasetCmp); -bool haveTsl = haveGencodeTable(tdb, "wgEncodeGencodeTranscriptionSupportLevel"); +bool haveTsl = haveGencodeTable(conn, tdb, "wgEncodeGencodeTranscriptionSupportLevel"); struct wgEncodeGencodeTranscriptionSupportLevel *tsl = haveTsl ? metaDataLoad(tdb, conn, gencodeId, "wgEncodeGencodeTranscriptionSupportLevel", "transcriptId", 0, (sqlLoadFunc)wgEncodeGencodeTranscriptionSupportLevelLoad) : NULL; int geneChromStart, geneChromEnd; getGeneBounds(tdb, conn, transAnno, &geneChromStart, &geneChromEnd); char title[256]; safef(title, sizeof(title), "GENCODE V%s Transcript Annotation", getGencodeVersion(tdb)); char header[256]; safef(header, sizeof(header), "%s %s", title, gencodeId); if (!isEmpty(transAttrs->geneName)) safef(header, sizeof(header), "%s %s (%s)", title, gencodeId, transAttrs->geneName); else safef(header, sizeof(header), "%s %s", title, gencodeId); cartWebStart(cart, database, "%s", header); printf("

%s

\n", header); @@ -944,17 +946,17 @@ else errAbort("doGencodeGene: track not handled: \"%s\"", tdb->track); htmlHorizontalLine(); printTrackHtml(tdb); genePredFreeList(&anno); hFreeConn(&conn); } bool isNewGencodeGene(struct trackDb *tdb) /* is this a new-style gencode (>= V7) track, as indicated by * the presence of the wgEncodeGencodeVersion setting */ { -return getGencodeVersion(tdb) != NULL; +return trackDbSetting(tdb, "wgEncodeGencodeVersion") != NULL; }