b29f1fbf93c9df5aa65fed050d9f8132dc6a2c73 braney Tue Nov 24 14:20:10 2015 -0800 support htslib for sam/bam/cram/tabix support #14717 diff --git src/inc/linefile.h src/inc/linefile.h index 5eb5df1..8594aeb 100644 --- src/inc/linefile.h +++ src/inc/linefile.h @@ -1,30 +1,41 @@ /* lineFile - stuff to rapidly read text files and parse them into * lines. * * This file is copyright 2002 Jim Kent, but license is hereby * granted for all use - public, private or commercial. */ #ifndef LINEFILE_H #define LINEFILE_H #include "dystring.h" #include "udc.h" #ifdef USE_TABIX +#ifdef USE_HTS +#define tabix_t tbx_t +#define ti_iter_t hts_itr_t +#define ti_open hts_open +#define ti_index_load tbx_index_load +#define ti_close tbx_destroy +#define ti_get_tid tbx_name2id +#define ti_queryi tbx_itr_queryi +#define ti_iter_destroy tbx_itr_destroy +#else #include "tabix.h" #endif +#endif #define LF_BOGUS_FILE_PREFIX "somefile." enum nlType { nlt_undet, /* undetermined */ nlt_unix, /* lf */ nlt_dos, /* crlf */ nlt_mac /* cr */ }; struct metaOutput /* struct to store list of file handles to output meta data to * meta data is text after # */ { struct metaOutput *next; /* next file handle */ @@ -42,33 +53,40 @@ off_t bufOffsetInFile; /* Offset in file of first buffer byte. */ int bytesInBuf; /* Bytes read into buffer. */ int reserved; /* Reserved (zero for now). */ int lineIx; /* Current line. */ int lineStart; /* Offset of line in buffer. */ int lineEnd; /* End of line in buffer. */ bool zTerm; /* Replace '\n' with zero? */ enum nlType nlType; /* type of line endings: dos, unix, mac or undet */ bool reuse; /* Set if reusing input. */ char *buf; /* Buffer. */ struct pipeline *pl; /* pipeline if reading compressed */ struct metaOutput *metaOutput; /* list of FILE handles to write metaData to */ bool isMetaUnique; /* if set, do not repeat comments in output */ struct hash *metaLines; /* save lines to suppress repetition */ #ifdef USE_TABIX +#ifdef USE_HTS + void *htsFile; /* HTS file handle */ + void *tabix; /* A tabix-compressed file and its binary index file (.tbi) */ + void *tabixIter; /* An iterator to get decompressed indexed lines of text */ + void *kline; /* A buffer used for reading from htsfile. */ +#else tabix_t *tabix; /* A tabix-compressed file and its binary index file (.tbi) */ ti_iter_t tabixIter; /* An iterator to get decompressed indexed lines of text */ #endif +#endif struct udcFile *udcFile; /* udc file if using caching */ struct dyString *fullLine; // Filled with full line when a lineFileNextFull is called struct dyString *rawLines; // Filled with raw lines used to create the full line boolean fullLineReuse; // If TRUE, next call to lineFileNextFull will get // already built fullLine void *dataForCallBack; // ptr to data needed for callbacks void(*checkSupport)(struct lineFile *lf, char *where); // check if operation supported boolean(*nextCallBack)(struct lineFile *lf, char **retStart, int *retSize); // next line callback void(*closeCallBack)(struct lineFile *lf); // close callback }; char *getFileNameFromHdrSig(char *m); /* Check if header has signature of supported compression stream, and return a phoney filename for it, or NULL if no sig found. */