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