1 | #define MEM_ALLOC_FACTOR 3/2 |
---|
2 | #define MEM_ALLOC_INIT_MASTER 3000 |
---|
3 | #define MEM_ALLOC_INIT_CLIENT 5000 |
---|
4 | #define MEM_ALLOC_INIT_MASTERS 30 |
---|
5 | #define MEM_ALLOC_INIT_CLIENTS 100 |
---|
6 | #define REL_DIFF_CLIENT_MASTER(x) x/150 |
---|
7 | #define MAX_REL_DIFF_CLIENT_MASTER(x) x/30 |
---|
8 | #define MAX_MASTERS 20 |
---|
9 | #define MAX_MASTERS_REMOVE_N 3 |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | #define PT_MAX_NN 3 |
---|
14 | #define PT_NAME_HASH_SIZE 10000 |
---|
15 | |
---|
16 | typedef enum PT_bases_enum { |
---|
17 | PT_QU = 0, |
---|
18 | PT_N = 1, |
---|
19 | PT_A, PT_C, PT_G, PT_T, PT_B_MAX } PT_BASES; |
---|
20 | |
---|
21 | #define PT_BASE_2_ASCII "?NACGT????" |
---|
22 | |
---|
23 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) |
---|
24 | |
---|
25 | // x is the relative index to the masters rel_2_abs list |
---|
26 | // y is the offset of rel_2_abs[rel] |
---|
27 | class master_gap_compress { |
---|
28 | public: |
---|
29 | int index; // used to save the master !!! |
---|
30 | int ref_cnt; |
---|
31 | class client_gap_compress *main_child; |
---|
32 | int alt_master; // is there any alternative master |
---|
33 | int memsize; |
---|
34 | int len; // save index |
---|
35 | long *rel_2_abs; // save mem |
---|
36 | short *rel_2_abss; // save mem |
---|
37 | master_gap_compress(void); |
---|
38 | ~master_gap_compress(void); |
---|
39 | void optimize(void); |
---|
40 | long read(long rel, long def_abs); |
---|
41 | void write(long rel, long abs); |
---|
42 | |
---|
43 | int save(FILE *out, int index_write, int &pos); |
---|
44 | int load(FILE *in, char *baseaddr); |
---|
45 | }; |
---|
46 | |
---|
47 | class client_gap_compress { |
---|
48 | long old_m; |
---|
49 | long old_rel; |
---|
50 | public: |
---|
51 | master_gap_compress *master; // save index as index !!!!! |
---|
52 | int memsize; |
---|
53 | int len; // save index |
---|
54 | struct client_gap_compress_data { // save mem |
---|
55 | long rel; |
---|
56 | short dx; |
---|
57 | short x; |
---|
58 | long y; |
---|
59 | } *l; |
---|
60 | long abs_seq_len; // save index |
---|
61 | long rel_seq_len; // save index |
---|
62 | |
---|
63 | |
---|
64 | client_gap_compress(master_gap_compress *mgc); |
---|
65 | void clean(master_gap_compress *mgc); |
---|
66 | ~client_gap_compress(void); |
---|
67 | void optimize(int realloc_flag); |
---|
68 | void basic_write(long rel, long x, long y); |
---|
69 | void write(long rel, long abs); |
---|
70 | void basic_write_sequence(char *sequence, long seq_len, int gap1,int gap2); |
---|
71 | void basic_write_master_sequence(char *sequence, long seq_len, int gap1,int gap2); |
---|
72 | void write_sequence(char *sequence, long seq_len, int gap1,int gap2); |
---|
73 | long rel_2_abs(long rel); |
---|
74 | int save(FILE *out, int index_write, int &pos); |
---|
75 | int load(FILE *in, char *baseaddr,master_gap_compress **masters); |
---|
76 | }; |
---|
77 | |
---|
78 | typedef int gap_index; |
---|
79 | |
---|
80 | class gap_compress { |
---|
81 | master_gap_compress *search_best_master(client_gap_compress *client, |
---|
82 | master_gap_compress *exclude,long max_diff, |
---|
83 | char *sequence, long seq_len, int gap1,int gap2, int &best_alt); |
---|
84 | int memmasters; |
---|
85 | int memclients; |
---|
86 | public: |
---|
87 | int nmasters; // save index |
---|
88 | master_gap_compress **masters; |
---|
89 | |
---|
90 | int nclients; // save index |
---|
91 | client_gap_compress **clients; |
---|
92 | |
---|
93 | gap_compress(void); |
---|
94 | ~gap_compress(void); |
---|
95 | |
---|
96 | gap_index write_sequence(char *sequence, long seq_len, |
---|
97 | int gap1, int gap2); |
---|
98 | |
---|
99 | char *read_sequence(gap_index index); // returns a '+-' seq. |
---|
100 | // returns an index for rel_2_abs |
---|
101 | void optimize(void); |
---|
102 | long rel_2_abs(gap_index index, long rel); |
---|
103 | void statistic(int full=1); |
---|
104 | |
---|
105 | int save(FILE *out, int index_write, int &pos); |
---|
106 | int load(FILE *in, char *baseaddr); |
---|
107 | }; |
---|
108 | |
---|
109 | class pt_species_class { |
---|
110 | public: |
---|
111 | //*************** not a public section !!!! |
---|
112 | int save(FILE *out, int index_write, int &pos); |
---|
113 | int load(FILE *in, char *baseaddr); |
---|
114 | client_gap_compress *cgc; |
---|
115 | void calc_gap_index(gap_compress *gc); |
---|
116 | char *abs_sequence; // including all gaps |
---|
117 | |
---|
118 | void set(char *sequence, long seq_len, char *name, char *fullname); |
---|
119 | |
---|
120 | //*************** here starts the read only section |
---|
121 | |
---|
122 | char *sequence; // save mem |
---|
123 | long abs_seq_len; // save index |
---|
124 | long seq_len; // save index |
---|
125 | char *name; // save index |
---|
126 | char *fullname; // save index |
---|
127 | gap_index index; // save index |
---|
128 | |
---|
129 | pt_species_class(void); |
---|
130 | ~pt_species_class(void); |
---|
131 | |
---|
132 | // ************* the real public section |
---|
133 | int get(int pos) { return sequence[pos]; }; |
---|
134 | long rel_2_abs(long rel); // after load |
---|
135 | |
---|
136 | void test_print(void); // after load |
---|
137 | }; |
---|
138 | |
---|
139 | class pt_main_class { |
---|
140 | void calc_name_hash(void); |
---|
141 | void calc_max_size_char_count(void); |
---|
142 | void calc_bi_ecoli(void); |
---|
143 | void init(GBDATA *gb_main); |
---|
144 | |
---|
145 | public: |
---|
146 | gap_compress *gc; |
---|
147 | pt_main_class(void); |
---|
148 | ~pt_main_class(void); |
---|
149 | |
---|
150 | int data_count; // save index |
---|
151 | char *ecoli; // save index |
---|
152 | |
---|
153 | pt_species_class *species; |
---|
154 | |
---|
155 | int save(GBDATA *gb_main, FILE *out, int index_write, int &pos); |
---|
156 | int load(FILE *in, char *baseaddr); |
---|
157 | |
---|
158 | |
---|
159 | long namehash; /* name to int */ |
---|
160 | int max_size; /* maximum sequence len */ |
---|
161 | long char_count; /* number of all 'acgtuACGTU' */ |
---|
162 | void *bi_ecoli; |
---|
163 | |
---|
164 | char *alignment_name; |
---|
165 | long abs_2_ecoli(long pos); |
---|
166 | int main_convert(GBDATA *gb_main, char *basename); |
---|
167 | int import_all(char *basename); |
---|
168 | }; |
---|
169 | |
---|
170 | |
---|
171 | char *pt_getstring(FILE *in); // reads short strings !!!! |
---|
172 | int pt_putstring(char *s,FILE *out); |
---|