+ rearranged code
[qpalma.git] / dyn_prog / qpalma_dp.h
1 #ifndef _QPALMA_DP_H_
2 #define _QPALMA_DP_H_
3
4 #include "penalty_info.h"
5
6 struct ArrayElem { //24B
7 double score;
8 int prev_j;
9 int prev_i;
10 int prev_matrix_no;
11 bool isSplice;
12 } ;
13
14 struct pre_score { //24B
15 double value; //8
16 int prev_i; //4
17 int prev_j; //4
18 int prev_matrix_no;//4
19 bool issplice;//4
20 };
21
22 typedef struct pre_score Pre_score;
23
24 typedef struct Align_pair { //24B
25 double value ;
26 bool issplice;
27 int previ,prevj ;
28 char est_char;
29 char dna_char;
30 };
31
32 void fill_matrix (int nr_paths, Pre_score* matrices[], int len_est, int len_dna, char* est, char* dna, double* prb, penalty_struct* functions, double* matchmatrix, penalty_struct* qualityScores, double* donor, double* acceptor, bool remove_duplicate_scores, int nr_donor_sites, int* donor_sites, int* max_score_positions, mode currentMode);
33
34 int check_char(char base);
35 void fassert(bool exp,int line, char* file);
36 #define FA(expr) (fassert(expr,__LINE__,__FILE__))
37
38 bool result_align (Pre_score* matrices[], int matrixnr, int i, int j, int* result_length_ptr, char* est, char* dna, double* prb, double* chastity, int* s_align, int* e_align, int* m_param, double* alignmentscores, int* max_score_positions, penalty_struct* qparam, mode currentMode);
39
40 extern void print_align(Pre_score* matrix, int length_est, int length_dna, Align_pair* vektor, int result_length, int print_matrix);
41
42
43 /*
44 * The function myalign calculates a new alignment given the scoring scheme
45 * Its input arguments are:
46 *
47 * num_path(id) -> an integer specifying which alignment has to be done
48 * dna ->
49 * est ->
50 * h ->
51 * mmatrix ->
52 * donor ->
53 * acceptor ->
54 * remove_duplicate_scores -> a boolean
55 * print_matrix -> a boolean
56 *
57 * [SpliceAlign, EstAlign, weightMatch, Gesamtscores, dnaest] = myalign_local(...
58 *
59 * the idea of the qualityScores array is as follows
60 *
61 * consider a matrix of 24 plifs
62 *
63 * -> row major
64 *
65 */
66
67 class Alignment {
68
69 private:
70 int* splice_align;
71 int* est_align;
72 int* mmatrix_param;
73 double* alignmentscores;
74 struct penalty_struct** qualityScoresAllPaths;
75
76 int dna_len;
77 int est_len;
78 int mlen;
79 int nr_paths;
80
81 int result_len;
82 int* DNA_ARRAY;
83 int* EST_ARRAY;
84
85 int numQualSuppPoints;
86 int numPlifs;
87 bool use_quality_scores;
88
89 uint splice_align_size ;
90 uint est_align_size ;
91 uint mmatrix_param_size ;
92 uint alignmentscores_size ;
93 uint numPathsPlifs ;
94
95 INT len;
96 REAL *limits;
97 REAL *penalties;
98 INT max_len;
99 INT min_len;
100 REAL *cache;
101 enum ETransformType transform ;
102 INT id;
103 char * name;
104 INT use_svm;
105
106 public:
107 Alignment(int numQPlifs ,int numq, bool use_qscores);
108 ~Alignment() {
109 if(splice_align != 0)
110 delete[] splice_align;
111
112 if(est_align != 0)
113 delete[] est_align;
114
115 if(mmatrix_param != 0)
116 delete[] mmatrix_param;
117
118 if(alignmentscores != 0)
119 delete[] alignmentscores;
120
121 if(qualityScoresAllPaths != 0)
122 delete[] qualityScoresAllPaths;
123 }
124
125 void myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
126 int est_len_p, double* prb, double* chastity, struct penalty_struct h,
127 double* matchmatrix, int mm_len, double* donor, int d_len, double* acceptor,
128 int a_len, struct penalty_struct* qualityScores, bool remove_duplicate_scores,
129 bool print_matrix);
130
131 void getDNAEST();
132 void getAlignmentResults(int* s_align, int* e_align,
133 int* mmatrix_p, double* alignscores, double* qScores);
134
135 int getResultLength() { return result_len; }
136 void getAlignmentArrays(int* dna_align, int* est_align);
137 };
138
139 #endif // _QPALMA_DP_H_