int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 3) usage(); clSeq = optionVal("seq", clSeq); clStart = optionInt("start", clStart); clEnd = optionInt("end", clEnd); clSeqList = optionVal("seqList", clSeqList); clBpt = optionVal("bpt", clBpt); clBed = optionVal("bed", clBed); clBedPos = optionExists("bedPos"); noMask = optionExists("noMask"); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); if (clBedPos && !clBed) errAbort("the -bedPos option requires the -bed option"); if (clBed != NULL) { if (clSeqList != NULL) errAbort("Can only have seqList or bed options, not both."); if (clSeq != NULL) errAbort("Can only have seq or bed options, not both."); } if ((clStart > clEnd) && (clSeq == NULL)) errAbort("must specify -seq with -start and -end"); if ((clSeq != NULL) && (clSeqList != NULL)) errAbort("can't specify both -seq and -seqList"); dnaUtilOpen(); twoBitToFa(argv[1], argv[2]); return 0; }
enum metaBigFileType isBigWigOrBed(char* filename) /* Peak at a file to see if it's bigWig */ { enum metaBigFileType ret = isNotBig; bits32 magic; struct udcFile* udc; udc = udcFileOpen(filename, udcDefaultDir()); /* Read magic number at head of file and use it to see if we are proper file type, and * see if we are byte-swapped. */ udcMustRead(udc, &magic, sizeof(magic)); if (magic == bigWigSig) ret = isaBigWig; else if (magic == bigBedSig) ret = isaBigBed; if (ret != isNotBig) { udcFileClose(&udc); return ret; } magic = byteSwap32(magic); if (magic == bigWigSig) ret = isaBigWig; else if (magic == bigBedSig) ret = isaBigBed; udcFileClose(&udc); return ret; }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 2) usage(); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); twoBitDup(argv[1]); return 0; }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 2) usage(); cacheDir = optionVal("cacheDir", udcDefaultDir()); testOnly = optionExists("test"); doCleanup(argv[1]); return 0; }
char *getSparseFileName(char *url) /* Return the path to sparseData cache file for url. */ { struct slName *sl, *cacheFiles = udcFileCacheFiles(url, udcDefaultDir()); char *sparseFileName = NULL; for (sl = cacheFiles; sl != NULL; sl = sl->next) if (endsWith(sl->name, "sparseData")) sparseFileName = sl->name; if (sparseFileName == NULL) errAbort("can't find sparseData file in udcFileCacheFiles(%s) results", url); return sparseFileName; }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); if (argc != 2) usage(); bigWigInfo(argv[1]); if (verboseLevel() > 1) printVmPeak(); return 0; }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 3) usage(); clChrom = optionVal("chrom", clChrom); clStart = optionInt("start", clStart); clEnd = optionInt("end", clEnd); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); bigWigToWig(argv[1], argv[2]); return 0; }
void usage() /* Explain usage and exit. */ { errAbort( "udcCleanup - Clean up old unused files in udcCache.\n" "usage:\n" " udcCleanup maxUnusedDays\n" "example:\n" " udcCleanup 7.5\n" "options:\n" " -cacheDir=dir use the indicated cache dir instead of the default (%s)\n" " -test - don't actually clean up, but do still figure cleanup bytes\n" , udcDefaultDir() ); }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 2) usage(); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); char *hubUrl = optionVal("addHub", NULL); if (hubUrl != NULL) return hubPublicAdd(argv[1],hubUrl); else return hubPublicCheck(argv[1]); }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); clChrom = optionVal("chrom", clChrom); clStart = optionInt("start", clStart); clEnd = optionInt("end", clEnd); maxItems = optionInt("maxItems", maxItems); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); if (argc != 3) usage(); bigBedToBed(argv[1], argv[2]); if (verboseLevel() > 1) printVmPeak(); return 0; }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 2) usage(); udcSetCacheTimeout(cacheTime); // UDC cache dir: first check for hg.conf setting, then override with command line option if given. setUdcCacheDir(); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); if (trackHubCrawl(argv[1])) { return 1; } return 0; }
struct crTreeFile *crTreeFileOpen(char *fileName) /* Open up r-tree index file - reading headers and verifying things. */ { /* Open file and allocate structure to hold info from header etc. */ struct udcFile *udc = udcFileOpen(fileName, udcDefaultDir()); struct crTreeFile *crt = needMem(sizeof(*crt)); fileName = crt->fileName = cloneString(fileName); crt->udc = udc; /* Read magic number at head of file and use it to see if we are proper file type, and * see if we are byte-swapped. */ bits32 magic; boolean isSwapped = FALSE; udcMustReadOne(udc, magic); if (magic != crTreeSig) { magic = byteSwap32(magic); isSwapped = crt->isSwapped = TRUE; if (magic != crTreeSig) errAbort("%s is not a chromosome r-tree index file", fileName); } /* Read rest of high level header including notably the offsets to the * chromosome and range indexes. */ bits32 reserved32; udcMustReadOne(udc, reserved32); crt->chromOffset = udcReadBits64(udc, isSwapped); crt->cirOffset = udcReadBits64(udc, isSwapped); /* Read in the chromosome index header. */ udcSeek(udc, crt->chromOffset); crt->chromBpt = bptFileAttach(fileName, udc); /* Read in range index header. */ udcSeek(udc, crt->cirOffset); crt->cir = cirTreeFileAttach(fileName, udc); return crt; }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); if (optionExists("fields")) { if (argc < 2) usage(); bigBedFields(argv[1]); } else { summaryType = optionVal("type", summaryType); if (argc != 6) usage(); bigBedSummary(argv[1], argv[2], sqlUnsigned(argv[3]), sqlUnsigned(argv[4]), sqlUnsigned(argv[5])); } if (verboseLevel() > 1) printVmPeak(); return 0; }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); blockSize = optionInt("blockSize", blockSize); itemsPerSlot = optionInt("itemsPerSlot", itemsPerSlot); asFile = optionVal("as", asFile); doCompress = !optionExists("unc"); sizesIs2Bit = optionExists("sizesIs2Bit"); extraIndex = optionVal("extraIndex", NULL); tabSep = optionExists("tab"); udcDir = optionVal("udcDir", udcDefaultDir()); if (argc != 4) usage(); udcSetDefaultDir(udcDir); if (optionExists("type")) { // parse type char *btype = cloneString(optionVal("type", "")); char *plus = strchr(btype, '+'); if (plus) { *plus++ = 0; if (isdigit(*plus)) bedP = sqlUnsigned(plus); } if (!startsWith("bed", btype)) errAbort("type must begin with \"bed\""); btype +=3; bedN = sqlUnsigned(btype); if (bedN < 3) errAbort("Bed must be 3 or higher, found %d\n", bedN); if (bedN > 15) errAbort("Bed must be 15 or lower, found %d\n", bedN); } else { if (asText) errAbort("If you specify the .as file, you must specify the -type as well so that\n" "the number of standard BED columns is known."); } /* If the haven't set bedN and bedP from the type var in the command line, then we sniff it * out from file. */ char *bedFileName = argv[1]; if (bedN == 0) { /* Just read in single line and count fields. */ struct lineFile *lf = lineFileOpen(bedFileName, TRUE); char *line; if (!lineFileNextReal(lf, &line)) errAbort("%s is empty", lf->fileName); int fieldCount; if (tabSep) fieldCount = chopByChar(line, '\t', NULL, 0); // Do not use chopString, see GOTCHA else fieldCount = chopByWhite(line, NULL, 0); if (fieldCount > 256) errAbort("Too many columns in %s, you sure it's a bed file?", lf->fileName); lineFileClose(&lf); /* Set up so that it looks like we are straight up bed for that many fields, * or if more than or maximum defined fields, then for bed15+ */ bedN = fieldCount; if (bedN > bedKnownFields) { bedP = bedN - bedKnownFields; bedN = bedKnownFields; } } /* Make sure that fields are defined, from bed spec if nowhere else. */ if (asFile) readInGulp(asFile, &asText, NULL); else asText = bedAsDef(bedN, bedN + bedP); bedToBigBed(bedFileName, argv[2], argv[3]); optionFree(); if (verboseLevel() > 1) printVmPeak(); return 0; }
struct cirTreeFile *cirTreeFileOpen(char *fileName) /* Open up r-tree index file - reading header and verifying things. */ { return cirTreeFileAttach(cloneString(fileName), udcFileOpen(fileName, udcDefaultDir())); }
struct bptFile *bptFileOpen(char *fileName) /* Open up index file - reading header and verifying things. */ { return bptFileAttach(cloneString(fileName), udcFileOpen(fileName, udcDefaultDir())); }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 2 && !optionExists("settings")) usage(); struct trackHubCheckOptions *checkOptions = NULL; AllocVar(checkOptions); checkOptions->specHost = (optionExists("test") ? "genome-test.soe.ucsc.edu" : "genome.ucsc.edu"); checkOptions->specHost = optionVal("specHost", checkOptions->specHost); checkOptions->printMeta = optionExists("printMeta"); checkOptions->checkFiles = !optionExists("noTracks"); checkOptions->checkSettings = optionExists("checkSettings"); struct trackHubSettingSpec *setting = NULL; AllocVar(setting); setting->level = optionVal("level", "all"); if (trackHubSettingLevel(setting) < 0) { fprintf(stderr, "ERROR: Unrecognized support level %s\n\n", setting->level); usage(); } checkOptions->level = setting->level; char *version = NULL; if (optionExists("version")) version = optionVal("version", NULL); checkOptions->version = version; char *extraFile = optionVal("extra", NULL); if (extraFile != NULL) addExtras(extraFile, checkOptions); cacheTime = optionInt("cacheTime", cacheTime); udcSetCacheTimeout(cacheTime); // UDC cache dir: first check for hg.conf setting, then override with command line option if given. setUdcCacheDir(); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); knetUdcInstall(); // make the htslib library use udc if (optionExists("settings")) { showSettings(checkOptions); return 0; } struct dyString *errors = newDyString(1024); if (trackHubCheck(argv[1], checkOptions, errors)) { // uniquify and count errors struct slName *errs = slNameListFromString(errors->string, '\n'); slUniqify(&errs, slNameCmp, slNameFree); int errCount = slCount(errs); printf("Found %d problem%s:\n", errCount, errCount == 1 ? "" : "s"); printf("%s\n", slNameListToString(errs, '\n')); return 1; } return 0; }
struct bbiFile *bbiFileOpen(char *fileName, bits32 sig, char *typeName) /* Open up big wig or big bed file. */ { /* This code needs to agree with code in two other places currently - bigBedFileCreate, * and bigWigFileCreate. I'm thinking of refactoring to share at least between * bigBedFileCreate and bigWigFileCreate. It'd be great so it could be structured * so that it could send the input in one chromosome at a time, and send in the zoom * stuff only after all the chromosomes are done. This'd potentially reduce the memory * footprint by a factor of 2 or 4. Still, for now it works. -JK */ struct bbiFile *bbi; AllocVar(bbi); bbi->fileName = cloneString(fileName); struct udcFile *udc = bbi->udc = udcFileOpen(fileName, udcDefaultDir()); /* Read magic number at head of file and use it to see if we are proper file type, and * see if we are byte-swapped. */ bits32 magic; boolean isSwapped = FALSE; udcMustRead(udc, &magic, sizeof(magic)); if (magic != sig) { magic = byteSwap32(magic); isSwapped = TRUE; if (magic != sig) errAbort("%s is not a %s file", fileName, typeName); } bbi->typeSig = sig; bbi->isSwapped = isSwapped; /* Read rest of defined bits of header, byte swapping as needed. */ bbi->version = udcReadBits16(udc, isSwapped); bbi->zoomLevels = udcReadBits16(udc, isSwapped); bbi->chromTreeOffset = udcReadBits64(udc, isSwapped); bbi->unzoomedDataOffset = udcReadBits64(udc, isSwapped); bbi->unzoomedIndexOffset = udcReadBits64(udc, isSwapped); bbi->fieldCount = udcReadBits16(udc, isSwapped); bbi->definedFieldCount = udcReadBits16(udc, isSwapped); bbi->asOffset = udcReadBits64(udc, isSwapped); bbi->totalSummaryOffset = udcReadBits64(udc, isSwapped); bbi->uncompressBufSize = udcReadBits32(udc, isSwapped); /* Skip over reserved area. */ udcSeek(udc, 64); /* Read zoom headers. */ int i; struct bbiZoomLevel *level, *levelList = NULL; for (i=0; i<bbi->zoomLevels; ++i) { AllocVar(level); level->reductionLevel = udcReadBits32(udc, isSwapped); level->reserved = udcReadBits32(udc, isSwapped); level->dataOffset = udcReadBits64(udc, isSwapped); level->indexOffset = udcReadBits64(udc, isSwapped); slAddHead(&levelList, level); } slReverse(&levelList); bbi->levelList = levelList; /* Attach B+ tree of chromosome names and ids. */ udcSeek(udc, bbi->chromTreeOffset); bbi->chromBpt = bptFileAttach(fileName, udc); return bbi; }