src/hg/hgTables/hgTables.c 1.175
1.175 2009/03/17 04:28:38 kent
Adding parameter to getHti, and creating a hti object for bigBed tables out of the associated .as information.
Index: src/hg/hgTables/hgTables.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTables/hgTables.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -b -B -U 4 -r1.174 -r1.175
--- src/hg/hgTables/hgTables.c 16 Mar 2009 17:44:24 -0000 1.174
+++ src/hg/hgTables/hgTables.c 17 Mar 2009 04:28:38 -0000 1.175
@@ -601,14 +601,18 @@
errAbort("Table %s doesn't exist", table);
freeMem(splitTable);
}
-struct hTableInfo *maybeGetHti(char *db, char *table)
-/* Return primary table info. */
+struct hTableInfo *maybeGetHti(char *db, char *table, struct sqlConnection *conn)
+/* Return primary table info, but don't abort if table not there. Conn should be open to db. */
{
struct hTableInfo *hti = NULL;
-if (isCustomTrack(table))
+if (isBigBed(table))
+ {
+ hti = bigBedToHti(table, conn);
+ }
+else if (isCustomTrack(table))
{
struct customTrack *ct = lookupCt(table);
hti = ctToHti(ct);
}
@@ -627,12 +631,12 @@
}
return(hti);
}
-struct hTableInfo *getHti(char *db, char *table)
+struct hTableInfo *getHti(char *db, char *table, struct sqlConnection *conn)
/* Return primary table info. */
{
-struct hTableInfo *hti = maybeGetHti(db, table);
+struct hTableInfo *hti = maybeGetHti(db, table, conn);
if (hti == NULL)
{
errAbort("Could not find table info for table %s in db %s",
@@ -640,8 +644,27 @@
}
return(hti);
}
+struct hTableInfo *getHtiOnDb(char *db, char *table)
+/* Return primary table info. */
+{
+struct sqlConnection *conn = hAllocConn(db);
+struct hTableInfo *hti = getHti(db, table, conn);
+hFreeConn(&conn);
+return hti;
+}
+
+struct hTableInfo *maybeGetHtiOnDb(char *db, char *table)
+/* Return primary table info, but don't abort if table not there. */
+{
+struct sqlConnection *conn = hAllocConn(db);
+struct hTableInfo *hti = maybeGetHti(db, table, conn);
+hFreeConn(&conn);
+return hti;
+}
+
+
boolean isPositional(char *db, char *table)
/* Return TRUE if it looks to be a positional table. */
{
boolean result = FALSE;
@@ -987,9 +1010,9 @@
if (hti != NULL && hti->nameField[0] != 0)
idField = cloneString(hti->nameField);
else if (track != NULL)
{
- struct hTableInfo *trackHti = maybeGetHti(db, track->tableName);
+ struct hTableInfo *trackHti = maybeGetHtiOnDb(db, track->tableName);
if (trackHti != NULL && isCustomTrack(table))
idField = cloneString(trackHti->nameField);
else if (hti != NULL && trackHti != NULL && trackHti->nameField[0] != 0)
{
@@ -1130,9 +1153,9 @@
boolean showItemRgb = FALSE;
int itemRgbCol = -1; /* -1 means not found */
boolean printedColumns = FALSE;
-hti = getHti(db, table);
+hti = getHti(db, table, conn);
idField = getIdField(db, curTrack, table, hti);
showItemRgb=bedItemRgb(curTrack); /* should we expect itemRgb */
/* instead of "reserved" */