1 /* $Id: iitdef.h 157223 2015-01-22 18:43:01Z twu $ */ 2 #ifndef IITDEF_INCLUDED 3 #define IITDEF_INCLUDED 4 #ifdef HAVE_CONFIG_H 5 #include <config.h> /* For HAVE_SYS_TYPES_H, HAVE_PTHREAD */ 6 #endif 7 8 #ifdef HAVE_SYS_TYPES_H 9 # include <sys/types.h> /* Needed to define pthread_t on Solaris */ 10 #endif 11 #ifdef HAVE_PTHREAD 12 #include <pthread.h> 13 #endif 14 #include "bool.h" 15 #include "access.h" 16 #include "interval.h" 17 #include "types.h" 18 19 20 #define IIT_LATEST_VERSION_NOVALUES 5 21 #define IIT_LATEST_VERSION_VALUES 6 22 23 24 /* version 1 starts with nintervals (now handled separately as a Univ_IIT_T) */ 25 /* version 2 starts with 0, then version number. Also adds sign to each interval. */ 26 /* version 3 allows for multiple divs */ 27 /* version 4 has label and annot pointers being 8-byte long unsigned ints */ 28 29 /* version 5 has two extra fields indicating whether label pointers are 30 4- or 8-bytes and whether annot pointers are 4- or 8-bytes. Also 31 stores rest of header line with annotation, so NULL => print '\n', 32 otherwise print annotation. */ 33 34 /* version 6 is like version 5, except it sorts intervals by a value 35 field. The intent is to have both versions 5 and 6 in current use. */ 36 37 38 typedef enum {NO_SORT, ALPHA_SORT, NUMERIC_ALPHA_SORT, CHROM_SORT, FILENAME_SORT} Sorttype_T; 39 40 typedef struct FNode_T *FNode_T; 41 struct FNode_T { 42 Chrpos_T value; 43 int a; 44 int b; 45 int leftindex; 46 int rightindex; 47 }; 48 49 50 #define T IIT_T 51 typedef struct T *T; 52 struct T { 53 char *name; /* Name of IIT (optional) */ 54 int version; 55 bool label_pointers_8p; 56 bool annot_pointers_8p; 57 58 int fd; 59 Access_T access; /* access type */ 60 61 #ifdef HAVE_PTHREAD 62 pthread_mutex_t read_mutex; 63 #endif 64 65 int ntypes; /* Always >= 1 */ 66 int nfields; /* Can be zero */ 67 68 int divsort; /* Really Sorttype_T */ 69 int ndivs; 70 UINT4 *divpointers; 71 char *divstrings; 72 73 int total_nintervals; 74 int *nintervals; /* Per div */ 75 int *cum_nintervals; 76 int *nnodes; /* Per div */ 77 int *cum_nnodes; 78 79 int **alphas; /* Strict ordering of Interval_low */ 80 int **betas; /* Strict ordering of Interval_high */ 81 int **sigmas; /* Ordering for IIT */ 82 int **omegas; /* Ordering for IIT */ 83 84 struct FNode_T **nodes; /* Per div */ 85 struct Interval_T **intervals; /* Per div */ 86 87 UINT4 *typepointers; 88 char *typestrings; 89 90 UINT4 *fieldpointers; 91 char *fieldstrings; 92 93 off_t valueorder_offset; 94 size_t valueorder_length; /* mmap length (mmap uses size_t, not off_t) */ 95 char *valueorder_mmap; 96 97 off_t value_offset; 98 size_t value_length; /* mmap length (mmap uses size_t, not off_t) */ 99 char *value_mmap; 100 101 off_t labelorder_offset; 102 size_t labelorder_length; /* mmap length (mmap uses size_t, not off_t) */ 103 char *labelorder_mmap; 104 105 off_t labelpointers_offset; 106 size_t labelpointers_length; /* mmap length (mmap uses size_t, not off_t) */ 107 char *labelpointers_mmap; 108 109 off_t label_offset; 110 size_t label_length; /* mmap length (mmap uses size_t, not off_t) */ 111 char *label_mmap; 112 113 off_t annotpointers_offset; 114 size_t annotpointers_length; /* mmap length (mmap uses size_t, not off_t) */ 115 char *annotpointers_mmap; 116 117 off_t annot_offset; 118 size_t annot_length; /* mmap length (mmap uses size_t, not off_t) */ 119 char *annot_mmap; 120 121 int *labelorder; 122 UINT4 *labelpointers; 123 #ifdef HAVE_64_BIT 124 UINT8 *labelpointers8; 125 #endif 126 char *labels; 127 128 bool valuep; 129 int *valueorder; /* For version 6 IITs */ 130 double *values; /* For version 6 IITs */ 131 132 UINT4 *annotpointers; 133 #ifdef HAVE_64_BIT 134 UINT8 *annotpointers8; 135 #endif 136 char *annotations; 137 138 void **datapointers; 139 }; 140 141 142 #undef T 143 #endif 144