c95bb9d37e9231523edeff445f1951f48d4a7046 angie Wed Oct 4 11:08:02 2017 -0700 hAnno.c did not yet recognize bigPsl -- since I anticipate more bigBed-based big* types in the future, I'll assume any big* that's not bigWig is bigBed-based. refs #20272 diff --git src/hg/lib/hAnno.c src/hg/lib/hAnno.c index 97bd5de..cafe6df 100644 --- src/hg/lib/hAnno.c +++ src/hg/lib/hAnno.c @@ -183,38 +183,41 @@ { struct annoStreamer *streamer = NULL; if (isEmpty(type)) type = customTrackTypeFromBigFile(fileOrUrl); if (type == NULL) { if (endsWith(fileOrUrl, "pgSnp") || endsWith(fileOrUrl, "pgsnp") || endsWith(fileOrUrl, "pgSnp.gz") || endsWith(fileOrUrl, "pgsnp.gz") || endsWith(fileOrUrl, "bed") || endsWith(fileOrUrl, "bed.gz")) { type = "pgSnp"; } else errAbort("Unrecognized bigData type of file or url '%s'", fileOrUrl); } -if (sameString(type, "bigBed") || sameString("bigGenePred", type)) +if (startsWith("big", type)) + { + if (startsWithWord("bigWig", type)) + streamer = annoStreamBigWigNew(fileOrUrl, assembly); + else streamer = annoStreamBigBedNew(fileOrUrl, assembly, maxOutRows); + } else if (sameString(type, "vcfTabix")) streamer = annoStreamVcfNew(fileOrUrl, indexUrl, TRUE, assembly, maxOutRows); else if (sameString(type, "vcf")) streamer = annoStreamVcfNew(fileOrUrl, NULL, FALSE, assembly, maxOutRows); -else if (sameString(type, "bigWig")) - streamer = annoStreamBigWigNew(fileOrUrl, assembly); else if (sameString(type, "pgSnp")) streamer = annoStreamTabNew(fileOrUrl, assembly, pgSnpFileAsObj(), maxOutRows); else if (sameString(type, "bam")) errAbort("Sorry, BAM is not yet supported"); else errAbort("Unrecognized bigData type %s of file or url '%s'", type, fileOrUrl); return streamer; } struct annoStreamer *hAnnoStreamerFromTrackDb(struct annoAssembly *assembly, char *selTable, struct trackDb *tdb, char *chrom, int maxOutRows, struct jsonElement *config) /* Figure out the source and type of data and make an annoStreamer. */ { struct annoStreamer *streamer = NULL; @@ -238,70 +241,68 @@ else if (sameString("vcfTabix", tdb->type)) { char *fileOrUrl = getBigDataFileName(dataDb, tdb, selTable, chrom); char *indexUrl = getBigDataIndexName(tdb); streamer = annoStreamVcfNew(fileOrUrl, indexUrl, TRUE, assembly, maxOutRows); } else if (sameString("vcf", tdb->type)) { char *fileOrUrl = getBigDataFileName(dataDb, tdb, dbTable, chrom); streamer = annoStreamVcfNew(fileOrUrl, NULL, FALSE, assembly, maxOutRows); } else if (sameString("bam", tdb->type)) { warn("Sorry, BAM is not yet supported"); } -else if (startsWith("bigBed", tdb->type) || sameString("bigGenePred", tdb->type)) - { - char *fileOrUrl = getBigDataFileName(dataDb, tdb, selTable, chrom); - streamer = annoStreamBigBedNew(fileOrUrl, assembly, maxOutRows); - } -else if (startsWith("bigWig", tdb->type)) +else if (startsWith("big", tdb->type)) { char *fileOrUrl = getBigDataFileName(dataDb, tdb, selTable, chrom); + if (startsWithWord("bigWig", tdb->type)) streamer = annoStreamBigWigNew(fileOrUrl, assembly); //#*** no maxOutRows support + else + streamer = annoStreamBigBedNew(fileOrUrl, assembly, maxOutRows); } else if (sameString("factorSource", tdb->type) && dbTableMatchesAutoSql(dataDb, tdb->table, factorSourceAsObj())) { char *sourceTable = trackDbSetting(tdb, "sourceTable"); char *inputsTable = trackDbSetting(tdb, "inputTrackTable"); streamer = annoStreamDbFactorSourceNew(dataDb, tdb->track, sourceTable, inputsTable, assembly, maxOutRows); } else if (trackHubDatabase(db)) errAbort("Unrecognized type '%s' for hub track '%s'", tdb->type, tdb->track); if (streamer == NULL) { streamer = annoStreamDbNew(dataDb, dbTable, assembly, maxOutRows, config); } return streamer; } struct annoGrator *hAnnoGratorFromBigFileUrl(char *fileOrUrl, char *indexUrl, struct annoAssembly *assembly, int maxOutRows, enum annoGratorOverlap overlapRule) /* Determine what kind of big data file/url we have and make streamer & grator for it. */ { struct annoStreamer *streamer = NULL; struct annoGrator *grator = NULL; char *type = customTrackTypeFromBigFile(fileOrUrl); -if (sameString(type, "bigBed") || sameString("bigGenePred", type)) +if (startsWithWord("bigWig", type)) + grator = annoGrateBigWigNew(fileOrUrl, assembly, agwmAverage); +else if (startsWith("big", type)) streamer = annoStreamBigBedNew(fileOrUrl, assembly, maxOutRows); else if (sameString(type, "vcfTabix")) streamer = annoStreamVcfNew(fileOrUrl, indexUrl, TRUE, assembly, maxOutRows); -else if (sameString(type, "bigWig")) - grator = annoGrateBigWigNew(fileOrUrl, assembly, agwmAverage); else if (sameString(type, "bam")) errAbort("Sorry, BAM is not yet supported"); else errAbort("Unrecognized bigData type %s of file or url '%s'", type, fileOrUrl); if (grator == NULL) grator = annoGratorNew(streamer); grator->setOverlapRule(grator, overlapRule); return grator; } struct annoGrator *hAnnoGratorFromTrackDb(struct annoAssembly *assembly, char *selTable, struct trackDb *tdb, char *chrom, int maxOutRows, struct asObject *primaryAsObj, enum annoGratorOverlap overlapRule, struct jsonElement *config) @@ -350,39 +351,39 @@ if (primaryIsVariants && (asColumnNamesMatchFirstN(streamer->asObj, genePredAsObj(), 10) || asObjectsMatch(streamer->asObj, bigGenePredAsObj()))) grator = annoGratorGpVarNew(streamer); else grator = annoGratorNew(streamer); } grator->setOverlapRule(grator, overlapRule); return grator; } static struct asObject *getAutoSqlForType(char *db, char *chrom, struct trackDb *tdb) /* Return an asObject for tdb->type if recognized as a hub or custom track type. */ { struct asObject * asObj = NULL; -if (startsWith("wig", tdb->type) || startsWith("bigWig", tdb->type)) +if (startsWith("wig", tdb->type) || startsWithWord("bigWig", tdb->type)) asObj = annoStreamBigWigAsObject(); -else if (startsWith("vcf", tdb->type)) - asObj = vcfAsObj(); -else if (startsWith("bigBed", tdb->type) || sameString("bigGenePred", tdb->type)) +else if (startsWith("big", tdb->type)) { char *fileOrUrl = getBigDataFileName(db, tdb, tdb->table, chrom); asObj = bigBedFileAsObjOrDefault(fileOrUrl); } +else if (startsWith("vcf", tdb->type)) + asObj = vcfAsObj(); else if (sameString("pgSnp", tdb->type)) asObj = pgSnpAsObj(); else if (sameString("bam", tdb->type) || sameString("maf", tdb->type)) warn("Sorry, %s is not yet supported", tdb->type); else if (startsWithWord("bed", tdb->type) && !strchr(tdb->type, '+')) { // BED with no + fields; parse bed field count out of type line. int bedFieldCount = 3; char typeCopy[PATH_LEN]; safecpy(typeCopy, sizeof(typeCopy), tdb->type); char *words[8]; int wordCount = chopLine(typeCopy, words); if (wordCount > 1) bedFieldCount = atoi(words[1]); asObj = asParseText(bedAsDef(bedFieldCount, bedFieldCount));