ba8ffb877e7fa5eb507334b772c88528b4ecadfe kate Thu Feb 11 11:52:18 2016 -0800 Finishing touches to GTEx gene details page. Added link to hgGeneand bent knownGene queries for gene description to handle both hg38 and hg19 conventions. refs #15645 diff --git src/hg/hgc/gtexClick.c src/hg/hgc/gtexClick.c index 9152616..c2aeee6 100644 --- src/hg/hgc/gtexClick.c +++ src/hg/hgc/gtexClick.c @@ -1,26 +1,27 @@ /* Details pages for GTEx tracks */ /* Copyright (C) 2015 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "hash.h" #include "hdb.h" #include "hvGfx.h" #include "trashDir.h" #include "hgc.h" +#include "hCommon.h" #include "gtexGeneBed.h" #include "gtexTissue.h" #include "gtexSampleData.h" #include "gtexUi.h" #include "gtexInfo.h" struct tissueSampleVals /* RPKM expression values for multiple samples */ { struct tissueSampleVals *next; char *name; /* GTEx tissue name */ char *description; /* GTEx tissue description */ int color; /* GTEx tissue color */ int count; /* number of samples */ @@ -161,51 +162,71 @@ val = slPopHead(&tsv->valList); if (doLogTransform) vals[i] = log10(val->val+1.0); else vals[i] = val->val; } doubleBoxWhiskerCalc(tsv->count, tsv->vals, &tsv->min, &tsv->q1, &tsv->median, &tsv->q3, &tsv->max); slAddHead(&tsList, tsv); } if (maxValRet != NULL) *maxValRet = maxVal; return tsList; } +char *getGeneDescription(struct gtexGeneBed *gtexGene) +/* Get description for gene. Needed because knownGene table semantics have changed in hg38 */ +{ +char query[256]; +if (sameString(database, "hg38")) + { + char *geneId = cloneString(gtexGene->geneId); + chopSuffix(geneId); + sqlSafef(query, sizeof(query), + "select kgXref.description from kgXref, knownCanonical where knownCanonical.protein like '%%%s%%' and knownCanonical.transcript=kgXref.kgID", geneId); + } +else + { + sqlSafef(query, sizeof(query), + "select kgXref.description from kgXref where geneSymbol='%s'", gtexGene->name); + } +struct sqlConnection *conn = hAllocConn(database); +char *desc = sqlQuickString(conn, query); +hFreeConn(&conn); +return desc; +} + void doGtexGeneExpr(struct trackDb *tdb, char *item) /* Details of GTEx gene expression item */ { struct gtexGeneBed *gtexGene = getGtexGene(item, tdb->table); if (gtexGene == NULL) errAbort("Can't find gene %s in GTEx gene table %s\n", item, tdb->table); genericHeader(tdb, item); // TODO: link to UCSC gene -printf("Gene: %s
", gtexGene->name); -char query[256]; -char *transcriptId = cloneString(gtexGene->transcriptId); -chopSuffix(transcriptId); -sqlSafef(query, sizeof(query), - "select kgXref.description from kgXref, knownToEnsembl where knownToEnsembl.value like '%%%s%%' and knownToEnsembl.name=kgXref.kgID", transcriptId); -struct sqlConnection *conn = hAllocConn(database); -char *desc = sqlQuickString(conn, query); -hFreeConn(&conn); +printf("Gene: %s
", + hgGeneName(), database, gtexGene->name, gtexGene->name); +char *desc = getGeneDescription(gtexGene); if (desc != NULL) printf("Description: %s
\n", desc); printf("Ensembl Gene ID: %s
\n", gtexGene->geneId); -printf("Ensembl Transcript ID: %s
\n", transcriptId); +printf("Ensembl Transcript ID: %s
\n", gtexGene->transcriptId); +printf("Genomic Position: %s:%d-%d
", + hgTracksPathAndSettings(), database, + gtexGene->chrom, gtexGene->chromStart+1, gtexGene->chromEnd, + gtexGene->chrom, gtexGene->chromStart+1, gtexGene->chromEnd); printf("View at GTEx portal
\n", gtexGene->geneId); puts("

"); boolean doLogTransform = cartUsualBooleanClosestToHome(cart, tdb, FALSE, GTEX_LOG_TRANSFORM, GTEX_LOG_TRANSFORM_DEFAULT); double maxVal = 0.0; char *versionSuffix = gtexVersionSuffix(tdb->table); struct tissueSampleVals *tsvs = getTissueSampleVals(gtexGene, doLogTransform, versionSuffix, &maxVal); char *version = gtexVersion(tdb->table); drawGtexRBoxplot(gtexGene, tsvs, doLogTransform, version); printTrackHtml(tdb); }