ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/GCdbYank.h
Revision: 16
Committed: Mon Jul 18 20:56:02 2011 UTC (8 years, 2 months ago) by gpertea
File size: 1950 byte(s)
Log Message:
sync with local source

Line User Rev File contents
1 gpertea 2 #ifndef _GCDBYANK_H
2     #define _GCDBYANK_H
3    
4     #include "gcdb.h"
5     #include <stdio.h>
6     #include "GFastaFile.h"
7     // FastaSeq class and *charFunc() callback type
8    
9     #define DEF_CDBREC_DELIM ">"
10    
11     #ifdef ENABLE_COMPRESSION
12     #include <zlib.h>
13     #define GCDBZ_SBUF_LEN 8192
14     #define GCDBZ_LBUF_LEN 8192*2
15    
16     class GCdbZFasta {
17     private:
18     char* recdelim;
19     char lbuf[GCDBZ_LBUF_LEN]; //larger buffer
20     char sbuf[GCDBZ_SBUF_LEN]; //smaller buffer
21     char* defline; //defline copy storage -- compression only
22     int defline_cap; //currently allocated length of defline
23     int defline_len; //currently used length of defline
24     z_stream zstream; // de/compression stream
25     FILE* zf; //compressed file
26     long zpos; //current position in zf
27     int zrecsize; // the size of the compressed record
28     GFastaCharHandler* chrhandler;
29     public:
30     GCdbZFasta(FILE* af, int zrsize=0, char* r_delim=DEF_CDBREC_DELIM);
31     ~GCdbZFasta();
32     FILE* getZFile() { return zf; }
33     void decomp_start(int zrsize);
34     void decomp_end();
35     int decompress(FastaSeq& rec, int csize=0, int zfofs=-1, charFunc* seqCallBack=NULL);
36     // uncompress csize bytes from file zf, from optional file offset zfofs,
37     // and send the uncompressed stream to callbackFn
38     };
39    
40     #endif
41    
42     class GCdbYank {
43     char* idxfile;
44     char* dbfile;
45     char* recdelim; //record delimiter -- typically ">"
46     int warnings;
47     bool is_compressed;
48     char* dbname;
49     char* info_dbname;
50     off_t db_size;
51     cdbInfo dbstat;
52     GCdbRead* cdb;
53     #ifdef ENABLE_COMPRESSION
54     GCdbZFasta* cdbz;
55     #endif
56     int fdb;
57     int fd;
58     FILE* fz; // if compressed
59     GFastaCharHandler* fastahandler;
60     #ifdef ENABLE_COMPRESSION
61     protected:
62     GCdbZFasta* openCdbz(char* p);
63     #endif
64     public:
65     GCdbYank(const char* fidx, const char* recsep=DEF_CDBREC_DELIM);
66     ~GCdbYank();
67     int getRecord(const char* key, FastaSeq& rec, charFunc* seqCallBack=NULL);
68 gpertea 16 off_t getRecordPos(const char* key, uint32* record_len=NULL);
69 gpertea 2 char* getDbName() { return dbname; }
70    
71     };
72    
73     #endif