+ parameter transfer to python layer works
[qpalma.git] / QPalmaDP / 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, 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
36 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);
37
38 extern void print_align(Pre_score* matrix, int length_est, int length_dna, Align_pair* vektor, int result_length, int print_matrix);
39
40
41 /*
42 * The function myalign calculates a new alignment given the scoring scheme
43 * Its input arguments are:
44 *
45 * num_path(id) -> an integer specifying which alignment has to be done
46 * dna ->
47 * est ->
48 * h ->
49 * mmatrix ->
50 * donor ->
51 * acceptor ->
52 * remove_duplicate_scores -> a boolean
53 * print_matrix -> a boolean
54 *
55 * [SpliceAlign, EstAlign, weightMatch, Gesamtscores, dnaest] = myalign_local(...
56 *
57 * the idea of the qualityScores array is as follows
58 *
59 * consider a matrix of 24 plifs
60 *
61 * -> row major
62 *
63 */
64
65 class Alignment {
66
67 private:
68 int* splice_align;
69 int* est_align;
70 int* mmatrix_param;
71 double* alignmentscores;
72 double* qualityMatrix;
73
74 int dna_len;
75 int est_len;
76 int mlen;
77 int nr_paths;
78
79 uint splice_align_size ;
80 uint est_align_size ;
81 uint mmatrix_param_size ;
82 uint alignmentscores_size ;
83 uint qScores_size ;
84
85 struct penalty_struct* qualityScoresAllPaths;
86
87 INT len;
88 REAL *limits;
89 REAL *penalties;
90 INT max_len;
91 INT min_len;
92 REAL *cache;
93 enum ETransformType transform ;
94 INT id;
95 char * name;
96 INT use_svm;
97
98 public:
99 Alignment();
100 ~Alignment() {
101 if(splice_align != 0)
102 delete[] splice_align;
103
104 if(est_align != 0)
105 delete[] est_align;
106
107 if(mmatrix_param != 0)
108 delete[] mmatrix_param;
109
110 if(alignmentscores != 0)
111 delete[] alignmentscores;
112 }
113
114 void myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
115 int est_len_p, double* prb, double* chastity, struct penalty_struct h,
116 double* matchmatrix, int mm_len, double* donor, int d_len, double* acceptor,
117 int a_len, struct penalty_struct* qualityScores, bool remove_duplicate_scores,
118 bool print_matrix);
119
120 void penSetLength(int l) { len = l; }
121 void penSetLimits(REAL* lts) {
122 limits = new REAL[len];
123 for(int i=0; i<len; i++)
124 limits[i] = lts[i];
125 }
126
127 void setQualityMatrix(double* qMat, int length);
128 void getDNAEST();
129 void getAlignmentResults(int* s_align, int* e_align,
130 int* mmatrix_p, double* alignscores, penalty_struct* qScores);
131 };
132
133 #endif // _QPALMA_DP_H_
134