53c1a54fa21c9b90af300dbc83d3a64b3b869f72 braney Fri Feb 15 14:03:58 2013 -0800 change twoBit library to use either UDC or stdio. #8072 diff --git src/inc/twoBit.h src/inc/twoBit.h index abe8957..9dade31 100644 --- src/inc/twoBit.h +++ src/inc/twoBit.h @@ -22,38 +22,48 @@ }; struct twoBitIndex /* An entry in twoBit index. */ { struct twoBitIndex *next; /* Next in list. */ char *name; /* Name - allocated in hash */ bits32 offset; /* Offset in file. */ }; struct twoBitFile /* Holds header and index info from .2bit file. */ { struct twoBitFile *next; char *fileName; /* Name of this file, for error reporting. */ - FILE *f; /* Open file. */ + void *f; /* Open file. */ boolean isSwapped; /* Is byte-swapping needed. */ bits32 version; /* Version of .2bit file */ bits32 seqCount; /* Number of sequences. */ bits32 reserved; /* Reserved, always zero for now. */ struct twoBitIndex *indexList; /* List of sequence. */ struct hash *hash; /* Hash of sequences. */ struct bptFile *bpt; /* Alternative index. */ + + /* the routines we use to access the twoBit. + * These may be UDC routines, or stdio + */ + void (*ourSeek)(void *file, bits64 offset); + void (*ourSeekCur)(void *file, bits64 offset); + bits32 (*ourReadBits32)(void *f, boolean isSwapped); + void (*ourClose)(void *pFile); + boolean (*ourFastReadString)(void *f, char buf[256]); + void (*ourMustRead)(void *file, void *buf, size_t size); }; struct twoBitSpec /* parsed .2bit file and sequence specs */ { char *fileName; /* path to file */ struct twoBitSeqSpec *seqs; /* list of sequences and subsequences */ }; struct twoBitSeqSpec /* specification for a seq or subsequence in a .2bit file */ { struct twoBitSeqSpec *next; char *name; /* name of sequence */ bits32 start; /* start of subsequence 0 */ @@ -96,30 +106,33 @@ struct dnaSeq *twoBitReadSeqFragLower(struct twoBitFile *tbf, char *name, int fragStart, int fragEnd); /* Same as twoBitReadSeqFrag, but sequence is returned in lower case. */ struct dnaSeq *twoBitLoadAll(char *spec); /* Return list of all sequences matching spec, which is in * the form: * * file/path/input.2bit[:seqSpec1][,seqSpec2,...] * * where seqSpec is either * seqName * or * seqName:start-end */ +struct slName *twoBitSeqNamesExt(char *fileName, boolean useUdc); +/* Get list of all sequences in twoBit file. */ + struct slName *twoBitSeqNames(char *fileName); /* Get list of all sequences in twoBit file. */ struct twoBit *twoBitFromDnaSeq(struct dnaSeq *seq, boolean doMask); /* Convert dnaSeq representation in memory to twoBit representation. * If doMask is true interpret lower-case letters as masked. */ struct twoBit *twoBitFromFile(char *fileName); /* Get twoBit list of all sequences in twoBit file. */ struct twoBit *twoBitOneFromFile(struct twoBitFile *tbf, char *name); /* Get single sequence as two bit. */ void twoBitFree(struct twoBit **pTwoBit); /* Free up a two bit structure. */ @@ -179,16 +192,17 @@ * specified twoBit file. Specifications are one per line in forms: * seqName * or * seqName:start-end */ void twoBitSpecFree(struct twoBitSpec **specPtr); /* free a twoBitSpec object */ void twoBitOutNBeds(struct twoBitFile *tbf, char *seqName, FILE *outF); /* output a series of bed3's that enumerate the number of N's in a sequence*/ int twoBitSeqSizeNoNs(struct twoBitFile *tbf, char *seqName); /* return the length of the sequence, not counting N's */ +struct twoBitFile *twoBitOpenExt(char *fileName, boolean useUdc); #endif /* TWOBIT_H */