a2d849d0acd9e8921d1ff131d907ca867c858d11 braney Thu Jul 19 10:47:57 2018 -0700 changes to support new new Gencode models in hgGene diff --git src/hg/hgGene/hgGene.c src/hg/hgGene/hgGene.c index 97406c4..3f28fd6 100644 --- src/hg/hgGene/hgGene.c +++ src/hg/hgGene/hgGene.c @@ -21,32 +21,34 @@ #include "genePred.h" #include "hgColors.h" #include "hgGene.h" #include "obscure.h" #include "genbank.h" /* ---- Global variables. ---- */ struct cart *cart; /* This holds cgi and other variables between clicks. */ struct hash *oldVars; /* Old cart hash. */ char *database; /* Name of genome database - hg15, mm3, or the like. */ char *genome; /* Name of genome - mouse, human, etc. */ char *curGeneId; /* Current Gene Id. */ char *curGeneName; /* Biological name of gene. */ char *curGeneChrom; /* Chromosome current gene is on. */ -char *curAlignId; +char *curAlignId; /* Align id from knownGene genePred */ struct genePred *curGenePred; /* Current gene prediction structure. */ +boolean isGencode; /* is this based on the Gencode models */ +boolean isGencode2; /* is this based on the Gencode models and use ensembl id as primary id */ int curGeneStart,curGeneEnd; /* Position in chromosome. */ struct sqlConnection *spConn; /* Connection to SwissProt database. */ char *swissProtAcc; /* SwissProt accession (may be NULL). */ int kgVersion = KG_UNKNOWN; /* KG version */ int measureTiming = FALSE; //#include "rgdInfo.c" void usage() /* Explain usage and exit. */ { errAbort( "hgGene - A CGI script to display the gene details page.\n" "usage:\n" " hgGene cgi-vars in var=val format\n" @@ -255,35 +257,34 @@ } static void printDescription(char *id, struct sqlConnection *conn, struct trackDb *tdb) /* Print out description of gene given ID. */ { char *description = descriptionString(id, conn); int i, exonCnt = 0, cdsExonCnt = 0; int cdsStart, cdsEnd; hPrintf("%s", description); freez(&description); /* print genome position and size */ char buffer[1024]; char *commaPos; -char *isGencode = trackDbSetting(tdb, "isGencode"); -if (isGencode) +if (isGencode || isGencode2) { - hPrintf("Gencode Transcript: %s
\n", curAlignId); + hPrintf("Gencode Transcript: %s
\n", isGencode2 ? curGeneId : curAlignId);; char buffer[1024]; hPrintf("Gencode Gene: %s
\n", getGencodeGeneId(conn, curGeneId, buffer, sizeof buffer)); } exonCnt = curGenePred->exonCount; safef(buffer, sizeof buffer, "%s:%d-%d", curGeneChrom, curGeneStart+1, curGeneEnd); commaPos = addCommasToPos(database, buffer); hPrintf("Transcript (Including UTRs)
\n"); hPrintf("   Position: %s %s ",database, commaPos); sprintLongWithCommas(buffer, (long long)curGeneEnd - curGeneStart); hPrintf("Size: %s ", buffer); hPrintf("Total Exon Count: %d ", exonCnt); hPrintf("Strand: %s
\n",curGenePred->strand); cdsStart = curGenePred->cdsStart; @@ -549,36 +550,35 @@ struct section *section; int total = 0; printf("

section, check time, print time, total
\n"); for (section = sectionList; section != NULL; section = section->next) { boolean isOpen = sectionIsOpen(section); int sectionTime = section->checkTime + section->printTime; printf("%s, %d, %d, %d %s
\n", section->shortLabel, section->checkTime, section->printTime, sectionTime, isOpen ? "" : "closed"); total += sectionTime; } printf("total = %d\n", total); printf("

"); } -void webMain(struct sqlConnection *conn) +void webMain(struct sqlConnection *conn, struct trackDb *tdb) /* Set up fancy web page with hotlinks bar and * sections. */ { struct section *sectionList = NULL; -struct trackDb *tdb = hTrackDbForTrack(database, genomeSetting("knownGene")); printDescription(curGeneId, conn, tdb); sectionList = loadSectionList(conn); printIndex(sectionList); printUpdateTime(database, tdb, NULL); printSections(sectionList, conn, curGeneId); printTiming(sectionList); } static char *findGeneId(struct sqlConnection *conn, char *name) /* Given some sort of gene name, see if it is in our primary gene table, and if not * look it up in alias table if we have one. */ { /* Just check if it's in the main gene table, and if so return input name. */ char *mainTable = genomeSetting("knownGene"); char query[256]; @@ -734,33 +734,36 @@ doGetMrnaSeq(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoWikiTrack)) doWikiTrack(conn); else if (cartVarExists(cart, hggDoGetProteinSeq)) doGetProteinSeq(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoRnaFoldDisplay)) doRnaFoldDisplay(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoOtherProteinSeq)) doOtherProteinSeq(conn, curGeneName); else if (cartVarExists(cart, hggDoOtherProteinAli)) doOtherProteinAli(conn, curGeneId, curGeneName); else { /* Default case - start fancy web page. */ measureTiming = isNotEmpty(cartOptionalString(cart, "measureTiming")); + struct trackDb *tdb = hTrackDbForTrack(database, genomeSetting("knownGene")); + isGencode = trackDbSettingOn(tdb, "isGencode"); + isGencode2 = trackDbSettingOn(tdb, "isGencode2"); cartWebStart(cart, database, "%s Gene %s (%s) Description and Page Index", - genome, curGeneName, curAlignId); - webMain(conn); + genome, curGeneName, isGencode2 ? curGeneId : curAlignId); + webMain(conn, tdb); cartWebEnd(); } hFreeConn(&spConn); hFreeConn(&conn); } cartRemovePrefix(cart, hggDoPrefix); } char *excludeVars[] = {"Submit", "submit", "ajax", hggAjaxSection, NULL}; int main(int argc, char *argv[]) /* Process command line. */ { long enteredMainTime = clock1000(); cgiSpoof(&argc, argv);