cb9df600fd62bdbb03fc0f1bee61a6f2b0440e09
aamp
  Sun Jul 17 09:56:30 2011 -0700
made a spinoff function of bamFetch() that also handles an already-open bam file/index for cases where fetch is done within a loop
diff --git src/inc/bamFile.h src/inc/bamFile.h
index 02f39b6..911d72c 100644
--- src/inc/bamFile.h
+++ src/inc/bamFile.h
@@ -26,32 +26,38 @@
 
 #endif // USE_BAM
 
 #ifndef DNASEQ_H
 #include "dnaseq.h"
 #endif
 
 #ifndef DYSTRING_H
 #include "dystring.h"
 #endif
 
 boolean bamFileExists(char *bamFileName);
 /* Return TRUE if we can successfully open the bam file and its index file. */
 
 samfile_t *bamOpen(char *fileOrUrl, char **retBamFileName);
-/* Return an open bam file, dealing with FUSE caching if need be. 
- * Return parameter if NON-null will return the file name after FUSing */
+/* Return an open bam file as well as the filename of the bam. */
+
+void bamFetchAlreadyOpen(samfile_t *samfile, bam_index_t *idx, char *bamFileName, 
+			 char *position, bam_fetch_f callbackFunc, void *callbackData);
+/* With the open bam file, return items the same way with the callbacks as with bamFetch() */
+/* except in this case use an already-open bam file and index (use bam_index_load and free() for */
+/* the index). It seems a little strange to pass the filename in with the open bam, but */
+/* it's just used to report errors. */
 
 void bamFetch(char *fileOrUrl, char *position, bam_fetch_f callbackFunc, void *callbackData,
 	samfile_t **pSamFile);
 /* Open the .bam file, fetch items in the seq:start-end position range,
  * and call callbackFunc on each bam item retrieved from the file plus callbackData.
  * This handles BAM files with "chr"-less sequence names, e.g. from Ensembl. 
  * The pSamFile parameter is optional.  If non-NULL it will be filled in, just for
  * the benefit of the callback function, with the open samFile.  */
 
 void bamClose(samfile_t **pSamFile);
 /* Close down a samefile_t */
 
 boolean bamIsRc(const bam1_t *bam);
 /* Return TRUE if alignment is on - strand. */