1c208beb06fed20869c546a09a0ca2b8999b4bee chmalee Wed Apr 17 16:46:31 2019 -0700 Taking bigDataUrl check out of hubCheck and into the trackHub lib so hgHubConnect can use it, refs #18870, #13428 diff --git src/hg/utils/hubCheck/hubCheck.c src/hg/utils/hubCheck/hubCheck.c index 55470a0..ebd4718 100644 --- src/hg/utils/hubCheck/hubCheck.c +++ src/hg/utils/hubCheck/hubCheck.c @@ -443,109 +443,30 @@ { /* check level */ struct trackHubSettingSpec *checkLevel = NULL; AllocVar(checkLevel); checkLevel->level = options->level; if (trackHubSettingLevel(hubSetting) < trackHubSettingLevel(checkLevel)) { dyStringPrintf(errors, "Setting '%s' is level '%s'\n", setting, hubSetting->level); retVal = 1; } freez(&checkLevel); } return retVal; } - -void hubCheckTrackFile(struct trackHub *hub, struct trackHubGenome *genome, struct trackDb *tdb) -/* Check remote file exists and is of correct type. Wrap this in error catcher */ -{ -char *relativeUrl = trackDbSetting(tdb, "bigDataUrl"); -if (relativeUrl != NULL) - { - char *type = trackDbRequiredSetting(tdb, "type"); - char *bigDataUrl = trackHubRelativeUrl(genome->trackDbFile, relativeUrl); - - char *bigDataIndex = NULL; - char *relIdxUrl = trackDbSetting(tdb, "bigDataIndex"); - if (relIdxUrl != NULL) - bigDataIndex = trackHubRelativeUrl(genome->trackDbFile, relIdxUrl); - - verbose(2, "checking %s.%s type %s at %s\n", genome->name, tdb->track, type, bigDataUrl); - if (startsWithWord("bigWig", type)) - { - /* Just open and close to verify file exists and is correct type. */ - struct bbiFile *bbi = bigWigFileOpen(bigDataUrl); - bbiFileClose(&bbi); - } - else if (startsWithWord("bigNarrowPeak", type) || startsWithWord("bigBed", type) || - startsWithWord("bigGenePred", type) || startsWithWord("bigPsl", type)|| - startsWithWord("bigChain", type)|| startsWithWord("bigMaf", type) || - startsWithWord("bigBarChart", type) || startsWithWord("bigInteract", type)) - { - /* Just open and close to verify file exists and is correct type. */ - struct bbiFile *bbi = bigBedFileOpen(bigDataUrl); - char *typeString = cloneString(type); - nextWord(&typeString); - if (startsWithWord("bigBed", type) && (typeString != NULL)) - { - unsigned numFields = sqlUnsigned(nextWord(&typeString)); - if (numFields > bbi->fieldCount) - errAbort("fewer fields in bigBed (%d) than in type statement (%d) for track %s with bigDataUrl %s", bbi->fieldCount, numFields, trackHubSkipHubName(tdb->track), bigDataUrl); - } - bbiFileClose(&bbi); - } - else if (startsWithWord("vcfTabix", type)) - { - /* Just open and close to verify file exists and is correct type. */ - struct vcfFile *vcf = vcfTabixFileAndIndexMayOpen(bigDataUrl, bigDataIndex, NULL, 0, 0, 1, 1); - if (vcf == NULL) - // Warnings already indicated whether the tabix file is missing etc. - errAbort("Couldn't open %s and/or its tabix index (.tbi) file. " - "See http://genome.ucsc.edu/goldenPath/help/vcf.html", - bigDataUrl); - vcfFileFree(&vcf); - } - else if (startsWithWord("bam", type)) - { - bamFileAndIndexMustExist(bigDataUrl, bigDataIndex); - } - else if (startsWithWord("longTabix", type)) - { - struct bedTabixFile *btf = bedTabixFileMayOpen(bigDataUrl, NULL, 0, 0); - if (btf == NULL) - errAbort("Couldn't open %s and/or its tabix index (.tbi) file.", bigDataUrl); - bedTabixFileClose(&btf); - } -#ifdef USE_HAL - else if (startsWithWord("halSnake", type)) - { - char *errString; - int handle = halOpenLOD(bigDataUrl, &errString); - if (handle < 0) - errAbort("HAL open error: %s", errString); - if (halClose(handle, &errString) < 0) - errAbort("HAL close error: %s", errString); - } -#endif - else - errAbort("unrecognized type %s in genome %s track %s", type, genome->name, tdb->track); - freez(&bigDataUrl); - } -} - - int hubCheckTrack(struct trackHub *hub, struct trackHubGenome *genome, struct trackDb *tdb, struct trackHubCheckOptions *options, struct dyString *errors) /* Check track settings and optionally, files */ { int retVal = 0; if (options->checkSettings && options->settings) { //verbose(3, "Found %d settings to check to spec\n", slCount(settings)); verbose(3, "Checking track: %s\n", tdb->shortLabel); verbose(3, "Found %d settings to check to spec\n", hashNumEntries(tdb->settingsHash)); struct hashEl *hel; struct hashCookie cookie = hashFirst(tdb->settingsHash); while ((hel = hashNext(&cookie)) != NULL) retVal |= hubCheckTrackSetting(hub, tdb, hel->name, options, errors); @@ -563,31 +484,31 @@ for(pair = metaPairs; pair; pair = pair->next) { printf("\t%s : %s\n", pair->name, (char *)pair->val); } printf("\n"); } slPairFreeValsAndList(&metaPairs); } if (!options->checkFiles) return retVal; struct errCatch *errCatch = errCatchNew(); if (errCatchStart(errCatch)) { - hubCheckTrackFile(hub, genome, tdb); + hubCheckBigDataUrl(hub, genome, tdb); } errCatchEnd(errCatch); if (errCatch->gotError) { retVal = 1; dyStringPrintf(errors, "%s", errCatch->message->string); } errCatchFree(&errCatch); return retVal; } int hubCheckGenome(struct trackHub *hub, struct trackHubGenome *genome, struct trackHubCheckOptions *options, struct dyString *errors)