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