11 #ifndef ALI_PROFILE_HXX
12 #define ALI_PROFILE_HXX
21 #define ALI_PROFILE_BORDER_LEFT '['
22 #define ALI_PROFILE_BORDER_RIGHT ']'
70 unsigned long prof_len;
74 unsigned long helix_len;
76 float (**base_weights)[4];
77 float (**sub_costs)[6];
78 float sub_costs_maximum;
81 float multi_insert_cost;
83 float multi_gap_factor;
85 float (*binding_costs)[5][5];
88 unsigned long *lmin, *lmax;
90 float ***gap_percents;
92 int is_binding_marker(
char c);
99 int find_next_helix(
char h[],
unsigned long h_len,
unsigned long pos,
100 unsigned long *helix_nr,
101 unsigned long *
start,
unsigned long *end);
102 int find_comp_helix(
char h[],
unsigned long h_len,
unsigned long pos,
103 unsigned long helix_nr,
104 unsigned long *start,
unsigned long *end);
105 void delete_comp_helix(
char h1[],
char h2[],
unsigned long h_len,
106 unsigned long start,
unsigned long end);
117 void print(
int start = -1,
int end = -1) {
121 if (start < 0 || (
unsigned long)(start) > prof_len - 1)
124 if ((
unsigned long)(end) > prof_len - 1 || end < 0)
125 end = (
int)prof_len - 1;
134 printf(
"\nProfile from %d to %d\n", start, end);
135 printf(
"Substitutions kosten:\n");
136 for (i = start; i <= end; i++) {
138 for (j = 0; j < 6; j++)
139 printf(
"%4.2f ", (*sub_costs)[i][j]);
143 printf(
"\nGap Bereiche:\n");
144 for (i = start; i <= end; i++) {
145 printf(
"%2d: %3ld %3ld\n", i, lmin[i], lmax[i]);
147 for (j = 0; j <= lmax[i] - lmin[i] + 1; j++)
148 printf(
"%4.2f ", (*gap_percents)[i][j]);
150 for (j = 0; j <= lmax[i] - lmin[i] + 1; j++)
151 printf(
"%4.2f ", (*gap_costs)[i][j]);
158 unsigned long *first,
unsigned long *last);
160 unsigned long *first,
unsigned long *last);
162 if (pos >= helix_len)
165 return (*helix)[pos];
172 for (l = (
long) pos - 1; l >= 0; l--)
173 switch ((*helix_borders)[l]) {
179 for (l = (
long) pos + 1; l < (
long) prof_len; l++)
180 switch ((*helix_borders)[l]) {
190 return norm_sequence->
is_begin(pos + 1);
196 char *
str, *str_buffer;
198 str = (
char *) calloc((
unsigned int) prof_len,
sizeof(
char));
202 for (i = 0; i < prof_len; i++)
203 switch ((*helix_borders)[i]) {
206 default: *str++ =
' ';
215 return norm_sequence;
218 return norm_sequence->
length();
224 return (*base_weights)[pos][c];
227 float w_sub(
unsigned long positiony,
unsigned long positionx) {
228 return (*sub_costs)[positiony][norm_sequence->
base(positionx)];
231 return (*sub_costs)[positiony][4];
234 return (*sub_costs)[positiony][4] * multi_gap_factor;
239 for (i = start; i <= end; i++)
241 return costs * multi_gap_factor;
245 return sub_costs_maximum;
248 float w_del(
unsigned long begin,
unsigned long end) {
249 if (begin <= lmin[end])
250 return (*gap_costs)[end][0];
252 if (begin <= lmax[end])
253 return (*gap_costs)[end][begin - lmin[end]];
255 return (*gap_costs)[end][lmax[end] - lmin[end] + 1];
259 return (*gap_costs)[position][0];
264 for (i = start; i <= end; i++)
265 costs +=
w_del(start, i);
271 for (i = start; i <= end; i++)
278 for (i = start; i <= end; i++)
279 costs +=
w_del(i, i);
283 float w_ins(
unsigned long ,
unsigned long ) {
287 return multi_insert_cost;
290 return (endx - startx + 1) * insert_cost;
293 return insert_cost + (endx - startx)*multi_insert_cost;
296 return (endx - startx + 1)*multi_insert_cost;
301 if (begin <= lmin[end])
302 return (*gap_percents)[end][0];
304 if (begin <= lmax[end])
305 return (*gap_percents)[end][begin - lmin[end]];
307 return (*gap_percents)[end][lmax[end] - lmin[end] + 1];
311 float w_bind(
unsigned long pos_1,
unsigned char base_1,
312 unsigned long pos_2,
unsigned char base_2) {
314 float cost_in, cost = 0;
317 return (*binding_costs)[base_1][base_2];
319 for (i = 0; i < 4; i++)
320 cost += (*base_weights)[pos_2][i] * (*binding_costs)[base_1][i];
324 for (i = 0; i < 4; i++)
325 cost += (*base_weights)[pos_1][i] * (*binding_costs)[i][base_2];
328 for (i = 0; i < 4; i++) {
329 for (j = 0, cost_in = 0; j < 4; j++)
330 cost_in += (*base_weights)[pos_2][j] * (*binding_costs)[i][j];
331 cost += (*base_weights)[pos_1][i] * cost_in;
336 float w_binding(
unsigned long first_position_of_sequence,
341 #error ali_profile.hxx included twice
342 #endif // ALI_PROFILE_HXX
float w_bind(unsigned long pos_1, unsigned char base_1, unsigned long pos_2, unsigned char base_2)
float w_ins_multi(unsigned long startx, unsigned long endx)
void ali_out_of_memory_if(bool cond)
ALI_PROFILE(ALI_SEQUENCE *sequence, ALI_PROFILE_CONTEXT *context)
int mark_family_extension_flag
float base_weight(unsigned long pos, unsigned char c)
float w_sub_gap_cheap(unsigned long positiony)
float w_sub_multi_gap_cheap(unsigned long start, unsigned long end)
float w_binding(unsigned long first_position_of_sequence, ALI_SEQUENCE *sequence)
int is_in_helix(unsigned long pos, unsigned long *first, unsigned long *last)
float w_ins(unsigned long, unsigned long)
float w_del(unsigned long begin, unsigned long end)
#define ALI_PROFILE_BORDER_RIGHT
float w_del_multi_cheap(unsigned long start, unsigned long end)
static HelixNrInfo * start
char * cheapest_sequence()
int ali_is_real_base_or_gap(char c)
ALI_NORM_SEQUENCE * sequence()
int complement_position(unsigned long pos)
unsigned char base(unsigned long position)
float w_ins_cheap(unsigned long, unsigned long)
int is_internal_last(unsigned long pos)
float w_del_cheap(unsigned long position)
float multi_insert_factor
float gap_percent(unsigned long begin, unsigned long end)
float w_del_multi_unweighted(unsigned long start, unsigned long end)
void ali_fatal_error(const char *message, const char *func)
float w_ins_multi_unweighted(unsigned long startx, unsigned long endx)
float w_sub(unsigned long positiony, unsigned long positionx)
unsigned long sequence_length()
float w_ins_multi_cheap(unsigned long startx, unsigned long endx)
int is_in_helix(unsigned long pos)
int is_outside_helix(unsigned long pos, unsigned long *first, unsigned long *last)
char * borders_sequence()
int is_begin(unsigned long pos)
double binding_matrix[5][5]
void print(int start=-1, int end=-1)
ali_family_member(ALI_SEQUENCE *seq, float m, float w=0.0)
float w_sub_gap(unsigned long positiony)
float w_del_multi(unsigned long start, unsigned long end)
double substitute_matrix[5][5]
#define ALI_PROFILE_BORDER_LEFT