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