modified: nfig1.py
[GalaxyCodeBases.git] / c_cpp / readscorr / gFileIO.h
blob7ef94db6a2d1e62e2564a539a035deffb5a5457a
1 // by Hu Xuesong
2 #ifndef _G_FILEIO_H
3 #define _G_FILEIO_H
5 #include "gFileType.h" // for file ID
6 #include <stdint.h> // uint64_t
7 //#include "sdleft.h"
9 #define GFIOCHRBASE 1
10 #define GFIODIBBASE 2
12 #ifndef KSTRING_T
13 #define KSTRING_T kstring_t
14 typedef struct __kstring_t {
15 size_t l, m; // l for sequence length in base-pairs, m for malloc in bytes.
16 char *s; // for 2bit ATCG, 1bp=2bit; for 6bit quality, 1bp=6bit.
17 } kstring_t;
18 #endif // Yes, it is the same as that in kseq.h
20 //typedef ssize_t (*G_ssize_t_oneIN)(void * const);
21 //typedef void (*G_p_oneIN)(void * const);
22 struct __SeqFileObj;
23 typedef ssize_t (G_ssize_t_oneIN)(struct __SeqFileObj * const);
24 typedef void (G_p_oneIN)(struct __SeqFileObj * const);
26 typedef struct __SeqFileObj {
27 size_t readlength,binNcount,binMallocedQQWord;
28 const char *name, *comment, *seq, *qual;
29 // $ cdecl explain "char * const* name"
30 // declare name as pointer to const pointer to char
31 uint64_t *diBseq; // 2bit, {A,C,G,T}={0,1,2,3}
32 unsigned char *hexBQ; // 0~63 for Quality, 128 for N, 64 for Eamss-masked or smallcase-masked
33 //int (*getNextSeq)(void *); // void * fh
34 G_ssize_t_oneIN *getNextSeq;
35 G_p_oneIN *closefh; // remember to close file handle
36 //= void (*closefh)(struct __SeqFileObj * const);
37 void *fobj; // Not just FILE *fp
38 long datePos[1]; // [1] for item id, [0] for offset. For Text file, item id == 0.
39 //long datePosOffset,datePosItem;
40 uint_fast8_t type; // 1->hasBaseChr, 2->hasQchar, 4->hasBase2bit,
41 // 8->hashexBQ or just array of {0,128} for N,
42 // 16->Eamss bit set, 32->Q value not raw, after Eamss.
43 } SeqFileObj; // We may support both FA/FQ and binary formats. So, object is a good thing.
45 SeqFileObj * inSeqFinit(const char * const, unsigned char);
46 //ssize_t inSeqFreadNext(SeqFileObj * const);
47 int inSeqFseek(SeqFileObj * const, const fpos_t datePos[]);
48 void inSeqFdestroy(SeqFileObj * const);
50 #endif /* gFileIO.h */