1 #ifdef _cplusplus
2 extern "C" {
3 #endif
4 #include "genephase6.h"
5
6
7 # line 289 "genephase6.dy"
AlnBlock_from_phased_protein_wrap(Protein * pro,ThreeStateModel * tsm,Genomic * gen,CodonMapper * cm,RandomModel * rm,CompMat * mat,PhasedProteinPara * ppp,GeneParameter21 * gpara,DPRunImpl * dpri,PackAln ** palret)8 AlnBlock * AlnBlock_from_phased_protein_wrap(Protein * pro,ThreeStateModel * tsm,Genomic * gen,CodonMapper * cm,RandomModel * rm,CompMat * mat,PhasedProteinPara * ppp,GeneParameter21 * gpara,DPRunImpl * dpri,PackAln ** palret)
9 {
10 PackAln * pal;
11 AlnBlock * alb;
12 GeneParser21Score * gp21s;
13 GeneParser4Score * gp4s;
14 ComplexSequence * cs;
15 ThreeStateModel * tsmin;
16
17 GeneralGeneModelScore * ggms;
18
19 GenePhaseModel * gpm;
20 GenePhaseScore * gps;
21
22 int i;
23
24 assert(gen != NULL);
25 assert(ppp != NULL);
26
27 ggms = vanilla_GeneralGeneModelScore(gpara->ct,Bits2Probability(10),1.0,Bits2Probability(10));
28
29 if( tsm == NULL ) {
30 if( pro == NULL ) {
31 warn("Major problem - neither a protein nor a tsm passed into phase model");
32 return NULL;
33 }
34 tsmin = ThreeStateModel_alloc_len(pro->baseseq->len);
35
36 if( pro->baseseq->name != NULL )
37 tsmin->name = stringalloc(pro->baseseq->name);
38 else tsmin->name = stringalloc("NoName");
39
40 tsmin->rm = hard_link_RandomModel(rm);
41
42 for(i=0;i<pro->baseseq->len;i++) {
43 add_ThreeStateModel(tsmin,ThreeStateUnit_from_half_bit_aminoacid(pro->baseseq->seq[i],mat,rm,ppp->gap,ppp->ext));
44 }
45 } else {
46 tsmin = hard_link_ThreeStateModel(tsm);
47 }
48
49
50 gpm = GenePhaseModel_from_ThreeStateModel(tsmin,cm,rm,mat,ppp);
51
52 GeneWise_fold_in_synchronised_RandomModel(gpm->gw,rm,gpara->cm,gpara->ct,0.5);
53
54 gps = GenePhaseScore_from_GenePhaseModel(gpm);
55
56 if( (gp21s = GeneParser21Score_from_GeneParser21(gpara->gp)) == NULL) {
57 warn("Unable to make GeneParserScore model");
58 return NULL;
59 }
60
61 gp4s = GeneParser4Score_from_GeneParser21Score(gp21s);
62
63 if( (cs=evaluate_ComplexSequence_Genomic(gen,gpara->cses,0,Probability2Score(0.01))) == FALSE ) {
64 warn("Unable to make ComplexSequence in TMS2DNA wrap");
65 }
66
67 pal = PackAln_bestmemory_GenePhase6(gps,cs,gp4s,ggms,NULL,dpri);
68
69 if( palret != NULL ) {
70 *palret = pal;
71 }
72
73 alb = convert_PackAln_to_AlnBlock_GenePhase6(pal);
74
75 free_GeneralGeneModelScore(ggms);
76 free_GenePhaseModel(gpm);
77 free_GenePhaseScore(gps);
78 free_ComplexSequence(cs);
79 free_GeneParser21Score(gp21s);
80 free_GeneParser4Score(gp4s);
81
82 free_ThreeStateModel(tsm);
83
84 return alb;
85
86 }
87
88 # line 87 "genephase6.c"
89
90
91 /***************** C functions ****************/
92 /* Written using dynamite */
93 /* Sat Sep 8 09:05:32 2007 */
94 /* email birney@sanger.ac.uk */
95 /* http://www.sanger.ac.uk/Users/birney/dynamite */
96 /*************************************************/
97
98
99 /* Please report any problems or bugs to */
100 /* Ewan Birney, birney@sanger.ac.uk */
101
102
103 /* basic set of macros to map states to numbers */
104 #define MATCH 0
105 #define INSERT 1
106 #define DELETE 2
107 #define INTRON_0 3
108 #define INTRON_1 4
109 #define INTRON_2 5
110
111
112 #define LOOP 0
113 #define START 1
114 #define END 2
115 #define BEFORE_MATCH_CODING 3
116 #define BEFORE_MATCH_INTRON_0 4
117 #define BEFORE_MATCH_INTRON_1 5
118 #define BEFORE_MATCH_INTRON_2 6
119 #define AFTER_MATCH_CODING 7
120
121
122 #define GenePhase6_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*6)+STATE][i+1]
123 #define GenePhase6_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10]
124 #define GenePhase6_READ_OFF_ERROR -12
125
126
127
128 #define GenePhase6_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+1)*6)+STATE]
129 #define GenePhase6_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE]
130
131
132
133
134 #define GenePhase6_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j]
135 #define GenePhase6_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE)
136
137
138 /* Function: PackAln_read_Shatter_GenePhase6(mat)
139 *
140 * Descrip: Reads off PackAln from shatter matrix structure
141 *
142 *
143 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
144 *
145 * Return [UNKN ] Undocumented return value [PackAln *]
146 *
147 */
PackAln_read_Shatter_GenePhase6(GenePhase6 * mat)148 PackAln * PackAln_read_Shatter_GenePhase6(GenePhase6 * mat)
149 {
150 GenePhase6_access_func_holder holder;
151
152
153 holder.access_main = GenePhase6_shatter_access_main;
154 holder.access_special = GenePhase6_shatter_access_special;
155 assert(mat);
156 assert(mat->shatter);
157 return PackAln_read_generic_GenePhase6(mat,holder);
158 }
159
160
161 /* Function: GenePhase6_shatter_access_main(mat,i,j,state)
162 *
163 * Descrip: No Description
164 *
165 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
166 * Arg: i [UNKN ] Undocumented argument [int]
167 * Arg: j [UNKN ] Undocumented argument [int]
168 * Arg: state [UNKN ] Undocumented argument [int]
169 *
170 * Return [UNKN ] Undocumented return value [int]
171 *
172 */
GenePhase6_shatter_access_main(GenePhase6 * mat,int i,int j,int state)173 int GenePhase6_shatter_access_main(GenePhase6 * mat,int i,int j,int state)
174 {
175 return GenePhase6_SHATTER_MATRIX(mat,i,j,state);
176 }
177
178
179 /* Function: GenePhase6_shatter_access_special(mat,i,j,state)
180 *
181 * Descrip: No Description
182 *
183 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
184 * Arg: i [UNKN ] Undocumented argument [int]
185 * Arg: j [UNKN ] Undocumented argument [int]
186 * Arg: state [UNKN ] Undocumented argument [int]
187 *
188 * Return [UNKN ] Undocumented return value [int]
189 *
190 */
GenePhase6_shatter_access_special(GenePhase6 * mat,int i,int j,int state)191 int GenePhase6_shatter_access_special(GenePhase6 * mat,int i,int j,int state)
192 {
193 return GenePhase6_SHATTER_SPECIAL(mat,i,j,state);
194 }
195
196
197 /* Function: calculate_shatter_GenePhase6(mat,dpenv)
198 *
199 * Descrip: This function calculates the GenePhase6 matrix when in shatter mode
200 *
201 *
202 * Arg: mat [UNKN ] (null) [GenePhase6 *]
203 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
204 *
205 * Return [UNKN ] Undocumented return value [boolean]
206 *
207 */
calculate_shatter_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv)208 boolean calculate_shatter_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv)
209 {
210 int i;
211 int j;
212 int k;
213 int should_calc;
214 int leni;
215 int lenj;
216 int tot;
217 int num;
218 int starti;
219 int startj;
220 int endi;
221 int endj;
222
223
224 int * SIG_0_0;
225 int * SIG_1_3;
226 int * SIG_1_6;
227 int * SIG_1_5;
228 int * SIG_1_4;
229 int * SIG_1_2;
230 int * SIG_1_1;
231 int * SIG_0_3;
232 int * SIG_0_6;
233 int * SIG_0_5;
234 int * SIG_0_4;
235 int * SIG_0_2;
236 int * SIG_0_1;
237 int * SIG_1_0;
238 int * SIG_0_8;
239 int * SIG_0_9;
240 int * SIG_0_10;
241
242
243 leni = mat->leni;
244 lenj = mat->lenj;
245
246
247 mat->shatter = new_ShatterMatrix(dpenv,6,lenj,8);
248 prepare_DPEnvelope(dpenv);
249 starti = dpenv->starti;
250 if( starti < 0 )
251 starti = 0;
252 startj = dpenv->startj;
253 if( startj < 0 )
254 startj = 0;
255 endi = dpenv->endi;
256 if( endi > mat->leni )
257 endi = mat->leni;
258 endj = dpenv->endj;
259 if( endj > mat->lenj )
260 endj = mat->lenj;
261 tot = (endi-starti) * (endj-startj);
262 num = 0;
263
264
265 start_reporting("GenePhase6 Matrix calculation: ");
266 for(j=startj;j<endj;j++) {
267 auto int score;
268 auto int temp;
269 for(i=starti;i<endi;i++) {
270 /* Check if is in envelope - code identical to is_in_DPEnvelope, but aggressively inlined here for speed */
271 should_calc = 0;
272 for(k=0;k<dpenv->len;k++) {
273 auto DPUnit * u;
274 u = dpenv->dpu[k];
275 switch(u->type) {
276 case DPENV_RECT :
277 if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length))
278 should_calc = 1;
279 break;
280 case DPENV_DIAG :
281 if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj)
282 should_calc = 1;
283 break;
284 }
285 if( should_calc == 1 )
286 break;
287 }
288 if( should_calc == 0)
289 continue;
290
291
292 SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j);
293 SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3);
294 SIG_1_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-6);
295 SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5);
296 SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4);
297 SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2);
298 SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1);
299 SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3);
300 SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6);
301 SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5);
302 SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4);
303 SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2);
304 SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1);
305 SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0);
306 SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8);
307 SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9);
308 SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10);
309
310
311
312
313 /* For state MATCH */
314 /* setting first movement to score */
315 score = SIG_1_3[MATCH] + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
316 /* From state INSERT to state MATCH */
317 temp = SIG_1_3[INSERT] + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
318 if( temp > score ) {
319 score = temp;
320 }
321 /* From state DELETE to state MATCH */
322 temp = SIG_1_3[DELETE] + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
323 if( temp > score ) {
324 score = temp;
325 }
326 /* From state START to state MATCH */
327 temp = GenePhase6_SHATTER_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]);
328 if( temp > score ) {
329 score = temp;
330 }
331 /* From state BEFORE_MATCH_CODING to state MATCH */
332 temp = GenePhase6_SHATTER_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
333 if( temp > score ) {
334 score = temp;
335 }
336 /* From state INTRON_0 to state MATCH */
337 temp = SIG_1_6[INTRON_0] + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
338 if( temp > score ) {
339 score = temp;
340 }
341 /* From state INTRON_1 to state MATCH */
342 temp = SIG_1_5[INTRON_1] + CSEQ_GENOMIC_3SS(mat->target,(j-2));
343 if( temp > score ) {
344 score = temp;
345 }
346 /* From state INTRON_2 to state MATCH */
347 temp = SIG_1_4[INTRON_2] + CSEQ_GENOMIC_3SS(mat->target,(j-1));
348 if( temp > score ) {
349 score = temp;
350 }
351 /* From state MATCH to state MATCH */
352 temp = SIG_1_2[MATCH] + mat->gp->transition[GP4_DELETE_1_BASE];
353 if( temp > score ) {
354 score = temp;
355 }
356 /* From state MATCH to state MATCH */
357 temp = SIG_1_1[MATCH] + mat->gp->transition[GP4_DELETE_2_BASE];
358 if( temp > score ) {
359 score = temp;
360 }
361 /* From state MATCH to state MATCH */
362 temp = SIG_1_4[MATCH] + mat->gp->transition[GP4_INSERT_1_BASE];
363 if( temp > score ) {
364 score = temp;
365 }
366 /* From state MATCH to state MATCH */
367 temp = SIG_1_5[MATCH] + mat->gp->transition[GP4_INSERT_2_BASE];
368 if( temp > score ) {
369 score = temp;
370 }
371
372
373 /* Ok - finished max calculation for MATCH */
374 /* Add any movement independant score and put away */
375 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
376 SIG_0_0[MATCH] = score;
377
378
379 /* state MATCH is a source for special LOOP */
380 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
381 if( temp > GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) ) {
382 GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) = temp;
383 }
384
385
386
387
388 /* state MATCH is a source for special AFTER_MATCH_CODING */
389 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
390 if( temp > GenePhase6_SHATTER_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) {
391 GenePhase6_SHATTER_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp;
392 }
393
394
395
396
397 /* Finished calculating state MATCH */
398
399
400 /* For state INSERT */
401 /* setting first movement to score */
402 score = SIG_0_3[MATCH] + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
403 /* From state INSERT to state INSERT */
404 temp = SIG_0_3[INSERT] + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
405 if( temp > score ) {
406 score = temp;
407 }
408 /* From state DELETE to state INSERT */
409 temp = SIG_0_3[DELETE] + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
410 if( temp > score ) {
411 score = temp;
412 }
413 /* From state LOOP to state INSERT */
414 temp = GenePhase6_SHATTER_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]);
415 if( temp > score ) {
416 score = temp;
417 }
418 /* From state INTRON_0 to state INSERT */
419 temp = SIG_0_6[INTRON_0] + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
420 if( temp > score ) {
421 score = temp;
422 }
423 /* From state INTRON_1 to state INSERT */
424 temp = SIG_0_5[INTRON_1] + CSEQ_GENOMIC_3SS(mat->target,(j-2));
425 if( temp > score ) {
426 score = temp;
427 }
428 /* From state INTRON_2 to state INSERT */
429 temp = SIG_0_4[INTRON_2] + CSEQ_GENOMIC_3SS(mat->target,(j-1));
430 if( temp > score ) {
431 score = temp;
432 }
433 /* From state INSERT to state INSERT */
434 temp = SIG_0_2[INSERT] + mat->gp->transition[GP4_DELETE_1_BASE];
435 if( temp > score ) {
436 score = temp;
437 }
438 /* From state INSERT to state INSERT */
439 temp = SIG_0_1[INSERT] + mat->gp->transition[GP4_DELETE_2_BASE];
440 if( temp > score ) {
441 score = temp;
442 }
443
444
445 /* Ok - finished max calculation for INSERT */
446 /* Add any movement independant score and put away */
447 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
448 SIG_0_0[INSERT] = score;
449
450
451 /* state INSERT is a source for special LOOP */
452 temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ;
453 if( temp > GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) ) {
454 GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) = temp;
455 }
456
457
458
459
460 /* Finished calculating state INSERT */
461
462
463 /* For state DELETE */
464 /* setting first movement to score */
465 score = SIG_1_0[MATCH] + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE];
466 /* From state INSERT to state DELETE */
467 temp = SIG_1_0[INSERT] + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE];
468 if( temp > score ) {
469 score = temp;
470 }
471 /* From state DELETE to state DELETE */
472 temp = SIG_1_0[DELETE] + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE];
473 if( temp > score ) {
474 score = temp;
475 }
476
477
478 /* Ok - finished max calculation for DELETE */
479 /* Add any movement independant score and put away */
480 SIG_0_0[DELETE] = score;
481
482
483 /* state DELETE is a source for special LOOP */
484 temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ;
485 if( temp > GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) ) {
486 GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) = temp;
487 }
488
489
490
491
492 /* Finished calculating state DELETE */
493
494
495 /* For state INTRON_0 */
496 /* setting first movement to score */
497 score = SIG_0_8[MATCH] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0);
498 /* From state INSERT to state INTRON_0 */
499 temp = SIG_0_8[INSERT] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
500 if( temp > score ) {
501 score = temp;
502 }
503 /* From state INTRON_0 to state INTRON_0 */
504 temp = SIG_0_1[INTRON_0] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
505 if( temp > score ) {
506 score = temp;
507 }
508
509
510 /* Ok - finished max calculation for INTRON_0 */
511 /* Add any movement independant score and put away */
512 SIG_0_0[INTRON_0] = score;
513
514
515 /* Finished calculating state INTRON_0 */
516
517
518 /* For state INTRON_1 */
519 /* setting first movement to score */
520 score = SIG_0_9[MATCH] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1);
521 /* From state INSERT to state INTRON_1 */
522 temp = SIG_0_9[INSERT] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
523 if( temp > score ) {
524 score = temp;
525 }
526 /* From state INTRON_1 to state INTRON_1 */
527 temp = SIG_0_1[INTRON_1] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
528 if( temp > score ) {
529 score = temp;
530 }
531
532
533 /* Ok - finished max calculation for INTRON_1 */
534 /* Add any movement independant score and put away */
535 SIG_0_0[INTRON_1] = score;
536
537
538 /* Finished calculating state INTRON_1 */
539
540
541 /* For state INTRON_2 */
542 /* setting first movement to score */
543 score = SIG_0_10[MATCH] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2);
544 /* From state INSERT to state INTRON_2 */
545 temp = SIG_0_10[INSERT] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
546 if( temp > score ) {
547 score = temp;
548 }
549 /* From state INTRON_2 to state INTRON_2 */
550 temp = SIG_0_1[INTRON_2] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
551 if( temp > score ) {
552 score = temp;
553 }
554
555
556 /* Ok - finished max calculation for INTRON_2 */
557 /* Add any movement independant score and put away */
558 SIG_0_0[INTRON_2] = score;
559
560
561 /* Finished calculating state INTRON_2 */
562 }
563
564
565 /* Special state LOOP has special to speical */
566 /* Set score to current score (remember, state probably updated during main loop */
567 score = GenePhase6_SHATTER_SPECIAL(mat,0,j,LOOP);
568
569
570 /* Source START is a special source for LOOP */
571 /* Has restricted position */
572 if( (j-1) == 0 ) {
573 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0);
574 if( temp > score )
575 score = temp;
576 }
577
578
579 /* Source MATCH for state LOOP is not special... already calculated */
580 /* Source INSERT for state LOOP is not special... already calculated */
581 /* Source DELETE for state LOOP is not special... already calculated */
582 /* Source LOOP is a special source for LOOP */
583 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0);
584 if( temp > score )
585 score = temp;
586
587
588 /* Put back score... (now updated!) */
589 GenePhase6_SHATTER_SPECIAL(mat,0,j,LOOP) = score;
590 /* Finished updating state LOOP */
591
592
593
594
595 /* Special state START has no special to special movements */
596
597
598 /* Special state END has special to speical */
599 /* Set score to current score (remember, state probably updated during main loop */
600 score = GenePhase6_SHATTER_SPECIAL(mat,0,j,END);
601
602
603 /* Source LOOP is a special source for END */
604 /* Has restricted position */
605 if( j == mat->lenj-1 ) {
606 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0);
607 if( temp > score )
608 score = temp;
609 }
610
611
612 /* Source AFTER_MATCH_CODING is a special source for END */
613 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
614 if( temp > score )
615 score = temp;
616
617
618 /* Put back score... (now updated!) */
619 GenePhase6_SHATTER_SPECIAL(mat,0,j,END) = score;
620 /* Finished updating state END */
621
622
623
624
625 /* Special state BEFORE_MATCH_CODING has special to speical */
626 /* Set score to current score (remember, state probably updated during main loop */
627 score = GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_CODING);
628
629
630 /* Source START is a special source for BEFORE_MATCH_CODING */
631 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
632 if( temp > score )
633 score = temp;
634
635
636 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */
637 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
638 if( temp > score )
639 score = temp;
640
641
642 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */
643 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0);
644 if( temp > score )
645 score = temp;
646
647
648 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */
649 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0);
650 if( temp > score )
651 score = temp;
652
653
654 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */
655 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0);
656 if( temp > score )
657 score = temp;
658
659
660 /* Put back score... (now updated!) */
661 GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score;
662 /* Finished updating state BEFORE_MATCH_CODING */
663
664
665
666
667 /* Special state BEFORE_MATCH_INTRON_0 has special to speical */
668 /* Set score to current score (remember, state probably updated during main loop */
669 score = GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0);
670
671
672 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */
673 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0);
674 if( temp > score )
675 score = temp;
676
677
678 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */
679 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
680 if( temp > score )
681 score = temp;
682
683
684 /* Put back score... (now updated!) */
685 GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score;
686 /* Finished updating state BEFORE_MATCH_INTRON_0 */
687
688
689
690
691 /* Special state BEFORE_MATCH_INTRON_1 has special to speical */
692 /* Set score to current score (remember, state probably updated during main loop */
693 score = GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1);
694
695
696 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */
697 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
698 if( temp > score )
699 score = temp;
700
701
702 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */
703 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
704 if( temp > score )
705 score = temp;
706
707
708 /* Put back score... (now updated!) */
709 GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score;
710 /* Finished updating state BEFORE_MATCH_INTRON_1 */
711
712
713
714
715 /* Special state BEFORE_MATCH_INTRON_2 has special to speical */
716 /* Set score to current score (remember, state probably updated during main loop */
717 score = GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2);
718
719
720 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */
721 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
722 if( temp > score )
723 score = temp;
724
725
726 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */
727 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
728 if( temp > score )
729 score = temp;
730
731
732 /* Put back score... (now updated!) */
733 GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score;
734 /* Finished updating state BEFORE_MATCH_INTRON_2 */
735
736
737
738
739 /* Special state AFTER_MATCH_CODING has special to speical */
740 /* Set score to current score (remember, state probably updated during main loop */
741 score = GenePhase6_SHATTER_SPECIAL(mat,0,j,AFTER_MATCH_CODING);
742
743
744 /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */
745 /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */
746 temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
747 if( temp > score )
748 score = temp;
749
750
751 /* Put back score... (now updated!) */
752 GenePhase6_SHATTER_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score;
753 /* Finished updating state AFTER_MATCH_CODING */
754
755
756 }
757 stop_reporting();
758 return TRUE;
759 }
760
761
762 /* Function: search_GenePhase6(dbsi,out,query,targetdb,gp,general_model)
763 *
764 * Descrip: This function makes a database search of GenePhase6
765 * It uses the dbsi structure to choose which implementation
766 * to use of the database searching. This way at run time you
767 * can switch between single threaded/multi-threaded or hardware
768 *
769 *
770 * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *]
771 * Arg: out [UNKN ] Undocumented argument [Hscore *]
772 * Arg: query [UNKN ] Undocumented argument [GenePhaseScore*]
773 * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*]
774 * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *]
775 * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *]
776 *
777 * Return [UNKN ] Undocumented return value [Search_Return_Type]
778 *
779 */
search_GenePhase6(DBSearchImpl * dbsi,Hscore * out,GenePhaseScore * query,GenomicDB * targetdb,GeneParser4Score * gp,GeneralGeneModelScore * general_model)780 Search_Return_Type search_GenePhase6(DBSearchImpl * dbsi,Hscore * out,GenePhaseScore* query,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model)
781 {
782 #ifdef PTHREAD
783 int i;
784 int thr_no;
785 pthread_attr_t pat;
786 struct thread_pool_holder_GenePhase6 * holder;
787 #endif
788 if( out == NULL ) {
789 warn("Passed in a null Hscore object into search_GenePhase6. Can't process results!");
790 return SEARCH_ERROR;
791 }
792 if( dbsi == NULL ) {
793 warn("Passed in a null DBSearchImpl object into search_GenePhase6. Can't process results!");
794 return SEARCH_ERROR;
795 }
796 if( dbsi->trace_level > 5 )
797 warn("Asking for trace level of %d in database search for GenePhase6, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level);
798 switch(dbsi->type) { /*switch on implementation*/
799 case DBSearchImpl_Serial :
800 return serial_search_GenePhase6(out,query, targetdb ,gp,general_model);
801 case DBSearchImpl_Pthreads :
802 #ifdef PTHREAD
803 holder = (struct thread_pool_holder_GenePhase6 *) ckalloc(sizeof(struct thread_pool_holder_GenePhase6));
804 if( holder == NULL ) {
805 warn("Unable to allocated thread pool datastructure...");
806 return SEARCH_ERROR;
807 }
808 holder->out = out;
809 holder->dbsi = dbsi;
810 holder->query = query;
811 holder->targetdb = targetdb;
812 holder->gp = gp;
813 holder->general_model = general_model;
814 if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 )
815 fatal("Unable to iniated input mutex lock");
816 if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 )
817 fatal("Unable to iniated output mutex lock");
818 /* Let us rock! */
819 thr_no = number_of_threads_DBSearchImpl(dbsi);
820 holder->pool = ckcalloc (thr_no,sizeof(pthread_t));
821 if( holder->pool == NULL ) {
822 warn("Unable to allocated thread pools");
823 return SEARCH_ERROR;
824 }
825 /* Build a thread attribute to make sure we get the most out of SMP boxes */
826 pthread_attr_init(&pat);
827 /* Give thread libraries a hint that threads should be kernel threads */
828 #ifndef __sgi /* SGI can't set system scope ... */
829 #ifdef HAS_PTHREAD_SETSCOPE
830 pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM);
831 #endif /* set scope */
832 #endif /* sgi */
833 /* Give thread libraries a hint that there are num of threads to run */
834 #ifdef HAS_PTHREAD_SETCONCURRENCY
835 pthread_setconcurrency(thr_no+1);
836 #endif /* set concurrency */
837 for(i=0;i<thr_no;i++) {
838 if( pthread_create(holder->pool+i,&pat,thread_loop_GenePhase6,(void *)holder) )
839 fatal("Unable to create a thread!");
840 }
841 /* Now - wait for all the threads to exit */
842 for(i=0;i<thr_no;i++) {
843 if( pthread_join(holder->pool[i],NULL) != 0 )
844 fatal("Unable to join a thread!");
845 }
846 /* Deallocate the thread structures */
847 ckfree(holder->pool);
848 ckfree(holder);
849 return SEARCH_OK;
850 #else /* not compiled with threads */
851 warn("You did not specifiy the PTHREAD compile when compiled the C code for GenePhase6");
852 #endif /* finished threads */
853 default :
854 warn("database search implementation %s was not provided in the compiled dynamite file from GenePhase6",impl_string_DBSearchImpl(dbsi));
855 return SEARCH_ERROR;
856 } /* end of switch on implementation */
857
858
859 }
860
861
862 /* Function: thread_loop_GenePhase6(ptr)
863 *
864 * Descrip: dummy loop code foreach thread for GenePhase6
865 *
866 *
867 * Arg: ptr [UNKN ] Undocumented argument [void *]
868 *
869 * Return [UNKN ] Undocumented return value [void *]
870 *
871 */
thread_loop_GenePhase6(void * ptr)872 void * thread_loop_GenePhase6(void * ptr)
873 {
874 fatal("dummy thread loop function");
875 }
876
877
878 /* Function: serial_search_GenePhase6(out,query,targetdb,gp,general_model)
879 *
880 * Descrip: This function makes a database search of GenePhase6
881 * It is a single processor implementation
882 *
883 *
884 * Arg: out [UNKN ] Undocumented argument [Hscore *]
885 * Arg: query [UNKN ] Undocumented argument [GenePhaseScore*]
886 * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*]
887 * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *]
888 * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *]
889 *
890 * Return [UNKN ] Undocumented return value [Search_Return_Type]
891 *
892 */
serial_search_GenePhase6(Hscore * out,GenePhaseScore * query,GenomicDB * targetdb,GeneParser4Score * gp,GeneralGeneModelScore * general_model)893 Search_Return_Type serial_search_GenePhase6(Hscore * out,GenePhaseScore* query,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model)
894 {
895 ComplexSequence* target;
896 int db_status;
897 int score;
898 int query_pos = 0;
899 int target_pos = 0;
900 DataScore * ds;
901
902
903 push_errormsg_stack("Before any actual search in db searching");
904
905
906 target_pos = 0;
907
908
909 target = init_GenomicDB(targetdb,&db_status);
910 if( db_status == DB_RETURN_ERROR ) {
911 warn("In searching GenePhase6, got a database init error on the target [target] database");
912 return SEARCH_ERROR;
913 }
914 for(;;) { /*For all target entries*/
915
916
917 /* No maximum length - allocated on-the-fly */
918 score = score_only_GenePhase6(query, target , gp, general_model);
919 if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/
920 ds = new_DataScore_from_storage(out);
921 if( ds == NULL ) {
922 warn("GenePhase6 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure");
923 return SEARCH_ERROR;
924 }
925 /* Now: add query/target information to the entry */
926 dataentry_add_GenomicDB(ds->target,target,targetdb);
927 ds->score = score;
928 add_Hscore(out,ds);
929 } /* end of if storing datascore */
930 pop_errormsg_stack();
931 push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos);
932
933
934 target = reload_GenomicDB(target,targetdb,&db_status);
935 if( db_status == DB_RETURN_ERROR ) {
936 warn("In searching GenePhase6, Reload error on database target, position %d,%d",query_pos,target_pos);
937 return SEARCH_ERROR;
938 }
939 if( db_status == DB_RETURN_END )
940 break; /* Out of target loop */
941 target_pos++;
942 } /* end of For all target entries */
943 close_GenomicDB(target,targetdb);
944 pop_errormsg_stack();
945 return SEARCH_OK;
946 }
947
948
949 /* Function: score_only_GenePhase6(query,target,gp,general_model)
950 *
951 * Descrip: This function just calculates the score for the matrix
952 * I am pretty sure we can do this better, but hey, for the moment...
953 * It calls /allocate_GenePhase6_only
954 *
955 *
956 * Arg: query [UNKN ] query data structure [GenePhaseScore*]
957 * Arg: target [UNKN ] target data structure [ComplexSequence*]
958 * Arg: gp [UNKN ] Resource [GeneParser4Score *]
959 * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *]
960 *
961 * Return [UNKN ] Undocumented return value [int]
962 *
963 */
score_only_GenePhase6(GenePhaseScore * query,ComplexSequence * target,GeneParser4Score * gp,GeneralGeneModelScore * general_model)964 int score_only_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model)
965 {
966 int bestscore = NEGI;
967 int i;
968 int j;
969 int k;
970 GenePhase6 * mat;
971
972
973 mat = allocate_GenePhase6_only(query, target , gp, general_model);
974 if( mat == NULL ) {
975 warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!");
976 return NEGI;
977 }
978 if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 1) * 6,11,8)) == NULL) {
979 warn("Score only matrix for GenePhase6 cannot be allocated, (asking for 10 by %d cells)",mat->leni*6);
980 mat = free_GenePhase6(mat);
981 return 0;
982 }
983 mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL;
984
985
986 /* Now, initiate matrix */
987 for(j=0;j<12;j++) {
988 for(i=(-1);i<mat->leni;i++) {
989 for(k=0;k<6;k++)
990 GenePhase6_VSMALL_MATRIX(mat,i,j,k) = NEGI;
991 }
992 GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) = NEGI;
993 GenePhase6_VSMALL_SPECIAL(mat,i,j,START) = 0;
994 GenePhase6_VSMALL_SPECIAL(mat,i,j,END) = NEGI;
995 GenePhase6_VSMALL_SPECIAL(mat,i,j,BEFORE_MATCH_CODING) = NEGI;
996 GenePhase6_VSMALL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_0) = NEGI;
997 GenePhase6_VSMALL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_1) = NEGI;
998 GenePhase6_VSMALL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_2) = NEGI;
999 GenePhase6_VSMALL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = NEGI;
1000 }
1001
1002
1003 /* Ok, lets do-o-o-o-o it */
1004
1005
1006 for(j=0;j<mat->lenj;j++) { /*for all target positions*/
1007 auto int score;
1008 auto int temp;
1009 for(i=0;i<mat->leni;i++) { /*for all query positions*/
1010
1011
1012 /* For state MATCH */
1013 /* setting first movement to score */
1014 score = GenePhase6_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
1015 /* From state INSERT to state MATCH */
1016 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
1017 if( temp > score ) {
1018 score = temp;
1019 }
1020 /* From state DELETE to state MATCH */
1021 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
1022 if( temp > score ) {
1023 score = temp;
1024 }
1025 /* From state START to state MATCH */
1026 temp = GenePhase6_VSMALL_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]);
1027 if( temp > score ) {
1028 score = temp;
1029 }
1030 /* From state BEFORE_MATCH_CODING to state MATCH */
1031 temp = GenePhase6_VSMALL_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
1032 if( temp > score ) {
1033 score = temp;
1034 }
1035 /* From state INTRON_0 to state MATCH */
1036 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
1037 if( temp > score ) {
1038 score = temp;
1039 }
1040 /* From state INTRON_1 to state MATCH */
1041 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
1042 if( temp > score ) {
1043 score = temp;
1044 }
1045 /* From state INTRON_2 to state MATCH */
1046 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
1047 if( temp > score ) {
1048 score = temp;
1049 }
1050 /* From state MATCH to state MATCH */
1051 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE];
1052 if( temp > score ) {
1053 score = temp;
1054 }
1055 /* From state MATCH to state MATCH */
1056 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE];
1057 if( temp > score ) {
1058 score = temp;
1059 }
1060 /* From state MATCH to state MATCH */
1061 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE];
1062 if( temp > score ) {
1063 score = temp;
1064 }
1065 /* From state MATCH to state MATCH */
1066 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE];
1067 if( temp > score ) {
1068 score = temp;
1069 }
1070
1071
1072 /* Ok - finished max calculation for MATCH */
1073 /* Add any movement independant score and put away */
1074 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
1075 GenePhase6_VSMALL_MATRIX(mat,i,j,MATCH) = score;
1076
1077
1078 /* state MATCH is a source for special LOOP */
1079 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
1080 if( temp > GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) ) {
1081 GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) = temp;
1082 }
1083
1084
1085
1086
1087 /* state MATCH is a source for special AFTER_MATCH_CODING */
1088 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
1089 if( temp > GenePhase6_VSMALL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) {
1090 GenePhase6_VSMALL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp;
1091 }
1092
1093
1094
1095
1096 /* Finished calculating state MATCH */
1097
1098
1099 /* For state INSERT */
1100 /* setting first movement to score */
1101 score = GenePhase6_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
1102 /* From state INSERT to state INSERT */
1103 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
1104 if( temp > score ) {
1105 score = temp;
1106 }
1107 /* From state DELETE to state INSERT */
1108 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
1109 if( temp > score ) {
1110 score = temp;
1111 }
1112 /* From state LOOP to state INSERT */
1113 temp = GenePhase6_VSMALL_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]);
1114 if( temp > score ) {
1115 score = temp;
1116 }
1117 /* From state INTRON_0 to state INSERT */
1118 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
1119 if( temp > score ) {
1120 score = temp;
1121 }
1122 /* From state INTRON_1 to state INSERT */
1123 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
1124 if( temp > score ) {
1125 score = temp;
1126 }
1127 /* From state INTRON_2 to state INSERT */
1128 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
1129 if( temp > score ) {
1130 score = temp;
1131 }
1132 /* From state INSERT to state INSERT */
1133 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE];
1134 if( temp > score ) {
1135 score = temp;
1136 }
1137 /* From state INSERT to state INSERT */
1138 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE];
1139 if( temp > score ) {
1140 score = temp;
1141 }
1142
1143
1144 /* Ok - finished max calculation for INSERT */
1145 /* Add any movement independant score and put away */
1146 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
1147 GenePhase6_VSMALL_MATRIX(mat,i,j,INSERT) = score;
1148
1149
1150 /* state INSERT is a source for special LOOP */
1151 temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ;
1152 if( temp > GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) ) {
1153 GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) = temp;
1154 }
1155
1156
1157
1158
1159 /* Finished calculating state INSERT */
1160
1161
1162 /* For state DELETE */
1163 /* setting first movement to score */
1164 score = GenePhase6_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE];
1165 /* From state INSERT to state DELETE */
1166 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE];
1167 if( temp > score ) {
1168 score = temp;
1169 }
1170 /* From state DELETE to state DELETE */
1171 temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE];
1172 if( temp > score ) {
1173 score = temp;
1174 }
1175
1176
1177 /* Ok - finished max calculation for DELETE */
1178 /* Add any movement independant score and put away */
1179 GenePhase6_VSMALL_MATRIX(mat,i,j,DELETE) = score;
1180
1181
1182 /* state DELETE is a source for special LOOP */
1183 temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ;
1184 if( temp > GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) ) {
1185 GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) = temp;
1186 }
1187
1188
1189
1190
1191 /* Finished calculating state DELETE */
1192
1193
1194 /* For state INTRON_0 */
1195 /* setting first movement to score */
1196 score = GenePhase6_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0);
1197 /* From state INSERT to state INTRON_0 */
1198 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
1199 if( temp > score ) {
1200 score = temp;
1201 }
1202 /* From state INTRON_0 to state INTRON_0 */
1203 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
1204 if( temp > score ) {
1205 score = temp;
1206 }
1207
1208
1209 /* Ok - finished max calculation for INTRON_0 */
1210 /* Add any movement independant score and put away */
1211 GenePhase6_VSMALL_MATRIX(mat,i,j,INTRON_0) = score;
1212
1213
1214 /* Finished calculating state INTRON_0 */
1215
1216
1217 /* For state INTRON_1 */
1218 /* setting first movement to score */
1219 score = GenePhase6_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1);
1220 /* From state INSERT to state INTRON_1 */
1221 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
1222 if( temp > score ) {
1223 score = temp;
1224 }
1225 /* From state INTRON_1 to state INTRON_1 */
1226 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
1227 if( temp > score ) {
1228 score = temp;
1229 }
1230
1231
1232 /* Ok - finished max calculation for INTRON_1 */
1233 /* Add any movement independant score and put away */
1234 GenePhase6_VSMALL_MATRIX(mat,i,j,INTRON_1) = score;
1235
1236
1237 /* Finished calculating state INTRON_1 */
1238
1239
1240 /* For state INTRON_2 */
1241 /* setting first movement to score */
1242 score = GenePhase6_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2);
1243 /* From state INSERT to state INTRON_2 */
1244 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
1245 if( temp > score ) {
1246 score = temp;
1247 }
1248 /* From state INTRON_2 to state INTRON_2 */
1249 temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
1250 if( temp > score ) {
1251 score = temp;
1252 }
1253
1254
1255 /* Ok - finished max calculation for INTRON_2 */
1256 /* Add any movement independant score and put away */
1257 GenePhase6_VSMALL_MATRIX(mat,i,j,INTRON_2) = score;
1258
1259
1260 /* Finished calculating state INTRON_2 */
1261 } /* end of for all query positions */
1262
1263
1264
1265
1266 /* Special state LOOP has special to speical */
1267 /* Set score to current score (remember, state probably updated during main loop */
1268 score = GenePhase6_VSMALL_SPECIAL(mat,0,j,LOOP);
1269
1270
1271 /* Source START is a special source for LOOP */
1272 /* Has restricted position */
1273 if( (j-1) == 0 ) {
1274 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0);
1275 if( temp > score )
1276 score = temp;
1277 }
1278
1279
1280 /* Source MATCH for state LOOP is not special... already calculated */
1281 /* Source INSERT for state LOOP is not special... already calculated */
1282 /* Source DELETE for state LOOP is not special... already calculated */
1283 /* Source LOOP is a special source for LOOP */
1284 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0);
1285 if( temp > score )
1286 score = temp;
1287
1288
1289 /* Put back score... (now updated!) */
1290 GenePhase6_VSMALL_SPECIAL(mat,0,j,LOOP) = score;
1291 /* Finished updating state LOOP */
1292
1293
1294
1295
1296 /* Special state START has no special to special movements */
1297
1298
1299 /* Special state END has special to speical */
1300 /* Set score to current score (remember, state probably updated during main loop */
1301 score = GenePhase6_VSMALL_SPECIAL(mat,0,j,END);
1302
1303
1304 /* Source LOOP is a special source for END */
1305 /* Has restricted position */
1306 if( j == mat->lenj-1 ) {
1307 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0);
1308 if( temp > score )
1309 score = temp;
1310 }
1311
1312
1313 /* Source AFTER_MATCH_CODING is a special source for END */
1314 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
1315 if( temp > score )
1316 score = temp;
1317
1318
1319 /* Put back score... (now updated!) */
1320 GenePhase6_VSMALL_SPECIAL(mat,0,j,END) = score;
1321 /* Finished updating state END */
1322
1323
1324
1325
1326 /* Special state BEFORE_MATCH_CODING has special to speical */
1327 /* Set score to current score (remember, state probably updated during main loop */
1328 score = GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING);
1329
1330
1331 /* Source START is a special source for BEFORE_MATCH_CODING */
1332 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
1333 if( temp > score )
1334 score = temp;
1335
1336
1337 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */
1338 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
1339 if( temp > score )
1340 score = temp;
1341
1342
1343 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */
1344 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0);
1345 if( temp > score )
1346 score = temp;
1347
1348
1349 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */
1350 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0);
1351 if( temp > score )
1352 score = temp;
1353
1354
1355 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */
1356 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0);
1357 if( temp > score )
1358 score = temp;
1359
1360
1361 /* Put back score... (now updated!) */
1362 GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score;
1363 /* Finished updating state BEFORE_MATCH_CODING */
1364
1365
1366
1367
1368 /* Special state BEFORE_MATCH_INTRON_0 has special to speical */
1369 /* Set score to current score (remember, state probably updated during main loop */
1370 score = GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0);
1371
1372
1373 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */
1374 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0);
1375 if( temp > score )
1376 score = temp;
1377
1378
1379 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */
1380 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
1381 if( temp > score )
1382 score = temp;
1383
1384
1385 /* Put back score... (now updated!) */
1386 GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score;
1387 /* Finished updating state BEFORE_MATCH_INTRON_0 */
1388
1389
1390
1391
1392 /* Special state BEFORE_MATCH_INTRON_1 has special to speical */
1393 /* Set score to current score (remember, state probably updated during main loop */
1394 score = GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1);
1395
1396
1397 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */
1398 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
1399 if( temp > score )
1400 score = temp;
1401
1402
1403 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */
1404 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
1405 if( temp > score )
1406 score = temp;
1407
1408
1409 /* Put back score... (now updated!) */
1410 GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score;
1411 /* Finished updating state BEFORE_MATCH_INTRON_1 */
1412
1413
1414
1415
1416 /* Special state BEFORE_MATCH_INTRON_2 has special to speical */
1417 /* Set score to current score (remember, state probably updated during main loop */
1418 score = GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2);
1419
1420
1421 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */
1422 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
1423 if( temp > score )
1424 score = temp;
1425
1426
1427 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */
1428 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
1429 if( temp > score )
1430 score = temp;
1431
1432
1433 /* Put back score... (now updated!) */
1434 GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score;
1435 /* Finished updating state BEFORE_MATCH_INTRON_2 */
1436
1437
1438
1439
1440 /* Special state AFTER_MATCH_CODING has special to speical */
1441 /* Set score to current score (remember, state probably updated during main loop */
1442 score = GenePhase6_VSMALL_SPECIAL(mat,0,j,AFTER_MATCH_CODING);
1443
1444
1445 /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */
1446 /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */
1447 temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
1448 if( temp > score )
1449 score = temp;
1450
1451
1452 /* Put back score... (now updated!) */
1453 GenePhase6_VSMALL_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score;
1454 /* Finished updating state AFTER_MATCH_CODING */
1455
1456
1457 if( bestscore < GenePhase6_VSMALL_SPECIAL(mat,0,j,END) )
1458 bestscore = GenePhase6_VSMALL_SPECIAL(mat,0,j,END);
1459 } /* end of for all target positions */
1460
1461
1462 mat = free_GenePhase6(mat);
1463 return bestscore;
1464 }
1465
1466
1467 /* Function: PackAln_bestmemory_GenePhase6(query,target,gp,general_model,dpenv,dpri)
1468 *
1469 * Descrip: This function chooses the best memory set-up for the alignment
1470 * using calls to basematrix, and then implements either a large
1471 * or small memory model.
1472 *
1473 * It is the best function to use if you just want an alignment
1474 *
1475 * If you want a label alignment, you will need
1476 * /convert_PackAln_to_AlnBlock_GenePhase6
1477 *
1478 *
1479 * Arg: query [UNKN ] query data structure [GenePhaseScore*]
1480 * Arg: target [UNKN ] target data structure [ComplexSequence*]
1481 * Arg: gp [UNKN ] Resource [GeneParser4Score *]
1482 * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *]
1483 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
1484 * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *]
1485 *
1486 * Return [UNKN ] Undocumented return value [PackAln *]
1487 *
1488 */
PackAln_bestmemory_GenePhase6(GenePhaseScore * query,ComplexSequence * target,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPEnvelope * dpenv,DPRunImpl * dpri)1489 PackAln * PackAln_bestmemory_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPEnvelope * dpenv,DPRunImpl * dpri)
1490 {
1491 long long total;
1492 GenePhase6 * mat;
1493 PackAln * out;
1494 DebugMatrix * de;
1495 DPRunImplMemory strategy;
1496 assert(dpri);
1497
1498
1499 total = query->len * target->seq->len;
1500 if( dpri->memory == DPIM_Default ) {
1501 if( (total * 6 * sizeof(int)) > 1000*dpri->kbyte_size) {
1502 strategy = DPIM_Linear;
1503 }
1504 else {
1505 strategy = DPIM_Explicit;
1506 }
1507 }
1508 else {
1509 strategy = dpri->memory;
1510 }
1511
1512
1513 if( dpenv != NULL ) {
1514 if( strategy == DPIM_Explicit) {
1515 if( (mat=allocate_Expl_GenePhase6(query, target , gp, general_model,dpri)) == NULL ) {
1516 warn("Unable to allocate large GenePhase6 version");
1517 return NULL;
1518 }
1519 calculate_dpenv_GenePhase6(mat,dpenv);
1520 out = PackAln_read_Expl_GenePhase6(mat);
1521 }
1522 else {
1523 mat = allocate_GenePhase6_only(query, target , gp, general_model);
1524 calculate_shatter_GenePhase6(mat,dpenv);
1525 out = PackAln_read_Shatter_GenePhase6(mat);
1526 }
1527 }
1528 else {
1529 if( strategy == DPIM_Linear ) {
1530 /* use small implementation */
1531 if( (mat=allocate_Small_GenePhase6(query, target , gp, general_model)) == NULL ) {
1532 warn("Unable to allocate small GenePhase6 version");
1533 return NULL;
1534 }
1535 out = PackAln_calculate_Small_GenePhase6(mat,dpenv);
1536 }
1537 else {
1538 /* use Large implementation */
1539 if( (mat=allocate_Expl_GenePhase6(query, target , gp, general_model,dpri)) == NULL ) {
1540 warn("Unable to allocate large GenePhase6 version");
1541 return NULL;
1542 }
1543 if( dpri->debug == TRUE) {
1544 fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source");
1545 }
1546 else {
1547 calculate_GenePhase6(mat);
1548 out = PackAln_read_Expl_GenePhase6(mat);
1549 }
1550 }
1551 }
1552
1553
1554 mat = free_GenePhase6(mat);
1555 return out;
1556 }
1557
1558
1559 /* Function: allocate_GenePhase6_only(query,target,gp,general_model)
1560 *
1561 * Descrip: This function only allocates the GenePhase6 structure
1562 * checks types where possible and determines leni and lenj
1563 * The basematrix area is delt with elsewhere
1564 *
1565 *
1566 * Arg: query [UNKN ] query data structure [GenePhaseScore*]
1567 * Arg: target [UNKN ] target data structure [ComplexSequence*]
1568 * Arg: gp [UNKN ] Resource [GeneParser4Score *]
1569 * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *]
1570 *
1571 * Return [UNKN ] Undocumented return value [GenePhase6 *]
1572 *
1573 */
allocate_GenePhase6_only(GenePhaseScore * query,ComplexSequence * target,GeneParser4Score * gp,GeneralGeneModelScore * general_model)1574 GenePhase6 * allocate_GenePhase6_only(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model)
1575 {
1576 GenePhase6 * out;
1577
1578
1579 if((out= GenePhase6_alloc()) == NULL) {
1580 warn("Allocation of basic GenePhase6 structure failed...");
1581 return NULL;
1582 }
1583
1584
1585 out->query = query;
1586 out->target = target;
1587 out->gp = gp;
1588 out->general_model = general_model;
1589 out->leni = query->len;
1590 out->lenj = target->seq->len;
1591 return out;
1592 }
1593
1594
1595 /* Function: allocate_Expl_GenePhase6(query,target,gp,general_model,dpri)
1596 *
1597 * Descrip: This function allocates the GenePhase6 structure
1598 * and the basematrix area for explicit memory implementations
1599 * It calls /allocate_GenePhase6_only
1600 *
1601 *
1602 * Arg: query [UNKN ] query data structure [GenePhaseScore*]
1603 * Arg: target [UNKN ] target data structure [ComplexSequence*]
1604 * Arg: gp [UNKN ] Resource [GeneParser4Score *]
1605 * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *]
1606 * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *]
1607 *
1608 * Return [UNKN ] Undocumented return value [GenePhase6 *]
1609 *
1610 */
allocate_Expl_GenePhase6(GenePhaseScore * query,ComplexSequence * target,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPRunImpl * dpri)1611 GenePhase6 * allocate_Expl_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPRunImpl * dpri)
1612 {
1613 GenePhase6 * out;
1614
1615
1616 out = allocate_GenePhase6_only(query, target , gp, general_model);
1617 if( out == NULL )
1618 return NULL;
1619 if( dpri->should_cache == TRUE ) {
1620 if( dpri->cache != NULL ) {
1621 if( dpri->cache->maxleni >= (out->lenj+10)*6 && dpri->cache->maxlenj >= (out->leni+1))
1622 out->basematrix = hard_link_BaseMatrix(dpri->cache);
1623 else
1624 dpri->cache = free_BaseMatrix(dpri->cache);
1625 }
1626 }
1627 if( out->basematrix == NULL ) {
1628 if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*6,(out->leni+1),8,out->lenj+10)) == NULL) {
1629 warn("Explicit matrix GenePhase6 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj);
1630 free_GenePhase6(out);
1631 return NULL;
1632 }
1633 }
1634 if( dpri->should_cache == TRUE && dpri->cache == NULL)
1635 dpri->cache = hard_link_BaseMatrix(out->basematrix);
1636 out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT;
1637 init_GenePhase6(out);
1638 return out;
1639 }
1640
1641
1642 /* Function: init_GenePhase6(mat)
1643 *
1644 * Descrip: This function initates GenePhase6 matrix when in explicit mode
1645 * Called in /allocate_Expl_GenePhase6
1646 *
1647 *
1648 * Arg: mat [UNKN ] GenePhase6 which contains explicit basematrix memory [GenePhase6 *]
1649 *
1650 */
init_GenePhase6(GenePhase6 * mat)1651 void init_GenePhase6(GenePhase6 * mat)
1652 {
1653 register int i;
1654 register int j;
1655 if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) {
1656 warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that");
1657 return;
1658 }
1659
1660
1661 for(i= (-1);i<mat->query->len;i++) {
1662 for(j= (-10);j<11;j++) {
1663 GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI;
1664 GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI;
1665 GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI;
1666 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI;
1667 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI;
1668 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI;
1669 }
1670 }
1671 for(j= (-10);j<mat->target->seq->len;j++) {
1672 for(i= (-1);i<2;i++) {
1673 GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI;
1674 GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI;
1675 GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI;
1676 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI;
1677 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI;
1678 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI;
1679 }
1680 GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI;
1681 GenePhase6_EXPL_SPECIAL(mat,i,j,START) = 0;
1682 GenePhase6_EXPL_SPECIAL(mat,i,j,END) = NEGI;
1683 GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_CODING) = NEGI;
1684 GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_0) = NEGI;
1685 GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_1) = NEGI;
1686 GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_2) = NEGI;
1687 GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = NEGI;
1688 }
1689 return;
1690 }
1691
1692
1693 /* Function: recalculate_PackAln_GenePhase6(pal,mat)
1694 *
1695 * Descrip: This function recalculates the PackAln structure produced by GenePhase6
1696 * For example, in linear space methods this is used to score them
1697 *
1698 *
1699 * Arg: pal [UNKN ] Undocumented argument [PackAln *]
1700 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
1701 *
1702 */
recalculate_PackAln_GenePhase6(PackAln * pal,GenePhase6 * mat)1703 void recalculate_PackAln_GenePhase6(PackAln * pal,GenePhase6 * mat)
1704 {
1705 int i,j,k,offi,offj;
1706 PackAlnUnit * prev;
1707 PackAlnUnit * pau;
1708
1709
1710 for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) {
1711 pau = pal->pau[k];
1712 i = pau->i;
1713 j = pau->j;
1714 offi = pau->i - prev->i;
1715 offj = pau->j - prev->j;
1716 switch(pau->state) {
1717 case MATCH :
1718 if( offi == 1 && offj == 3 && prev->state == MATCH ) {
1719 pau->score = (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1720 continue;
1721 }
1722 if( offi == 1 && offj == 3 && prev->state == INSERT ) {
1723 pau->score = (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1724 continue;
1725 }
1726 if( offi == 1 && offj == 3 && prev->state == DELETE ) {
1727 pau->score = (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1728 continue;
1729 }
1730 if( offj == 3 && prev->state == (START+6) ) {
1731 pau->score = ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1732 continue;
1733 }
1734 if( offj == 3 && prev->state == (BEFORE_MATCH_CODING+6) ) {
1735 pau->score = (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1736 continue;
1737 }
1738 if( offi == 1 && offj == 6 && prev->state == INTRON_0 ) {
1739 pau->score = (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1740 continue;
1741 }
1742 if( offi == 1 && offj == 5 && prev->state == INTRON_1 ) {
1743 pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-2)) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1744 continue;
1745 }
1746 if( offi == 1 && offj == 4 && prev->state == INTRON_2 ) {
1747 pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-1)) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1748 continue;
1749 }
1750 if( offi == 1 && offj == 2 && prev->state == MATCH ) {
1751 pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1752 continue;
1753 }
1754 if( offi == 1 && offj == 1 && prev->state == MATCH ) {
1755 pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1756 continue;
1757 }
1758 if( offi == 1 && offj == 4 && prev->state == MATCH ) {
1759 pau->score = mat->gp->transition[GP4_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1760 continue;
1761 }
1762 if( offi == 1 && offj == 5 && prev->state == MATCH ) {
1763 pau->score = mat->gp->transition[GP4_INSERT_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1764 continue;
1765 }
1766 warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state);
1767 break;
1768 case INSERT :
1769 if( offi == 0 && offj == 3 && prev->state == MATCH ) {
1770 pau->score = (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1771 continue;
1772 }
1773 if( offi == 0 && offj == 3 && prev->state == INSERT ) {
1774 pau->score = (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1775 continue;
1776 }
1777 if( offi == 0 && offj == 3 && prev->state == DELETE ) {
1778 pau->score = (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1779 continue;
1780 }
1781 if( offj == 3 && prev->state == (LOOP+6) ) {
1782 pau->score = ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1783 continue;
1784 }
1785 if( offi == 0 && offj == 6 && prev->state == INTRON_0 ) {
1786 pau->score = (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1787 continue;
1788 }
1789 if( offi == 0 && offj == 5 && prev->state == INTRON_1 ) {
1790 pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-2)) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1791 continue;
1792 }
1793 if( offi == 0 && offj == 4 && prev->state == INTRON_2 ) {
1794 pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-1)) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1795 continue;
1796 }
1797 if( offi == 0 && offj == 2 && prev->state == INSERT ) {
1798 pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1799 continue;
1800 }
1801 if( offi == 0 && offj == 1 && prev->state == INSERT ) {
1802 pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
1803 continue;
1804 }
1805 warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state);
1806 break;
1807 case DELETE :
1808 if( offi == 1 && offj == 0 && prev->state == MATCH ) {
1809 pau->score = mat->query->gws->seg[i]->transition[GW_MATCH2DELETE] + (0);
1810 continue;
1811 }
1812 if( offi == 1 && offj == 0 && prev->state == INSERT ) {
1813 pau->score = mat->query->gws->seg[i]->transition[GW_INSERT2DELETE] + (0);
1814 continue;
1815 }
1816 if( offi == 1 && offj == 0 && prev->state == DELETE ) {
1817 pau->score = mat->query->gws->seg[i]->transition[GW_DELETE2DELETE] + (0);
1818 continue;
1819 }
1820 warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state);
1821 break;
1822 case INTRON_0 :
1823 if( offi == 0 && offj == 8 && prev->state == MATCH ) {
1824 pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0) + (0);
1825 continue;
1826 }
1827 if( offi == 0 && offj == 8 && prev->state == INSERT ) {
1828 pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) + (0);
1829 continue;
1830 }
1831 if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) {
1832 pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0);
1833 continue;
1834 }
1835 warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state);
1836 break;
1837 case INTRON_1 :
1838 if( offi == 0 && offj == 9 && prev->state == MATCH ) {
1839 pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1) + (0);
1840 continue;
1841 }
1842 if( offi == 0 && offj == 9 && prev->state == INSERT ) {
1843 pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) + (0);
1844 continue;
1845 }
1846 if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) {
1847 pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0);
1848 continue;
1849 }
1850 warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state);
1851 break;
1852 case INTRON_2 :
1853 if( offi == 0 && offj == 10 && prev->state == MATCH ) {
1854 pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2) + (0);
1855 continue;
1856 }
1857 if( offi == 0 && offj == 10 && prev->state == INSERT ) {
1858 pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) + (0);
1859 continue;
1860 }
1861 if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) {
1862 pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0);
1863 continue;
1864 }
1865 warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state);
1866 break;
1867 case (LOOP+6) :
1868 if( offj == 1 && prev->state == (START+6) ) {
1869 pau->score = 0 + (0);
1870 continue;
1871 }
1872 if( offj == 0 && prev->state == MATCH ) {
1873 /* i here comes from the previous state ;) - not the real one */
1874 i = prev->i;
1875 pau->score = mat->query->gws->seg[i]->transition[GW_MATCH2END] + (0);
1876 continue;
1877 }
1878 if( offj == 0 && prev->state == INSERT ) {
1879 /* i here comes from the previous state ;) - not the real one */
1880 i = prev->i;
1881 pau->score = mat->query->gws->seg[i]->transition[GW_INSERT2END] + (0);
1882 continue;
1883 }
1884 if( offj == 0 && prev->state == DELETE ) {
1885 /* i here comes from the previous state ;) - not the real one */
1886 i = prev->i;
1887 pau->score = mat->query->gws->seg[i]->transition[GW_DELETE2END] + (0);
1888 continue;
1889 }
1890 if( offj == 1 && prev->state == (LOOP+6) ) {
1891 pau->score = mat->gp->transition[GP4_LOOP2LOOP] + (0);
1892 continue;
1893 }
1894 warn("In recaluclating PackAln with state LOOP, got a bad source state. Error!");
1895 break;
1896 case (START+6) :
1897 warn("In recaluclating PackAln with state START, got a bad source state. Error!");
1898 break;
1899 case (END+6) :
1900 if( offj == 1 && prev->state == (LOOP+6) ) {
1901 pau->score = 0 + (0);
1902 continue;
1903 }
1904 if( offj == 3 && prev->state == (AFTER_MATCH_CODING+6) ) {
1905 pau->score = mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0);
1906 continue;
1907 }
1908 warn("In recaluclating PackAln with state END, got a bad source state. Error!");
1909 break;
1910 case (BEFORE_MATCH_CODING+6) :
1911 if( offj == 3 && prev->state == (START+6) ) {
1912 pau->score = mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0);
1913 continue;
1914 }
1915 if( offj == 3 && prev->state == (BEFORE_MATCH_CODING+6) ) {
1916 pau->score = mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0);
1917 continue;
1918 }
1919 if( offj == 6 && prev->state == (BEFORE_MATCH_INTRON_0+6) ) {
1920 pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-3)) + (0);
1921 continue;
1922 }
1923 if( offj == 5 && prev->state == (BEFORE_MATCH_INTRON_1+6) ) {
1924 pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-2)) + (0);
1925 continue;
1926 }
1927 if( offj == 4 && prev->state == (BEFORE_MATCH_INTRON_2+6) ) {
1928 pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-1)) + (0);
1929 continue;
1930 }
1931 warn("In recaluclating PackAln with state BEFORE_MATCH_CODING, got a bad source state. Error!");
1932 break;
1933 case (BEFORE_MATCH_INTRON_0+6) :
1934 if( offj == 1 && prev->state == (BEFORE_MATCH_CODING+6) ) {
1935 pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0);
1936 continue;
1937 }
1938 if( offj == 1 && prev->state == (BEFORE_MATCH_INTRON_0+6) ) {
1939 pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0);
1940 continue;
1941 }
1942 warn("In recaluclating PackAln with state BEFORE_MATCH_INTRON_0, got a bad source state. Error!");
1943 break;
1944 case (BEFORE_MATCH_INTRON_1+6) :
1945 if( offj == 9 && prev->state == (BEFORE_MATCH_CODING+6) ) {
1946 pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0);
1947 continue;
1948 }
1949 if( offj == 1 && prev->state == (BEFORE_MATCH_INTRON_1+6) ) {
1950 pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0);
1951 continue;
1952 }
1953 warn("In recaluclating PackAln with state BEFORE_MATCH_INTRON_1, got a bad source state. Error!");
1954 break;
1955 case (BEFORE_MATCH_INTRON_2+6) :
1956 if( offj == 10 && prev->state == (BEFORE_MATCH_CODING+6) ) {
1957 pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0);
1958 continue;
1959 }
1960 if( offj == 1 && prev->state == (BEFORE_MATCH_INTRON_2+6) ) {
1961 pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0);
1962 continue;
1963 }
1964 warn("In recaluclating PackAln with state BEFORE_MATCH_INTRON_2, got a bad source state. Error!");
1965 break;
1966 case (AFTER_MATCH_CODING+6) :
1967 if( offj == 0 && prev->state == MATCH ) {
1968 /* i here comes from the previous state ;) - not the real one */
1969 i = prev->i;
1970 pau->score = mat->query->gws->seg[i]->transition[GW_MATCH2END] + (0);
1971 continue;
1972 }
1973 if( offj == 3 && prev->state == (AFTER_MATCH_CODING+6) ) {
1974 pau->score = mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0);
1975 continue;
1976 }
1977 warn("In recaluclating PackAln with state AFTER_MATCH_CODING, got a bad source state. Error!");
1978 break;
1979 default :
1980 warn("In recaluclating PackAln got a bad recipient state. Error!");
1981 }
1982 prev = pau;
1983 }
1984 return;
1985 }
1986 /* divide and conquor macros are next */
1987 #define GenePhase6_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+1)*6+state])
1988 #define GenePhase6_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+1)*6+state])
1989 #define GenePhase6_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)])
1990 #define GenePhase6_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)])
1991 #define GenePhase6_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+1)*6 + state])
1992 #define GenePhase6_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)])
1993 #define GenePhase6_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 6) + ((i+1) * 6) + (state)])
1994 #define GenePhase6_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 48) + ((i+1) * 48) + (state * 8) + shadow+1])
1995 #define GenePhase6_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)])
1996 /* Function: allocate_Small_GenePhase6(query,target,gp,general_model)
1997 *
1998 * Descrip: This function allocates the GenePhase6 structure
1999 * and the basematrix area for a small memory implementations
2000 * It calls /allocate_GenePhase6_only
2001 *
2002 *
2003 * Arg: query [UNKN ] query data structure [GenePhaseScore*]
2004 * Arg: target [UNKN ] target data structure [ComplexSequence*]
2005 * Arg: gp [UNKN ] Resource [GeneParser4Score *]
2006 * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *]
2007 *
2008 * Return [UNKN ] Undocumented return value [GenePhase6 *]
2009 *
2010 */
2011 #define GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)])
allocate_Small_GenePhase6(GenePhaseScore * query,ComplexSequence * target,GeneParser4Score * gp,GeneralGeneModelScore * general_model)2012 GenePhase6 * allocate_Small_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model)
2013 {
2014 GenePhase6 * out;
2015
2016
2017 out = allocate_GenePhase6_only(query, target , gp, general_model);
2018 if( out == NULL )
2019 return NULL;
2020 out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 1) * 6,64,out->lenj+10);
2021 if(out == NULL) {
2022 warn("Small shadow matrix GenePhase6 cannot be allocated, (asking for 11 by %d main cells)",out->leni+2);
2023 free_GenePhase6(out);
2024 return NULL;
2025 }
2026 out->basematrix->type = BASEMATRIX_TYPE_SHADOW;
2027 return out;
2028 }
2029
2030
2031 /* Function: PackAln_calculate_Small_GenePhase6(mat,dpenv)
2032 *
2033 * Descrip: This function calculates an alignment for GenePhase6 structure in linear space
2034 * If you want only the start/end points
2035 * use /AlnRangeSet_calculate_Small_GenePhase6
2036 *
2037 * The function basically
2038 * finds start/end points
2039 * foreach start/end point
2040 * calls /full_dc_GenePhase6
2041 *
2042 *
2043 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
2044 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
2045 *
2046 * Return [UNKN ] Undocumented return value [PackAln *]
2047 *
2048 */
PackAln_calculate_Small_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv)2049 PackAln * PackAln_calculate_Small_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv)
2050 {
2051 int endj;
2052 int score;
2053 PackAln * out;
2054 PackAlnUnit * pau;
2055 int starti;
2056 int startj;
2057 int startstate;
2058 int stopi;
2059 int stopj;
2060 int stopstate;
2061 int temp;
2062 int donej; /* This is for reporting, will be passed as a & arg in */
2063 int totalj; /* This also is for reporting, but as is not changed, can be passed by value */
2064
2065
2066 if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) {
2067 warn("Could not calculate packaln small for GenePhase6 due to wrong type of matrix");
2068 return NULL;
2069 }
2070
2071
2072 out = PackAln_alloc_std();
2073
2074
2075 start_reporting("Find start end points: ");
2076 dc_optimised_start_end_calc_GenePhase6(mat,dpenv);
2077 score = start_end_find_end_GenePhase6(mat,&endj);
2078 out->score = score;
2079 stopstate = END;
2080
2081 /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */
2082 log_full_error(REPORT,0,"End at %d Score %d",endj,score);
2083 stop_reporting();
2084 for(;;) { /*while there are more special bits to recover*/
2085 start_reporting("Special cell aln end %d:",endj);
2086 if( read_special_strip_GenePhase6(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) {
2087 warn("Problem in reading off special state system... going to return partial alignment");
2088 break;
2089 }
2090 if( startstate == START || endj <= 0) {
2091 log_full_error(REPORT,0,"Recovered complete alignment");
2092 stop_reporting();
2093 break;
2094 }
2095
2096
2097 log_full_error(REPORT,0,"Finished to %d",endj);
2098 stop_reporting();
2099
2100
2101 /* Ok... have to eat up another piece of matrix <sigh> */
2102 temp = startstate;
2103 starti = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0);
2104 startj = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1);
2105 startstate = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2);
2106 stopi = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3);
2107 stopj = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4);
2108 stopstate = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5);
2109
2110
2111 /* Get out the score of this block. V. important! */
2112 temp = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6);
2113 totalj = stopj - startj;
2114 donej = 0;
2115 start_reporting("Main matrix aln [%d,%d]:",startj,stopj);
2116 if(full_dc_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) {
2117 warn("In the alignment GenePhase6 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj);
2118 return out;
2119 }
2120
2121
2122 /* now have to figure out which special we came from... yikes */
2123 max_matrix_to_special_GenePhase6(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL);
2124 if( stopi == GenePhase6_READ_OFF_ERROR) {
2125 warn("In GenePhase6 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj);
2126 invert_PackAln(out);
2127 recalculate_PackAln_GenePhase6(out,mat);
2128 return out;
2129 }
2130 /* if at start, break, otherwise, back to eat another strip */
2131 if( stopstate == START) {
2132 log_full_error(REPORT,0,"Recovered complete alignment ");
2133 stop_reporting();
2134 break;
2135 }
2136 log_full_error(REPORT,0,"Finished alignment to %d ",startj);
2137 stop_reporting();
2138 endj = stopj;
2139 /* stopstate is correct as it is */
2140 } /* end of while there are more special bits to recover */
2141 invert_PackAln(out);
2142 recalculate_PackAln_GenePhase6(out,mat);
2143 return out;
2144
2145
2146 }
2147
2148
2149 /* Function: AlnRangeSet_calculate_Small_GenePhase6(mat)
2150 *
2151 * Descrip: This function calculates an alignment for GenePhase6 structure in linear space
2152 * If you want the full alignment, use /PackAln_calculate_Small_GenePhase6
2153 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GenePhase6
2154 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GenePhase6
2155 *
2156 *
2157 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
2158 *
2159 * Return [UNKN ] Undocumented return value [AlnRangeSet *]
2160 *
2161 */
AlnRangeSet_calculate_Small_GenePhase6(GenePhase6 * mat)2162 AlnRangeSet * AlnRangeSet_calculate_Small_GenePhase6(GenePhase6 * mat)
2163 {
2164 AlnRangeSet * out;
2165
2166
2167 start_reporting("Find start end points: ");
2168 dc_optimised_start_end_calc_GenePhase6(mat,NULL);
2169 log_full_error(REPORT,0,"Calculated");
2170
2171
2172 out = AlnRangeSet_from_GenePhase6(mat);
2173 return out;
2174 }
2175
2176
2177 /* Function: AlnRangeSet_from_GenePhase6(mat)
2178 *
2179 * Descrip: This function reads off a start/end structure
2180 * for GenePhase6 structure in linear space
2181 * If you want the full alignment use
2182 * /PackAln_calculate_Small_GenePhase6
2183 * If you have not calculated the matrix use
2184 * /AlnRange_calculate_Small_GenePhase6
2185 *
2186 *
2187 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
2188 *
2189 * Return [UNKN ] Undocumented return value [AlnRangeSet *]
2190 *
2191 */
AlnRangeSet_from_GenePhase6(GenePhase6 * mat)2192 AlnRangeSet * AlnRangeSet_from_GenePhase6(GenePhase6 * mat)
2193 {
2194 AlnRangeSet * out;
2195 AlnRange * temp;
2196 int jpos;
2197 int state;
2198
2199
2200 if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) {
2201 warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GenePhase6");
2202 return NULL;
2203 }
2204
2205
2206 out = AlnRangeSet_alloc_std();
2207 /* Find the end position */
2208 out->score = start_end_find_end_GenePhase6(mat,&jpos);
2209 state = END;
2210
2211
2212 while( (temp = AlnRange_build_GenePhase6(mat,jpos,state,&jpos,&state)) != NULL)
2213 add_AlnRangeSet(out,temp);
2214 return out;
2215 }
2216
2217
2218 /* Function: AlnRange_build_GenePhase6(mat,stopj,stopspecstate,startj,startspecstate)
2219 *
2220 * Descrip: This function calculates a single start/end set in linear space
2221 * Really a sub-routine for /AlnRangeSet_from_PackAln_GenePhase6
2222 *
2223 *
2224 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
2225 * Arg: stopj [UNKN ] Undocumented argument [int]
2226 * Arg: stopspecstate [UNKN ] Undocumented argument [int]
2227 * Arg: startj [UNKN ] Undocumented argument [int *]
2228 * Arg: startspecstate [UNKN ] Undocumented argument [int *]
2229 *
2230 * Return [UNKN ] Undocumented return value [AlnRange *]
2231 *
2232 */
AlnRange_build_GenePhase6(GenePhase6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate)2233 AlnRange * AlnRange_build_GenePhase6(GenePhase6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate)
2234 {
2235 AlnRange * out;
2236 int jpos;
2237 int state;
2238
2239
2240 if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) {
2241 warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GenePhase6");
2242 return NULL;
2243 }
2244
2245
2246 /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */
2247 if( read_special_strip_GenePhase6(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) {
2248 warn("In AlnRanger_build_GenePhase6 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj);
2249 return NULL;
2250 }
2251 if( state == START || jpos <= 0)
2252 return NULL;
2253
2254
2255 out = AlnRange_alloc();
2256
2257
2258 out->starti = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0);
2259 out->startj = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1);
2260 out->startstate = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2);
2261 out->stopi = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3);
2262 out->stopj = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4);
2263 out->stopstate = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5);
2264 out->startscore = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6);
2265 out->stopscore = GenePhase6_DC_SHADOW_SPECIAL(mat,0,jpos,state);
2266
2267
2268 /* Now, we have to figure out where this state came from in the specials */
2269 max_matrix_to_special_GenePhase6(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL);
2270 if( jpos == GenePhase6_READ_OFF_ERROR) {
2271 warn("In AlnRange_build_GenePhase6 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj);
2272 return out;
2273 }
2274
2275
2276 /* Put in the correct score for startstate, from the special */
2277 out->startscore = GenePhase6_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate);
2278 /* The correct j coords have been put into startj, startspecstate... so just return out */
2279 return out;
2280 }
2281
2282
2283 /* Function: read_hidden_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,out)
2284 *
2285 * Descrip: No Description
2286 *
2287 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
2288 * Arg: starti [UNKN ] Undocumented argument [int]
2289 * Arg: startj [UNKN ] Undocumented argument [int]
2290 * Arg: startstate [UNKN ] Undocumented argument [int]
2291 * Arg: stopi [UNKN ] Undocumented argument [int]
2292 * Arg: stopj [UNKN ] Undocumented argument [int]
2293 * Arg: stopstate [UNKN ] Undocumented argument [int]
2294 * Arg: out [UNKN ] Undocumented argument [PackAln *]
2295 *
2296 * Return [UNKN ] Undocumented return value [boolean]
2297 *
2298 */
read_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out)2299 boolean read_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out)
2300 {
2301 int i;
2302 int j;
2303 int state;
2304 int cellscore;
2305 int isspecial;
2306 /* We don't need hiddenj here, 'cause matrix access handled by max funcs */
2307 PackAlnUnit * pau;
2308
2309
2310 /* stop position is on the path */
2311 i = stopi;
2312 j = stopj;
2313 state= stopstate;
2314 isspecial = FALSE;
2315
2316
2317 while( i >= starti && j >= startj) {
2318 /* Put away current i,j,state */
2319 pau = PackAlnUnit_alloc();/* Should deal with memory overflow */
2320 pau->i = i;
2321 pau->j = j;
2322 pau->state = state;
2323 add_PackAln(out,pau);
2324
2325
2326 max_hidden_GenePhase6(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore);
2327
2328
2329 if( i == GenePhase6_READ_OFF_ERROR) {
2330 warn("In GenePhase6 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj);
2331 return FALSE;
2332 }
2333
2334
2335 if( i == starti && j == startj && state == startstate) {
2336 /* Put away final state (start of this block) */
2337 pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */
2338 pau->i = i;
2339 pau->j = j;
2340 pau->state = state;
2341 add_PackAln(out,pau);
2342 return TRUE;
2343 }
2344 if( i == starti && j == startj) {
2345 warn("In GenePhase6 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj);
2346 return FALSE;
2347 }
2348 }
2349 warn("In GenePhase6 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state);
2350 return FALSE;
2351 }
2352
2353
2354 /* Function: max_hidden_GenePhase6(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore)
2355 *
2356 * Descrip: No Description
2357 *
2358 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
2359 * Arg: hiddenj [UNKN ] Undocumented argument [int]
2360 * Arg: i [UNKN ] Undocumented argument [int]
2361 * Arg: j [UNKN ] Undocumented argument [int]
2362 * Arg: state [UNKN ] Undocumented argument [int]
2363 * Arg: isspecial [UNKN ] Undocumented argument [boolean]
2364 * Arg: reti [UNKN ] Undocumented argument [int *]
2365 * Arg: retj [UNKN ] Undocumented argument [int *]
2366 * Arg: retstate [UNKN ] Undocumented argument [int *]
2367 * Arg: retspecial [UNKN ] Undocumented argument [boolean *]
2368 * Arg: cellscore [UNKN ] Undocumented argument [int *]
2369 *
2370 * Return [UNKN ] Undocumented return value [int]
2371 *
2372 */
max_hidden_GenePhase6(GenePhase6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)2373 int max_hidden_GenePhase6(GenePhase6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)
2374 {
2375 register int temp;
2376 register int cscore;
2377
2378
2379 *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR;
2380
2381
2382 if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) {
2383 warn("In GenePhase6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state);
2384 return -1;
2385 }
2386
2387
2388 /* Then you have to select the correct switch statement to figure out the readoff */
2389 /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */
2390 cscore = GenePhase6_HIDDEN_MATRIX(mat,i,j,state);
2391 switch(state) { /*Switch state */
2392 case MATCH :
2393 temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2394 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) {
2395 *reti = i - 1;
2396 *retj = j - 5;
2397 *retstate = MATCH;
2398 *retspecial = FALSE;
2399 if( cellscore != NULL) {
2400 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH);
2401 }
2402 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH);
2403 }
2404 temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2405 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) {
2406 *reti = i - 1;
2407 *retj = j - 4;
2408 *retstate = MATCH;
2409 *retspecial = FALSE;
2410 if( cellscore != NULL) {
2411 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH);
2412 }
2413 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH);
2414 }
2415 temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2416 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) {
2417 *reti = i - 1;
2418 *retj = j - 1;
2419 *retstate = MATCH;
2420 *retspecial = FALSE;
2421 if( cellscore != NULL) {
2422 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH);
2423 }
2424 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH);
2425 }
2426 temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2427 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) {
2428 *reti = i - 1;
2429 *retj = j - 2;
2430 *retstate = MATCH;
2431 *retspecial = FALSE;
2432 if( cellscore != NULL) {
2433 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH);
2434 }
2435 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH);
2436 }
2437 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2438 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2) ) {
2439 *reti = i - 1;
2440 *retj = j - 4;
2441 *retstate = INTRON_2;
2442 *retspecial = FALSE;
2443 if( cellscore != NULL) {
2444 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2);
2445 }
2446 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2);
2447 }
2448 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2449 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1) ) {
2450 *reti = i - 1;
2451 *retj = j - 5;
2452 *retstate = INTRON_1;
2453 *retspecial = FALSE;
2454 if( cellscore != NULL) {
2455 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1);
2456 }
2457 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1);
2458 }
2459 temp = cscore - ((mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2460 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0) ) {
2461 *reti = i - 1;
2462 *retj = j - 6;
2463 *retstate = INTRON_0;
2464 *retspecial = FALSE;
2465 if( cellscore != NULL) {
2466 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0);
2467 }
2468 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0);
2469 }
2470 /* Not allowing special sources.. skipping BEFORE_MATCH_CODING */
2471 /* Not allowing special sources.. skipping START */
2472 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2473 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) {
2474 *reti = i - 1;
2475 *retj = j - 3;
2476 *retstate = DELETE;
2477 *retspecial = FALSE;
2478 if( cellscore != NULL) {
2479 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE);
2480 }
2481 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE);
2482 }
2483 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2484 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) {
2485 *reti = i - 1;
2486 *retj = j - 3;
2487 *retstate = INSERT;
2488 *retspecial = FALSE;
2489 if( cellscore != NULL) {
2490 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT);
2491 }
2492 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT);
2493 }
2494 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2495 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) {
2496 *reti = i - 1;
2497 *retj = j - 3;
2498 *retstate = MATCH;
2499 *retspecial = FALSE;
2500 if( cellscore != NULL) {
2501 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH);
2502 }
2503 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH);
2504 }
2505 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
2506 return (-1);
2507 case INSERT :
2508 temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2509 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) {
2510 *reti = i - 0;
2511 *retj = j - 1;
2512 *retstate = INSERT;
2513 *retspecial = FALSE;
2514 if( cellscore != NULL) {
2515 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT);
2516 }
2517 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT);
2518 }
2519 temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2520 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) {
2521 *reti = i - 0;
2522 *retj = j - 2;
2523 *retstate = INSERT;
2524 *retspecial = FALSE;
2525 if( cellscore != NULL) {
2526 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT);
2527 }
2528 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT);
2529 }
2530 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2531 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2) ) {
2532 *reti = i - 0;
2533 *retj = j - 4;
2534 *retstate = INTRON_2;
2535 *retspecial = FALSE;
2536 if( cellscore != NULL) {
2537 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2);
2538 }
2539 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2);
2540 }
2541 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2542 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1) ) {
2543 *reti = i - 0;
2544 *retj = j - 5;
2545 *retstate = INTRON_1;
2546 *retspecial = FALSE;
2547 if( cellscore != NULL) {
2548 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1);
2549 }
2550 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1);
2551 }
2552 temp = cscore - ((mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2553 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0) ) {
2554 *reti = i - 0;
2555 *retj = j - 6;
2556 *retstate = INTRON_0;
2557 *retspecial = FALSE;
2558 if( cellscore != NULL) {
2559 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0);
2560 }
2561 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0);
2562 }
2563 /* Not allowing special sources.. skipping LOOP */
2564 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2565 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) {
2566 *reti = i - 0;
2567 *retj = j - 3;
2568 *retstate = DELETE;
2569 *retspecial = FALSE;
2570 if( cellscore != NULL) {
2571 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE);
2572 }
2573 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE);
2574 }
2575 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2576 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) {
2577 *reti = i - 0;
2578 *retj = j - 3;
2579 *retstate = INSERT;
2580 *retspecial = FALSE;
2581 if( cellscore != NULL) {
2582 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT);
2583 }
2584 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT);
2585 }
2586 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
2587 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) {
2588 *reti = i - 0;
2589 *retj = j - 3;
2590 *retstate = MATCH;
2591 *retspecial = FALSE;
2592 if( cellscore != NULL) {
2593 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH);
2594 }
2595 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH);
2596 }
2597 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
2598 return (-1);
2599 case DELETE :
2600 temp = cscore - (mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]) - (0);
2601 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) {
2602 *reti = i - 1;
2603 *retj = j - 0;
2604 *retstate = DELETE;
2605 *retspecial = FALSE;
2606 if( cellscore != NULL) {
2607 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE);
2608 }
2609 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE);
2610 }
2611 temp = cscore - (mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]) - (0);
2612 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) {
2613 *reti = i - 1;
2614 *retj = j - 0;
2615 *retstate = INSERT;
2616 *retspecial = FALSE;
2617 if( cellscore != NULL) {
2618 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT);
2619 }
2620 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT);
2621 }
2622 temp = cscore - (mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]) - (0);
2623 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) {
2624 *reti = i - 1;
2625 *retj = j - 0;
2626 *retstate = MATCH;
2627 *retspecial = FALSE;
2628 if( cellscore != NULL) {
2629 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH);
2630 }
2631 return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH);
2632 }
2633 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
2634 return (-1);
2635 case INTRON_0 :
2636 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
2637 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) {
2638 *reti = i - 0;
2639 *retj = j - 1;
2640 *retstate = INTRON_0;
2641 *retspecial = FALSE;
2642 if( cellscore != NULL) {
2643 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0);
2644 }
2645 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0);
2646 }
2647 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0);
2648 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) {
2649 *reti = i - 0;
2650 *retj = j - 8;
2651 *retstate = INSERT;
2652 *retspecial = FALSE;
2653 if( cellscore != NULL) {
2654 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT);
2655 }
2656 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT);
2657 }
2658 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0)) - (0);
2659 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) {
2660 *reti = i - 0;
2661 *retj = j - 8;
2662 *retstate = MATCH;
2663 *retspecial = FALSE;
2664 if( cellscore != NULL) {
2665 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH);
2666 }
2667 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH);
2668 }
2669 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
2670 return (-1);
2671 case INTRON_1 :
2672 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
2673 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) {
2674 *reti = i - 0;
2675 *retj = j - 1;
2676 *retstate = INTRON_1;
2677 *retspecial = FALSE;
2678 if( cellscore != NULL) {
2679 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1);
2680 }
2681 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1);
2682 }
2683 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0);
2684 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) {
2685 *reti = i - 0;
2686 *retj = j - 9;
2687 *retstate = INSERT;
2688 *retspecial = FALSE;
2689 if( cellscore != NULL) {
2690 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT);
2691 }
2692 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT);
2693 }
2694 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1)) - (0);
2695 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) {
2696 *reti = i - 0;
2697 *retj = j - 9;
2698 *retstate = MATCH;
2699 *retspecial = FALSE;
2700 if( cellscore != NULL) {
2701 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH);
2702 }
2703 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH);
2704 }
2705 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
2706 return (-1);
2707 case INTRON_2 :
2708 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
2709 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) {
2710 *reti = i - 0;
2711 *retj = j - 1;
2712 *retstate = INTRON_2;
2713 *retspecial = FALSE;
2714 if( cellscore != NULL) {
2715 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2);
2716 }
2717 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2);
2718 }
2719 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0);
2720 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) {
2721 *reti = i - 0;
2722 *retj = j - 10;
2723 *retstate = INSERT;
2724 *retspecial = FALSE;
2725 if( cellscore != NULL) {
2726 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT);
2727 }
2728 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT);
2729 }
2730 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2)) - (0);
2731 if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) {
2732 *reti = i - 0;
2733 *retj = j - 10;
2734 *retstate = MATCH;
2735 *retspecial = FALSE;
2736 if( cellscore != NULL) {
2737 *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH);
2738 }
2739 return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH);
2740 }
2741 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
2742 return (-1);
2743 default:
2744 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
2745 return (-1);
2746 } /* end of Switch state */
2747 }
2748
2749
2750 /* Function: read_special_strip_GenePhase6(mat,stopi,stopj,stopstate,startj,startstate,out)
2751 *
2752 * Descrip: No Description
2753 *
2754 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
2755 * Arg: stopi [UNKN ] Undocumented argument [int]
2756 * Arg: stopj [UNKN ] Undocumented argument [int]
2757 * Arg: stopstate [UNKN ] Undocumented argument [int]
2758 * Arg: startj [UNKN ] Undocumented argument [int *]
2759 * Arg: startstate [UNKN ] Undocumented argument [int *]
2760 * Arg: out [UNKN ] Undocumented argument [PackAln *]
2761 *
2762 * Return [UNKN ] Undocumented return value [boolean]
2763 *
2764 */
read_special_strip_GenePhase6(GenePhase6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out)2765 boolean read_special_strip_GenePhase6(GenePhase6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out)
2766 {
2767 int i;
2768 int j;
2769 int state;
2770 int cellscore;
2771 int isspecial;
2772 PackAlnUnit * pau;
2773
2774
2775 /* stop position is on the path */
2776 i = stopi;
2777 j = stopj;
2778 state= stopstate;
2779 isspecial = TRUE;
2780
2781
2782 /* Loop until state has the same j as its stop in shadow pointers */
2783 /* This will be the state is came out from, OR it has hit !start */
2784 /* We may not want to get the alignment, in which case out will be NULL */
2785 while( j > GenePhase6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/
2786 /* Put away current state, if we should */
2787 if(out != NULL) {
2788 pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */
2789 pau->i = i;
2790 pau->j = j;
2791 pau->state = state + 6;
2792 add_PackAln(out,pau);
2793 }
2794
2795
2796 max_special_strip_GenePhase6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore);
2797 if( i == GenePhase6_READ_OFF_ERROR) {
2798 warn("In special strip read GenePhase6, got a bad read off error. Sorry!");
2799 return FALSE;
2800 }
2801 } /* end of while more specials to eat up */
2802
2803
2804 /* check to see we have not gone too far! */
2805 if( state != START && j < GenePhase6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) {
2806 warn("In special strip read GenePhase6, at special [%d] state [%d] overshot!",j,state);
2807 return FALSE;
2808 }
2809 /* Put away last state */
2810 if(out != NULL) {
2811 pau = PackAlnUnit_alloc();/* Should deal with memory overflow */
2812 pau->i = i;
2813 pau->j = j;
2814 pau->state = state + 6;
2815 add_PackAln(out,pau);
2816 }
2817
2818
2819 /* Put away where we are in startj and startstate */
2820 *startj = j;
2821 *startstate = state;
2822 return TRUE;
2823 }
2824
2825
2826 /* Function: max_special_strip_GenePhase6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore)
2827 *
2828 * Descrip: A pretty intense internal function. Deals with read-off only in specials
2829 *
2830 *
2831 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
2832 * Arg: i [UNKN ] Undocumented argument [int]
2833 * Arg: j [UNKN ] Undocumented argument [int]
2834 * Arg: state [UNKN ] Undocumented argument [int]
2835 * Arg: isspecial [UNKN ] Undocumented argument [boolean]
2836 * Arg: reti [UNKN ] Undocumented argument [int *]
2837 * Arg: retj [UNKN ] Undocumented argument [int *]
2838 * Arg: retstate [UNKN ] Undocumented argument [int *]
2839 * Arg: retspecial [UNKN ] Undocumented argument [boolean *]
2840 * Arg: cellscore [UNKN ] Undocumented argument [int *]
2841 *
2842 * Return [UNKN ] Undocumented return value [int]
2843 *
2844 */
max_special_strip_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)2845 int max_special_strip_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)
2846 {
2847 int temp;
2848 int cscore;
2849
2850
2851 *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR;
2852 if( isspecial == FALSE ) {
2853 warn("In special strip max function for GenePhase6, got a non special start point. Problem! (bad!)");
2854 return (-1);
2855 }
2856
2857
2858 if( j < 0 || j > mat->target->seq->len) {
2859 warn("In GenePhase6 matrix special read off - out of bounds on matrix [j is %d in special]",j);
2860 return -1;
2861 }
2862
2863
2864 cscore = GenePhase6_DC_SHADOW_SPECIAL(mat,i,j,state);
2865 switch(state) { /*switch on special states*/
2866 case LOOP :
2867 /* source LOOP is a special */
2868 temp = cscore - (mat->gp->transition[GP4_LOOP2LOOP]) - (0);
2869 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) {
2870 *reti = i - 0;
2871 *retj = j - 1;
2872 *retstate = LOOP;
2873 *retspecial = TRUE;
2874 if( cellscore != NULL) {
2875 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP);
2876 }
2877 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ;
2878 }
2879 /* Source DELETE is not a special */
2880 /* Source INSERT is not a special */
2881 /* Source MATCH is not a special */
2882 /* source START is a special */
2883 temp = cscore - (0) - (0);
2884 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) {
2885 *reti = i - 0;
2886 *retj = j - 1;
2887 *retstate = START;
2888 *retspecial = TRUE;
2889 if( cellscore != NULL) {
2890 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,START);
2891 }
2892 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ;
2893 }
2894 case START :
2895 case END :
2896 /* source AFTER_MATCH_CODING is a special */
2897 temp = cscore - (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0);
2898 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) {
2899 *reti = i - 0;
2900 *retj = j - 3;
2901 *retstate = AFTER_MATCH_CODING;
2902 *retspecial = TRUE;
2903 if( cellscore != NULL) {
2904 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,AFTER_MATCH_CODING);
2905 }
2906 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,AFTER_MATCH_CODING) ;
2907 }
2908 /* source LOOP is a special */
2909 temp = cscore - (0) - (0);
2910 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) {
2911 *reti = i - 0;
2912 *retj = j - 1;
2913 *retstate = LOOP;
2914 *retspecial = TRUE;
2915 if( cellscore != NULL) {
2916 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP);
2917 }
2918 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ;
2919 }
2920 case BEFORE_MATCH_CODING :
2921 /* source BEFORE_MATCH_INTRON_2 is a special */
2922 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (0);
2923 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2) ) {
2924 *reti = i - 0;
2925 *retj = j - 4;
2926 *retstate = BEFORE_MATCH_INTRON_2;
2927 *retspecial = TRUE;
2928 if( cellscore != NULL) {
2929 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-4,BEFORE_MATCH_INTRON_2);
2930 }
2931 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2) ;
2932 }
2933 /* source BEFORE_MATCH_INTRON_1 is a special */
2934 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (0);
2935 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1) ) {
2936 *reti = i - 0;
2937 *retj = j - 5;
2938 *retstate = BEFORE_MATCH_INTRON_1;
2939 *retspecial = TRUE;
2940 if( cellscore != NULL) {
2941 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-5,BEFORE_MATCH_INTRON_1);
2942 }
2943 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1) ;
2944 }
2945 /* source BEFORE_MATCH_INTRON_0 is a special */
2946 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-3))) - (0);
2947 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0) ) {
2948 *reti = i - 0;
2949 *retj = j - 6;
2950 *retstate = BEFORE_MATCH_INTRON_0;
2951 *retspecial = TRUE;
2952 if( cellscore != NULL) {
2953 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-6,BEFORE_MATCH_INTRON_0);
2954 }
2955 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0) ;
2956 }
2957 /* source BEFORE_MATCH_CODING is a special */
2958 temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0);
2959 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ) {
2960 *reti = i - 0;
2961 *retj = j - 3;
2962 *retstate = BEFORE_MATCH_CODING;
2963 *retspecial = TRUE;
2964 if( cellscore != NULL) {
2965 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,BEFORE_MATCH_CODING);
2966 }
2967 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ;
2968 }
2969 /* source START is a special */
2970 temp = cscore - (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0);
2971 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) {
2972 *reti = i - 0;
2973 *retj = j - 3;
2974 *retstate = START;
2975 *retspecial = TRUE;
2976 if( cellscore != NULL) {
2977 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,START);
2978 }
2979 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ;
2980 }
2981 case BEFORE_MATCH_INTRON_0 :
2982 /* source BEFORE_MATCH_INTRON_0 is a special */
2983 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
2984 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0) ) {
2985 *reti = i - 0;
2986 *retj = j - 1;
2987 *retstate = BEFORE_MATCH_INTRON_0;
2988 *retspecial = TRUE;
2989 if( cellscore != NULL) {
2990 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_MATCH_INTRON_0);
2991 }
2992 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0) ;
2993 }
2994 /* source BEFORE_MATCH_CODING is a special */
2995 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0);
2996 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_MATCH_CODING) ) {
2997 *reti = i - 0;
2998 *retj = j - 1;
2999 *retstate = BEFORE_MATCH_CODING;
3000 *retspecial = TRUE;
3001 if( cellscore != NULL) {
3002 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_MATCH_CODING);
3003 }
3004 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_MATCH_CODING) ;
3005 }
3006 case BEFORE_MATCH_INTRON_1 :
3007 /* source BEFORE_MATCH_INTRON_1 is a special */
3008 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
3009 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1) ) {
3010 *reti = i - 0;
3011 *retj = j - 1;
3012 *retstate = BEFORE_MATCH_INTRON_1;
3013 *retspecial = TRUE;
3014 if( cellscore != NULL) {
3015 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_MATCH_INTRON_1);
3016 }
3017 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1) ;
3018 }
3019 /* source BEFORE_MATCH_CODING is a special */
3020 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0);
3021 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 9,BEFORE_MATCH_CODING) ) {
3022 *reti = i - 0;
3023 *retj = j - 9;
3024 *retstate = BEFORE_MATCH_CODING;
3025 *retspecial = TRUE;
3026 if( cellscore != NULL) {
3027 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-9,BEFORE_MATCH_CODING);
3028 }
3029 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 9,BEFORE_MATCH_CODING) ;
3030 }
3031 case BEFORE_MATCH_INTRON_2 :
3032 /* source BEFORE_MATCH_INTRON_2 is a special */
3033 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
3034 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2) ) {
3035 *reti = i - 0;
3036 *retj = j - 1;
3037 *retstate = BEFORE_MATCH_INTRON_2;
3038 *retspecial = TRUE;
3039 if( cellscore != NULL) {
3040 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_MATCH_INTRON_2);
3041 }
3042 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2) ;
3043 }
3044 /* source BEFORE_MATCH_CODING is a special */
3045 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0);
3046 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 10,BEFORE_MATCH_CODING) ) {
3047 *reti = i - 0;
3048 *retj = j - 10;
3049 *retstate = BEFORE_MATCH_CODING;
3050 *retspecial = TRUE;
3051 if( cellscore != NULL) {
3052 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-10,BEFORE_MATCH_CODING);
3053 }
3054 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 10,BEFORE_MATCH_CODING) ;
3055 }
3056 case AFTER_MATCH_CODING :
3057 /* source AFTER_MATCH_CODING is a special */
3058 temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0);
3059 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) {
3060 *reti = i - 0;
3061 *retj = j - 3;
3062 *retstate = AFTER_MATCH_CODING;
3063 *retspecial = TRUE;
3064 if( cellscore != NULL) {
3065 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,AFTER_MATCH_CODING);
3066 }
3067 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,AFTER_MATCH_CODING) ;
3068 }
3069 /* Source MATCH is not a special */
3070 default:
3071 warn("Major problem (!) - in GenePhase6 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state);
3072 return (-1);
3073 } /* end of switch on special states */
3074 }
3075
3076
3077 /* Function: max_matrix_to_special_GenePhase6(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore)
3078 *
3079 * Descrip: No Description
3080 *
3081 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
3082 * Arg: i [UNKN ] Undocumented argument [int]
3083 * Arg: j [UNKN ] Undocumented argument [int]
3084 * Arg: state [UNKN ] Undocumented argument [int]
3085 * Arg: cscore [UNKN ] Undocumented argument [int]
3086 * Arg: reti [UNKN ] Undocumented argument [int *]
3087 * Arg: retj [UNKN ] Undocumented argument [int *]
3088 * Arg: retstate [UNKN ] Undocumented argument [int *]
3089 * Arg: retspecial [UNKN ] Undocumented argument [boolean *]
3090 * Arg: cellscore [UNKN ] Undocumented argument [int *]
3091 *
3092 * Return [UNKN ] Undocumented return value [int]
3093 *
3094 */
max_matrix_to_special_GenePhase6(GenePhase6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)3095 int max_matrix_to_special_GenePhase6(GenePhase6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)
3096 {
3097 int temp;
3098 *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR;
3099
3100
3101 if( j < 0 || j > mat->lenj) {
3102 warn("In GenePhase6 matrix to special read off - out of bounds on matrix [j is %d in special]",j);
3103 return -1;
3104 }
3105
3106
3107 switch(state) { /*Switch state */
3108 case MATCH :
3109 /* Source MATCH is not a special, should not get here! */
3110 /* Source MATCH is not a special, should not get here! */
3111 /* Source MATCH is not a special, should not get here! */
3112 /* Source MATCH is not a special, should not get here! */
3113 /* Source INTRON_2 is not a special, should not get here! */
3114 /* Source INTRON_1 is not a special, should not get here! */
3115 /* Source INTRON_0 is not a special, should not get here! */
3116 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
3117 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,BEFORE_MATCH_CODING) ) {
3118 *reti = i - 1;
3119 *retj = j - 3;
3120 *retstate = BEFORE_MATCH_CODING;
3121 *retspecial = TRUE;
3122 if( cellscore != NULL) {
3123 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING);
3124 }
3125 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 1,j - 3,BEFORE_MATCH_CODING) ;
3126 }
3127 temp = cscore - (((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
3128 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) {
3129 *reti = i - 1;
3130 *retj = j - 3;
3131 *retstate = START;
3132 *retspecial = TRUE;
3133 if( cellscore != NULL) {
3134 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-1,j-3,START);
3135 }
3136 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ;
3137 }
3138 /* Source DELETE is not a special, should not get here! */
3139 /* Source INSERT is not a special, should not get here! */
3140 /* Source MATCH is not a special, should not get here! */
3141 warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state);
3142 return (-1);
3143 case INSERT :
3144 /* Source INSERT is not a special, should not get here! */
3145 /* Source INSERT is not a special, should not get here! */
3146 /* Source INTRON_2 is not a special, should not get here! */
3147 /* Source INTRON_1 is not a special, should not get here! */
3148 /* Source INTRON_0 is not a special, should not get here! */
3149 temp = cscore - (((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
3150 if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,LOOP) ) {
3151 *reti = i - 0;
3152 *retj = j - 3;
3153 *retstate = LOOP;
3154 *retspecial = TRUE;
3155 if( cellscore != NULL) {
3156 *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,LOOP);
3157 }
3158 return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,LOOP) ;
3159 }
3160 /* Source DELETE is not a special, should not get here! */
3161 /* Source INSERT is not a special, should not get here! */
3162 /* Source MATCH is not a special, should not get here! */
3163 warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state);
3164 return (-1);
3165 case DELETE :
3166 /* Source DELETE is not a special, should not get here! */
3167 /* Source INSERT is not a special, should not get here! */
3168 /* Source MATCH is not a special, should not get here! */
3169 warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state);
3170 return (-1);
3171 case INTRON_0 :
3172 /* Source INTRON_0 is not a special, should not get here! */
3173 /* Source INSERT is not a special, should not get here! */
3174 /* Source MATCH is not a special, should not get here! */
3175 warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state);
3176 return (-1);
3177 case INTRON_1 :
3178 /* Source INTRON_1 is not a special, should not get here! */
3179 /* Source INSERT is not a special, should not get here! */
3180 /* Source MATCH is not a special, should not get here! */
3181 warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state);
3182 return (-1);
3183 case INTRON_2 :
3184 /* Source INTRON_2 is not a special, should not get here! */
3185 /* Source INSERT is not a special, should not get here! */
3186 /* Source MATCH is not a special, should not get here! */
3187 warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state);
3188 return (-1);
3189 default:
3190 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
3191 return (-1);
3192 } /* end of Switch state */
3193
3194
3195 }
3196
3197
3198 /* Function: calculate_hidden_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv)
3199 *
3200 * Descrip: No Description
3201 *
3202 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
3203 * Arg: starti [UNKN ] Undocumented argument [int]
3204 * Arg: startj [UNKN ] Undocumented argument [int]
3205 * Arg: startstate [UNKN ] Undocumented argument [int]
3206 * Arg: stopi [UNKN ] Undocumented argument [int]
3207 * Arg: stopj [UNKN ] Undocumented argument [int]
3208 * Arg: stopstate [UNKN ] Undocumented argument [int]
3209 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
3210 *
3211 */
calculate_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv)3212 void calculate_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv)
3213 {
3214 register int i;
3215 register int j;
3216 register int score;
3217 register int temp;
3218 register int hiddenj;
3219
3220
3221 hiddenj = startj;
3222
3223
3224 init_hidden_GenePhase6(mat,starti,startj,stopi,stopj);
3225
3226
3227 GenePhase6_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0;
3228
3229
3230 for(j=startj;j<=stopj;j++) {
3231 for(i=starti;i<=stopi;i++) {
3232 /* Should *not* do very first cell as this is the one set to zero in one state! */
3233 if( i == starti && j == startj )
3234 continue;
3235 if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/
3236 GenePhase6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI;
3237 GenePhase6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI;
3238 GenePhase6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI;
3239 GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI;
3240 GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI;
3241 GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI;
3242 continue;
3243 } /* end of Is not in envelope */
3244
3245
3246 /* For state MATCH */
3247 /* setting first movement to score */
3248 score = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
3249 /* From state INSERT to state MATCH */
3250 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
3251 if( temp > score ) {
3252 score = temp;
3253 }
3254 /* From state DELETE to state MATCH */
3255 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
3256 if( temp > score ) {
3257 score = temp;
3258 }
3259 /* From state INTRON_0 to state MATCH */
3260 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
3261 if( temp > score ) {
3262 score = temp;
3263 }
3264 /* From state INTRON_1 to state MATCH */
3265 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
3266 if( temp > score ) {
3267 score = temp;
3268 }
3269 /* From state INTRON_2 to state MATCH */
3270 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
3271 if( temp > score ) {
3272 score = temp;
3273 }
3274 /* From state MATCH to state MATCH */
3275 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE];
3276 if( temp > score ) {
3277 score = temp;
3278 }
3279 /* From state MATCH to state MATCH */
3280 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE];
3281 if( temp > score ) {
3282 score = temp;
3283 }
3284 /* From state MATCH to state MATCH */
3285 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE];
3286 if( temp > score ) {
3287 score = temp;
3288 }
3289 /* From state MATCH to state MATCH */
3290 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE];
3291 if( temp > score ) {
3292 score = temp;
3293 }
3294
3295
3296 /* Ok - finished max calculation for MATCH */
3297 /* Add any movement independant score and put away */
3298 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
3299 GenePhase6_HIDDEN_MATRIX(mat,i,j,MATCH) = score;
3300 /* Finished calculating state MATCH */
3301
3302
3303 /* For state INSERT */
3304 /* setting first movement to score */
3305 score = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
3306 /* From state INSERT to state INSERT */
3307 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
3308 if( temp > score ) {
3309 score = temp;
3310 }
3311 /* From state DELETE to state INSERT */
3312 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
3313 if( temp > score ) {
3314 score = temp;
3315 }
3316 /* From state INTRON_0 to state INSERT */
3317 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
3318 if( temp > score ) {
3319 score = temp;
3320 }
3321 /* From state INTRON_1 to state INSERT */
3322 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
3323 if( temp > score ) {
3324 score = temp;
3325 }
3326 /* From state INTRON_2 to state INSERT */
3327 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
3328 if( temp > score ) {
3329 score = temp;
3330 }
3331 /* From state INSERT to state INSERT */
3332 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE];
3333 if( temp > score ) {
3334 score = temp;
3335 }
3336 /* From state INSERT to state INSERT */
3337 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE];
3338 if( temp > score ) {
3339 score = temp;
3340 }
3341
3342
3343 /* Ok - finished max calculation for INSERT */
3344 /* Add any movement independant score and put away */
3345 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
3346 GenePhase6_HIDDEN_MATRIX(mat,i,j,INSERT) = score;
3347 /* Finished calculating state INSERT */
3348
3349
3350 /* For state DELETE */
3351 /* setting first movement to score */
3352 score = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE];
3353 /* From state INSERT to state DELETE */
3354 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE];
3355 if( temp > score ) {
3356 score = temp;
3357 }
3358 /* From state DELETE to state DELETE */
3359 temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE];
3360 if( temp > score ) {
3361 score = temp;
3362 }
3363
3364
3365 /* Ok - finished max calculation for DELETE */
3366 /* Add any movement independant score and put away */
3367 GenePhase6_HIDDEN_MATRIX(mat,i,j,DELETE) = score;
3368 /* Finished calculating state DELETE */
3369
3370
3371 /* For state INTRON_0 */
3372 /* setting first movement to score */
3373 score = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0);
3374 /* From state INSERT to state INTRON_0 */
3375 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
3376 if( temp > score ) {
3377 score = temp;
3378 }
3379 /* From state INTRON_0 to state INTRON_0 */
3380 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
3381 if( temp > score ) {
3382 score = temp;
3383 }
3384
3385
3386 /* Ok - finished max calculation for INTRON_0 */
3387 /* Add any movement independant score and put away */
3388 GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score;
3389 /* Finished calculating state INTRON_0 */
3390
3391
3392 /* For state INTRON_1 */
3393 /* setting first movement to score */
3394 score = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1);
3395 /* From state INSERT to state INTRON_1 */
3396 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
3397 if( temp > score ) {
3398 score = temp;
3399 }
3400 /* From state INTRON_1 to state INTRON_1 */
3401 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
3402 if( temp > score ) {
3403 score = temp;
3404 }
3405
3406
3407 /* Ok - finished max calculation for INTRON_1 */
3408 /* Add any movement independant score and put away */
3409 GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score;
3410 /* Finished calculating state INTRON_1 */
3411
3412
3413 /* For state INTRON_2 */
3414 /* setting first movement to score */
3415 score = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2);
3416 /* From state INSERT to state INTRON_2 */
3417 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
3418 if( temp > score ) {
3419 score = temp;
3420 }
3421 /* From state INTRON_2 to state INTRON_2 */
3422 temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
3423 if( temp > score ) {
3424 score = temp;
3425 }
3426
3427
3428 /* Ok - finished max calculation for INTRON_2 */
3429 /* Add any movement independant score and put away */
3430 GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score;
3431 /* Finished calculating state INTRON_2 */
3432 }
3433 }
3434
3435
3436 return;
3437 }
3438
3439
3440 /* Function: init_hidden_GenePhase6(mat,starti,startj,stopi,stopj)
3441 *
3442 * Descrip: No Description
3443 *
3444 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
3445 * Arg: starti [UNKN ] Undocumented argument [int]
3446 * Arg: startj [UNKN ] Undocumented argument [int]
3447 * Arg: stopi [UNKN ] Undocumented argument [int]
3448 * Arg: stopj [UNKN ] Undocumented argument [int]
3449 *
3450 */
init_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int stopi,int stopj)3451 void init_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int stopi,int stopj)
3452 {
3453 register int i;
3454 register int j;
3455 register int hiddenj;
3456
3457
3458 hiddenj = startj;
3459 for(j=(startj-10);j<=stopj;j++) {
3460 for(i=(starti-1);i<=stopi;i++) {
3461 GenePhase6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI;
3462
3463 GenePhase6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI;
3464
3465 GenePhase6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI;
3466
3467 GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI;
3468
3469 GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI;
3470
3471 GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI;
3472
3473 }
3474 }
3475
3476
3477 return;
3478 }
3479
3480
3481 /* Function: full_dc_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv)
3482 *
3483 * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GenePhase6
3484 * Not this function, which is pretty hard core.
3485 * Function is given start/end points (in main matrix) for alignment
3486 * It does some checks, decides whether start/end in j is small enough for explicit calc
3487 * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE
3488 * - if no, uses /do_dc_single_pass_GenePhase6 to get mid-point
3489 * saves midpoint, and calls itself to do right portion then left portion
3490 * right then left ensures PackAln is added the 'right' way, ie, back-to-front
3491 * returns FALSE on any error, with a warning
3492 *
3493 *
3494 * Arg: mat [UNKN ] Matrix with small memory implementation [GenePhase6 *]
3495 * Arg: starti [UNKN ] Start position in i [int]
3496 * Arg: startj [UNKN ] Start position in j [int]
3497 * Arg: startstate [UNKN ] Start position state number [int]
3498 * Arg: stopi [UNKN ] Stop position in i [int]
3499 * Arg: stopj [UNKN ] Stop position in j [int]
3500 * Arg: stopstate [UNKN ] Stop position state number [int]
3501 * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *]
3502 * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *]
3503 * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int]
3504 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
3505 *
3506 * Return [UNKN ] Undocumented return value [boolean]
3507 *
3508 */
full_dc_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv)3509 boolean full_dc_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv)
3510 {
3511 int lstarti;
3512 int lstartj;
3513 int lstate;
3514
3515
3516 if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) {
3517 warn("*Very* bad error! - non shadow matrix type in full_dc_GenePhase6");
3518 return FALSE;
3519 }
3520
3521
3522 if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) {
3523 warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate);
3524 return FALSE;
3525 }
3526
3527
3528 if( stopj - startj < 50) {
3529 log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */
3530 calculate_hidden_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv);
3531 *donej += (stopj - startj); /* Now read it off into out */
3532 if( read_hidden_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) {
3533 warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj);
3534 return FALSE;
3535 }
3536 return TRUE;
3537 }
3538
3539
3540 /* In actual divide and conquor */
3541 if( do_dc_single_pass_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) {
3542 warn("In divide and conquor for GenePhase6, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj);
3543 return FALSE;
3544 }
3545
3546
3547 /* Ok... now we have to call on each side of the matrix */
3548 /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */
3549 lstarti= GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0);
3550 lstartj= GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1);
3551 lstate = GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2);
3552
3553
3554 /* Call on right hand side: this lets us do the correct read off */
3555 if( full_dc_GenePhase6(mat,GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) {
3556 /* Warning already issued, simply chained back up to top */
3557 return FALSE;
3558 }
3559 /* Call on left hand side */
3560 if( full_dc_GenePhase6(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) {
3561 /* Warning already issued, simply chained back up to top */
3562 return FALSE;
3563 }
3564
3565
3566 return TRUE;
3567 }
3568
3569
3570 /* Function: do_dc_single_pass_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done)
3571 *
3572 * Descrip: No Description
3573 *
3574 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
3575 * Arg: starti [UNKN ] Undocumented argument [int]
3576 * Arg: startj [UNKN ] Undocumented argument [int]
3577 * Arg: startstate [UNKN ] Undocumented argument [int]
3578 * Arg: stopi [UNKN ] Undocumented argument [int]
3579 * Arg: stopj [UNKN ] Undocumented argument [int]
3580 * Arg: stopstate [UNKN ] Undocumented argument [int]
3581 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
3582 * Arg: perc_done [UNKN ] Undocumented argument [int]
3583 *
3584 * Return [UNKN ] Undocumented return value [boolean]
3585 *
3586 */
do_dc_single_pass_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done)3587 boolean do_dc_single_pass_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done)
3588 {
3589 int halfj;
3590 halfj = startj + ((stopj - startj)/2);
3591
3592
3593 init_dc_GenePhase6(mat);
3594
3595
3596 GenePhase6_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0;
3597 run_up_dc_GenePhase6(mat,starti,stopi,startj,halfj-1,dpenv,perc_done);
3598 push_dc_at_merge_GenePhase6(mat,starti,stopi,halfj,&halfj,dpenv);
3599 follow_on_dc_GenePhase6(mat,starti,stopi,halfj,stopj,dpenv,perc_done);
3600 return TRUE;
3601 }
3602
3603
3604 /* Function: push_dc_at_merge_GenePhase6(mat,starti,stopi,startj,stopj,dpenv)
3605 *
3606 * Descrip: No Description
3607 *
3608 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
3609 * Arg: starti [UNKN ] Undocumented argument [int]
3610 * Arg: stopi [UNKN ] Undocumented argument [int]
3611 * Arg: startj [UNKN ] Undocumented argument [int]
3612 * Arg: stopj [UNKN ] Undocumented argument [int *]
3613 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
3614 *
3615 */
push_dc_at_merge_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv)3616 void push_dc_at_merge_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv)
3617 {
3618 register int i;
3619 register int j;
3620 register int k;
3621 register int count;
3622 register int mergej;/* Sources below this j will be stamped by triples */
3623 register int score;
3624 register int temp;
3625
3626
3627 mergej = startj -1;
3628 for(count=0,j=startj;count<10;count++,j++) {
3629 for(i=starti;i<=stopi;i++) {
3630 if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/
3631 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI;
3632 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100);
3633 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100);
3634 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI;
3635 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100);
3636 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100);
3637 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI;
3638 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100);
3639 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100);
3640 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI;
3641 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100);
3642 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100);
3643 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI;
3644 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100);
3645 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100);
3646 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI;
3647 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100);
3648 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100);
3649 continue;
3650 } /* end of Is not in envelope */
3651
3652
3653 /* For state MATCH, pushing when j - offj <= mergej */
3654 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
3655 if( j - 3 <= mergej) {
3656 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3657 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3;
3658 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH;
3659 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3660 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3661 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3662 }
3663 else {
3664 for(k=0;k<7;k++)
3665 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k);
3666 }
3667
3668
3669 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
3670 if( temp > score) {
3671 score = temp;
3672
3673
3674 if( j - 3 <= mergej) {
3675 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3676 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3;
3677 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT;
3678 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3679 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3680 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3681 }
3682 else {
3683 for(k=0;k<7;k++)
3684 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k);
3685 }
3686 }
3687
3688
3689 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
3690 if( temp > score) {
3691 score = temp;
3692
3693
3694 if( j - 3 <= mergej) {
3695 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3696 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3;
3697 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE;
3698 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3699 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3700 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3701 }
3702 else {
3703 for(k=0;k<7;k++)
3704 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k);
3705 }
3706 }
3707
3708
3709 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
3710 if( temp > score) {
3711 score = temp;
3712
3713
3714 if( j - 6 <= mergej) {
3715 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3716 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6;
3717 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_0;
3718 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3719 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3720 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3721 }
3722 else {
3723 for(k=0;k<7;k++)
3724 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k);
3725 }
3726 }
3727
3728
3729 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
3730 if( temp > score) {
3731 score = temp;
3732
3733
3734 if( j - 5 <= mergej) {
3735 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3736 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5;
3737 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_1;
3738 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3739 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3740 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3741 }
3742 else {
3743 for(k=0;k<7;k++)
3744 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k);
3745 }
3746 }
3747
3748
3749 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
3750 if( temp > score) {
3751 score = temp;
3752
3753
3754 if( j - 4 <= mergej) {
3755 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3756 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4;
3757 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_2;
3758 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3759 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3760 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3761 }
3762 else {
3763 for(k=0;k<7;k++)
3764 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k);
3765 }
3766 }
3767
3768
3769 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE];
3770 if( temp > score) {
3771 score = temp;
3772
3773
3774 if( j - 2 <= mergej) {
3775 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3776 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2;
3777 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH;
3778 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3779 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3780 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3781 }
3782 else {
3783 for(k=0;k<7;k++)
3784 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k);
3785 }
3786 }
3787
3788
3789 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE];
3790 if( temp > score) {
3791 score = temp;
3792
3793
3794 if( j - 1 <= mergej) {
3795 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3796 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1;
3797 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH;
3798 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3799 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3800 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3801 }
3802 else {
3803 for(k=0;k<7;k++)
3804 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k);
3805 }
3806 }
3807
3808
3809 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE];
3810 if( temp > score) {
3811 score = temp;
3812
3813
3814 if( j - 4 <= mergej) {
3815 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3816 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4;
3817 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH;
3818 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3819 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3820 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3821 }
3822 else {
3823 for(k=0;k<7;k++)
3824 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k);
3825 }
3826 }
3827
3828
3829 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE];
3830 if( temp > score) {
3831 score = temp;
3832
3833
3834 if( j - 5 <= mergej) {
3835 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1;
3836 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5;
3837 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH;
3838 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i;
3839 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j;
3840 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH;
3841 }
3842 else {
3843 for(k=0;k<7;k++)
3844 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k);
3845 }
3846 }
3847 /* Add any movement independant score */
3848 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
3849 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score;
3850 /* Finished with state MATCH */
3851
3852
3853 /* For state INSERT, pushing when j - offj <= mergej */
3854 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
3855 if( j - 3 <= mergej) {
3856 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0;
3857 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3;
3858 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH;
3859 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i;
3860 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j;
3861 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT;
3862 }
3863 else {
3864 for(k=0;k<7;k++)
3865 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k);
3866 }
3867
3868
3869 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
3870 if( temp > score) {
3871 score = temp;
3872
3873
3874 if( j - 3 <= mergej) {
3875 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0;
3876 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3;
3877 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT;
3878 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i;
3879 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j;
3880 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT;
3881 }
3882 else {
3883 for(k=0;k<7;k++)
3884 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k);
3885 }
3886 }
3887
3888
3889 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
3890 if( temp > score) {
3891 score = temp;
3892
3893
3894 if( j - 3 <= mergej) {
3895 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0;
3896 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3;
3897 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE;
3898 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i;
3899 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j;
3900 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT;
3901 }
3902 else {
3903 for(k=0;k<7;k++)
3904 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k);
3905 }
3906 }
3907
3908
3909 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
3910 if( temp > score) {
3911 score = temp;
3912
3913
3914 if( j - 6 <= mergej) {
3915 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0;
3916 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6;
3917 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_0;
3918 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i;
3919 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j;
3920 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT;
3921 }
3922 else {
3923 for(k=0;k<7;k++)
3924 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k);
3925 }
3926 }
3927
3928
3929 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
3930 if( temp > score) {
3931 score = temp;
3932
3933
3934 if( j - 5 <= mergej) {
3935 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0;
3936 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5;
3937 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_1;
3938 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i;
3939 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j;
3940 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT;
3941 }
3942 else {
3943 for(k=0;k<7;k++)
3944 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k);
3945 }
3946 }
3947
3948
3949 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
3950 if( temp > score) {
3951 score = temp;
3952
3953
3954 if( j - 4 <= mergej) {
3955 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0;
3956 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4;
3957 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_2;
3958 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i;
3959 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j;
3960 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT;
3961 }
3962 else {
3963 for(k=0;k<7;k++)
3964 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k);
3965 }
3966 }
3967
3968
3969 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE];
3970 if( temp > score) {
3971 score = temp;
3972
3973
3974 if( j - 2 <= mergej) {
3975 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0;
3976 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2;
3977 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT;
3978 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i;
3979 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j;
3980 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT;
3981 }
3982 else {
3983 for(k=0;k<7;k++)
3984 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k);
3985 }
3986 }
3987
3988
3989 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE];
3990 if( temp > score) {
3991 score = temp;
3992
3993
3994 if( j - 1 <= mergej) {
3995 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0;
3996 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1;
3997 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT;
3998 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i;
3999 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j;
4000 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT;
4001 }
4002 else {
4003 for(k=0;k<7;k++)
4004 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k);
4005 }
4006 }
4007 /* Add any movement independant score */
4008 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
4009 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score;
4010 /* Finished with state INSERT */
4011
4012
4013 /* For state DELETE, pushing when j - offj <= mergej */
4014 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE];
4015 if( j - 0 <= mergej) {
4016 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1;
4017 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0;
4018 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH;
4019 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i;
4020 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j;
4021 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE;
4022 }
4023 else {
4024 for(k=0;k<7;k++)
4025 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k);
4026 }
4027
4028
4029 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE];
4030 if( temp > score) {
4031 score = temp;
4032
4033
4034 if( j - 0 <= mergej) {
4035 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1;
4036 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0;
4037 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT;
4038 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i;
4039 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j;
4040 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE;
4041 }
4042 else {
4043 for(k=0;k<7;k++)
4044 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k);
4045 }
4046 }
4047
4048
4049 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE];
4050 if( temp > score) {
4051 score = temp;
4052
4053
4054 if( j - 0 <= mergej) {
4055 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1;
4056 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0;
4057 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE;
4058 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i;
4059 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j;
4060 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE;
4061 }
4062 else {
4063 for(k=0;k<7;k++)
4064 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k);
4065 }
4066 }
4067 /* Add any movement independant score */
4068 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score;
4069 /* Finished with state DELETE */
4070
4071
4072 /* For state INTRON_0, pushing when j - offj <= mergej */
4073 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0);
4074 if( j - 8 <= mergej) {
4075 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0;
4076 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8;
4077 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = MATCH;
4078 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i;
4079 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j;
4080 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0;
4081 }
4082 else {
4083 for(k=0;k<7;k++)
4084 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k);
4085 }
4086
4087
4088 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
4089 if( temp > score) {
4090 score = temp;
4091
4092
4093 if( j - 8 <= mergej) {
4094 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0;
4095 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8;
4096 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INSERT;
4097 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i;
4098 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j;
4099 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0;
4100 }
4101 else {
4102 for(k=0;k<7;k++)
4103 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k);
4104 }
4105 }
4106
4107
4108 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
4109 if( temp > score) {
4110 score = temp;
4111
4112
4113 if( j - 1 <= mergej) {
4114 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0;
4115 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1;
4116 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0;
4117 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i;
4118 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j;
4119 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0;
4120 }
4121 else {
4122 for(k=0;k<7;k++)
4123 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k);
4124 }
4125 }
4126 /* Add any movement independant score */
4127 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score;
4128 /* Finished with state INTRON_0 */
4129
4130
4131 /* For state INTRON_1, pushing when j - offj <= mergej */
4132 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1);
4133 if( j - 9 <= mergej) {
4134 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0;
4135 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9;
4136 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = MATCH;
4137 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i;
4138 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j;
4139 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1;
4140 }
4141 else {
4142 for(k=0;k<7;k++)
4143 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k);
4144 }
4145
4146
4147 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
4148 if( temp > score) {
4149 score = temp;
4150
4151
4152 if( j - 9 <= mergej) {
4153 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0;
4154 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9;
4155 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INSERT;
4156 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i;
4157 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j;
4158 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1;
4159 }
4160 else {
4161 for(k=0;k<7;k++)
4162 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k);
4163 }
4164 }
4165
4166
4167 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
4168 if( temp > score) {
4169 score = temp;
4170
4171
4172 if( j - 1 <= mergej) {
4173 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0;
4174 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1;
4175 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1;
4176 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i;
4177 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j;
4178 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1;
4179 }
4180 else {
4181 for(k=0;k<7;k++)
4182 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k);
4183 }
4184 }
4185 /* Add any movement independant score */
4186 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score;
4187 /* Finished with state INTRON_1 */
4188
4189
4190 /* For state INTRON_2, pushing when j - offj <= mergej */
4191 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2);
4192 if( j - 10 <= mergej) {
4193 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0;
4194 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10;
4195 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = MATCH;
4196 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i;
4197 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j;
4198 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2;
4199 }
4200 else {
4201 for(k=0;k<7;k++)
4202 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k);
4203 }
4204
4205
4206 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
4207 if( temp > score) {
4208 score = temp;
4209
4210
4211 if( j - 10 <= mergej) {
4212 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0;
4213 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10;
4214 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INSERT;
4215 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i;
4216 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j;
4217 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2;
4218 }
4219 else {
4220 for(k=0;k<7;k++)
4221 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k);
4222 }
4223 }
4224
4225
4226 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
4227 if( temp > score) {
4228 score = temp;
4229
4230
4231 if( j - 1 <= mergej) {
4232 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0;
4233 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1;
4234 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2;
4235 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i;
4236 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j;
4237 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2;
4238 }
4239 else {
4240 for(k=0;k<7;k++)
4241 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k);
4242 }
4243 }
4244 /* Add any movement independant score */
4245 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score;
4246 /* Finished with state INTRON_2 */
4247 }
4248 }
4249 /* Put back j into * stop j so that calling function gets it correct */
4250 if( stopj == NULL)
4251 warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!");
4252 else
4253 *stopj = j;
4254
4255
4256 return;
4257 }
4258
4259
4260 /* Function: follow_on_dc_GenePhase6(mat,starti,stopi,startj,stopj,dpenv,perc_done)
4261 *
4262 * Descrip: No Description
4263 *
4264 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
4265 * Arg: starti [UNKN ] Undocumented argument [int]
4266 * Arg: stopi [UNKN ] Undocumented argument [int]
4267 * Arg: startj [UNKN ] Undocumented argument [int]
4268 * Arg: stopj [UNKN ] Undocumented argument [int]
4269 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
4270 * Arg: perc_done [UNKN ] Undocumented argument [int]
4271 *
4272 */
follow_on_dc_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done)4273 void follow_on_dc_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done)
4274 {
4275 int i;
4276 int j;
4277 int k;
4278 int score;
4279 int temp;
4280 int localshadow[7];
4281 long int total;
4282 long int num;
4283
4284
4285 total = (stopi - starti+1) * (stopj - startj+1);
4286 num = 0;
4287
4288
4289 for(j=startj;j<=stopj;j++) { /*for each valid j column*/
4290 for(i=starti;i<=stopi;i++) { /*this is strip*/
4291 num++;
4292 if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/
4293 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI;
4294 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI;
4295 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI;
4296 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI;
4297 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI;
4298 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI;
4299 continue;
4300 } /* end of Is not in envelope */
4301 if( num % 1000 == 0 )
4302 log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total);
4303
4304
4305 /* For state MATCH */
4306 /* setting first movement to score */
4307 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
4308 /* shift first shadow numbers */
4309 for(k=0;k<7;k++)
4310 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k);
4311 /* From state INSERT to state MATCH */
4312 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
4313 if( temp > score ) {
4314 score = temp;
4315 for(k=0;k<7;k++)
4316 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k);
4317 }
4318 /* From state DELETE to state MATCH */
4319 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
4320 if( temp > score ) {
4321 score = temp;
4322 for(k=0;k<7;k++)
4323 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k);
4324 }
4325 /* From state INTRON_0 to state MATCH */
4326 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
4327 if( temp > score ) {
4328 score = temp;
4329 for(k=0;k<7;k++)
4330 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k);
4331 }
4332 /* From state INTRON_1 to state MATCH */
4333 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
4334 if( temp > score ) {
4335 score = temp;
4336 for(k=0;k<7;k++)
4337 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k);
4338 }
4339 /* From state INTRON_2 to state MATCH */
4340 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
4341 if( temp > score ) {
4342 score = temp;
4343 for(k=0;k<7;k++)
4344 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k);
4345 }
4346 /* From state MATCH to state MATCH */
4347 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE];
4348 if( temp > score ) {
4349 score = temp;
4350 for(k=0;k<7;k++)
4351 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k);
4352 }
4353 /* From state MATCH to state MATCH */
4354 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE];
4355 if( temp > score ) {
4356 score = temp;
4357 for(k=0;k<7;k++)
4358 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k);
4359 }
4360 /* From state MATCH to state MATCH */
4361 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE];
4362 if( temp > score ) {
4363 score = temp;
4364 for(k=0;k<7;k++)
4365 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k);
4366 }
4367 /* From state MATCH to state MATCH */
4368 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE];
4369 if( temp > score ) {
4370 score = temp;
4371 for(k=0;k<7;k++)
4372 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k);
4373 }
4374
4375
4376 /* Ok - finished max calculation for MATCH */
4377 /* Add any movement independant score and put away */
4378 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
4379 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score;
4380 for(k=0;k<7;k++)
4381 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k];
4382 /* Now figure out if any specials need this score */
4383 /* Finished calculating state MATCH */
4384
4385
4386 /* For state INSERT */
4387 /* setting first movement to score */
4388 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
4389 /* shift first shadow numbers */
4390 for(k=0;k<7;k++)
4391 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k);
4392 /* From state INSERT to state INSERT */
4393 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
4394 if( temp > score ) {
4395 score = temp;
4396 for(k=0;k<7;k++)
4397 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k);
4398 }
4399 /* From state DELETE to state INSERT */
4400 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
4401 if( temp > score ) {
4402 score = temp;
4403 for(k=0;k<7;k++)
4404 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k);
4405 }
4406 /* From state INTRON_0 to state INSERT */
4407 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
4408 if( temp > score ) {
4409 score = temp;
4410 for(k=0;k<7;k++)
4411 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k);
4412 }
4413 /* From state INTRON_1 to state INSERT */
4414 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
4415 if( temp > score ) {
4416 score = temp;
4417 for(k=0;k<7;k++)
4418 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k);
4419 }
4420 /* From state INTRON_2 to state INSERT */
4421 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
4422 if( temp > score ) {
4423 score = temp;
4424 for(k=0;k<7;k++)
4425 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k);
4426 }
4427 /* From state INSERT to state INSERT */
4428 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE];
4429 if( temp > score ) {
4430 score = temp;
4431 for(k=0;k<7;k++)
4432 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k);
4433 }
4434 /* From state INSERT to state INSERT */
4435 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE];
4436 if( temp > score ) {
4437 score = temp;
4438 for(k=0;k<7;k++)
4439 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k);
4440 }
4441
4442
4443 /* Ok - finished max calculation for INSERT */
4444 /* Add any movement independant score and put away */
4445 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
4446 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score;
4447 for(k=0;k<7;k++)
4448 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k];
4449 /* Now figure out if any specials need this score */
4450 /* Finished calculating state INSERT */
4451
4452
4453 /* For state DELETE */
4454 /* setting first movement to score */
4455 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE];
4456 /* shift first shadow numbers */
4457 for(k=0;k<7;k++)
4458 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k);
4459 /* From state INSERT to state DELETE */
4460 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE];
4461 if( temp > score ) {
4462 score = temp;
4463 for(k=0;k<7;k++)
4464 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k);
4465 }
4466 /* From state DELETE to state DELETE */
4467 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE];
4468 if( temp > score ) {
4469 score = temp;
4470 for(k=0;k<7;k++)
4471 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k);
4472 }
4473
4474
4475 /* Ok - finished max calculation for DELETE */
4476 /* Add any movement independant score and put away */
4477 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score;
4478 for(k=0;k<7;k++)
4479 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k];
4480 /* Now figure out if any specials need this score */
4481 /* Finished calculating state DELETE */
4482
4483
4484 /* For state INTRON_0 */
4485 /* setting first movement to score */
4486 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0);
4487 /* shift first shadow numbers */
4488 for(k=0;k<7;k++)
4489 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k);
4490 /* From state INSERT to state INTRON_0 */
4491 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
4492 if( temp > score ) {
4493 score = temp;
4494 for(k=0;k<7;k++)
4495 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k);
4496 }
4497 /* From state INTRON_0 to state INTRON_0 */
4498 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
4499 if( temp > score ) {
4500 score = temp;
4501 for(k=0;k<7;k++)
4502 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k);
4503 }
4504
4505
4506 /* Ok - finished max calculation for INTRON_0 */
4507 /* Add any movement independant score and put away */
4508 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score;
4509 for(k=0;k<7;k++)
4510 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k];
4511 /* Now figure out if any specials need this score */
4512 /* Finished calculating state INTRON_0 */
4513
4514
4515 /* For state INTRON_1 */
4516 /* setting first movement to score */
4517 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1);
4518 /* shift first shadow numbers */
4519 for(k=0;k<7;k++)
4520 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k);
4521 /* From state INSERT to state INTRON_1 */
4522 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
4523 if( temp > score ) {
4524 score = temp;
4525 for(k=0;k<7;k++)
4526 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k);
4527 }
4528 /* From state INTRON_1 to state INTRON_1 */
4529 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
4530 if( temp > score ) {
4531 score = temp;
4532 for(k=0;k<7;k++)
4533 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k);
4534 }
4535
4536
4537 /* Ok - finished max calculation for INTRON_1 */
4538 /* Add any movement independant score and put away */
4539 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score;
4540 for(k=0;k<7;k++)
4541 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k];
4542 /* Now figure out if any specials need this score */
4543 /* Finished calculating state INTRON_1 */
4544
4545
4546 /* For state INTRON_2 */
4547 /* setting first movement to score */
4548 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2);
4549 /* shift first shadow numbers */
4550 for(k=0;k<7;k++)
4551 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k);
4552 /* From state INSERT to state INTRON_2 */
4553 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
4554 if( temp > score ) {
4555 score = temp;
4556 for(k=0;k<7;k++)
4557 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k);
4558 }
4559 /* From state INTRON_2 to state INTRON_2 */
4560 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
4561 if( temp > score ) {
4562 score = temp;
4563 for(k=0;k<7;k++)
4564 localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k);
4565 }
4566
4567
4568 /* Ok - finished max calculation for INTRON_2 */
4569 /* Add any movement independant score and put away */
4570 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score;
4571 for(k=0;k<7;k++)
4572 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k];
4573 /* Now figure out if any specials need this score */
4574 /* Finished calculating state INTRON_2 */
4575 } /* end of this is strip */
4576 } /* end of for each valid j column */
4577
4578
4579 /* Function: run_up_dc_GenePhase6(mat,starti,stopi,startj,stopj,dpenv,perc_done)
4580 *
4581 * Descrip: No Description
4582 *
4583 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
4584 * Arg: starti [UNKN ] Undocumented argument [int]
4585 * Arg: stopi [UNKN ] Undocumented argument [int]
4586 * Arg: startj [UNKN ] Undocumented argument [int]
4587 * Arg: stopj [UNKN ] Undocumented argument [int]
4588 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
4589 * Arg: perc_done [UNKN ] Undocumented argument [int]
4590 *
4591 */
4592 }
run_up_dc_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done)4593 void run_up_dc_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done)
4594 {
4595 register int i;
4596 register int j;
4597 register int score;
4598 register int temp;
4599 long int total;
4600 long int num;
4601
4602
4603 total = (stopi - starti+1) * (stopj - startj+1);
4604 if( total <= 0 )
4605 total = 1;
4606 num = 0;
4607
4608
4609 for(j=startj;j<=stopj;j++) { /*for each valid j column*/
4610 for(i=starti;i<=stopi;i++) { /*this is strip*/
4611 if( j == startj && i == starti)
4612 continue;
4613 num++;
4614 if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/
4615 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI;
4616 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI;
4617 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI;
4618 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI;
4619 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI;
4620 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI;
4621 continue;
4622 } /* end of Is not in envelope */
4623 if( num % 1000 == 0 )
4624 log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total);
4625
4626
4627 /* For state MATCH */
4628 /* setting first movement to score */
4629 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
4630 /* From state INSERT to state MATCH */
4631 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
4632 if( temp > score ) {
4633 score = temp;
4634 }
4635 /* From state DELETE to state MATCH */
4636 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
4637 if( temp > score ) {
4638 score = temp;
4639 }
4640 /* From state INTRON_0 to state MATCH */
4641 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
4642 if( temp > score ) {
4643 score = temp;
4644 }
4645 /* From state INTRON_1 to state MATCH */
4646 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
4647 if( temp > score ) {
4648 score = temp;
4649 }
4650 /* From state INTRON_2 to state MATCH */
4651 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
4652 if( temp > score ) {
4653 score = temp;
4654 }
4655 /* From state MATCH to state MATCH */
4656 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE];
4657 if( temp > score ) {
4658 score = temp;
4659 }
4660 /* From state MATCH to state MATCH */
4661 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE];
4662 if( temp > score ) {
4663 score = temp;
4664 }
4665 /* From state MATCH to state MATCH */
4666 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE];
4667 if( temp > score ) {
4668 score = temp;
4669 }
4670 /* From state MATCH to state MATCH */
4671 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE];
4672 if( temp > score ) {
4673 score = temp;
4674 }
4675
4676
4677 /* Ok - finished max calculation for MATCH */
4678 /* Add any movement independant score and put away */
4679 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
4680 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score;
4681 /* Finished calculating state MATCH */
4682
4683
4684 /* For state INSERT */
4685 /* setting first movement to score */
4686 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
4687 /* From state INSERT to state INSERT */
4688 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
4689 if( temp > score ) {
4690 score = temp;
4691 }
4692 /* From state DELETE to state INSERT */
4693 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
4694 if( temp > score ) {
4695 score = temp;
4696 }
4697 /* From state INTRON_0 to state INSERT */
4698 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
4699 if( temp > score ) {
4700 score = temp;
4701 }
4702 /* From state INTRON_1 to state INSERT */
4703 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
4704 if( temp > score ) {
4705 score = temp;
4706 }
4707 /* From state INTRON_2 to state INSERT */
4708 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
4709 if( temp > score ) {
4710 score = temp;
4711 }
4712 /* From state INSERT to state INSERT */
4713 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE];
4714 if( temp > score ) {
4715 score = temp;
4716 }
4717 /* From state INSERT to state INSERT */
4718 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE];
4719 if( temp > score ) {
4720 score = temp;
4721 }
4722
4723
4724 /* Ok - finished max calculation for INSERT */
4725 /* Add any movement independant score and put away */
4726 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
4727 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score;
4728 /* Finished calculating state INSERT */
4729
4730
4731 /* For state DELETE */
4732 /* setting first movement to score */
4733 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE];
4734 /* From state INSERT to state DELETE */
4735 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE];
4736 if( temp > score ) {
4737 score = temp;
4738 }
4739 /* From state DELETE to state DELETE */
4740 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE];
4741 if( temp > score ) {
4742 score = temp;
4743 }
4744
4745
4746 /* Ok - finished max calculation for DELETE */
4747 /* Add any movement independant score and put away */
4748 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score;
4749 /* Finished calculating state DELETE */
4750
4751
4752 /* For state INTRON_0 */
4753 /* setting first movement to score */
4754 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0);
4755 /* From state INSERT to state INTRON_0 */
4756 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
4757 if( temp > score ) {
4758 score = temp;
4759 }
4760 /* From state INTRON_0 to state INTRON_0 */
4761 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
4762 if( temp > score ) {
4763 score = temp;
4764 }
4765
4766
4767 /* Ok - finished max calculation for INTRON_0 */
4768 /* Add any movement independant score and put away */
4769 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score;
4770 /* Finished calculating state INTRON_0 */
4771
4772
4773 /* For state INTRON_1 */
4774 /* setting first movement to score */
4775 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1);
4776 /* From state INSERT to state INTRON_1 */
4777 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
4778 if( temp > score ) {
4779 score = temp;
4780 }
4781 /* From state INTRON_1 to state INTRON_1 */
4782 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
4783 if( temp > score ) {
4784 score = temp;
4785 }
4786
4787
4788 /* Ok - finished max calculation for INTRON_1 */
4789 /* Add any movement independant score and put away */
4790 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score;
4791 /* Finished calculating state INTRON_1 */
4792
4793
4794 /* For state INTRON_2 */
4795 /* setting first movement to score */
4796 score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2);
4797 /* From state INSERT to state INTRON_2 */
4798 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
4799 if( temp > score ) {
4800 score = temp;
4801 }
4802 /* From state INTRON_2 to state INTRON_2 */
4803 temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
4804 if( temp > score ) {
4805 score = temp;
4806 }
4807
4808
4809 /* Ok - finished max calculation for INTRON_2 */
4810 /* Add any movement independant score and put away */
4811 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score;
4812 /* Finished calculating state INTRON_2 */
4813 } /* end of this is strip */
4814 } /* end of for each valid j column */
4815
4816
4817 /* Function: init_dc_GenePhase6(mat)
4818 *
4819 * Descrip: No Description
4820 *
4821 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
4822 *
4823 */
4824 }
init_dc_GenePhase6(GenePhase6 * mat)4825 void init_dc_GenePhase6(GenePhase6 * mat)
4826 {
4827 register int i;
4828 register int j;
4829 register int k;
4830
4831
4832 for(j=0;j<12;j++) {
4833 for(i=(-1);i<mat->query->len;i++) {
4834 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI;
4835 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI;
4836 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI;
4837 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI;
4838 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI;
4839 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI;
4840 for(k=0;k<7;k++) {
4841 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1);
4842 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1);
4843 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1);
4844 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1);
4845 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1);
4846 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1);
4847 }
4848 }
4849 }
4850
4851
4852 return;
4853 }
4854
4855
4856 /* Function: start_end_find_end_GenePhase6(mat,endj)
4857 *
4858 * Descrip: First function used to find end of the best path in the special state !end
4859 *
4860 *
4861 * Arg: mat [UNKN ] Matrix in small mode [GenePhase6 *]
4862 * Arg: endj [WRITE] position of end in j (meaningless in i) [int *]
4863 *
4864 * Return [UNKN ] Undocumented return value [int]
4865 *
4866 */
start_end_find_end_GenePhase6(GenePhase6 * mat,int * endj)4867 int start_end_find_end_GenePhase6(GenePhase6 * mat,int * endj)
4868 {
4869 register int j;
4870 register int max;
4871 register int maxj;
4872
4873
4874 max = GenePhase6_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END);
4875 maxj = mat->target->seq->len-1;
4876 for(j= mat->target->seq->len-2 ;j >= 0 ;j--) {
4877 if( GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) {
4878 max = GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,END);
4879 maxj = j;
4880 }
4881 }
4882
4883
4884 if( endj != NULL)
4885 *endj = maxj;
4886
4887
4888 return max;
4889 }
4890
4891
4892 /* Function: dc_optimised_start_end_calc_GenePhase6(*mat,dpenv)
4893 *
4894 * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix
4895 * Works off specially laid out memory from steve searle
4896 *
4897 *
4898 * Arg: *mat [UNKN ] Undocumented argument [GenePhase6]
4899 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
4900 *
4901 * Return [UNKN ] Undocumented return value [boolean]
4902 *
4903 */
dc_optimised_start_end_calc_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv)4904 boolean dc_optimised_start_end_calc_GenePhase6(GenePhase6 *mat,DPEnvelope * dpenv)
4905 {
4906 int i;
4907 int j;
4908 int k;
4909 int score;
4910 int temp;
4911 int leni;
4912 int lenj;
4913 int localshadow[7];
4914 long int total;
4915 long int num=0;
4916 int * score_pointers;
4917 int * shadow_pointers;
4918 int * localsp;
4919 leni = mat->query->len;
4920 lenj = mat->target->seq->len;
4921 total = leni * lenj;
4922
4923
4924 score_pointers = (int *) calloc (10 * (leni + 1) * 6,sizeof(int));
4925 shadow_pointers = (int *) calloc (10 * (leni + 1) * 6 * 8,sizeof(int));
4926
4927
4928 for(j=0;j<lenj;j++) { /*for each j strip*/
4929 for(i=0;i<leni;i++) { /*for each i position in strip*/
4930 num++;
4931 if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/
4932 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI;
4933 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI;
4934 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI;
4935 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI;
4936 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI;
4937 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI;
4938 continue;
4939 } /* end of Is not in envelope */
4940 if( num%1000 == 0)
4941 log_full_error(REPORT,0,"%6d Cells done [%2d%%%%]",num,num*100/total);
4942
4943
4944
4945
4946 /* For state MATCH */
4947 /* setting first movement to score */
4948 score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
4949 /* assign local shadown pointer */
4950 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0));
4951 /* From state INSERT to state MATCH */
4952 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
4953 if( temp > score ) {
4954 score = temp;
4955 /* assign local shadown pointer */
4956 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0));
4957 }
4958 /* From state DELETE to state MATCH */
4959 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
4960 if( temp > score ) {
4961 score = temp;
4962 /* assign local shadown pointer */
4963 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0));
4964 }
4965 /* From state START to state MATCH */
4966 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
4967 if( temp > score ) {
4968 score = temp;
4969 /* This state [START] is a special for MATCH... push top shadow pointers here */
4970 localshadow[0]= i;
4971 localshadow[1]= j;
4972 localshadow[2]= MATCH;
4973 localshadow[3]= (-1);
4974 localshadow[4]= (-1);
4975 localshadow[5]= (-1);
4976 localshadow[6]= score;
4977 localsp = localshadow;
4978 }
4979 /* From state BEFORE_MATCH_CODING to state MATCH */
4980 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
4981 if( temp > score ) {
4982 score = temp;
4983 /* This state [BEFORE_MATCH_CODING] is a special for MATCH... push top shadow pointers here */
4984 localshadow[0]= i;
4985 localshadow[1]= j;
4986 localshadow[2]= MATCH;
4987 localshadow[3]= (-1);
4988 localshadow[4]= (-1);
4989 localshadow[5]= (-1);
4990 localshadow[6]= score;
4991 localsp = localshadow;
4992 }
4993 /* From state INTRON_0 to state MATCH */
4994 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
4995 if( temp > score ) {
4996 score = temp;
4997 /* assign local shadown pointer */
4998 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,0));
4999 }
5000 /* From state INTRON_1 to state MATCH */
5001 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5002 if( temp > score ) {
5003 score = temp;
5004 /* assign local shadown pointer */
5005 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,0));
5006 }
5007 /* From state INTRON_2 to state MATCH */
5008 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5009 if( temp > score ) {
5010 score = temp;
5011 /* assign local shadown pointer */
5012 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,0));
5013 }
5014 /* From state MATCH to state MATCH */
5015 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5016 if( temp > score ) {
5017 score = temp;
5018 /* assign local shadown pointer */
5019 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0));
5020 }
5021 /* From state MATCH to state MATCH */
5022 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5023 if( temp > score ) {
5024 score = temp;
5025 /* assign local shadown pointer */
5026 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0));
5027 }
5028 /* From state MATCH to state MATCH */
5029 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5030 if( temp > score ) {
5031 score = temp;
5032 /* assign local shadown pointer */
5033 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0));
5034 }
5035 /* From state MATCH to state MATCH */
5036 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5037 if( temp > score ) {
5038 score = temp;
5039 /* assign local shadown pointer */
5040 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0));
5041 }
5042
5043
5044 /* Ok - finished max calculation for MATCH */
5045 /* Add any movement independant score and put away */
5046 /* Actually, already done inside scores */
5047 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score;
5048 for(k=0;k<7;k++)
5049 GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k];
5050 /* Now figure out if any specials need this score */
5051
5052
5053 /* state MATCH is a source for special LOOP */
5054 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
5055 if( temp > GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) {
5056 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp;
5057 /* Have to push only bottem half of system here */
5058 for(k=0;k<3;k++)
5059 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k);
5060 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6);
5061 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i;
5062 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j;
5063 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = MATCH;
5064 }
5065
5066
5067
5068
5069 /* state MATCH is a source for special AFTER_MATCH_CODING */
5070 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
5071 if( temp > GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) {
5072 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp;
5073 /* Have to push only bottem half of system here */
5074 for(k=0;k<3;k++)
5075 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k);
5076 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,6) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6);
5077 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,3) = i;
5078 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,4) = j;
5079 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,5) = MATCH;
5080 }
5081
5082
5083
5084
5085 /* Finished calculating state MATCH */
5086
5087
5088 /* For state INSERT */
5089 /* setting first movement to score */
5090 score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
5091 /* assign local shadown pointer */
5092 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0));
5093 /* From state INSERT to state INSERT */
5094 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5095 if( temp > score ) {
5096 score = temp;
5097 /* assign local shadown pointer */
5098 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0));
5099 }
5100 /* From state DELETE to state INSERT */
5101 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5102 if( temp > score ) {
5103 score = temp;
5104 /* assign local shadown pointer */
5105 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0));
5106 }
5107 /* From state LOOP to state INSERT */
5108 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j));
5109 if( temp > score ) {
5110 score = temp;
5111 /* This state [LOOP] is a special for INSERT... push top shadow pointers here */
5112 localshadow[0]= i;
5113 localshadow[1]= j;
5114 localshadow[2]= INSERT;
5115 localshadow[3]= (-1);
5116 localshadow[4]= (-1);
5117 localshadow[5]= (-1);
5118 localshadow[6]= score;
5119 localsp = localshadow;
5120 }
5121 /* From state INTRON_0 to state INSERT */
5122 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5123 if( temp > score ) {
5124 score = temp;
5125 /* assign local shadown pointer */
5126 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,0));
5127 }
5128 /* From state INTRON_1 to state INSERT */
5129 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5130 if( temp > score ) {
5131 score = temp;
5132 /* assign local shadown pointer */
5133 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,0));
5134 }
5135 /* From state INTRON_2 to state INSERT */
5136 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)) +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5137 if( temp > score ) {
5138 score = temp;
5139 /* assign local shadown pointer */
5140 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,0));
5141 }
5142 /* From state INSERT to state INSERT */
5143 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5144 if( temp > score ) {
5145 score = temp;
5146 /* assign local shadown pointer */
5147 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0));
5148 }
5149 /* From state INSERT to state INSERT */
5150 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j));
5151 if( temp > score ) {
5152 score = temp;
5153 /* assign local shadown pointer */
5154 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0));
5155 }
5156
5157
5158 /* Ok - finished max calculation for INSERT */
5159 /* Add any movement independant score and put away */
5160 /* Actually, already done inside scores */
5161 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score;
5162 for(k=0;k<7;k++)
5163 GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k];
5164 /* Now figure out if any specials need this score */
5165
5166
5167 /* state INSERT is a source for special LOOP */
5168 temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ;
5169 if( temp > GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) {
5170 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp;
5171 /* Have to push only bottem half of system here */
5172 for(k=0;k<3;k++)
5173 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k);
5174 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6);
5175 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i;
5176 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j;
5177 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = INSERT;
5178 }
5179
5180
5181
5182
5183 /* Finished calculating state INSERT */
5184
5185
5186 /* For state DELETE */
5187 /* setting first movement to score */
5188 score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE] + (0);
5189 /* assign local shadown pointer */
5190 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0));
5191 /* From state INSERT to state DELETE */
5192 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE] +(0);
5193 if( temp > score ) {
5194 score = temp;
5195 /* assign local shadown pointer */
5196 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0));
5197 }
5198 /* From state DELETE to state DELETE */
5199 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE] +(0);
5200 if( temp > score ) {
5201 score = temp;
5202 /* assign local shadown pointer */
5203 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0));
5204 }
5205
5206
5207 /* Ok - finished max calculation for DELETE */
5208 /* Add any movement independant score and put away */
5209 /* Actually, already done inside scores */
5210 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score;
5211 for(k=0;k<7;k++)
5212 GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k];
5213 /* Now figure out if any specials need this score */
5214
5215
5216 /* state DELETE is a source for special LOOP */
5217 temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ;
5218 if( temp > GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) {
5219 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp;
5220 /* Have to push only bottem half of system here */
5221 for(k=0;k<3;k++)
5222 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k);
5223 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6);
5224 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i;
5225 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j;
5226 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = DELETE;
5227 }
5228
5229
5230
5231
5232 /* Finished calculating state DELETE */
5233
5234
5235 /* For state INTRON_0 */
5236 /* setting first movement to score */
5237 score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0) + (0);
5238 /* assign local shadown pointer */
5239 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0));
5240 /* From state INSERT to state INTRON_0 */
5241 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) +(0);
5242 if( temp > score ) {
5243 score = temp;
5244 /* assign local shadown pointer */
5245 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0));
5246 }
5247 /* From state INTRON_0 to state INTRON_0 */
5248 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0);
5249 if( temp > score ) {
5250 score = temp;
5251 /* assign local shadown pointer */
5252 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0));
5253 }
5254
5255
5256 /* Ok - finished max calculation for INTRON_0 */
5257 /* Add any movement independant score and put away */
5258 /* Actually, already done inside scores */
5259 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score;
5260 for(k=0;k<7;k++)
5261 GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k];
5262 /* Now figure out if any specials need this score */
5263
5264
5265 /* Finished calculating state INTRON_0 */
5266
5267
5268 /* For state INTRON_1 */
5269 /* setting first movement to score */
5270 score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1) + (0);
5271 /* assign local shadown pointer */
5272 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0));
5273 /* From state INSERT to state INTRON_1 */
5274 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) +(0);
5275 if( temp > score ) {
5276 score = temp;
5277 /* assign local shadown pointer */
5278 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0));
5279 }
5280 /* From state INTRON_1 to state INTRON_1 */
5281 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0);
5282 if( temp > score ) {
5283 score = temp;
5284 /* assign local shadown pointer */
5285 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0));
5286 }
5287
5288
5289 /* Ok - finished max calculation for INTRON_1 */
5290 /* Add any movement independant score and put away */
5291 /* Actually, already done inside scores */
5292 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score;
5293 for(k=0;k<7;k++)
5294 GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k];
5295 /* Now figure out if any specials need this score */
5296
5297
5298 /* Finished calculating state INTRON_1 */
5299
5300
5301 /* For state INTRON_2 */
5302 /* setting first movement to score */
5303 score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2) + (0);
5304 /* assign local shadown pointer */
5305 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0));
5306 /* From state INSERT to state INTRON_2 */
5307 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) +(0);
5308 if( temp > score ) {
5309 score = temp;
5310 /* assign local shadown pointer */
5311 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0));
5312 }
5313 /* From state INTRON_2 to state INTRON_2 */
5314 temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0);
5315 if( temp > score ) {
5316 score = temp;
5317 /* assign local shadown pointer */
5318 localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0));
5319 }
5320
5321
5322 /* Ok - finished max calculation for INTRON_2 */
5323 /* Add any movement independant score and put away */
5324 /* Actually, already done inside scores */
5325 GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score;
5326 for(k=0;k<7;k++)
5327 GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k];
5328 /* Now figure out if any specials need this score */
5329
5330
5331 /* Finished calculating state INTRON_2 */
5332
5333
5334 } /* end of for each i position in strip */
5335
5336
5337 /* Special state LOOP has special to speical */
5338 /* Set score to current score (remember, state probably updated during main loop */
5339 score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP);
5340
5341
5342 /* Source START is a special source for LOOP */
5343 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0);
5344 if( temp > score ) {
5345 score = temp;
5346 /* Also got to propagate shadows */
5347 for(k=0;k<7;k++)
5348 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k);
5349 }
5350
5351
5352 /* Source MATCH for state LOOP is not special... already calculated */
5353 /* Source INSERT for state LOOP is not special... already calculated */
5354 /* Source DELETE for state LOOP is not special... already calculated */
5355 /* Source LOOP is a special source for LOOP */
5356 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0);
5357 if( temp > score ) {
5358 score = temp;
5359 /* Also got to propagate shadows */
5360 for(k=0;k<7;k++)
5361 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k);
5362 }
5363
5364
5365 /* Put back score... (now updated!) */
5366 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP) = score;
5367 /* Finished updating state LOOP */
5368
5369
5370
5371
5372 /* Special state START has no special to special movements */
5373
5374
5375 /* Special state END has special to speical */
5376 /* Set score to current score (remember, state probably updated during main loop */
5377 score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,END);
5378
5379
5380 /* Source LOOP is a special source for END */
5381 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0);
5382 if( temp > score ) {
5383 score = temp;
5384 /* Also got to propagate shadows */
5385 for(k=0;k<7;k++)
5386 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k);
5387 }
5388
5389
5390 /* Source AFTER_MATCH_CODING is a special source for END */
5391 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
5392 if( temp > score ) {
5393 score = temp;
5394 /* Also got to propagate shadows */
5395 for(k=0;k<7;k++)
5396 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,AFTER_MATCH_CODING,k);
5397 }
5398
5399
5400 /* Put back score... (now updated!) */
5401 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score;
5402 /* Finished updating state END */
5403
5404
5405
5406
5407 /* Special state BEFORE_MATCH_CODING has special to speical */
5408 /* Set score to current score (remember, state probably updated during main loop */
5409 score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_CODING);
5410
5411
5412 /* Source START is a special source for BEFORE_MATCH_CODING */
5413 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
5414 if( temp > score ) {
5415 score = temp;
5416 /* Also got to propagate shadows */
5417 for(k=0;k<7;k++)
5418 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,START,k);
5419 }
5420
5421
5422 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */
5423 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
5424 if( temp > score ) {
5425 score = temp;
5426 /* Also got to propagate shadows */
5427 for(k=0;k<7;k++)
5428 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,BEFORE_MATCH_CODING,k);
5429 }
5430
5431
5432 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */
5433 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0);
5434 if( temp > score ) {
5435 score = temp;
5436 /* Also got to propagate shadows */
5437 for(k=0;k<7;k++)
5438 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0,k);
5439 }
5440
5441
5442 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */
5443 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0);
5444 if( temp > score ) {
5445 score = temp;
5446 /* Also got to propagate shadows */
5447 for(k=0;k<7;k++)
5448 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1,k);
5449 }
5450
5451
5452 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */
5453 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0);
5454 if( temp > score ) {
5455 score = temp;
5456 /* Also got to propagate shadows */
5457 for(k=0;k<7;k++)
5458 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2,k);
5459 }
5460
5461
5462 /* Put back score... (now updated!) */
5463 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score;
5464 /* Finished updating state BEFORE_MATCH_CODING */
5465
5466
5467
5468
5469 /* Special state BEFORE_MATCH_INTRON_0 has special to speical */
5470 /* Set score to current score (remember, state probably updated during main loop */
5471 score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0);
5472
5473
5474 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */
5475 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0);
5476 if( temp > score ) {
5477 score = temp;
5478 /* Also got to propagate shadows */
5479 for(k=0;k<7;k++)
5480 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_0,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_MATCH_CODING,k);
5481 }
5482
5483
5484 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */
5485 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
5486 if( temp > score ) {
5487 score = temp;
5488 /* Also got to propagate shadows */
5489 for(k=0;k<7;k++)
5490 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_0,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0,k);
5491 }
5492
5493
5494 /* Put back score... (now updated!) */
5495 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score;
5496 /* Finished updating state BEFORE_MATCH_INTRON_0 */
5497
5498
5499
5500
5501 /* Special state BEFORE_MATCH_INTRON_1 has special to speical */
5502 /* Set score to current score (remember, state probably updated during main loop */
5503 score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1);
5504
5505
5506 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */
5507 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
5508 if( temp > score ) {
5509 score = temp;
5510 /* Also got to propagate shadows */
5511 for(k=0;k<7;k++)
5512 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_1,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 9,BEFORE_MATCH_CODING,k);
5513 }
5514
5515
5516 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */
5517 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
5518 if( temp > score ) {
5519 score = temp;
5520 /* Also got to propagate shadows */
5521 for(k=0;k<7;k++)
5522 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_1,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1,k);
5523 }
5524
5525
5526 /* Put back score... (now updated!) */
5527 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score;
5528 /* Finished updating state BEFORE_MATCH_INTRON_1 */
5529
5530
5531
5532
5533 /* Special state BEFORE_MATCH_INTRON_2 has special to speical */
5534 /* Set score to current score (remember, state probably updated during main loop */
5535 score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2);
5536
5537
5538 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */
5539 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
5540 if( temp > score ) {
5541 score = temp;
5542 /* Also got to propagate shadows */
5543 for(k=0;k<7;k++)
5544 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_2,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 10,BEFORE_MATCH_CODING,k);
5545 }
5546
5547
5548 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */
5549 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
5550 if( temp > score ) {
5551 score = temp;
5552 /* Also got to propagate shadows */
5553 for(k=0;k<7;k++)
5554 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_2,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2,k);
5555 }
5556
5557
5558 /* Put back score... (now updated!) */
5559 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score;
5560 /* Finished updating state BEFORE_MATCH_INTRON_2 */
5561
5562
5563
5564
5565 /* Special state AFTER_MATCH_CODING has special to speical */
5566 /* Set score to current score (remember, state probably updated during main loop */
5567 score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_MATCH_CODING);
5568
5569
5570 /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */
5571 /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */
5572 temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
5573 if( temp > score ) {
5574 score = temp;
5575 /* Also got to propagate shadows */
5576 for(k=0;k<7;k++)
5577 GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,AFTER_MATCH_CODING,k);
5578 }
5579
5580
5581 /* Put back score... (now updated!) */
5582 GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score;
5583 /* Finished updating state AFTER_MATCH_CODING */
5584
5585
5586 } /* end of for each j strip */
5587 free(score_pointers);
5588 free(shadow_pointers);
5589 return TRUE;
5590 }
5591
5592
5593 /* Function: init_start_end_linear_GenePhase6(mat)
5594 *
5595 * Descrip: No Description
5596 *
5597 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
5598 *
5599 */
init_start_end_linear_GenePhase6(GenePhase6 * mat)5600 void init_start_end_linear_GenePhase6(GenePhase6 * mat)
5601 {
5602 register int i;
5603 register int j;
5604 for(j=0;j<12;j++) {
5605 for(i=(-1);i<mat->query->len;i++) {
5606 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI;
5607 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1);
5608 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI;
5609 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1);
5610 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI;
5611 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1);
5612 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI;
5613 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1);
5614 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI;
5615 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1);
5616 GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI;
5617 GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1);
5618 }
5619 }
5620
5621
5622 for(j=(-10);j<mat->target->seq->len;j++) {
5623 GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,LOOP) = NEGI;
5624 GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,LOOP,0) = (-1);
5625 GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,START) = 0;
5626 GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j;
5627 GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI;
5628 GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1);
5629 GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = NEGI;
5630 GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_MATCH_CODING,0) = (-1);
5631 GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = NEGI;
5632 GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_MATCH_INTRON_0,0) = (-1);
5633 GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = NEGI;
5634 GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_MATCH_INTRON_1,0) = (-1);
5635 GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = NEGI;
5636 GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_MATCH_INTRON_2,0) = (-1);
5637 GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = NEGI;
5638 GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,AFTER_MATCH_CODING,0) = (-1);
5639 }
5640
5641
5642 return;
5643 }
5644
5645
5646 /* Function: convert_PackAln_to_AlnBlock_GenePhase6(pal)
5647 *
5648 * Descrip: Converts a path alignment to a label alignment
5649 * The label alignment is probably much more useful than the path
5650 *
5651 *
5652 * Arg: pal [UNKN ] Undocumented argument [PackAln *]
5653 *
5654 * Return [UNKN ] Undocumented return value [AlnBlock *]
5655 *
5656 */
convert_PackAln_to_AlnBlock_GenePhase6(PackAln * pal)5657 AlnBlock * convert_PackAln_to_AlnBlock_GenePhase6(PackAln * pal)
5658 {
5659 AlnConvertSet * acs;
5660 AlnBlock * alb;
5661
5662
5663 acs = AlnConvertSet_GenePhase6();
5664 alb = AlnBlock_from_PackAln(acs,pal);
5665 free_AlnConvertSet(acs);
5666 return alb;
5667 }
5668
5669
5670 static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_STATE","LOOP_STATE","END","BEFORE_MATCH","BEFORE_MATCH_INTRON","AFTER_MATCH" };
5671 /* Function: AlnConvertSet_GenePhase6(void)
5672 *
5673 * Descrip: No Description
5674 *
5675 *
5676 * Return [UNKN ] Undocumented return value [AlnConvertSet *]
5677 *
5678 */
5679 static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","5SS_PHASE_0","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","RANDOM_SEQUENCE","END" };
AlnConvertSet_GenePhase6(void)5680 AlnConvertSet * AlnConvertSet_GenePhase6(void)
5681 {
5682 AlnConvertUnit * acu;
5683 AlnConvertSet * out;
5684
5685
5686 out = AlnConvertSet_alloc_std();
5687
5688
5689 acu = AlnConvertUnit_alloc();
5690 add_AlnConvertSet(out,acu);
5691 acu->state1 = MATCH;
5692 acu->state2 = MATCH;
5693 acu->offi = 1;
5694 acu->offj = 3;
5695 acu->label1 = query_label[0];
5696 acu->label2 = target_label[0];
5697 acu = AlnConvertUnit_alloc();
5698 add_AlnConvertSet(out,acu);
5699 acu->state1 = INSERT;
5700 acu->state2 = MATCH;
5701 acu->offi = 1;
5702 acu->offj = 3;
5703 acu->label1 = query_label[0];
5704 acu->label2 = target_label[0];
5705 acu = AlnConvertUnit_alloc();
5706 add_AlnConvertSet(out,acu);
5707 acu->state1 = DELETE;
5708 acu->state2 = MATCH;
5709 acu->offi = 1;
5710 acu->offj = 3;
5711 acu->label1 = query_label[0];
5712 acu->label2 = target_label[0];
5713 acu = AlnConvertUnit_alloc();
5714 add_AlnConvertSet(out,acu);
5715 acu->state1 = START + 6;
5716 acu->is_from_special = TRUE;
5717 acu->state2 = MATCH;
5718 acu->offi = (-1);
5719 acu->offj = 3;
5720 acu->label1 = query_label[0];
5721 acu->label2 = target_label[0];
5722 acu = AlnConvertUnit_alloc();
5723 add_AlnConvertSet(out,acu);
5724 acu->state1 = BEFORE_MATCH_CODING + 6;
5725 acu->is_from_special = TRUE;
5726 acu->state2 = MATCH;
5727 acu->offi = (-1);
5728 acu->offj = 3;
5729 acu->label1 = query_label[0];
5730 acu->label2 = target_label[0];
5731 acu = AlnConvertUnit_alloc();
5732 add_AlnConvertSet(out,acu);
5733 acu->state1 = INTRON_0;
5734 acu->state2 = MATCH;
5735 acu->offi = 1;
5736 acu->offj = 6;
5737 acu->label1 = query_label[0];
5738 acu->label2 = target_label[1];
5739 acu = AlnConvertUnit_alloc();
5740 add_AlnConvertSet(out,acu);
5741 acu->state1 = INTRON_1;
5742 acu->state2 = MATCH;
5743 acu->offi = 1;
5744 acu->offj = 5;
5745 acu->label1 = query_label[0];
5746 acu->label2 = target_label[2];
5747 acu = AlnConvertUnit_alloc();
5748 add_AlnConvertSet(out,acu);
5749 acu->state1 = INTRON_2;
5750 acu->state2 = MATCH;
5751 acu->offi = 1;
5752 acu->offj = 4;
5753 acu->label1 = query_label[0];
5754 acu->label2 = target_label[3];
5755 acu = AlnConvertUnit_alloc();
5756 add_AlnConvertSet(out,acu);
5757 acu->state1 = MATCH;
5758 acu->state2 = MATCH;
5759 acu->offi = 1;
5760 acu->offj = 2;
5761 acu->label1 = query_label[0];
5762 acu->label2 = target_label[4];
5763 acu = AlnConvertUnit_alloc();
5764 add_AlnConvertSet(out,acu);
5765 acu->state1 = MATCH;
5766 acu->state2 = MATCH;
5767 acu->offi = 1;
5768 acu->offj = 1;
5769 acu->label1 = query_label[0];
5770 acu->label2 = target_label[4];
5771 acu = AlnConvertUnit_alloc();
5772 add_AlnConvertSet(out,acu);
5773 acu->state1 = MATCH;
5774 acu->state2 = MATCH;
5775 acu->offi = 1;
5776 acu->offj = 4;
5777 acu->label1 = query_label[0];
5778 acu->label2 = target_label[5];
5779 acu = AlnConvertUnit_alloc();
5780 add_AlnConvertSet(out,acu);
5781 acu->state1 = MATCH;
5782 acu->state2 = MATCH;
5783 acu->offi = 1;
5784 acu->offj = 5;
5785 acu->label1 = query_label[0];
5786 acu->label2 = target_label[5];
5787 acu = AlnConvertUnit_alloc();
5788 add_AlnConvertSet(out,acu);
5789 acu->state1 = MATCH;
5790 acu->state2 = INSERT;
5791 acu->offi = 0;
5792 acu->offj = 3;
5793 acu->label1 = query_label[1];
5794 acu->label2 = target_label[0];
5795 acu = AlnConvertUnit_alloc();
5796 add_AlnConvertSet(out,acu);
5797 acu->state1 = INSERT;
5798 acu->state2 = INSERT;
5799 acu->offi = 0;
5800 acu->offj = 3;
5801 acu->label1 = query_label[1];
5802 acu->label2 = target_label[0];
5803 acu = AlnConvertUnit_alloc();
5804 add_AlnConvertSet(out,acu);
5805 acu->state1 = DELETE;
5806 acu->state2 = INSERT;
5807 acu->offi = 0;
5808 acu->offj = 3;
5809 acu->label1 = query_label[1];
5810 acu->label2 = target_label[0];
5811 acu = AlnConvertUnit_alloc();
5812 add_AlnConvertSet(out,acu);
5813 acu->state1 = LOOP + 6;
5814 acu->is_from_special = TRUE;
5815 acu->state2 = INSERT;
5816 acu->offi = (-1);
5817 acu->offj = 3;
5818 acu->label1 = query_label[1];
5819 acu->label2 = target_label[0];
5820 acu = AlnConvertUnit_alloc();
5821 add_AlnConvertSet(out,acu);
5822 acu->state1 = INTRON_0;
5823 acu->state2 = INSERT;
5824 acu->offi = 0;
5825 acu->offj = 6;
5826 acu->label1 = query_label[1];
5827 acu->label2 = target_label[1];
5828 acu = AlnConvertUnit_alloc();
5829 add_AlnConvertSet(out,acu);
5830 acu->state1 = INTRON_1;
5831 acu->state2 = INSERT;
5832 acu->offi = 0;
5833 acu->offj = 5;
5834 acu->label1 = query_label[1];
5835 acu->label2 = target_label[2];
5836 acu = AlnConvertUnit_alloc();
5837 add_AlnConvertSet(out,acu);
5838 acu->state1 = INTRON_2;
5839 acu->state2 = INSERT;
5840 acu->offi = 0;
5841 acu->offj = 4;
5842 acu->label1 = query_label[1];
5843 acu->label2 = target_label[3];
5844 acu = AlnConvertUnit_alloc();
5845 add_AlnConvertSet(out,acu);
5846 acu->state1 = INSERT;
5847 acu->state2 = INSERT;
5848 acu->offi = 0;
5849 acu->offj = 2;
5850 acu->label1 = query_label[1];
5851 acu->label2 = target_label[4];
5852 acu = AlnConvertUnit_alloc();
5853 add_AlnConvertSet(out,acu);
5854 acu->state1 = INSERT;
5855 acu->state2 = INSERT;
5856 acu->offi = 0;
5857 acu->offj = 1;
5858 acu->label1 = query_label[1];
5859 acu->label2 = target_label[4];
5860 acu = AlnConvertUnit_alloc();
5861 add_AlnConvertSet(out,acu);
5862 acu->state1 = MATCH;
5863 acu->state2 = DELETE;
5864 acu->offi = 1;
5865 acu->offj = 0;
5866 acu->label1 = query_label[2];
5867 acu->label2 = target_label[6];
5868 acu = AlnConvertUnit_alloc();
5869 add_AlnConvertSet(out,acu);
5870 acu->state1 = INSERT;
5871 acu->state2 = DELETE;
5872 acu->offi = 1;
5873 acu->offj = 0;
5874 acu->label1 = query_label[2];
5875 acu->label2 = target_label[6];
5876 acu = AlnConvertUnit_alloc();
5877 add_AlnConvertSet(out,acu);
5878 acu->state1 = DELETE;
5879 acu->state2 = DELETE;
5880 acu->offi = 1;
5881 acu->offj = 0;
5882 acu->label1 = query_label[2];
5883 acu->label2 = target_label[6];
5884 acu = AlnConvertUnit_alloc();
5885 add_AlnConvertSet(out,acu);
5886 acu->state1 = MATCH;
5887 acu->state2 = INTRON_0;
5888 acu->offi = 0;
5889 acu->offj = 8;
5890 acu->label1 = query_label[3];
5891 acu->label2 = target_label[7];
5892 acu = AlnConvertUnit_alloc();
5893 add_AlnConvertSet(out,acu);
5894 acu->state1 = INSERT;
5895 acu->state2 = INTRON_0;
5896 acu->offi = 0;
5897 acu->offj = 8;
5898 acu->label1 = query_label[3];
5899 acu->label2 = target_label[7];
5900 acu = AlnConvertUnit_alloc();
5901 add_AlnConvertSet(out,acu);
5902 acu->state1 = INTRON_0;
5903 acu->state2 = INTRON_0;
5904 acu->offi = 0;
5905 acu->offj = 1;
5906 acu->label1 = query_label[3];
5907 acu->label2 = target_label[8];
5908 acu = AlnConvertUnit_alloc();
5909 add_AlnConvertSet(out,acu);
5910 acu->state1 = MATCH;
5911 acu->state2 = INTRON_1;
5912 acu->offi = 0;
5913 acu->offj = 9;
5914 acu->label1 = query_label[3];
5915 acu->label2 = target_label[9];
5916 acu = AlnConvertUnit_alloc();
5917 add_AlnConvertSet(out,acu);
5918 acu->state1 = INSERT;
5919 acu->state2 = INTRON_1;
5920 acu->offi = 0;
5921 acu->offj = 9;
5922 acu->label1 = query_label[3];
5923 acu->label2 = target_label[9];
5924 acu = AlnConvertUnit_alloc();
5925 add_AlnConvertSet(out,acu);
5926 acu->state1 = INTRON_1;
5927 acu->state2 = INTRON_1;
5928 acu->offi = 0;
5929 acu->offj = 1;
5930 acu->label1 = query_label[3];
5931 acu->label2 = target_label[8];
5932 acu = AlnConvertUnit_alloc();
5933 add_AlnConvertSet(out,acu);
5934 acu->state1 = MATCH;
5935 acu->state2 = INTRON_2;
5936 acu->offi = 0;
5937 acu->offj = 10;
5938 acu->label1 = query_label[3];
5939 acu->label2 = target_label[10];
5940 acu = AlnConvertUnit_alloc();
5941 add_AlnConvertSet(out,acu);
5942 acu->state1 = INSERT;
5943 acu->state2 = INTRON_2;
5944 acu->offi = 0;
5945 acu->offj = 10;
5946 acu->label1 = query_label[3];
5947 acu->label2 = target_label[10];
5948 acu = AlnConvertUnit_alloc();
5949 add_AlnConvertSet(out,acu);
5950 acu->state1 = INTRON_2;
5951 acu->state2 = INTRON_2;
5952 acu->offi = 0;
5953 acu->offj = 1;
5954 acu->label1 = query_label[3];
5955 acu->label2 = target_label[8];
5956 acu = AlnConvertUnit_alloc();
5957 add_AlnConvertSet(out,acu);
5958 acu->state1 = START + 6;
5959 acu->state2 = LOOP + 6;
5960 acu->offi = (-1);
5961 acu->offj = 1;
5962 acu->label1 = query_label[4];
5963 acu->label2 = target_label[11];
5964 acu = AlnConvertUnit_alloc();
5965 add_AlnConvertSet(out,acu);
5966 acu->state1 = MATCH;
5967 acu->state2 = LOOP + 6;
5968 acu->offi = (-1);
5969 acu->offj = 0;
5970 acu->label1 = query_label[4];
5971 acu->label2 = target_label[11];
5972 acu = AlnConvertUnit_alloc();
5973 add_AlnConvertSet(out,acu);
5974 acu->state1 = INSERT;
5975 acu->state2 = LOOP + 6;
5976 acu->offi = (-1);
5977 acu->offj = 0;
5978 acu->label1 = query_label[4];
5979 acu->label2 = target_label[11];
5980 acu = AlnConvertUnit_alloc();
5981 add_AlnConvertSet(out,acu);
5982 acu->state1 = DELETE;
5983 acu->state2 = LOOP + 6;
5984 acu->offi = (-1);
5985 acu->offj = 0;
5986 acu->label1 = query_label[4];
5987 acu->label2 = target_label[11];
5988 acu = AlnConvertUnit_alloc();
5989 add_AlnConvertSet(out,acu);
5990 acu->state1 = LOOP + 6;
5991 acu->state2 = LOOP + 6;
5992 acu->offi = (-1);
5993 acu->offj = 1;
5994 acu->label1 = query_label[4];
5995 acu->label2 = target_label[11];
5996 acu = AlnConvertUnit_alloc();
5997 add_AlnConvertSet(out,acu);
5998 acu->state1 = LOOP + 6;
5999 acu->state2 = END + 6;
6000 acu->offi = (-1);
6001 acu->offj = 1;
6002 acu->label1 = query_label[5];
6003 acu->label2 = target_label[12];
6004 acu = AlnConvertUnit_alloc();
6005 add_AlnConvertSet(out,acu);
6006 acu->state1 = AFTER_MATCH_CODING + 6;
6007 acu->state2 = END + 6;
6008 acu->offi = (-1);
6009 acu->offj = 3;
6010 acu->label1 = query_label[5];
6011 acu->label2 = target_label[12];
6012 acu = AlnConvertUnit_alloc();
6013 add_AlnConvertSet(out,acu);
6014 acu->state1 = START + 6;
6015 acu->state2 = BEFORE_MATCH_CODING + 6;
6016 acu->offi = (-1);
6017 acu->offj = 3;
6018 acu->label1 = query_label[6];
6019 acu->label2 = target_label[0];
6020 acu = AlnConvertUnit_alloc();
6021 add_AlnConvertSet(out,acu);
6022 acu->state1 = BEFORE_MATCH_CODING + 6;
6023 acu->state2 = BEFORE_MATCH_CODING + 6;
6024 acu->offi = (-1);
6025 acu->offj = 3;
6026 acu->label1 = query_label[6];
6027 acu->label2 = target_label[0];
6028 acu = AlnConvertUnit_alloc();
6029 add_AlnConvertSet(out,acu);
6030 acu->state1 = BEFORE_MATCH_INTRON_0 + 6;
6031 acu->state2 = BEFORE_MATCH_CODING + 6;
6032 acu->offi = (-1);
6033 acu->offj = 6;
6034 acu->label1 = query_label[6];
6035 acu->label2 = target_label[1];
6036 acu = AlnConvertUnit_alloc();
6037 add_AlnConvertSet(out,acu);
6038 acu->state1 = BEFORE_MATCH_INTRON_1 + 6;
6039 acu->state2 = BEFORE_MATCH_CODING + 6;
6040 acu->offi = (-1);
6041 acu->offj = 5;
6042 acu->label1 = query_label[6];
6043 acu->label2 = target_label[2];
6044 acu = AlnConvertUnit_alloc();
6045 add_AlnConvertSet(out,acu);
6046 acu->state1 = BEFORE_MATCH_INTRON_2 + 6;
6047 acu->state2 = BEFORE_MATCH_CODING + 6;
6048 acu->offi = (-1);
6049 acu->offj = 4;
6050 acu->label1 = query_label[6];
6051 acu->label2 = target_label[3];
6052 acu = AlnConvertUnit_alloc();
6053 add_AlnConvertSet(out,acu);
6054 acu->state1 = BEFORE_MATCH_CODING + 6;
6055 acu->state2 = BEFORE_MATCH_INTRON_0 + 6;
6056 acu->offi = (-1);
6057 acu->offj = 1;
6058 acu->label1 = query_label[7];
6059 acu->label2 = target_label[7];
6060 acu = AlnConvertUnit_alloc();
6061 add_AlnConvertSet(out,acu);
6062 acu->state1 = BEFORE_MATCH_INTRON_0 + 6;
6063 acu->state2 = BEFORE_MATCH_INTRON_0 + 6;
6064 acu->offi = (-1);
6065 acu->offj = 1;
6066 acu->label1 = query_label[7];
6067 acu->label2 = target_label[8];
6068 acu = AlnConvertUnit_alloc();
6069 add_AlnConvertSet(out,acu);
6070 acu->state1 = BEFORE_MATCH_CODING + 6;
6071 acu->state2 = BEFORE_MATCH_INTRON_1 + 6;
6072 acu->offi = (-1);
6073 acu->offj = 9;
6074 acu->label1 = query_label[7];
6075 acu->label2 = target_label[9];
6076 acu = AlnConvertUnit_alloc();
6077 add_AlnConvertSet(out,acu);
6078 acu->state1 = BEFORE_MATCH_INTRON_1 + 6;
6079 acu->state2 = BEFORE_MATCH_INTRON_1 + 6;
6080 acu->offi = (-1);
6081 acu->offj = 1;
6082 acu->label1 = query_label[7];
6083 acu->label2 = target_label[8];
6084 acu = AlnConvertUnit_alloc();
6085 add_AlnConvertSet(out,acu);
6086 acu->state1 = BEFORE_MATCH_CODING + 6;
6087 acu->state2 = BEFORE_MATCH_INTRON_2 + 6;
6088 acu->offi = (-1);
6089 acu->offj = 10;
6090 acu->label1 = query_label[7];
6091 acu->label2 = target_label[10];
6092 acu = AlnConvertUnit_alloc();
6093 add_AlnConvertSet(out,acu);
6094 acu->state1 = BEFORE_MATCH_INTRON_2 + 6;
6095 acu->state2 = BEFORE_MATCH_INTRON_2 + 6;
6096 acu->offi = (-1);
6097 acu->offj = 1;
6098 acu->label1 = query_label[7];
6099 acu->label2 = target_label[8];
6100 acu = AlnConvertUnit_alloc();
6101 add_AlnConvertSet(out,acu);
6102 acu->state1 = MATCH;
6103 acu->state2 = AFTER_MATCH_CODING + 6;
6104 acu->offi = (-1);
6105 acu->offj = 0;
6106 acu->label1 = query_label[8];
6107 acu->label2 = target_label[0];
6108 acu = AlnConvertUnit_alloc();
6109 add_AlnConvertSet(out,acu);
6110 acu->state1 = AFTER_MATCH_CODING + 6;
6111 acu->state2 = AFTER_MATCH_CODING + 6;
6112 acu->offi = (-1);
6113 acu->offj = 3;
6114 acu->label1 = query_label[8];
6115 acu->label2 = target_label[0];
6116 add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON");
6117 add_collapse_label_AlnConvertSet(out,"BEFORE_MATCH_INTRON","CENTRAL_INTRON");
6118 add_collapse_label_AlnConvertSet(out,"AFTER_MATCH_INTRON","CENTRAL_INTRON");
6119 add_collapse_label_AlnConvertSet(out,"LOOP_STATE","RANDOM_SEQUENCE");
6120 return out;
6121 }
6122
6123
6124 /* Function: PackAln_read_Expl_GenePhase6(mat)
6125 *
6126 * Descrip: Reads off PackAln from explicit matrix structure
6127 *
6128 *
6129 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
6130 *
6131 * Return [UNKN ] Undocumented return value [PackAln *]
6132 *
6133 */
PackAln_read_Expl_GenePhase6(GenePhase6 * mat)6134 PackAln * PackAln_read_Expl_GenePhase6(GenePhase6 * mat)
6135 {
6136 GenePhase6_access_func_holder holder;
6137
6138
6139 holder.access_main = GenePhase6_explicit_access_main;
6140 holder.access_special = GenePhase6_explicit_access_special;
6141 return PackAln_read_generic_GenePhase6(mat,holder);
6142 }
6143
6144
6145 /* Function: GenePhase6_explicit_access_main(mat,i,j,state)
6146 *
6147 * Descrip: No Description
6148 *
6149 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
6150 * Arg: i [UNKN ] Undocumented argument [int]
6151 * Arg: j [UNKN ] Undocumented argument [int]
6152 * Arg: state [UNKN ] Undocumented argument [int]
6153 *
6154 * Return [UNKN ] Undocumented return value [int]
6155 *
6156 */
GenePhase6_explicit_access_main(GenePhase6 * mat,int i,int j,int state)6157 int GenePhase6_explicit_access_main(GenePhase6 * mat,int i,int j,int state)
6158 {
6159 return GenePhase6_EXPL_MATRIX(mat,i,j,state);
6160 }
6161
6162
6163 /* Function: GenePhase6_explicit_access_special(mat,i,j,state)
6164 *
6165 * Descrip: No Description
6166 *
6167 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
6168 * Arg: i [UNKN ] Undocumented argument [int]
6169 * Arg: j [UNKN ] Undocumented argument [int]
6170 * Arg: state [UNKN ] Undocumented argument [int]
6171 *
6172 * Return [UNKN ] Undocumented return value [int]
6173 *
6174 */
GenePhase6_explicit_access_special(GenePhase6 * mat,int i,int j,int state)6175 int GenePhase6_explicit_access_special(GenePhase6 * mat,int i,int j,int state)
6176 {
6177 return GenePhase6_EXPL_SPECIAL(mat,i,j,state);
6178 }
6179
6180
6181 /* Function: PackAln_read_generic_GenePhase6(mat,h)
6182 *
6183 * Descrip: Reads off PackAln from explicit matrix structure
6184 *
6185 *
6186 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
6187 * Arg: h [UNKN ] Undocumented argument [GenePhase6_access_func_holder]
6188 *
6189 * Return [UNKN ] Undocumented return value [PackAln *]
6190 *
6191 */
PackAln_read_generic_GenePhase6(GenePhase6 * mat,GenePhase6_access_func_holder h)6192 PackAln * PackAln_read_generic_GenePhase6(GenePhase6 * mat,GenePhase6_access_func_holder h)
6193 {
6194 register PackAln * out;
6195 int i;
6196 int j;
6197 int state;
6198 int cellscore = (-1);
6199 boolean isspecial;
6200 PackAlnUnit * pau = NULL;
6201 PackAlnUnit * prev = NULL;
6202
6203
6204 assert(mat);
6205 assert(h.access_main);
6206 assert(h.access_special);
6207
6208
6209 out = PackAln_alloc_std();
6210 if( out == NULL )
6211 return NULL;
6212
6213
6214 out->score = find_end_GenePhase6(mat,&i,&j,&state,&isspecial,h);
6215
6216
6217 /* Add final end transition (at the moment we have not got the score! */
6218 if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) {
6219 warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GenePhase6_basic_read, returning a mess.(Sorry!)",out->len);
6220 return out;
6221 }
6222
6223
6224 /* Put in positions for end trans. Remember that coordinates in C style */
6225 pau->i = i;
6226 pau->j = j;
6227 if( isspecial != TRUE)
6228 pau->state = state;
6229 else pau->state = state + 6;
6230 prev=pau;
6231 while( state != START || isspecial != TRUE) { /*while state != START*/
6232
6233
6234 if( isspecial == TRUE )
6235 max_calc_special_GenePhase6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h);
6236 else
6237 max_calc_GenePhase6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h);
6238 if(i == GenePhase6_READ_OFF_ERROR || j == GenePhase6_READ_OFF_ERROR || state == GenePhase6_READ_OFF_ERROR ) {
6239 warn("Problem - hit bad read off system, exiting now");
6240 break;
6241 }
6242 if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) {
6243 warn("Failed a PackAlnUnit alloc, %d length of Alignment in GenePhase6_basic_read, returning partial alignment",out->len);
6244 break;
6245 }
6246
6247
6248 /* Put in positions for block. Remember that coordinates in C style */
6249 pau->i = i;
6250 pau->j = j;
6251 if( isspecial != TRUE)
6252 pau->state = state;
6253 else pau->state = state + 6;
6254 prev->score = cellscore;
6255 prev = pau;
6256 } /* end of while state != START */
6257
6258
6259 invert_PackAln(out);
6260 return out;
6261 }
6262
6263
6264 /* Function: find_end_GenePhase6(mat,ri,rj,state,isspecial,h)
6265 *
6266 * Descrip: No Description
6267 *
6268 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
6269 * Arg: ri [UNKN ] Undocumented argument [int *]
6270 * Arg: rj [UNKN ] Undocumented argument [int *]
6271 * Arg: state [UNKN ] Undocumented argument [int *]
6272 * Arg: isspecial [UNKN ] Undocumented argument [boolean *]
6273 * Arg: h [UNKN ] Undocumented argument [GenePhase6_access_func_holder]
6274 *
6275 * Return [UNKN ] Undocumented return value [int]
6276 *
6277 */
find_end_GenePhase6(GenePhase6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GenePhase6_access_func_holder h)6278 int find_end_GenePhase6(GenePhase6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GenePhase6_access_func_holder h)
6279 {
6280 int j;
6281 int max;
6282 int maxj;
6283 int temp;
6284
6285
6286 max = (*h.access_special)(mat,0,mat->target->seq->len-1,END);
6287 maxj = mat->target->seq->len-1;
6288 for(j= mat->target->seq->len-2 ;j >= 0 ;j--) {
6289 if( (temp =(*h.access_special)(mat,0,j,END)) > max ) {
6290 max = temp;
6291 maxj = j;
6292 }
6293 }
6294
6295
6296 if( ri != NULL)
6297 *ri = 0;
6298 if( rj != NULL)
6299 *rj = maxj;
6300 if( state != NULL)
6301 *state = END;
6302 if( isspecial != NULL)
6303 *isspecial = TRUE;
6304
6305
6306 return max;
6307 }
6308
6309
6310 /* Function: GenePhase6_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp)
6311 *
6312 * Descrip: No Description
6313 *
6314 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
6315 * Arg: starti [UNKN ] Undocumented argument [int]
6316 * Arg: stopi [UNKN ] Undocumented argument [int]
6317 * Arg: startj [UNKN ] Undocumented argument [int]
6318 * Arg: stopj [UNKN ] Undocumented argument [int]
6319 * Arg: ofp [UNKN ] Undocumented argument [FILE *]
6320 *
6321 */
GenePhase6_debug_show_matrix(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp)6322 void GenePhase6_debug_show_matrix(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp)
6323 {
6324 register int i;
6325 register int j;
6326
6327
6328 for(i=starti;i<stopi && i < mat->query->len;i++) {
6329 for(j=startj;j<stopj && j < mat->target->seq->len;j++) {
6330 fprintf(ofp,"Cell [%d - %d]\n",i,j);
6331 fprintf(ofp,"State MATCH %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,MATCH));
6332 fprintf(ofp,"State INSERT %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,INSERT));
6333 fprintf(ofp,"State DELETE %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,DELETE));
6334 fprintf(ofp,"State INTRON_0 %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0));
6335 fprintf(ofp,"State INTRON_1 %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1));
6336 fprintf(ofp,"State INTRON_2 %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2));
6337 fprintf(ofp,"\n\n");
6338 }
6339 }
6340
6341
6342 }
6343
6344
6345 /* Function: max_calc_GenePhase6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h)
6346 *
6347 * Descrip: No Description
6348 *
6349 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
6350 * Arg: i [UNKN ] Undocumented argument [int]
6351 * Arg: j [UNKN ] Undocumented argument [int]
6352 * Arg: state [UNKN ] Undocumented argument [int]
6353 * Arg: isspecial [UNKN ] Undocumented argument [boolean]
6354 * Arg: reti [UNKN ] Undocumented argument [int *]
6355 * Arg: retj [UNKN ] Undocumented argument [int *]
6356 * Arg: retstate [UNKN ] Undocumented argument [int *]
6357 * Arg: retspecial [UNKN ] Undocumented argument [boolean *]
6358 * Arg: cellscore [UNKN ] Undocumented argument [int *]
6359 * Arg: h [UNKN ] Undocumented argument [GenePhase6_access_func_holder]
6360 *
6361 * Return [UNKN ] Undocumented return value [int]
6362 *
6363 */
max_calc_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenePhase6_access_func_holder h)6364 int max_calc_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenePhase6_access_func_holder h)
6365 {
6366 register int temp;
6367 register int cscore;
6368
6369
6370 *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR;
6371
6372
6373 if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) {
6374 warn("In GenePhase6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state);
6375 return -1;
6376 }
6377
6378
6379 /* Then you have to select the correct switch statement to figure out the readoff */
6380 /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */
6381 cscore = (*h.access_main)(mat,i,j,state);
6382 switch(state) { /*Switch state */
6383 case MATCH :
6384 temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6385 if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) {
6386 *reti = i - 1;
6387 *retj = j - 5;
6388 *retstate = MATCH;
6389 *retspecial = FALSE;
6390 if( cellscore != NULL) {
6391 *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH);
6392 }
6393 return (*h.access_main)(mat,i - 1,j - 5,MATCH);
6394 }
6395 temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6396 if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) {
6397 *reti = i - 1;
6398 *retj = j - 4;
6399 *retstate = MATCH;
6400 *retspecial = FALSE;
6401 if( cellscore != NULL) {
6402 *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH);
6403 }
6404 return (*h.access_main)(mat,i - 1,j - 4,MATCH);
6405 }
6406 temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6407 if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) {
6408 *reti = i - 1;
6409 *retj = j - 1;
6410 *retstate = MATCH;
6411 *retspecial = FALSE;
6412 if( cellscore != NULL) {
6413 *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH);
6414 }
6415 return (*h.access_main)(mat,i - 1,j - 1,MATCH);
6416 }
6417 temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6418 if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) {
6419 *reti = i - 1;
6420 *retj = j - 2;
6421 *retstate = MATCH;
6422 *retspecial = FALSE;
6423 if( cellscore != NULL) {
6424 *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH);
6425 }
6426 return (*h.access_main)(mat,i - 1,j - 2,MATCH);
6427 }
6428 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6429 if( temp == (*h.access_main)(mat,i - 1,j - 4,INTRON_2) ) {
6430 *reti = i - 1;
6431 *retj = j - 4;
6432 *retstate = INTRON_2;
6433 *retspecial = FALSE;
6434 if( cellscore != NULL) {
6435 *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INTRON_2);
6436 }
6437 return (*h.access_main)(mat,i - 1,j - 4,INTRON_2);
6438 }
6439 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6440 if( temp == (*h.access_main)(mat,i - 1,j - 5,INTRON_1) ) {
6441 *reti = i - 1;
6442 *retj = j - 5;
6443 *retstate = INTRON_1;
6444 *retspecial = FALSE;
6445 if( cellscore != NULL) {
6446 *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INTRON_1);
6447 }
6448 return (*h.access_main)(mat,i - 1,j - 5,INTRON_1);
6449 }
6450 temp = cscore - ((mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6451 if( temp == (*h.access_main)(mat,i - 1,j - 6,INTRON_0) ) {
6452 *reti = i - 1;
6453 *retj = j - 6;
6454 *retstate = INTRON_0;
6455 *retspecial = FALSE;
6456 if( cellscore != NULL) {
6457 *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,INTRON_0);
6458 }
6459 return (*h.access_main)(mat,i - 1,j - 6,INTRON_0);
6460 }
6461 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6462 if( temp == (*h.access_special)(mat,i - 1,j - 3,BEFORE_MATCH_CODING) ) {
6463 *reti = i - 1;
6464 *retj = j - 3;
6465 *retstate = BEFORE_MATCH_CODING;
6466 *retspecial = TRUE;
6467 if( cellscore != NULL) {
6468 *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,BEFORE_MATCH_CODING);
6469 }
6470 return (*h.access_main)(mat,i - 1,j - 3,BEFORE_MATCH_CODING);
6471 }
6472 temp = cscore - (((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6473 if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) {
6474 *reti = i - 1;
6475 *retj = j - 3;
6476 *retstate = START;
6477 *retspecial = TRUE;
6478 if( cellscore != NULL) {
6479 *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START);
6480 }
6481 return (*h.access_main)(mat,i - 1,j - 3,START);
6482 }
6483 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6484 if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) {
6485 *reti = i - 1;
6486 *retj = j - 3;
6487 *retstate = DELETE;
6488 *retspecial = FALSE;
6489 if( cellscore != NULL) {
6490 *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE);
6491 }
6492 return (*h.access_main)(mat,i - 1,j - 3,DELETE);
6493 }
6494 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6495 if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) {
6496 *reti = i - 1;
6497 *retj = j - 3;
6498 *retstate = INSERT;
6499 *retspecial = FALSE;
6500 if( cellscore != NULL) {
6501 *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT);
6502 }
6503 return (*h.access_main)(mat,i - 1,j - 3,INSERT);
6504 }
6505 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6506 if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) {
6507 *reti = i - 1;
6508 *retj = j - 3;
6509 *retstate = MATCH;
6510 *retspecial = FALSE;
6511 if( cellscore != NULL) {
6512 *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH);
6513 }
6514 return (*h.access_main)(mat,i - 1,j - 3,MATCH);
6515 }
6516 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
6517 return (-1);
6518 case INSERT :
6519 temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6520 if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) {
6521 *reti = i - 0;
6522 *retj = j - 1;
6523 *retstate = INSERT;
6524 *retspecial = FALSE;
6525 if( cellscore != NULL) {
6526 *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT);
6527 }
6528 return (*h.access_main)(mat,i - 0,j - 1,INSERT);
6529 }
6530 temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6531 if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) {
6532 *reti = i - 0;
6533 *retj = j - 2;
6534 *retstate = INSERT;
6535 *retspecial = FALSE;
6536 if( cellscore != NULL) {
6537 *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT);
6538 }
6539 return (*h.access_main)(mat,i - 0,j - 2,INSERT);
6540 }
6541 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6542 if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON_2) ) {
6543 *reti = i - 0;
6544 *retj = j - 4;
6545 *retstate = INTRON_2;
6546 *retspecial = FALSE;
6547 if( cellscore != NULL) {
6548 *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON_2);
6549 }
6550 return (*h.access_main)(mat,i - 0,j - 4,INTRON_2);
6551 }
6552 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6553 if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON_1) ) {
6554 *reti = i - 0;
6555 *retj = j - 5;
6556 *retstate = INTRON_1;
6557 *retspecial = FALSE;
6558 if( cellscore != NULL) {
6559 *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON_1);
6560 }
6561 return (*h.access_main)(mat,i - 0,j - 5,INTRON_1);
6562 }
6563 temp = cscore - ((mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6564 if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON_0) ) {
6565 *reti = i - 0;
6566 *retj = j - 6;
6567 *retstate = INTRON_0;
6568 *retspecial = FALSE;
6569 if( cellscore != NULL) {
6570 *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON_0);
6571 }
6572 return (*h.access_main)(mat,i - 0,j - 6,INTRON_0);
6573 }
6574 temp = cscore - (((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6575 if( temp == (*h.access_special)(mat,i - 0,j - 3,LOOP) ) {
6576 *reti = i - 0;
6577 *retj = j - 3;
6578 *retstate = LOOP;
6579 *retspecial = TRUE;
6580 if( cellscore != NULL) {
6581 *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,LOOP);
6582 }
6583 return (*h.access_main)(mat,i - 0,j - 3,LOOP);
6584 }
6585 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6586 if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) {
6587 *reti = i - 0;
6588 *retj = j - 3;
6589 *retstate = DELETE;
6590 *retspecial = FALSE;
6591 if( cellscore != NULL) {
6592 *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE);
6593 }
6594 return (*h.access_main)(mat,i - 0,j - 3,DELETE);
6595 }
6596 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6597 if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) {
6598 *reti = i - 0;
6599 *retj = j - 3;
6600 *retstate = INSERT;
6601 *retspecial = FALSE;
6602 if( cellscore != NULL) {
6603 *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT);
6604 }
6605 return (*h.access_main)(mat,i - 0,j - 3,INSERT);
6606 }
6607 temp = cscore - ((mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j));
6608 if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) {
6609 *reti = i - 0;
6610 *retj = j - 3;
6611 *retstate = MATCH;
6612 *retspecial = FALSE;
6613 if( cellscore != NULL) {
6614 *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH);
6615 }
6616 return (*h.access_main)(mat,i - 0,j - 3,MATCH);
6617 }
6618 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
6619 return (-1);
6620 case DELETE :
6621 temp = cscore - (mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]) - (0);
6622 if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) {
6623 *reti = i - 1;
6624 *retj = j - 0;
6625 *retstate = DELETE;
6626 *retspecial = FALSE;
6627 if( cellscore != NULL) {
6628 *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE);
6629 }
6630 return (*h.access_main)(mat,i - 1,j - 0,DELETE);
6631 }
6632 temp = cscore - (mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]) - (0);
6633 if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) {
6634 *reti = i - 1;
6635 *retj = j - 0;
6636 *retstate = INSERT;
6637 *retspecial = FALSE;
6638 if( cellscore != NULL) {
6639 *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT);
6640 }
6641 return (*h.access_main)(mat,i - 1,j - 0,INSERT);
6642 }
6643 temp = cscore - (mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]) - (0);
6644 if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) {
6645 *reti = i - 1;
6646 *retj = j - 0;
6647 *retstate = MATCH;
6648 *retspecial = FALSE;
6649 if( cellscore != NULL) {
6650 *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH);
6651 }
6652 return (*h.access_main)(mat,i - 1,j - 0,MATCH);
6653 }
6654 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
6655 return (-1);
6656 case INTRON_0 :
6657 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
6658 if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) {
6659 *reti = i - 0;
6660 *retj = j - 1;
6661 *retstate = INTRON_0;
6662 *retspecial = FALSE;
6663 if( cellscore != NULL) {
6664 *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0);
6665 }
6666 return (*h.access_main)(mat,i - 0,j - 1,INTRON_0);
6667 }
6668 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0);
6669 if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) {
6670 *reti = i - 0;
6671 *retj = j - 8;
6672 *retstate = INSERT;
6673 *retspecial = FALSE;
6674 if( cellscore != NULL) {
6675 *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT);
6676 }
6677 return (*h.access_main)(mat,i - 0,j - 8,INSERT);
6678 }
6679 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0)) - (0);
6680 if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) {
6681 *reti = i - 0;
6682 *retj = j - 8;
6683 *retstate = MATCH;
6684 *retspecial = FALSE;
6685 if( cellscore != NULL) {
6686 *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH);
6687 }
6688 return (*h.access_main)(mat,i - 0,j - 8,MATCH);
6689 }
6690 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
6691 return (-1);
6692 case INTRON_1 :
6693 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
6694 if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) {
6695 *reti = i - 0;
6696 *retj = j - 1;
6697 *retstate = INTRON_1;
6698 *retspecial = FALSE;
6699 if( cellscore != NULL) {
6700 *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1);
6701 }
6702 return (*h.access_main)(mat,i - 0,j - 1,INTRON_1);
6703 }
6704 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0);
6705 if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) {
6706 *reti = i - 0;
6707 *retj = j - 9;
6708 *retstate = INSERT;
6709 *retspecial = FALSE;
6710 if( cellscore != NULL) {
6711 *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT);
6712 }
6713 return (*h.access_main)(mat,i - 0,j - 9,INSERT);
6714 }
6715 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1)) - (0);
6716 if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) {
6717 *reti = i - 0;
6718 *retj = j - 9;
6719 *retstate = MATCH;
6720 *retspecial = FALSE;
6721 if( cellscore != NULL) {
6722 *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH);
6723 }
6724 return (*h.access_main)(mat,i - 0,j - 9,MATCH);
6725 }
6726 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
6727 return (-1);
6728 case INTRON_2 :
6729 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
6730 if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) {
6731 *reti = i - 0;
6732 *retj = j - 1;
6733 *retstate = INTRON_2;
6734 *retspecial = FALSE;
6735 if( cellscore != NULL) {
6736 *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2);
6737 }
6738 return (*h.access_main)(mat,i - 0,j - 1,INTRON_2);
6739 }
6740 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0);
6741 if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) {
6742 *reti = i - 0;
6743 *retj = j - 10;
6744 *retstate = INSERT;
6745 *retspecial = FALSE;
6746 if( cellscore != NULL) {
6747 *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT);
6748 }
6749 return (*h.access_main)(mat,i - 0,j - 10,INSERT);
6750 }
6751 temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2)) - (0);
6752 if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) {
6753 *reti = i - 0;
6754 *retj = j - 10;
6755 *retstate = MATCH;
6756 *retspecial = FALSE;
6757 if( cellscore != NULL) {
6758 *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH);
6759 }
6760 return (*h.access_main)(mat,i - 0,j - 10,MATCH);
6761 }
6762 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
6763 return (-1);
6764 default:
6765 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state);
6766 return (-1);
6767 } /* end of Switch state */
6768 }
6769
6770
6771 /* Function: max_calc_special_GenePhase6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h)
6772 *
6773 * Descrip: No Description
6774 *
6775 * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *]
6776 * Arg: i [UNKN ] Undocumented argument [int]
6777 * Arg: j [UNKN ] Undocumented argument [int]
6778 * Arg: state [UNKN ] Undocumented argument [int]
6779 * Arg: isspecial [UNKN ] Undocumented argument [boolean]
6780 * Arg: reti [UNKN ] Undocumented argument [int *]
6781 * Arg: retj [UNKN ] Undocumented argument [int *]
6782 * Arg: retstate [UNKN ] Undocumented argument [int *]
6783 * Arg: retspecial [UNKN ] Undocumented argument [boolean *]
6784 * Arg: cellscore [UNKN ] Undocumented argument [int *]
6785 * Arg: h [UNKN ] Undocumented argument [GenePhase6_access_func_holder]
6786 *
6787 * Return [UNKN ] Undocumented return value [int]
6788 *
6789 */
max_calc_special_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenePhase6_access_func_holder h)6790 int max_calc_special_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenePhase6_access_func_holder h)
6791 {
6792 register int temp;
6793 register int cscore;
6794
6795
6796 *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR;
6797
6798
6799 if( j < 0 || j > mat->target->seq->len) {
6800 warn("In GenePhase6 matrix special read off - out of bounds on matrix [j is %d in special]",j);
6801 return -1;
6802 }
6803
6804
6805 cscore = (*h.access_special)(mat,i,j,state);
6806 switch(state) { /*switch on special states*/
6807 case LOOP :
6808 /* source LOOP is a special */
6809 temp = cscore - (mat->gp->transition[GP4_LOOP2LOOP]) - (0);
6810 if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) {
6811 *reti = i - 0;
6812 *retj = j - 1;
6813 *retstate = LOOP;
6814 *retspecial = TRUE;
6815 if( cellscore != NULL) {
6816 *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP);
6817 }
6818 return (*h.access_special)(mat,i - 0,j - 1,LOOP) ;
6819 }
6820 /* source DELETE is from main matrix */
6821 for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/
6822 temp = cscore - (mat->query->gws->seg[i]->transition[GW_DELETE2END]) - (0);
6823 if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) {
6824 *reti = i - 0;
6825 *retj = j - 0;
6826 *retstate = DELETE;
6827 *retspecial = FALSE;
6828 if( cellscore != NULL) {
6829 *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE);
6830 }
6831 return (*h.access_main)(mat,i - 0,j - 0,DELETE) ;
6832 }
6833 } /* end of for i >= 0 */
6834 /* source INSERT is from main matrix */
6835 for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/
6836 temp = cscore - (mat->query->gws->seg[i]->transition[GW_INSERT2END]) - (0);
6837 if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) {
6838 *reti = i - 0;
6839 *retj = j - 0;
6840 *retstate = INSERT;
6841 *retspecial = FALSE;
6842 if( cellscore != NULL) {
6843 *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT);
6844 }
6845 return (*h.access_main)(mat,i - 0,j - 0,INSERT) ;
6846 }
6847 } /* end of for i >= 0 */
6848 /* source MATCH is from main matrix */
6849 for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/
6850 temp = cscore - (mat->query->gws->seg[i]->transition[GW_MATCH2END]) - (0);
6851 if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) {
6852 *reti = i - 0;
6853 *retj = j - 0;
6854 *retstate = MATCH;
6855 *retspecial = FALSE;
6856 if( cellscore != NULL) {
6857 *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH);
6858 }
6859 return (*h.access_main)(mat,i - 0,j - 0,MATCH) ;
6860 }
6861 } /* end of for i >= 0 */
6862 /* source START is a special */
6863 temp = cscore - (0) - (0);
6864 if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) {
6865 *reti = i - 0;
6866 *retj = j - 1;
6867 *retstate = START;
6868 *retspecial = TRUE;
6869 if( cellscore != NULL) {
6870 *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START);
6871 }
6872 return (*h.access_special)(mat,i - 0,j - 1,START) ;
6873 }
6874 case START :
6875 case END :
6876 /* source AFTER_MATCH_CODING is a special */
6877 temp = cscore - (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0);
6878 if( temp == (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) {
6879 *reti = i - 0;
6880 *retj = j - 3;
6881 *retstate = AFTER_MATCH_CODING;
6882 *retspecial = TRUE;
6883 if( cellscore != NULL) {
6884 *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,AFTER_MATCH_CODING);
6885 }
6886 return (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ;
6887 }
6888 /* source LOOP is a special */
6889 temp = cscore - (0) - (0);
6890 if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) {
6891 *reti = i - 0;
6892 *retj = j - 1;
6893 *retstate = LOOP;
6894 *retspecial = TRUE;
6895 if( cellscore != NULL) {
6896 *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP);
6897 }
6898 return (*h.access_special)(mat,i - 0,j - 1,LOOP) ;
6899 }
6900 case BEFORE_MATCH_CODING :
6901 /* source BEFORE_MATCH_INTRON_2 is a special */
6902 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (0);
6903 if( temp == (*h.access_special)(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2) ) {
6904 *reti = i - 0;
6905 *retj = j - 4;
6906 *retstate = BEFORE_MATCH_INTRON_2;
6907 *retspecial = TRUE;
6908 if( cellscore != NULL) {
6909 *cellscore = cscore - (*h.access_special)(mat,i-0,j-4,BEFORE_MATCH_INTRON_2);
6910 }
6911 return (*h.access_special)(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2) ;
6912 }
6913 /* source BEFORE_MATCH_INTRON_1 is a special */
6914 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (0);
6915 if( temp == (*h.access_special)(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1) ) {
6916 *reti = i - 0;
6917 *retj = j - 5;
6918 *retstate = BEFORE_MATCH_INTRON_1;
6919 *retspecial = TRUE;
6920 if( cellscore != NULL) {
6921 *cellscore = cscore - (*h.access_special)(mat,i-0,j-5,BEFORE_MATCH_INTRON_1);
6922 }
6923 return (*h.access_special)(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1) ;
6924 }
6925 /* source BEFORE_MATCH_INTRON_0 is a special */
6926 temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-3))) - (0);
6927 if( temp == (*h.access_special)(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0) ) {
6928 *reti = i - 0;
6929 *retj = j - 6;
6930 *retstate = BEFORE_MATCH_INTRON_0;
6931 *retspecial = TRUE;
6932 if( cellscore != NULL) {
6933 *cellscore = cscore - (*h.access_special)(mat,i-0,j-6,BEFORE_MATCH_INTRON_0);
6934 }
6935 return (*h.access_special)(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0) ;
6936 }
6937 /* source BEFORE_MATCH_CODING is a special */
6938 temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0);
6939 if( temp == (*h.access_special)(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ) {
6940 *reti = i - 0;
6941 *retj = j - 3;
6942 *retstate = BEFORE_MATCH_CODING;
6943 *retspecial = TRUE;
6944 if( cellscore != NULL) {
6945 *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,BEFORE_MATCH_CODING);
6946 }
6947 return (*h.access_special)(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ;
6948 }
6949 /* source START is a special */
6950 temp = cscore - (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0);
6951 if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) {
6952 *reti = i - 0;
6953 *retj = j - 3;
6954 *retstate = START;
6955 *retspecial = TRUE;
6956 if( cellscore != NULL) {
6957 *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START);
6958 }
6959 return (*h.access_special)(mat,i - 0,j - 3,START) ;
6960 }
6961 case BEFORE_MATCH_INTRON_0 :
6962 /* source BEFORE_MATCH_INTRON_0 is a special */
6963 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
6964 if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0) ) {
6965 *reti = i - 0;
6966 *retj = j - 1;
6967 *retstate = BEFORE_MATCH_INTRON_0;
6968 *retspecial = TRUE;
6969 if( cellscore != NULL) {
6970 *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_MATCH_INTRON_0);
6971 }
6972 return (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0) ;
6973 }
6974 /* source BEFORE_MATCH_CODING is a special */
6975 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0);
6976 if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_CODING) ) {
6977 *reti = i - 0;
6978 *retj = j - 1;
6979 *retstate = BEFORE_MATCH_CODING;
6980 *retspecial = TRUE;
6981 if( cellscore != NULL) {
6982 *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_MATCH_CODING);
6983 }
6984 return (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_CODING) ;
6985 }
6986 case BEFORE_MATCH_INTRON_1 :
6987 /* source BEFORE_MATCH_INTRON_1 is a special */
6988 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
6989 if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1) ) {
6990 *reti = i - 0;
6991 *retj = j - 1;
6992 *retstate = BEFORE_MATCH_INTRON_1;
6993 *retspecial = TRUE;
6994 if( cellscore != NULL) {
6995 *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_MATCH_INTRON_1);
6996 }
6997 return (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1) ;
6998 }
6999 /* source BEFORE_MATCH_CODING is a special */
7000 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0);
7001 if( temp == (*h.access_special)(mat,i - 0,j - 9,BEFORE_MATCH_CODING) ) {
7002 *reti = i - 0;
7003 *retj = j - 9;
7004 *retstate = BEFORE_MATCH_CODING;
7005 *retspecial = TRUE;
7006 if( cellscore != NULL) {
7007 *cellscore = cscore - (*h.access_special)(mat,i-0,j-9,BEFORE_MATCH_CODING);
7008 }
7009 return (*h.access_special)(mat,i - 0,j - 9,BEFORE_MATCH_CODING) ;
7010 }
7011 case BEFORE_MATCH_INTRON_2 :
7012 /* source BEFORE_MATCH_INTRON_2 is a special */
7013 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0);
7014 if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2) ) {
7015 *reti = i - 0;
7016 *retj = j - 1;
7017 *retstate = BEFORE_MATCH_INTRON_2;
7018 *retspecial = TRUE;
7019 if( cellscore != NULL) {
7020 *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_MATCH_INTRON_2);
7021 }
7022 return (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2) ;
7023 }
7024 /* source BEFORE_MATCH_CODING is a special */
7025 temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0);
7026 if( temp == (*h.access_special)(mat,i - 0,j - 10,BEFORE_MATCH_CODING) ) {
7027 *reti = i - 0;
7028 *retj = j - 10;
7029 *retstate = BEFORE_MATCH_CODING;
7030 *retspecial = TRUE;
7031 if( cellscore != NULL) {
7032 *cellscore = cscore - (*h.access_special)(mat,i-0,j-10,BEFORE_MATCH_CODING);
7033 }
7034 return (*h.access_special)(mat,i - 0,j - 10,BEFORE_MATCH_CODING) ;
7035 }
7036 case AFTER_MATCH_CODING :
7037 /* source AFTER_MATCH_CODING is a special */
7038 temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0);
7039 if( temp == (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) {
7040 *reti = i - 0;
7041 *retj = j - 3;
7042 *retstate = AFTER_MATCH_CODING;
7043 *retspecial = TRUE;
7044 if( cellscore != NULL) {
7045 *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,AFTER_MATCH_CODING);
7046 }
7047 return (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ;
7048 }
7049 /* source MATCH is from main matrix */
7050 for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/
7051 temp = cscore - (mat->query->gws->seg[i]->transition[GW_MATCH2END]) - (0);
7052 if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) {
7053 *reti = i - 0;
7054 *retj = j - 0;
7055 *retstate = MATCH;
7056 *retspecial = FALSE;
7057 if( cellscore != NULL) {
7058 *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH);
7059 }
7060 return (*h.access_main)(mat,i - 0,j - 0,MATCH) ;
7061 }
7062 } /* end of for i >= 0 */
7063 default:
7064 warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state);
7065 return (-1);
7066 } /* end of switch on special states */
7067 }
7068
7069
7070 /* Function: calculate_GenePhase6(mat)
7071 *
7072 * Descrip: This function calculates the GenePhase6 matrix when in explicit mode
7073 * To allocate the matrix use /allocate_Expl_GenePhase6
7074 *
7075 *
7076 * Arg: mat [UNKN ] GenePhase6 which contains explicit basematrix memory [GenePhase6 *]
7077 *
7078 * Return [UNKN ] Undocumented return value [boolean]
7079 *
7080 */
calculate_GenePhase6(GenePhase6 * mat)7081 boolean calculate_GenePhase6(GenePhase6 * mat)
7082 {
7083 int i;
7084 int j;
7085 int leni;
7086 int lenj;
7087 int tot;
7088 int num;
7089
7090
7091 if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) {
7092 warn("in calculate_GenePhase6, passed a non Explicit matrix type, cannot calculate!");
7093 return FALSE;
7094 }
7095
7096
7097 leni = mat->leni;
7098 lenj = mat->lenj;
7099 tot = leni * lenj;
7100 num = 0;
7101
7102
7103 start_reporting("GenePhase6 Matrix calculation: ");
7104 for(j=0;j<lenj;j++) {
7105 auto int score;
7106 auto int temp;
7107 for(i=0;i<leni;i++) {
7108 if( num%1000 == 0 )
7109 log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot);
7110 num++;
7111
7112
7113 /* For state MATCH */
7114 /* setting first movement to score */
7115 score = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
7116 /* From state INSERT to state MATCH */
7117 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
7118 if( temp > score ) {
7119 score = temp;
7120 }
7121 /* From state DELETE to state MATCH */
7122 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
7123 if( temp > score ) {
7124 score = temp;
7125 }
7126 /* From state START to state MATCH */
7127 temp = GenePhase6_EXPL_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]);
7128 if( temp > score ) {
7129 score = temp;
7130 }
7131 /* From state BEFORE_MATCH_CODING to state MATCH */
7132 temp = GenePhase6_EXPL_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
7133 if( temp > score ) {
7134 score = temp;
7135 }
7136 /* From state INTRON_0 to state MATCH */
7137 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
7138 if( temp > score ) {
7139 score = temp;
7140 }
7141 /* From state INTRON_1 to state MATCH */
7142 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
7143 if( temp > score ) {
7144 score = temp;
7145 }
7146 /* From state INTRON_2 to state MATCH */
7147 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
7148 if( temp > score ) {
7149 score = temp;
7150 }
7151 /* From state MATCH to state MATCH */
7152 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE];
7153 if( temp > score ) {
7154 score = temp;
7155 }
7156 /* From state MATCH to state MATCH */
7157 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE];
7158 if( temp > score ) {
7159 score = temp;
7160 }
7161 /* From state MATCH to state MATCH */
7162 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE];
7163 if( temp > score ) {
7164 score = temp;
7165 }
7166 /* From state MATCH to state MATCH */
7167 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE];
7168 if( temp > score ) {
7169 score = temp;
7170 }
7171
7172
7173 /* Ok - finished max calculation for MATCH */
7174 /* Add any movement independant score and put away */
7175 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
7176 GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = score;
7177
7178
7179 /* state MATCH is a source for special LOOP */
7180 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
7181 if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) {
7182 GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp;
7183 }
7184
7185
7186
7187
7188 /* state MATCH is a source for special AFTER_MATCH_CODING */
7189 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
7190 if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) {
7191 GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp;
7192 }
7193
7194
7195
7196
7197 /* Finished calculating state MATCH */
7198
7199
7200 /* For state INSERT */
7201 /* setting first movement to score */
7202 score = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
7203 /* From state INSERT to state INSERT */
7204 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
7205 if( temp > score ) {
7206 score = temp;
7207 }
7208 /* From state DELETE to state INSERT */
7209 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
7210 if( temp > score ) {
7211 score = temp;
7212 }
7213 /* From state LOOP to state INSERT */
7214 temp = GenePhase6_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]);
7215 if( temp > score ) {
7216 score = temp;
7217 }
7218 /* From state INTRON_0 to state INSERT */
7219 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
7220 if( temp > score ) {
7221 score = temp;
7222 }
7223 /* From state INTRON_1 to state INSERT */
7224 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
7225 if( temp > score ) {
7226 score = temp;
7227 }
7228 /* From state INTRON_2 to state INSERT */
7229 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
7230 if( temp > score ) {
7231 score = temp;
7232 }
7233 /* From state INSERT to state INSERT */
7234 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE];
7235 if( temp > score ) {
7236 score = temp;
7237 }
7238 /* From state INSERT to state INSERT */
7239 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE];
7240 if( temp > score ) {
7241 score = temp;
7242 }
7243
7244
7245 /* Ok - finished max calculation for INSERT */
7246 /* Add any movement independant score and put away */
7247 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
7248 GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = score;
7249
7250
7251 /* state INSERT is a source for special LOOP */
7252 temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ;
7253 if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) {
7254 GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp;
7255 }
7256
7257
7258
7259
7260 /* Finished calculating state INSERT */
7261
7262
7263 /* For state DELETE */
7264 /* setting first movement to score */
7265 score = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE];
7266 /* From state INSERT to state DELETE */
7267 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE];
7268 if( temp > score ) {
7269 score = temp;
7270 }
7271 /* From state DELETE to state DELETE */
7272 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE];
7273 if( temp > score ) {
7274 score = temp;
7275 }
7276
7277
7278 /* Ok - finished max calculation for DELETE */
7279 /* Add any movement independant score and put away */
7280 GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = score;
7281
7282
7283 /* state DELETE is a source for special LOOP */
7284 temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ;
7285 if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) {
7286 GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp;
7287 }
7288
7289
7290
7291
7292 /* Finished calculating state DELETE */
7293
7294
7295 /* For state INTRON_0 */
7296 /* setting first movement to score */
7297 score = GenePhase6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0);
7298 /* From state INSERT to state INTRON_0 */
7299 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
7300 if( temp > score ) {
7301 score = temp;
7302 }
7303 /* From state INTRON_0 to state INTRON_0 */
7304 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
7305 if( temp > score ) {
7306 score = temp;
7307 }
7308
7309
7310 /* Ok - finished max calculation for INTRON_0 */
7311 /* Add any movement independant score and put away */
7312 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = score;
7313
7314
7315 /* Finished calculating state INTRON_0 */
7316
7317
7318 /* For state INTRON_1 */
7319 /* setting first movement to score */
7320 score = GenePhase6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1);
7321 /* From state INSERT to state INTRON_1 */
7322 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
7323 if( temp > score ) {
7324 score = temp;
7325 }
7326 /* From state INTRON_1 to state INTRON_1 */
7327 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
7328 if( temp > score ) {
7329 score = temp;
7330 }
7331
7332
7333 /* Ok - finished max calculation for INTRON_1 */
7334 /* Add any movement independant score and put away */
7335 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = score;
7336
7337
7338 /* Finished calculating state INTRON_1 */
7339
7340
7341 /* For state INTRON_2 */
7342 /* setting first movement to score */
7343 score = GenePhase6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2);
7344 /* From state INSERT to state INTRON_2 */
7345 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
7346 if( temp > score ) {
7347 score = temp;
7348 }
7349 /* From state INTRON_2 to state INTRON_2 */
7350 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
7351 if( temp > score ) {
7352 score = temp;
7353 }
7354
7355
7356 /* Ok - finished max calculation for INTRON_2 */
7357 /* Add any movement independant score and put away */
7358 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = score;
7359
7360
7361 /* Finished calculating state INTRON_2 */
7362 }
7363
7364
7365 /* Special state LOOP has special to speical */
7366 /* Set score to current score (remember, state probably updated during main loop */
7367 score = GenePhase6_EXPL_SPECIAL(mat,0,j,LOOP);
7368
7369
7370 /* Source START is a special source for LOOP */
7371 /* Has restricted position */
7372 if( (j-1) == 0 ) {
7373 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0);
7374 if( temp > score )
7375 score = temp;
7376 }
7377
7378
7379 /* Source MATCH for state LOOP is not special... already calculated */
7380 /* Source INSERT for state LOOP is not special... already calculated */
7381 /* Source DELETE for state LOOP is not special... already calculated */
7382 /* Source LOOP is a special source for LOOP */
7383 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0);
7384 if( temp > score )
7385 score = temp;
7386
7387
7388 /* Put back score... (now updated!) */
7389 GenePhase6_EXPL_SPECIAL(mat,0,j,LOOP) = score;
7390 /* Finished updating state LOOP */
7391
7392
7393
7394
7395 /* Special state START has no special to special movements */
7396
7397
7398 /* Special state END has special to speical */
7399 /* Set score to current score (remember, state probably updated during main loop */
7400 score = GenePhase6_EXPL_SPECIAL(mat,0,j,END);
7401
7402
7403 /* Source LOOP is a special source for END */
7404 /* Has restricted position */
7405 if( j == mat->lenj-1 ) {
7406 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0);
7407 if( temp > score )
7408 score = temp;
7409 }
7410
7411
7412 /* Source AFTER_MATCH_CODING is a special source for END */
7413 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
7414 if( temp > score )
7415 score = temp;
7416
7417
7418 /* Put back score... (now updated!) */
7419 GenePhase6_EXPL_SPECIAL(mat,0,j,END) = score;
7420 /* Finished updating state END */
7421
7422
7423
7424
7425 /* Special state BEFORE_MATCH_CODING has special to speical */
7426 /* Set score to current score (remember, state probably updated during main loop */
7427 score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING);
7428
7429
7430 /* Source START is a special source for BEFORE_MATCH_CODING */
7431 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
7432 if( temp > score )
7433 score = temp;
7434
7435
7436 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */
7437 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
7438 if( temp > score )
7439 score = temp;
7440
7441
7442 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */
7443 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0);
7444 if( temp > score )
7445 score = temp;
7446
7447
7448 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */
7449 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0);
7450 if( temp > score )
7451 score = temp;
7452
7453
7454 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */
7455 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0);
7456 if( temp > score )
7457 score = temp;
7458
7459
7460 /* Put back score... (now updated!) */
7461 GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score;
7462 /* Finished updating state BEFORE_MATCH_CODING */
7463
7464
7465
7466
7467 /* Special state BEFORE_MATCH_INTRON_0 has special to speical */
7468 /* Set score to current score (remember, state probably updated during main loop */
7469 score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0);
7470
7471
7472 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */
7473 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0);
7474 if( temp > score )
7475 score = temp;
7476
7477
7478 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */
7479 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
7480 if( temp > score )
7481 score = temp;
7482
7483
7484 /* Put back score... (now updated!) */
7485 GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score;
7486 /* Finished updating state BEFORE_MATCH_INTRON_0 */
7487
7488
7489
7490
7491 /* Special state BEFORE_MATCH_INTRON_1 has special to speical */
7492 /* Set score to current score (remember, state probably updated during main loop */
7493 score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1);
7494
7495
7496 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */
7497 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
7498 if( temp > score )
7499 score = temp;
7500
7501
7502 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */
7503 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
7504 if( temp > score )
7505 score = temp;
7506
7507
7508 /* Put back score... (now updated!) */
7509 GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score;
7510 /* Finished updating state BEFORE_MATCH_INTRON_1 */
7511
7512
7513
7514
7515 /* Special state BEFORE_MATCH_INTRON_2 has special to speical */
7516 /* Set score to current score (remember, state probably updated during main loop */
7517 score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2);
7518
7519
7520 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */
7521 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
7522 if( temp > score )
7523 score = temp;
7524
7525
7526 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */
7527 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
7528 if( temp > score )
7529 score = temp;
7530
7531
7532 /* Put back score... (now updated!) */
7533 GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score;
7534 /* Finished updating state BEFORE_MATCH_INTRON_2 */
7535
7536
7537
7538
7539 /* Special state AFTER_MATCH_CODING has special to speical */
7540 /* Set score to current score (remember, state probably updated during main loop */
7541 score = GenePhase6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING);
7542
7543
7544 /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */
7545 /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */
7546 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
7547 if( temp > score )
7548 score = temp;
7549
7550
7551 /* Put back score... (now updated!) */
7552 GenePhase6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score;
7553 /* Finished updating state AFTER_MATCH_CODING */
7554
7555
7556 }
7557 stop_reporting();
7558 return TRUE;
7559 }
7560
7561
7562 /* Function: calculate_dpenv_GenePhase6(mat,dpenv)
7563 *
7564 * Descrip: This function calculates the GenePhase6 matrix when in explicit mode, subject to the envelope
7565 *
7566 *
7567 * Arg: mat [UNKN ] GenePhase6 which contains explicit basematrix memory [GenePhase6 *]
7568 * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *]
7569 *
7570 * Return [UNKN ] Undocumented return value [boolean]
7571 *
7572 */
calculate_dpenv_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv)7573 boolean calculate_dpenv_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv)
7574 {
7575 int i;
7576 int j;
7577 int k;
7578 int starti;
7579 int startj;
7580 int endi;
7581 int endj;
7582 int tot;
7583 int num;
7584 int should_calc;
7585
7586
7587 if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) {
7588 warn("in calculate_GenePhase6, passed a non Explicit matrix type, cannot calculate!");
7589 return FALSE;
7590 }
7591
7592
7593 prepare_DPEnvelope(dpenv);
7594 starti = dpenv->starti;
7595 if( starti < 0 )
7596 starti = 0;
7597 startj = dpenv->startj;
7598 if( startj < 0 )
7599 startj = 0;
7600 endi = dpenv->endi;
7601 if( endi > mat->leni )
7602 endi = mat->leni;
7603 endj = dpenv->endj;
7604 if( endj > mat->lenj )
7605 endj = mat->lenj;
7606 tot = (endi-starti) * (endj-startj);
7607 num = 0;
7608
7609
7610 for(j=startj-10;j<endj;j++) {
7611 for(i=1;i<mat->leni;i++) {
7612 GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI;
7613 GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI;
7614 GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI;
7615 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI;
7616 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI;
7617 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI;
7618 }
7619 }
7620 for(j=-10;j<mat->lenj;j++) {
7621 GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI;
7622 GenePhase6_EXPL_SPECIAL(mat,i,j,START) = 0;
7623 GenePhase6_EXPL_SPECIAL(mat,i,j,END) = NEGI;
7624 GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_CODING) = NEGI;
7625 GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_0) = NEGI;
7626 GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_1) = NEGI;
7627 GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_2) = NEGI;
7628 GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = NEGI;
7629 }
7630
7631
7632 start_reporting("GenePhase6 Matrix calculation: ");
7633 for(j=startj;j<endj;j++) {
7634 auto int score;
7635 auto int temp;
7636 for(i=starti;i<endi;i++) {
7637 /* Check if is in envelope - code identical to is_in_DPEnvelope, but aggressively inlined here for speed */
7638 should_calc = 0;
7639 for(k=0;k<dpenv->len;k++) {
7640 auto DPUnit * u;
7641 u = dpenv->dpu[k];
7642 switch(u->type) {
7643 case DPENV_RECT :
7644 if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length))
7645 should_calc = 1;
7646 break;
7647 case DPENV_DIAG :
7648 if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj)
7649 should_calc = 1;
7650 break;
7651 }
7652 if( should_calc == 1 )
7653 break;
7654 }
7655 if( should_calc == 0) {
7656 GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI;
7657 GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI;
7658 GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI;
7659 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI;
7660 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI;
7661 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI;
7662 continue;
7663 }
7664
7665
7666 if( num%1000 == 0 )
7667 log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot);
7668 num++;
7669
7670
7671 /* For state MATCH */
7672 /* setting first movement to score */
7673 score = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
7674 /* From state INSERT to state MATCH */
7675 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
7676 if( temp > score ) {
7677 score = temp;
7678 }
7679 /* From state DELETE to state MATCH */
7680 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
7681 if( temp > score ) {
7682 score = temp;
7683 }
7684 /* From state START to state MATCH */
7685 temp = GenePhase6_EXPL_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]);
7686 if( temp > score ) {
7687 score = temp;
7688 }
7689 /* From state BEFORE_MATCH_CODING to state MATCH */
7690 temp = GenePhase6_EXPL_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]);
7691 if( temp > score ) {
7692 score = temp;
7693 }
7694 /* From state INTRON_0 to state MATCH */
7695 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
7696 if( temp > score ) {
7697 score = temp;
7698 }
7699 /* From state INTRON_1 to state MATCH */
7700 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
7701 if( temp > score ) {
7702 score = temp;
7703 }
7704 /* From state INTRON_2 to state MATCH */
7705 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
7706 if( temp > score ) {
7707 score = temp;
7708 }
7709 /* From state MATCH to state MATCH */
7710 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE];
7711 if( temp > score ) {
7712 score = temp;
7713 }
7714 /* From state MATCH to state MATCH */
7715 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE];
7716 if( temp > score ) {
7717 score = temp;
7718 }
7719 /* From state MATCH to state MATCH */
7720 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE];
7721 if( temp > score ) {
7722 score = temp;
7723 }
7724 /* From state MATCH to state MATCH */
7725 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE];
7726 if( temp > score ) {
7727 score = temp;
7728 }
7729
7730
7731 /* Ok - finished max calculation for MATCH */
7732 /* Add any movement independant score and put away */
7733 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
7734 GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = score;
7735
7736
7737 /* state MATCH is a source for special LOOP */
7738 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
7739 if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) {
7740 GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp;
7741 }
7742
7743
7744
7745
7746 /* state MATCH is a source for special AFTER_MATCH_CODING */
7747 temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ;
7748 if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) {
7749 GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp;
7750 }
7751
7752
7753
7754
7755 /* Finished calculating state MATCH */
7756
7757
7758 /* For state INSERT */
7759 /* setting first movement to score */
7760 score = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
7761 /* From state INSERT to state INSERT */
7762 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
7763 if( temp > score ) {
7764 score = temp;
7765 }
7766 /* From state DELETE to state INSERT */
7767 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]);
7768 if( temp > score ) {
7769 score = temp;
7770 }
7771 /* From state LOOP to state INSERT */
7772 temp = GenePhase6_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]);
7773 if( temp > score ) {
7774 score = temp;
7775 }
7776 /* From state INTRON_0 to state INSERT */
7777 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)));
7778 if( temp > score ) {
7779 score = temp;
7780 }
7781 /* From state INTRON_1 to state INSERT */
7782 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2));
7783 if( temp > score ) {
7784 score = temp;
7785 }
7786 /* From state INTRON_2 to state INSERT */
7787 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1));
7788 if( temp > score ) {
7789 score = temp;
7790 }
7791 /* From state INSERT to state INSERT */
7792 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE];
7793 if( temp > score ) {
7794 score = temp;
7795 }
7796 /* From state INSERT to state INSERT */
7797 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE];
7798 if( temp > score ) {
7799 score = temp;
7800 }
7801
7802
7803 /* Ok - finished max calculation for INSERT */
7804 /* Add any movement independant score and put away */
7805 score += CSEQ_GENOMIC_CDSPOT(mat->target,j);
7806 GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = score;
7807
7808
7809 /* state INSERT is a source for special LOOP */
7810 temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ;
7811 if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) {
7812 GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp;
7813 }
7814
7815
7816
7817
7818 /* Finished calculating state INSERT */
7819
7820
7821 /* For state DELETE */
7822 /* setting first movement to score */
7823 score = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE];
7824 /* From state INSERT to state DELETE */
7825 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE];
7826 if( temp > score ) {
7827 score = temp;
7828 }
7829 /* From state DELETE to state DELETE */
7830 temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE];
7831 if( temp > score ) {
7832 score = temp;
7833 }
7834
7835
7836 /* Ok - finished max calculation for DELETE */
7837 /* Add any movement independant score and put away */
7838 GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = score;
7839
7840
7841 /* state DELETE is a source for special LOOP */
7842 temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ;
7843 if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) {
7844 GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp;
7845 }
7846
7847
7848
7849
7850 /* Finished calculating state DELETE */
7851
7852
7853 /* For state INTRON_0 */
7854 /* setting first movement to score */
7855 score = GenePhase6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0);
7856 /* From state INSERT to state INTRON_0 */
7857 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
7858 if( temp > score ) {
7859 score = temp;
7860 }
7861 /* From state INTRON_0 to state INTRON_0 */
7862 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
7863 if( temp > score ) {
7864 score = temp;
7865 }
7866
7867
7868 /* Ok - finished max calculation for INTRON_0 */
7869 /* Add any movement independant score and put away */
7870 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = score;
7871
7872
7873 /* Finished calculating state INTRON_0 */
7874
7875
7876 /* For state INTRON_1 */
7877 /* setting first movement to score */
7878 score = GenePhase6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1);
7879 /* From state INSERT to state INTRON_1 */
7880 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
7881 if( temp > score ) {
7882 score = temp;
7883 }
7884 /* From state INTRON_1 to state INTRON_1 */
7885 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
7886 if( temp > score ) {
7887 score = temp;
7888 }
7889
7890
7891 /* Ok - finished max calculation for INTRON_1 */
7892 /* Add any movement independant score and put away */
7893 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = score;
7894
7895
7896 /* Finished calculating state INTRON_1 */
7897
7898
7899 /* For state INTRON_2 */
7900 /* setting first movement to score */
7901 score = GenePhase6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2);
7902 /* From state INSERT to state INTRON_2 */
7903 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron);
7904 if( temp > score ) {
7905 score = temp;
7906 }
7907 /* From state INTRON_2 to state INTRON_2 */
7908 temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]);
7909 if( temp > score ) {
7910 score = temp;
7911 }
7912
7913
7914 /* Ok - finished max calculation for INTRON_2 */
7915 /* Add any movement independant score and put away */
7916 GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = score;
7917
7918
7919 /* Finished calculating state INTRON_2 */
7920 }
7921
7922
7923 /* Special state LOOP has special to speical */
7924 /* Set score to current score (remember, state probably updated during main loop */
7925 score = GenePhase6_EXPL_SPECIAL(mat,0,j,LOOP);
7926
7927
7928 /* Source START is a special source for LOOP */
7929 /* Has restricted position */
7930 if( (j-1) == 0 ) {
7931 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0);
7932 if( temp > score )
7933 score = temp;
7934 }
7935
7936
7937 /* Source MATCH for state LOOP is not special... already calculated */
7938 /* Source INSERT for state LOOP is not special... already calculated */
7939 /* Source DELETE for state LOOP is not special... already calculated */
7940 /* Source LOOP is a special source for LOOP */
7941 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0);
7942 if( temp > score )
7943 score = temp;
7944
7945
7946 /* Put back score... (now updated!) */
7947 GenePhase6_EXPL_SPECIAL(mat,0,j,LOOP) = score;
7948 /* Finished updating state LOOP */
7949
7950
7951
7952
7953 /* Special state START has no special to special movements */
7954
7955
7956 /* Special state END has special to speical */
7957 /* Set score to current score (remember, state probably updated during main loop */
7958 score = GenePhase6_EXPL_SPECIAL(mat,0,j,END);
7959
7960
7961 /* Source LOOP is a special source for END */
7962 /* Has restricted position */
7963 if( j == mat->lenj-1 ) {
7964 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0);
7965 if( temp > score )
7966 score = temp;
7967 }
7968
7969
7970 /* Source AFTER_MATCH_CODING is a special source for END */
7971 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
7972 if( temp > score )
7973 score = temp;
7974
7975
7976 /* Put back score... (now updated!) */
7977 GenePhase6_EXPL_SPECIAL(mat,0,j,END) = score;
7978 /* Finished updating state END */
7979
7980
7981
7982
7983 /* Special state BEFORE_MATCH_CODING has special to speical */
7984 /* Set score to current score (remember, state probably updated during main loop */
7985 score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING);
7986
7987
7988 /* Source START is a special source for BEFORE_MATCH_CODING */
7989 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
7990 if( temp > score )
7991 score = temp;
7992
7993
7994 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */
7995 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
7996 if( temp > score )
7997 score = temp;
7998
7999
8000 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */
8001 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0);
8002 if( temp > score )
8003 score = temp;
8004
8005
8006 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */
8007 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0);
8008 if( temp > score )
8009 score = temp;
8010
8011
8012 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */
8013 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0);
8014 if( temp > score )
8015 score = temp;
8016
8017
8018 /* Put back score... (now updated!) */
8019 GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score;
8020 /* Finished updating state BEFORE_MATCH_CODING */
8021
8022
8023
8024
8025 /* Special state BEFORE_MATCH_INTRON_0 has special to speical */
8026 /* Set score to current score (remember, state probably updated during main loop */
8027 score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0);
8028
8029
8030 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */
8031 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0);
8032 if( temp > score )
8033 score = temp;
8034
8035
8036 /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */
8037 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
8038 if( temp > score )
8039 score = temp;
8040
8041
8042 /* Put back score... (now updated!) */
8043 GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score;
8044 /* Finished updating state BEFORE_MATCH_INTRON_0 */
8045
8046
8047
8048
8049 /* Special state BEFORE_MATCH_INTRON_1 has special to speical */
8050 /* Set score to current score (remember, state probably updated during main loop */
8051 score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1);
8052
8053
8054 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */
8055 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
8056 if( temp > score )
8057 score = temp;
8058
8059
8060 /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */
8061 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
8062 if( temp > score )
8063 score = temp;
8064
8065
8066 /* Put back score... (now updated!) */
8067 GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score;
8068 /* Finished updating state BEFORE_MATCH_INTRON_1 */
8069
8070
8071
8072
8073 /* Special state BEFORE_MATCH_INTRON_2 has special to speical */
8074 /* Set score to current score (remember, state probably updated during main loop */
8075 score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2);
8076
8077
8078 /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */
8079 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0);
8080 if( temp > score )
8081 score = temp;
8082
8083
8084 /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */
8085 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0);
8086 if( temp > score )
8087 score = temp;
8088
8089
8090 /* Put back score... (now updated!) */
8091 GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score;
8092 /* Finished updating state BEFORE_MATCH_INTRON_2 */
8093
8094
8095
8096
8097 /* Special state AFTER_MATCH_CODING has special to speical */
8098 /* Set score to current score (remember, state probably updated during main loop */
8099 score = GenePhase6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING);
8100
8101
8102 /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */
8103 /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */
8104 temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0);
8105 if( temp > score )
8106 score = temp;
8107
8108
8109 /* Put back score... (now updated!) */
8110 GenePhase6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score;
8111 /* Finished updating state AFTER_MATCH_CODING */
8112
8113
8114 }
8115 stop_reporting();
8116 return TRUE;
8117 }
8118
8119
8120 /* Function: GenePhase6_alloc(void)
8121 *
8122 * Descrip: Allocates structure: assigns defaults if given
8123 *
8124 *
8125 *
8126 * Return [UNKN ] Undocumented return value [GenePhase6 *]
8127 *
8128 */
GenePhase6_alloc(void)8129 GenePhase6 * GenePhase6_alloc(void)
8130 {
8131 GenePhase6 * out; /* out is exported at end of function */
8132
8133
8134 /* call ckalloc and see if NULL */
8135 if((out=(GenePhase6 *) ckalloc (sizeof(GenePhase6))) == NULL) {
8136 warn("GenePhase6_alloc failed ");
8137 return NULL; /* calling function should respond! */
8138 }
8139 out->dynamite_hard_link = 1;
8140 #ifdef PTHREAD
8141 pthread_mutex_init(&(out->dynamite_mutex),NULL);
8142 #endif
8143 out->basematrix = NULL;
8144 out->shatter = NULL;
8145 out->leni = 0;
8146 out->lenj = 0;
8147
8148
8149 return out;
8150 }
8151
8152
8153 /* Function: free_GenePhase6(obj)
8154 *
8155 * Descrip: Free Function: removes the memory held by obj
8156 * Will chain up to owned members and clear all lists
8157 *
8158 *
8159 * Arg: obj [UNKN ] Object that is free'd [GenePhase6 *]
8160 *
8161 * Return [UNKN ] Undocumented return value [GenePhase6 *]
8162 *
8163 */
free_GenePhase6(GenePhase6 * obj)8164 GenePhase6 * free_GenePhase6(GenePhase6 * obj)
8165 {
8166 int return_early = 0;
8167
8168
8169 if( obj == NULL) {
8170 warn("Attempting to free a NULL pointer to a GenePhase6 obj. Should be trappable");
8171 return NULL;
8172 }
8173
8174
8175 #ifdef PTHREAD
8176 assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0);
8177 #endif
8178 if( obj->dynamite_hard_link > 1) {
8179 return_early = 1;
8180 obj->dynamite_hard_link--;
8181 }
8182 #ifdef PTHREAD
8183 assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);
8184 #endif
8185 if( return_early == 1)
8186 return NULL;
8187 if( obj->basematrix != NULL)
8188 free_BaseMatrix(obj->basematrix);
8189 if( obj->shatter != NULL)
8190 free_ShatterMatrix(obj->shatter);
8191 /* obj->query is linked in */
8192 /* obj->target is linked in */
8193 /* obj->gp is linked in */
8194 /* obj->general_model is linked in */
8195
8196
8197 ckfree(obj);
8198 return NULL;
8199 }
8200
8201
8202
8203
8204
8205 #ifdef _cplusplus
8206 }
8207 #endif
8208