41861d25a94c0578853ae4280d195d7d8ca2fcb4 kate Mon Mar 21 17:17:46 2016 -0700 Add version awareness to tissue handling. refs #15645 diff --git src/hg/lib/gtexTissue.c src/hg/lib/gtexTissue.c index 7e9afd2..fa38829 100644 --- src/hg/lib/gtexTissue.c +++ src/hg/lib/gtexTissue.c @@ -1,24 +1,25 @@ /* gtexTissue.c was originally generated by the autoSql program, which also * generated gtexTissue.h and gtexTissue.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 "hdb.h" +#include "gtexInfo.h" #include "gtexTissue.h" char *gtexTissueCommaSepFieldNames = "id,name,description,organ,color"; void gtexTissueStaticLoad(char **row, struct gtexTissue *ret) /* Load a row from gtexTissue table into ret. The contents of ret will * be replaced at the next call to this function. */ { ret->id = sqlUnsigned(row[0]); ret->name = row[1]; ret->description = row[2]; ret->organ = row[3]; @@ -184,49 +185,51 @@ char query[1024]; sqlSafef(query, sizeof(query), "CREATE TABLE %s (\n" " id int unsigned not null, # internal id\n" " name varchar(255) not null, # short UCSC identifier\n" " description varchar(255) not null, # GTEx tissue type detail\n" " organ varchar(255) not null, # GTEx tissue collection area\n" " color int unsigned not null, # GTEx assigned color\n" " #Indices\n" " PRIMARY KEY(id)\n" ")\n", table); sqlRemakeTable(conn, table, query); } -struct gtexTissue *gtexGetTissues() +struct gtexTissue *gtexGetTissues(char *version) /* Get tissue id, descriptions, colors, etc. */ { char query[1024]; struct sqlConnection *conn = hAllocConn("hgFixed"); -sqlSafef(query, sizeof(query), "select * from gtexTissue order by id"); +sqlSafef(query, sizeof(query), "select * from gtexTissue%s order by id", + gtexVersionSuffix(version)); struct gtexTissue *gtexTissues = gtexTissueLoadByQuery(conn, query); hFreeConn(&conn); return gtexTissues; } -struct hash *gtexGetTissueSampleCount() +struct hash *gtexGetTissueSampleCount(char *version) /* Return hash of sample counts keyed by tissue name */ { char query[1024]; struct sqlResult *sr; char **row; struct sqlConnection *conn = hAllocConn("hgFixed"); -sqlSafef(query, sizeof(query), "select tissue, count(tissue) from gtexSample group by tissue"); +sqlSafef(query, sizeof(query), "select tissue, count(tissue) from gtexSample%s group by tissue", + gtexVersionSuffix(version)); struct hash *tscHash = hashNew(0); sr = sqlGetResult(conn,query); while ((row = sqlNextRow(sr)) != NULL) { char *tissue = cloneString(row[0]); int samples = sqlUnsigned(row[1]); hashAddInt(tscHash, tissue, samples); } sqlFreeResult(&sr); hFreeConn(&conn); return tscHash; } struct rgbColor gtexTissueBrightenColor(struct rgbColor rgb) /* Increase brightness for better visibility of small items */