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