dd7de217e2d618040912a49708435e9729edba2a
kent
  Sat Mar 26 12:53:48 2011 -0700
Making a chromosome-at-a-time access object for bigWigs. Had repeated this code 3 times, so it's time....
diff --git src/inc/bigWig.h src/inc/bigWig.h
index 5f5d808..d705c59 100644
--- src/inc/bigWig.h
+++ src/inc/bigWig.h
@@ -11,30 +11,33 @@
  *
  * To read all the data out of a bigWig get the chromosome info with bbiChromList
  * and then fetch all of it for each chromosome using bigWigIntervalQuery.
  *
  * See also the module bbiFile that has a description of they structure of
  * a bigWig file, and lower level routines used to implement this interface.
  */
 
 #ifndef BIGWIG_H
 #define BIGWIG_H
 
 #ifndef BBIFILE
 #include "bbiFile.h"
 #endif
 
+#ifndef BITS_H
+#include "bits.h"
+#endif
 
 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. */
 	char *outName);
 /* Convert ascii format wig file (in fixedStep, variableStep or bedGraph format) 
  * to binary big wig format. */
 
 struct bbiFile *bigWigFileOpen(char *fileName);
 /* Open up big wig file.   Free this up with bbiFileClose */
 
@@ -59,17 +62,41 @@
 
 boolean bigWigSummaryArrayExtended(struct bbiFile *bwf, char *chrom, bits32 start, bits32 end,
 	int summarySize, struct bbiSummaryElement *summary);
 /* Get extended summary information for summarySize evenely spaced elements into
  * the summary array. */
 
 double bigWigSingleSummary(struct bbiFile *bwf, char *chrom, int start, int end,
     enum bbiSummaryType summaryType, double defaultVal);
 /* Return the summarized single value for a range. */
 
 boolean isBigWig(char *fileName);
 /* Peak at a file to see if it's bigWig */
 
 boolean bigWigFileCheckSigs(char *fileName);
 /* check file signatures at beginning and end of file */
+
+
+struct bigWigValsOnChrom
+/* Object for bulk access a chromosome at a time.  This is faster than
+ * doing bigWigInterval queries when you have ~5000 or more queries. */
+     {
+     struct bigWigValsOnChrom *next;
+     char *chrom;	/* Current chromosome. */
+     long chromSize;	/* Size of current chromosome. */
+     long bufSize;	/* Size of allocated buffer */
+     double *valBuf;	/* A value for each base on chrom. Zero where no data. */
+     Bits *covBuf;	/* A bit for each base with data. */
+     };
+
+struct bigWigValsOnChrom *bigWigValsOnChromNew();
+/* Allocate new empty bigWigValsOnChromStructure. */
+
+void bigWigValsOnChromFree(struct bigWigValsOnChrom **pChromVals);
+/* Free up bigWigValsOnChrom */
+
+boolean bigWigValsOnChromFetchData(struct bigWigValsOnChrom *chromVals, char *chrom, 
+	struct bbiFile *bigWig);
+/* Fetch data for chromosome from bigWig. Returns FALSE if not data on that chrom. */
+
 #endif /* BIGWIG_H */