void bigWigFileCreate( char *inName, /* Input file in ascii wiggle format. */ char *chromSizes, /* Two column tab-separated file: <chromosome> <size>. */ int blockSize, /* Number of items to bundle in r-tree. 1024 is good. */ int itemsPerSlot, /* Number of items in lowest level of tree. 512 is good. */ boolean clipDontDie, /* If TRUE then clip items off end of chrom rather than dying. */ boolean compress, /* If TRUE then compress data. */ boolean keepAllChromosomes, /* If TRUE then store all chromosomes in chromosomal b-tree. */ boolean fixedSummaries, /* If TRUE then impose fixed summary levels. */ char *outName) /* Convert ascii format wig file (in fixedStep, variableStep or bedGraph format) * to binary big wig format. */ { /* This code needs to agree with code in two other places currently - bigBedFileCreate, * and bbiFileOpen. 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 hash *chromSizeHash = bbiChromSizesFromFile(chromSizes); struct lm *lm = lmInit(0); struct bwgSection *sectionList = bwgParseWig(inName, clipDontDie, chromSizeHash, itemsPerSlot, lm); if (sectionList == NULL) errAbort("%s is empty of data", inName); bwgCreate(sectionList, chromSizeHash, blockSize, itemsPerSlot, compress, keepAllChromosomes, fixedSummaries, outName); lmCleanup(&lm); }
void writeBw(char *inName, char *outName, struct hash *chromSizeHash) /* copied from bwtool_shared.c */ { struct lm *lm = lmInit(0); struct bwgSection *sectionList = bwgParseWig(inName, TRUE, chromSizeHash, 1024, lm); if (sectionList == NULL) errAbort("%s is empty of data", inName); bwgCreate(sectionList, chromSizeHash, 256, 1024, TRUE, outName); lmCleanup(&lm); }
SEXP BWGFile_fromWIG(SEXP r_infile, SEXP r_seqlengths, SEXP r_outfile) { pushRHandlers(); struct lm *lm = lmInit(0); struct hash *lenHash = createIntHash(r_seqlengths); struct bwgSection *sections = bwgParseWig((char *)CHAR(asChar(r_infile)), FALSE, lenHash, itemsPerSlot, lm); bwgCreate(sections, lenHash, blockSize, itemsPerSlot, TRUE, TRUE, TRUE, (char *)CHAR(asChar(r_outfile))); lmCleanup(&lm); freeHash(&lenHash); popRHandlers(); return r_outfile; }
/* --- .Call ENTRY POINT --- */ SEXP BWGSectionList_write(SEXP r_sections, SEXP r_seqlengths, SEXP r_compress, SEXP r_file) { struct bwgSection *sections = NULL; struct hash *lenHash = createIntHash(r_seqlengths); if (r_sections != R_NilValue) { sections = R_ExternalPtrAddr(r_sections); slReverse(§ions); } pushRHandlers(); bwgCreate(sections, lenHash, blockSize, itemsPerSlot, asLogical(r_compress), (char *)CHAR(asChar(r_file))); freeHash(&lenHash); popRHandlers(); return r_file; }
void bigWigFileCreate2( char *inName, /* Input file in ascii wiggle format. */ struct hash *chromSizeHash, /* chrom size hash. */ char *outName) /* Convert ascii format wig file (in fixedStep, variableStep or bedGraph format) * to binary big wig format. */ { /* This code needs to agree with code in two other places currently - bigBedFileCreate, * and bbiFileOpen. 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 lm *lm = lmInit(0); struct bwgSection *sectionList = bwgParseWig(inName, clipDontDie, chromSizeHash, itemsPerSlot, lm); if (sectionList == NULL) errAbort("%s is empty of data", inName); bwgCreate(sectionList, chromSizeHash, blockSize, itemsPerSlot, compress, outName); lmCleanup(&lm); }