bc20671bb19cc948bda2c36063601ac5edc4d514 angie Tue Feb 15 10:57:59 2011 -0800 Fixing bug found while playing w/hgTables for Code Review #2840(not caused by Brian's changes): BAM tracks can have separate BAM files per chromosome, in which case the db table has an extra column seqName, so bigWigFileName() won't return the correct fileName for those tracks. Share bigWigFileName's logic for detecting custom track or hub track, and use bamFile.h's bamFileNameFromTable() for database tables. diff --git src/hg/hgTables/bigWig.c src/hg/hgTables/bigWig.c index d37169a..e13564e 100644 --- src/hg/hgTables/bigWig.c +++ src/hg/hgTables/bigWig.c @@ -23,49 +23,57 @@ static char const rcsid[] = "$Id: bigWig.c,v 1.7 2010/06/03 18:53:59 kent Exp $"; boolean isBigWigTable(char *table) /* Return TRUE if table corresponds to a bigWig file. */ { if (isHubTrack(table)) { struct trackDb *tdb = hashFindVal(fullTrackAndSubtrackHash, table); return startsWithWord("bigWig", tdb->type); } else return trackIsType(database, table, curTrack, "bigWig", ctLookupName); } -char *bigWigFileName(char *table, struct sqlConnection *conn) -/* Return file name associated with bigWig. This handles differences whether it's - * a custom or built-in track. Do a freeMem on returned string when done. */ +char *bigFileNameFromCtOrHub(char *table, struct sqlConnection *conn) +/* If table is a custom track or hub track, return the bigDataUrl setting; + * otherwise return NULL. Do a freeMem on returned string when done. */ { char *fileName = NULL; if (isCustomTrack(table)) { struct customTrack *ct = ctLookupName(table); if (ct != NULL) fileName = cloneString(trackDbSetting(ct->tdb, "bigDataUrl")); } else if (isHubTrack(table)) { struct trackDb *tdb = hashFindVal(fullTrackAndSubtrackHash, table); assert(tdb != NULL); fileName = cloneString(trackDbSetting(tdb, "bigDataUrl")); assert(fileName != NULL); } -else +return fileName; +} + +char *bigWigFileName(char *table, struct sqlConnection *conn) +/* Return file name associated with bigWig. This handles differences whether it's + * a custom or built-in track. Do a freeMem on returned string when done. */ +{ +char *fileName = bigFileNameFromCtOrHub(table, conn); +if (fileName == NULL) { char query[256]; safef(query, sizeof(query), "select fileName from %s", table); fileName = sqlQuickString(conn, query); } return fileName; } struct bbiInterval *intersectedFilteredBbiIntervalsOnRegion(struct sqlConnection *conn, struct bbiFile *bwf, struct region *region, enum wigCompare filterCmp, double filterLl, double filterUl, struct lm *lm) /* Get list of bbiIntervals (more-or-less bedGraph things from bigWig) out of bigWig file * and if necessary apply filter and intersection. Return list which is allocated in lm. */ { char *chrom = region->chrom;