3116bfb1702fdd6bae75aae1d1f78364adfe12a7
braney
Fri Apr 24 14:21:48 2015 -0700
cahnges to browser to support Gencode KnownGene #14639
diff --git src/hg/hgGene/hgGene.c src/hg/hgGene/hgGene.c
index 6898014..958820f 100644
--- src/hg/hgGene/hgGene.c
+++ src/hg/hgGene/hgGene.c
@@ -20,30 +20,31 @@
#include "spDb.h"
#include "genePred.h"
#include "hgColors.h"
#include "hgGene.h"
#include "obscure.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;
struct genePred *curGenePred; /* Current gene prediction structure. */
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 */
//#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"
@@ -232,44 +233,47 @@
if (genomeOptionalSetting("summaryIdSql"))
{
char *summaryId = genoQuery(id, "summaryIdSql", conn);
if (summaryId != NULL)
dyStringPrintf(description, " (%s)", summaryId);
}
dyStringPrintf(description, ": %s", summary);
freez(&summary);
dyStringPrintf(description, "
\n");
}
}
}
return dyStringCannibalize(&description);
}
-static void printDescription(char *id, struct sqlConnection *conn)
+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)
+ hPrintf("Gencode Transcript: %s
\n", curAlignId);
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 ",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;
cdsEnd = curGenePred->cdsEnd;
/* count CDS exons */
@@ -500,34 +504,34 @@
section->print(section, conn, geneId);
}
else
{
printf("Press \"+\" in the title bar above to open this section.");
}
dyStringFree(&header);
}
}
void webMain(struct sqlConnection *conn)
/* Set up fancy web page with hotlinks bar and
* sections. */
{
struct section *sectionList = NULL;
-printDescription(curGeneId, conn);
+struct trackDb *tdb = hTrackDbForTrack(database, genomeSetting("knownGene"));
+printDescription(curGeneId, conn, tdb);
sectionList = loadSectionList(conn);
printIndex(sectionList);
-struct trackDb *tdb = hTrackDbForTrack(database, genomeSetting("knownGene"));
printUpdateTime(database, tdb, NULL);
printSections(sectionList, conn, curGeneId);
}
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];
sqlSafef(query, sizeof(query), "select count(*) from %s where name = '%s'", mainTable, name);
if (sqlQuickNum(conn, query) > 0)
return name;
else
@@ -600,31 +604,34 @@
{
char *track = genomeSetting("knownGene");
char table[64];
boolean hasBin;
char query[256];
struct sqlResult *sr;
char **row;
struct genePred *gp = NULL;
hFindSplitTable(sqlGetDatabase(conn), curGeneChrom, track, table, &hasBin);
sqlSafef(query, sizeof(query),
"select * from %s where name = '%s' "
"and chrom = '%s' and txStart=%d and txEnd=%d"
, table, curGeneId, curGeneChrom, curGeneStart, curGeneEnd);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
+ {
gp = genePredLoad(row + hasBin);
+ curAlignId = cloneString(row[11]);
+ }
sqlFreeResult(&sr);
if (gp == NULL)
errAbort("getCurGenePred: Can't find %s", query);
return gp;
}
void doKgMethod()
/* display knownGene.html content (UCSC Known Genes
* Method, Credits, and Data Use Restrictions) */
{
cartWebStart(cart, database, "Methods, Credits, and Use Restrictions");
struct trackDb *tdb = hTrackDbForTrack(database, genomeSetting("knownGene"));
hPrintf("%s", tdb->html);
cartWebEnd();
}