5c5df1a7446ad3368896deba413360935c334188
kate
  Wed Feb 10 13:12:47 2016 -0800
Support for multiple GTEx releases/versions (to add V6 track). refs #15645

diff --git src/hg/lib/gtexInfo.c src/hg/lib/gtexInfo.c
index 8715d7b..e307845 100644
--- src/hg/lib/gtexInfo.c
+++ src/hg/lib/gtexInfo.c
@@ -1,24 +1,25 @@
 /* gtexInfo.c was originally generated by the autoSql program, which also 
  * generated gtexInfo.h and gtexInfo.sql.  This module links the database and
  * the RAM representation of objects. */
 
 #include "common.h"
 #include "linefile.h"
 #include "dystring.h"
 #include "jksql.h"
 #include "gtexInfo.h"
+#include "gtexGeneBed.h"
 
 
 
 char *gtexInfoCommaSepFieldNames = "version,releaseDate,maxScore,maxMedianScore";
 
 void gtexInfoStaticLoad(char **row, struct gtexInfo *ret)
 /* Load a row from gtexInfo table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->version = row[0];
 ret->releaseDate = row[1];
 ret->maxScore = sqlDouble(row[2]);
 ret->maxMedianScore = sqlDouble(row[3]);
 }
@@ -184,23 +185,33 @@
 "    maxMedianScore double not null,	# Maximum score observed for a tissue median (use to scale display)\n"
 "        #Indices\n"
 "    PRIMARY KEY(version)\n"
 ")\n",   table);
 sqlRemakeTable(conn, table, query);
 }
 
 double gtexMaxMedianScore(char *version)
 /* Retrieve max median score for latest (or named) version */
 {
 char query[1024];
 struct sqlConnection *conn = hAllocConn("hgFixed");
 if (!conn)
     return 0;
 // TODO: trackDB setting for this
-if (!version)
+if (!version || sameString(version, ""))
     version = "V4";
 sqlSafef(query, sizeof query, "select maxMedianScore from gtexInfo where version='%s'", version);
 double score = sqlQuickDouble(conn, query);
+if (score == 0.0)
+    errAbort("Internal error: GTEx version \"%s\" not found in gtexInfo table", version);
 hFreeConn(&conn);
 return score;
 }
 
+char *gtexVersion(char *table)
+/* Return version string based on table suffix */
+{
+char *suffix = gtexVersionSuffix(table);
+// Currently the V4 tables have no suffix
+return (sameString(suffix, "")) ? "V4" : suffix;
+}
+