f04cc66905720a6146a43fbb5aa5d9df797d32cb kent Tue Apr 29 11:11:46 2014 -0700 Renaming samMustOpen to bamMustOpenLocal and putting in library. diff --git src/inc/bamFile.h src/inc/bamFile.h index 94aa717..84b7b45 100644 --- src/inc/bamFile.h +++ src/inc/bamFile.h @@ -35,30 +35,41 @@ struct bamChromInfo *next; char *name; /* Chromosome name */ bits32 size; /* Chromosome size in bases */ }; boolean bamFileExists(char *bamFileName); /* Return TRUE if we can successfully open the bam file and its index file. */ void bamFileAndIndexMustExist(char *fileOrUrl); /* Open both a bam file and its accompanying index or errAbort; this is what it * takes for diagnostic info to propagate up through errCatches in calling code. */ samfile_t *bamOpen(char *fileOrUrl, char **retBamFileName); /* Return an open bam file as well as the filename of the bam. */ +samfile_t *bamMustOpenLocal(char *fileName, char *mode, void *extraHeader); +/* Open up sam or bam file or die trying. The mode parameter is + * "r" - open SAM to read + * "rb" - open BAM to read + * "w" - open SAM to write + * "wb" - open BAM to write + * The extraHeader is generally NULL in the read case, and the write case + * contains a pointer to a bam_header_t with information about the header. + * The implementation is just a wrapper around samopen from the samtools library + * that aborts with error message if there's a problem with the open. */ + 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. */