26c2f650359cc1c74fb31d96109bc0f8dedbc3d7 angie Thu May 30 10:32:19 2019 -0700 Adding BAM and VCF item counts to hubApi's list/tracks function. Note: older index files may not contain counts. refs #18869, #23521 diff --git src/inc/bamFile.h src/inc/bamFile.h index d11dc14..5da2dd1 100644 --- src/inc/bamFile.h +++ src/inc/bamFile.h @@ -38,30 +38,37 @@ 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. */ +long long bamFileItemCount(char *fileOrUrl, char *baiFileOrUrl); +/* Return the total number of mapped items across all sequences in fileOrUrl, using index file. + * If baiFileOrUrl is NULL, the index file is assumed to be fileOrUrl.bai. + * NOTE: not all bam index files include mapped item counts, so this may return 0 even for large + * bam. As of May 2019, our copy of hts_idx_get_stat does not support cram indexes + * (perhaps they never include counts?), so this always returns 0 for cram. */ + void bamFetchAlreadyOpen(samfile_t *samfile, bam_hdr_t *header, 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 bamAndIndexFetchPlus(char *fileOrUrl, char *baiFileOrUrl, char *position, bam_fetch_f callbackFunc, void *callbackData, samfile_t **pSamFile, char *refUrl, char *cacheDir); /* Open the .bam file with the .bai index specified by baiFileOrUrl. * baiFileOrUrl can be NULL and defaults to .bai. * 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