060ada2535fca719656219c1214a3e1c16490693 tdreszer Wed Nov 9 16:06:41 2011 -0800 Moved as code in hgTables down to lib and access it from hgc and hgTrackUi. This is to remove 'extraFields' support as per Jim's request in redmine 5883 and 5582 diff --git src/hg/hgTables/bigBed.c src/hg/hgTables/bigBed.c index b73c0d7..6e83e89 100644 --- src/hg/hgTables/bigBed.c +++ src/hg/hgTables/bigBed.c @@ -16,84 +16,54 @@ #include "hmmstats.h" #include "correlate.h" #include "asParse.h" #include "bbiFile.h" #include "bigBed.h" #include "hubConnect.h" #include "asFilter.h" #include "hgTables.h" static char const rcsid[] = "$Id: bigBed.c,v 1.11 2010/05/21 23:45:38 braney Exp $"; boolean isBigBed(char *database, char *table, struct trackDb *parent, struct customTrack *(*ctLookupName)(char *table)) /* Local test to see if something is big bed. Handles hub tracks unlike hIsBigBed. */ { -if (isHubTrack(table)) - { - struct trackDb *tdb = hashMustFindVal(fullTrackAndSubtrackHash, table); - return startsWithWord("bigBed", tdb->type); - } +struct trackDb *tdb = hashFindVal(fullTrackAndSubtrackHash, table); +if (tdb) + return tdbIsBigBed(tdb); else return hIsBigBed(database, table, parent, ctLookupName); } -char *bigBedFileName(char *table, struct sqlConnection *conn) -/* Return file name associated with bigBed. This handles differences whether it's - * a custom or built-in track. Do a freeMem on returned string when done. */ -{ -/* Implementation is same as bigWig. */ -return bigWigFileName(table, conn); -} - -struct hash *asColumnHash(struct asObject *as) +static struct hash *asColumnHash(struct asObject *as) /* Return a hash full of the object's columns, keyed by colum name */ { struct hash *hash = hashNew(6); struct asColumn *col; for (col = as->columnList; col != NULL; col = col->next) hashAdd(hash, col->name, col); return hash; } static void fillField(struct hash *colHash, char *key, char output[HDB_MAX_FIELD_STRING]) /* If key is in colHash, then copy key to output. */ { if (hashLookup(colHash, key)) strncpy(output, key, HDB_MAX_FIELD_STRING-1); } -static struct asObject *bigBedAsOrDefault(struct bbiFile *bbi) -/* Get asObject associated with bigBed - if none exists in file make it up from field counts. */ -{ -struct asObject *as = bigBedAs(bbi); -if (as == NULL) - as = asParseText(bedAsDef(bbi->definedFieldCount, bbi->fieldCount)); -return as; -} - -struct asObject *bigBedAsForTable(char *table, struct sqlConnection *conn) -/* Get asObject associated with bigBed table. */ -{ -char *fileName = bigBedFileName(table, conn); -struct bbiFile *bbi = bigBedFileOpen(fileName); -struct asObject *as = bigBedAsOrDefault(bbi); -bbiFileClose(&bbi); -freeMem(fileName); -return as; -} - struct hTableInfo *bigBedToHti(char *table, struct sqlConnection *conn) /* Get fields of bigBed into hti structure. */ { /* Get columns in asObject format. */ char *fileName = bigBedFileName(table, conn); struct bbiFile *bbi = bigBedFileOpen(fileName); struct asObject *as = bigBedAsOrDefault(bbi); /* Allocate hTableInfo structure and fill in info about bed fields. */ struct hash *colHash = asColumnHash(as); struct hTableInfo *hti; AllocVar(hti); hti->rootName = cloneString(table); hti->isPos= TRUE; fillField(colHash, "chrom", hti->chromField); @@ -276,33 +246,31 @@ } void showSchemaBigBed(char *table) /* Show schema on bigBed. */ { /* Figure out bigBed file name and open it. Get contents for first chromosome as an example. */ struct sqlConnection *conn = hAllocConn(database); char *fileName = bigBedFileName(table, conn); struct bbiFile *bbi = bigBedFileOpen(fileName); struct bbiChromInfo *chromList = bbiChromList(bbi); struct lm *lm = lmInit(0); struct bigBedInterval *ivList = bigBedIntervalQuery(bbi, chromList->name, 0, chromList->size, 10, lm); /* Get description of columns, making it up from BED records if need be. */ -struct asObject *as = bigBedAs(bbi); -if (as == NULL) - as = asParseText(bedAsDef(bbi->definedFieldCount, bbi->fieldCount)); +struct asObject *as = bigBedAsOrDefault(bbi); hPrintf("<B>Database:</B> %s", database); hPrintf(" <B>Primary Table:</B> %s<br>", table); hPrintf("<B>Big Bed File:</B> %s", fileName); if (bbi->version >= 2) { hPrintf(" <B>Item Count:</B> "); printLongWithCommas(stdout, bigBedItemCount(bbi)); } hPrintf("<BR>\n"); hPrintf("<B>Format description:</B> %s<BR>", as->comment); /* Put up table that describes fields. */ hTableStart(); hPrintf("<TR><TH>field</TH>");