df52d842cf575c8b1f250baed87aa0b937f385a8 kate Thu Jan 26 14:09:50 2017 -0800 Initial cut of hgTracks and hgTrackUi for new barchart type track (generalization of GTEx gene expression display). refs #18736 diff --git src/hg/inc/barChartBed.h src/hg/inc/barChartBed.h new file mode 100644 index 0000000..ffde0f5 --- /dev/null +++ src/hg/inc/barChartBed.h @@ -0,0 +1,92 @@ +/* barChartBed.h was originally generated by the autoSql program, which also + * generated barChartBed.c and barChartBed.sql. This header links the database and + * the RAM representation of objects. */ + +#ifndef BARCHARTBED_H +#define BARCHARTBED_H + +#include "jksql.h" +#define BARCHARTBED_NUM_COLS 8 + +extern char *barChartBedCommaSepFieldNames; + +// TODO: add fields for description and unique identifier/name + +struct barChartBed +/* BED6+ with additional fields for category count and values */ + { + struct barChartBed *next; /* Next in singly linked list. */ + char *chrom; /* Reference sequence chromosome or scaffold */ + unsigned chromStart; /* Start position in chromosome */ + unsigned chromEnd; /* End position in chromosome */ + char *name; /* Item identifier */ + unsigned score; /* Score from 0-1000; derived from total median all categories (log-transformed and scaled) */ + char strand[2]; /* + or - for strand */ + unsigned expCount; /* Number of categories */ + float *expScores; /* Comma separated list of category values */ + }; + +struct barChartBed *barChartBedLoadByQuery(struct sqlConnection *conn, char *query); +/* Load all barChartBed from table that satisfy the query given. + * Where query is of the form 'select * from example where something=something' + * or 'select example.* from example, anotherTable where example.something = + * anotherTable.something'. + * Dispose of this with barChartBedFreeList(). */ + +void barChartBedSaveToDb(struct sqlConnection *conn, struct barChartBed *el, char *tableName, int updateSize); +/* Save barChartBed as a row to the table specified by tableName. + * As blob fields may be arbitrary size updateSize specifies the approx size + * of a string that would contain the entire query. Arrays of native types are + * converted to comma separated strings and loaded as such, User defined types are + * inserted as NULL. This function automatically escapes quoted strings for mysql. */ + +struct barChartBed *barChartBedLoad(char **row); +/* Load a barChartBed from row fetched with select * from barChartBed + * from database. Dispose of this with barChartBedFree(). */ + +struct barChartBed *barChartBedLoadAll(char *fileName); +/* Load all barChartBed from whitespace-separated file. + * Dispose of this with barChartBedFreeList(). */ + +struct barChartBed *barChartBedLoadAllByChar(char *fileName, char chopper); +/* Load all barChartBed from chopper separated file. + * Dispose of this with barChartBedFreeList(). */ + +#define barChartBedLoadAllByTab(a) barChartBedLoadAllByChar(a, '\t'); +/* Load all barChartBed from tab separated file. + * Dispose of this with barChartBedFreeList(). */ + +struct barChartBed *barChartBedCommaIn(char **pS, struct barChartBed *ret); +/* Create a barChartBed out of a comma separated string. + * This will fill in ret if non-null, otherwise will + * return a new barChartBed */ + +void barChartBedFree(struct barChartBed **pEl); +/* Free a single dynamically allocated barChartBed such as created + * with barChartBedLoad(). */ + +void barChartBedFreeList(struct barChartBed **pList); +/* Free a list of dynamically allocated barChartBed's */ + +void barChartBedOutput(struct barChartBed *el, FILE *f, char sep, char lastSep); +/* Print out barChartBed. Separate fields with sep. Follow last field with lastSep. */ + +#define barChartBedTabOut(el,f) barChartBedOutput(el,f,'\t','\n'); +/* Print out barChartBed as a line in a tab-separated file. */ + +#define barChartBedCommaOut(el,f) barChartBedOutput(el,f,',',','); +/* Print out barChartBed as a comma separated list including final comma. */ + +/* -------------------------------- End autoSql Generated Code -------------------------------- */ + +void barChartBedCreateTable(struct sqlConnection *conn, char *table); +/* Create barChart format table of given name. */ + +float barChartTotalValue(struct barChartBed *bed); +/* Return total of all category values */ + +float barChartHighestValue(struct barChartBed *bed, int *categIdRet); +/* Return value and id of category with highest value for this item */ + +#endif /* BARCHARTBED_H */ +