1 #ifndef _MBALIGN_H_
2 #define _MBALIGN_H_
3 
4 #include <ncbi.h>
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 typedef Uint4 edit_op_t; /* 32 bits */
11 typedef struct {
12     edit_op_t *op;                  /* array of edit operations */
13     Uint4 size, num;         /* size of allocation, number in use */
14     edit_op_t last;                 /* most recent operation added */
15 } edit_script_t;
16 
17 edit_script_t *edit_script_free(edit_script_t *es);
18 edit_script_t *edit_script_new(void);
19 edit_script_t *edit_script_append(edit_script_t *es, edit_script_t *et);
20 
21 enum {
22     EDIT_OP_MASK = 0x3,
23     EDIT_OP_ERR  = 0x0,
24     EDIT_OP_INS  = 0x1,
25     EDIT_OP_DEL  = 0x2,
26     EDIT_OP_REP  = 0x3
27 };
28 
29 enum {         /* half of the (fixed) match score */
30     ERROR_FRACTION=2,  /* 1/this */
31     MAX_SPACE=1000000,
32     sC = 0, sI = 1, sD = 2, LARGE=100000000
33 };
34 
35 /* ----- pool allocator ----- */
36 typedef struct _three_val_ {
37     Int4 I, C, D;
38 } ThreeVal, PNTR ThreeValPtr;
39 
40 typedef struct mb_space_struct {
41     ThreeValPtr space_array;
42     Int4 used, size;
43     struct mb_space_struct *next;
44 } MBSpace, *MBSpacePtr;
45 
46 #define EDIT_VAL(op) (op >> 2)
47 
48 #define EDIT_OPC(op) (op & EDIT_OP_MASK)
49 
50 MBSpacePtr new_mb_space(void);
51 void refresh_mb_space(MBSpacePtr sp);
52 void free_mb_space(MBSpacePtr sp);
53 ThreeValPtr get_mb_space(MBSpacePtr S, Int4 amount);
54 
55 typedef struct greedy_align_mem {
56    Int4Ptr PNTR flast_d;
57    Int4Ptr max_row_free;
58    ThreeValPtr PNTR flast_d_affine;
59    Int4Ptr uplow_free;
60    MBSpacePtr space;
61 } GreedyAlignMem, PNTR GreedyAlignMemPtr;
62 
63 Int4
64 MegaBlastGreedyAlign PROTO((const UcharPtr s1, Int4 len1,
65 			     const UcharPtr s2, Int4 len2,
66 			     Boolean reverse, Int4 xdrop_threshold,
67 			     Int4 match_cost, Int4 mismatch_cost,
68 			     Int4Ptr e1, Int4Ptr e2, GreedyAlignMemPtr abmp,
69 			     edit_script_t *S, Uint1 rem));
70 Int4
71 MegaBlastAffineGreedyAlign PROTO((const UcharPtr s1, Int4 len1,
72 				  const UcharPtr s2, Int4 len2,
73 				  Boolean reverse, Int4 xdrop_threshold,
74 				  Int4 match_cost, Int4 mismatch_cost,
75 				  Int4 gap_open, Int4 gap_extend,
76 				  Int4Ptr e1, Int4Ptr e2,
77 				  GreedyAlignMemPtr abmp,
78 				  edit_script_t *S, Uint1 rem));
79 
80 
81 
82 GreedyAlignMemPtr
83 GreedyAlignMemFree PROTO((GreedyAlignMemPtr abmp));
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 #endif /* _MBALIGN_H_ */
89