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