1 #ifndef DYNAMITEhsptwohitscanHEADERFILE
2 #define DYNAMITEhsptwohitscanHEADERFILE
3 #ifdef _cplusplus
4 extern "C" {
5 #endif
6 #include "hsplookupscan.h"
7 
8 
9 #define TwoHitBufferLISTLENGTH 4096
10 #define TwoHitSequenceLISTLENGTH 90
11 
12 #define TWOHIT_FIRST_ENTRY  56
13 #define TWOHIT_FIRST_STORED 57
14 #define TWOHIT_HANDLED      58
15 
16 
17 typedef struct TwoHitStore {
18    int hit_state;
19    Sequence * target;
20    int target_pos;
21    int query_pos;
22    int diagonal;
23  } TwoHitStore;
24 
25 
26 #define TWOHIT_BLOCK_SIZE   40000
27 #define TWOHIT_BLOCK_DEPTH  1000
28 
29 typedef struct TwoHitStoreBlockAllocator {
30   TwoHitStore ** block;
31   int current_block;
32   int current_pos;
33   int block_len;
34 } TwoHitStoreBlockAllocator;
35 
36 
37 
38 struct Wise2_TwoHitSequence {
39     int dynamite_hard_link;
40 #ifdef PTHREAD
41     pthread_mutex_t dynamite_mutex;
42 #endif
43     TwoHitStore ** word;
44     int len;/* len for above word  */
45     int maxlen; /* maxlen for above word */
46     GHashTable  * diagonal_hash;
47     } ;
48 /* TwoHitSequence defined */
49 #ifndef DYNAMITE_DEFINED_TwoHitSequence
50 typedef struct Wise2_TwoHitSequence Wise2_TwoHitSequence;
51 #define TwoHitSequence Wise2_TwoHitSequence
52 #define DYNAMITE_DEFINED_TwoHitSequence
53 #endif
54 
55 
56 struct Wise2_TwoHitBuffer {
57     int dynamite_hard_link;
58 #ifdef PTHREAD
59     pthread_mutex_t dynamite_mutex;
60 #endif
61     TwoHitSequence ** buffer;
62     int len;/* len for above buffer  */
63     int maxlen; /* maxlen for above buffer */
64     GHashTable      * target_hash;
65     TwoHitStoreBlockAllocator * thba;
66     } ;
67 /* TwoHitBuffer defined */
68 #ifndef DYNAMITE_DEFINED_TwoHitBuffer
69 typedef struct Wise2_TwoHitBuffer Wise2_TwoHitBuffer;
70 #define TwoHitBuffer Wise2_TwoHitBuffer
71 #define DYNAMITE_DEFINED_TwoHitBuffer
72 #endif
73 
74 
75 
76 
77     /***************************************************/
78     /* Callable functions                              */
79     /* These are the functions you are expected to use */
80     /***************************************************/
81 
82 
83 
84 /* Function:  new_twohit_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff)
85  *
86  * Descrip:    Builds a twohit scan interface. This
87  *             does expands the query using a matrix but
88  *             just be considering off by one cases
89  *
90  *
91  * Arg:                 sli [UNKN ] Undocumented argument [SeqLookupInterface *]
92  * Arg:                 mat [UNKN ] Undocumented argument [CompMat *]
93  * Arg:            drop_off [UNKN ] Undocumented argument [int]
94  * Arg:        score_cutoff [UNKN ] Undocumented argument [int]
95  *
96  * Return [UNKN ]  Undocumented return value [HSPScanInterface *]
97  *
98  */
99 HSPScanInterface * Wise2_new_twohit_one_off_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff);
100 #define new_twohit_one_off_HSPScanInterface Wise2_new_twohit_one_off_HSPScanInterface
101 
102 
103 /* Function:  twohit_one_off_HSPscan_scan_query_direct(data,seq,para)
104  *
105  * Descrip:    Word expansion with two hit semantics
106  *
107  *
108  * Arg:        data [UNKN ] Undocumented argument [void *]
109  * Arg:         seq [UNKN ] Undocumented argument [Sequence *]
110  * Arg:        para [UNKN ] Undocumented argument [HSPScanInterfacePara *]
111  *
112  * Return [UNKN ]  Undocumented return value [LinearHSPmanager *]
113  *
114  */
115 LinearHSPmanager * Wise2_twohit_one_off_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para);
116 #define twohit_one_off_HSPscan_scan_query_direct Wise2_twohit_one_off_HSPscan_scan_query_direct
117 
118 
119 /* Function:  add_to_TwoHitBuffer(thb,target,query_pos,target_pos)
120  *
121  * Descrip:    adds a new potential hit to the TwoHitBuffer,
122  *             returning the HitStore datastructure updated
123  *             if hit is 1 then this is first entry
124  *             if hit is more than 1 second
125  *
126  *
127  * Arg:               thb [UNKN ] Undocumented argument [TwoHitBuffer *]
128  * Arg:            target [UNKN ] Undocumented argument [Sequence *]
129  * Arg:         query_pos [UNKN ] Undocumented argument [int]
130  * Arg:        target_pos [UNKN ] Undocumented argument [int]
131  *
132  * Return [UNKN ]  Undocumented return value [TwoHitStore *]
133  *
134  */
135 TwoHitStore * Wise2_add_to_TwoHitBuffer(TwoHitBuffer * thb,Sequence * target,int query_pos,int target_pos);
136 #define add_to_TwoHitBuffer Wise2_add_to_TwoHitBuffer
137 
138 
139 /* Function:  new_TwoHitBuffer(void)
140  *
141  * Descrip:    makes a new TwoHitBuffer ready for use
142  *
143  *
144  *
145  * Return [UNKN ]  Undocumented return value [TwoHitBuffer *]
146  *
147  */
148 TwoHitBuffer * Wise2_new_TwoHitBuffer(void);
149 #define new_TwoHitBuffer Wise2_new_TwoHitBuffer
150 
151 
152 /* Function:  new_TwoHitSequence(void)
153  *
154  * Descrip:    make a new TwoHitSequence ready for use
155  *
156  *
157  *
158  * Return [UNKN ]  Undocumented return value [TwoHitSequence *]
159  *
160  */
161 TwoHitSequence * Wise2_new_TwoHitSequence(void);
162 #define new_TwoHitSequence Wise2_new_TwoHitSequence
163 
164 
165 /* Function:  free_TwoHitSequence(t)
166  *
167  * Descrip:    Frees the TwoHitSequence
168  *
169  *
170  * Arg:        t [UNKN ] Undocumented argument [TwoHitSequence *]
171  *
172  * Return [UNKN ]  Undocumented return value [TwoHitSequence *]
173  *
174  */
175 TwoHitSequence * Wise2_free_TwoHitSequence(TwoHitSequence * t);
176 #define free_TwoHitSequence Wise2_free_TwoHitSequence
177 
178 
179 /* Function:  free_TwoHitBuffer(t)
180  *
181  * Descrip:    Frees the TwoHitBuffer
182  *
183  *
184  * Arg:        t [UNKN ] Undocumented argument [TwoHitBuffer *]
185  *
186  * Return [UNKN ]  Undocumented return value [TwoHitBuffer *]
187  *
188  */
189 TwoHitBuffer * Wise2_free_TwoHitBuffer(TwoHitBuffer * t);
190 #define free_TwoHitBuffer Wise2_free_TwoHitBuffer
191 
192 
193 /* Function:  TwoHitStore_alloc(void)
194  *
195  * Descrip:    allocator for twohitstore
196  *
197  *
198  *
199  * Return [UNKN ]  Undocumented return value [TwoHitStore *]
200  *
201  */
202 TwoHitStore * Wise2_TwoHitStore_alloc(void);
203 #define TwoHitStore_alloc Wise2_TwoHitStore_alloc
204 
205 
206 /* Function:  free_TwoHitStore(t)
207  *
208  * Descrip:    free for twohitstore
209  *
210  *
211  * Arg:        t [UNKN ] Undocumented argument [TwoHitStore *]
212  *
213  * Return [UNKN ]  Undocumented return value [TwoHitStore *]
214  *
215  */
216 TwoHitStore * Wise2_free_TwoHitStore(TwoHitStore * t);
217 #define free_TwoHitStore Wise2_free_TwoHitStore
218 
219 
220 /* Function:  new_TwoHitStore_from_Allocator(a)
221  *
222  * Descrip:    gets a new store from a block allocator
223  *
224  *
225  * Arg:        a [UNKN ] Undocumented argument [TwoHitStoreBlockAllocator *]
226  *
227  * Return [UNKN ]  Undocumented return value [TwoHitStore *]
228  *
229  */
230 TwoHitStore * Wise2_new_TwoHitStore_from_Allocator(TwoHitStoreBlockAllocator * a);
231 #define new_TwoHitStore_from_Allocator Wise2_new_TwoHitStore_from_Allocator
232 
233 
234 /* Function:  free_TwoHitStoreBlockAllocator(a)
235  *
236  * Descrip:    frees a block allocator
237  *
238  *
239  * Arg:        a [UNKN ] Undocumented argument [TwoHitStoreBlockAllocator *]
240  *
241  * Return [UNKN ]  Undocumented return value [TwoHitStoreBlockAllocator *]
242  *
243  */
244 TwoHitStoreBlockAllocator * Wise2_free_TwoHitStoreBlockAllocator(TwoHitStoreBlockAllocator * a);
245 #define free_TwoHitStoreBlockAllocator Wise2_free_TwoHitStoreBlockAllocator
246 
247 
248 /* Function:  new_TwoHitStoreBlockAllocator(void)
249  *
250  * Descrip:    makes a new block allocator
251  *
252  *
253  *
254  * Return [UNKN ]  Undocumented return value [TwoHitStoreBlockAllocator *]
255  *
256  */
257 TwoHitStoreBlockAllocator * Wise2_new_TwoHitStoreBlockAllocator(void);
258 #define new_TwoHitStoreBlockAllocator Wise2_new_TwoHitStoreBlockAllocator
259 
260 
261 /* Function:  add_TwoHitSequence(obj,add)
262  *
263  * Descrip:    Adds another object to the list. It will expand the list if necessary
264  *
265  *
266  * Arg:        obj [UNKN ] Object which contains the list [TwoHitSequence *]
267  * Arg:        add [OWNER] Object to add to the list [TwoHitStore *]
268  *
269  * Return [UNKN ]  Undocumented return value [boolean]
270  *
271  */
272 boolean Wise2_add_TwoHitSequence(TwoHitSequence * obj,TwoHitStore * add);
273 #define add_TwoHitSequence Wise2_add_TwoHitSequence
274 
275 
276 /* Function:  flush_TwoHitSequence(obj)
277  *
278  * Descrip:    Frees the list elements, sets length to 0
279  *             If you want to save some elements, use hard_link_xxx
280  *             to protect them from being actually destroyed in the free
281  *
282  *
283  * Arg:        obj [UNKN ] Object which contains the list  [TwoHitSequence *]
284  *
285  * Return [UNKN ]  Undocumented return value [int]
286  *
287  */
288 int Wise2_flush_TwoHitSequence(TwoHitSequence * obj);
289 #define flush_TwoHitSequence Wise2_flush_TwoHitSequence
290 
291 
292 /* Function:  TwoHitSequence_alloc_std(void)
293  *
294  * Descrip:    Equivalent to TwoHitSequence_alloc_len(TwoHitSequenceLISTLENGTH)
295  *
296  *
297  *
298  * Return [UNKN ]  Undocumented return value [TwoHitSequence *]
299  *
300  */
301 TwoHitSequence * Wise2_TwoHitSequence_alloc_std(void);
302 #define TwoHitSequence_alloc_std Wise2_TwoHitSequence_alloc_std
303 
304 
305 /* Function:  TwoHitSequence_alloc_len(len)
306  *
307  * Descrip:    Allocates len length to all lists
308  *
309  *
310  * Arg:        len [UNKN ] Length of lists to allocate [int]
311  *
312  * Return [UNKN ]  Undocumented return value [TwoHitSequence *]
313  *
314  */
315 TwoHitSequence * Wise2_TwoHitSequence_alloc_len(int len);
316 #define TwoHitSequence_alloc_len Wise2_TwoHitSequence_alloc_len
317 
318 
319 /* Function:  hard_link_TwoHitSequence(obj)
320  *
321  * Descrip:    Bumps up the reference count of the object
322  *             Meaning that multiple pointers can 'own' it
323  *
324  *
325  * Arg:        obj [UNKN ] Object to be hard linked [TwoHitSequence *]
326  *
327  * Return [UNKN ]  Undocumented return value [TwoHitSequence *]
328  *
329  */
330 TwoHitSequence * Wise2_hard_link_TwoHitSequence(TwoHitSequence * obj);
331 #define hard_link_TwoHitSequence Wise2_hard_link_TwoHitSequence
332 
333 
334 /* Function:  TwoHitSequence_alloc(void)
335  *
336  * Descrip:    Allocates structure: assigns defaults if given
337  *
338  *
339  *
340  * Return [UNKN ]  Undocumented return value [TwoHitSequence *]
341  *
342  */
343 TwoHitSequence * Wise2_TwoHitSequence_alloc(void);
344 #define TwoHitSequence_alloc Wise2_TwoHitSequence_alloc
345 
346 
347 /* Function:  add_TwoHitBuffer(obj,add)
348  *
349  * Descrip:    Adds another object to the list. It will expand the list if necessary
350  *
351  *
352  * Arg:        obj [UNKN ] Object which contains the list [TwoHitBuffer *]
353  * Arg:        add [OWNER] Object to add to the list [TwoHitSequence *]
354  *
355  * Return [UNKN ]  Undocumented return value [boolean]
356  *
357  */
358 boolean Wise2_add_TwoHitBuffer(TwoHitBuffer * obj,TwoHitSequence * add);
359 #define add_TwoHitBuffer Wise2_add_TwoHitBuffer
360 
361 
362 /* Function:  flush_TwoHitBuffer(obj)
363  *
364  * Descrip:    Frees the list elements, sets length to 0
365  *             If you want to save some elements, use hard_link_xxx
366  *             to protect them from being actually destroyed in the free
367  *
368  *
369  * Arg:        obj [UNKN ] Object which contains the list  [TwoHitBuffer *]
370  *
371  * Return [UNKN ]  Undocumented return value [int]
372  *
373  */
374 int Wise2_flush_TwoHitBuffer(TwoHitBuffer * obj);
375 #define flush_TwoHitBuffer Wise2_flush_TwoHitBuffer
376 
377 
378 /* Function:  TwoHitBuffer_alloc_std(void)
379  *
380  * Descrip:    Equivalent to TwoHitBuffer_alloc_len(TwoHitBufferLISTLENGTH)
381  *
382  *
383  *
384  * Return [UNKN ]  Undocumented return value [TwoHitBuffer *]
385  *
386  */
387 TwoHitBuffer * Wise2_TwoHitBuffer_alloc_std(void);
388 #define TwoHitBuffer_alloc_std Wise2_TwoHitBuffer_alloc_std
389 
390 
391 /* Function:  TwoHitBuffer_alloc_len(len)
392  *
393  * Descrip:    Allocates len length to all lists
394  *
395  *
396  * Arg:        len [UNKN ] Length of lists to allocate [int]
397  *
398  * Return [UNKN ]  Undocumented return value [TwoHitBuffer *]
399  *
400  */
401 TwoHitBuffer * Wise2_TwoHitBuffer_alloc_len(int len);
402 #define TwoHitBuffer_alloc_len Wise2_TwoHitBuffer_alloc_len
403 
404 
405 /* Function:  hard_link_TwoHitBuffer(obj)
406  *
407  * Descrip:    Bumps up the reference count of the object
408  *             Meaning that multiple pointers can 'own' it
409  *
410  *
411  * Arg:        obj [UNKN ] Object to be hard linked [TwoHitBuffer *]
412  *
413  * Return [UNKN ]  Undocumented return value [TwoHitBuffer *]
414  *
415  */
416 TwoHitBuffer * Wise2_hard_link_TwoHitBuffer(TwoHitBuffer * obj);
417 #define hard_link_TwoHitBuffer Wise2_hard_link_TwoHitBuffer
418 
419 
420 /* Function:  TwoHitBuffer_alloc(void)
421  *
422  * Descrip:    Allocates structure: assigns defaults if given
423  *
424  *
425  *
426  * Return [UNKN ]  Undocumented return value [TwoHitBuffer *]
427  *
428  */
429 TwoHitBuffer * Wise2_TwoHitBuffer_alloc(void);
430 #define TwoHitBuffer_alloc Wise2_TwoHitBuffer_alloc
431 
432 
433   /* Unplaced functions */
434   /* There has been no indication of the use of these functions */
435 
436 
437     /***************************************************/
438     /* Internal functions                              */
439     /* you are not expected to have to call these      */
440     /***************************************************/
441 void Wise2_swap_TwoHitSequence(TwoHitStore ** list,int i,int j) ;
442 #define swap_TwoHitSequence Wise2_swap_TwoHitSequence
443 void Wise2_qsort_TwoHitSequence(TwoHitStore ** list,int left,int right,int (*comp)(TwoHitStore * ,TwoHitStore * ));
444 #define qsort_TwoHitSequence Wise2_qsort_TwoHitSequence
445 void Wise2_sort_TwoHitSequence(TwoHitSequence * obj,int (*comp)(TwoHitStore *, TwoHitStore *));
446 #define sort_TwoHitSequence Wise2_sort_TwoHitSequence
447 boolean Wise2_expand_TwoHitSequence(TwoHitSequence * obj,int len);
448 #define expand_TwoHitSequence Wise2_expand_TwoHitSequence
449 void Wise2_swap_TwoHitBuffer(TwoHitSequence ** list,int i,int j) ;
450 #define swap_TwoHitBuffer Wise2_swap_TwoHitBuffer
451 void Wise2_qsort_TwoHitBuffer(TwoHitSequence ** list,int left,int right,int (*comp)(TwoHitSequence * ,TwoHitSequence * ));
452 #define qsort_TwoHitBuffer Wise2_qsort_TwoHitBuffer
453 void Wise2_sort_TwoHitBuffer(TwoHitBuffer * obj,int (*comp)(TwoHitSequence *, TwoHitSequence *));
454 #define sort_TwoHitBuffer Wise2_sort_TwoHitBuffer
455 boolean Wise2_expand_TwoHitBuffer(TwoHitBuffer * obj,int len);
456 #define expand_TwoHitBuffer Wise2_expand_TwoHitBuffer
457 
458 #ifdef _cplusplus
459 }
460 #endif
461 
462 #endif
463