1 static char rcsid[] = "$Id: terminal.c 223081 2020-09-13 14:21:03Z twu $";
2 #ifdef HAVE_CONFIG_H
3 #include <config.h>
4 #endif
5 #ifndef HAVE_MEMCPY
6 #define memcpy(d,s,n) bcopy((s),(d),(n))
7 #endif
8 #ifndef HAVE_MEMMOVE
9 #define memmove(d,s,n) bcopy((s),(d),(n))
10 #endif
11 
12 #include "terminal.h"
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include "mem.h"
17 #include "assert.h"
18 #include "types.h"
19 
20 #include "genomicpos.h"
21 #include "substring.h"
22 
23 #include "genome128_hr.h"
24 #include "extension-search.h"	/* For handling Elt_T objects */
25 
26 
27 #define MAXTERMINALS 1000
28 
29 static Univ_IIT_T chromosome_iit;
30 static Univcoord_T genomelength;
31 static int circular_typeint;
32 
33 static Genome_T genomebits;
34 static Genome_T genomebits_alt;
35 
36 static bool splicingp;
37 
38 static int index1part = 15;
39 static int index1interval = 3;
40 
41 static int subopt_levels;
42 
43 
44 #ifdef DEBUG
45 #define debug(x) x
46 #else
47 #define debug(x)
48 #endif
49 
50 #ifdef DEBUG4E
51 #define debug4e(x) x
52 #else
53 #define debug4e(x)
54 #endif
55 
56 
57 /* Modified from find_spliceends_rna */
58 static void
find_terminals(List_T * sense_terminals,List_T * antisense_terminals,List_T elt_set,char * queryptr,int querylength,int query_lastpos,int * mismatch_positions_alloc,Compress_T query_compress,Listpool_T listpool,bool plusp,int genestrand)59 find_terminals (List_T *sense_terminals, List_T *antisense_terminals, List_T elt_set,
60 #ifdef DEBUG4E
61 		char *queryptr,
62 #endif
63 		int querylength, int query_lastpos, int *mismatch_positions_alloc,
64 		Compress_T query_compress, Listpool_T listpool,
65 		bool plusp, int genestrand) {
66 #ifdef DEBUG4E
67   char *gbuffer;
68 #endif
69 
70   Elt_T elt;
71   List_T p;
72   int k;
73 
74   Substring_T substring;
75   Univcoord_T segment_univdiagonal, segment_left;
76   int first_querypos, last_querypos, querystart, queryend, pos5_trimmed, pos3_trimmed, pos5, pos3;
77   int nmismatches_ignore;
78 
79   /* int nmismatches_left, nmismatches_right; */
80   int *mismatch_positions;
81   int *positions_alloc;
82 
83   Chrnum_T chrnum;
84   Univcoord_T chroffset, chrhigh;
85   Chrpos_T chrlength;
86 
87 
88 #ifdef HAVE_ALLOCA
89   if (querylength <= MAX_STACK_READLENGTH) {
90     mismatch_positions = (int *) ALLOCA((querylength+1)*sizeof(int));
91     positions_alloc = (int *) ALLOCA((querylength+1)*sizeof(int));
92   } else {
93     mismatch_positions = (int *) MALLOC((querylength+1)*sizeof(int));
94     positions_alloc = (int *) MALLOC((querylength+1)*sizeof(int));
95   }
96 #else
97   mismatch_positions = (int *) MALLOC((querylength+1)*sizeof(int));
98   positions_alloc = (int *) MALLOC((querylength+1)*sizeof(int));
99 #endif
100 
101   debug4e(printf("Entering find_spliceends_rna (plusp %d) with %d elts\n",plusp,List_length(elt_set)));
102 
103   for (p = elt_set; p != NULL; p = List_next(p)) {
104     elt = (Elt_T) List_head(p);
105 #if 0
106     /* Not sure if this is still necessary */
107     if ((first_querypos = segment->querystart - (index1interval - 1)) < 0) {
108       first_querypos = 0;
109     }
110     if ((last_querypos = segment->queryend + (index1interval - 1)) > querylength) {
111       last_querypos = querylength;
112     }
113 #else
114     first_querypos = elt->qstart;
115     last_querypos = elt->qend;
116 #endif
117 
118     if (last_querypos < query_lastpos /*&& (first_querypos < index1part || segment->spliceable_low_p == true)*/) {
119       /* Find splices on genomic right */
120       for (k = 0; k < elt->n_all_univdiagonals; k++) {
121 	segment_univdiagonal = elt->all_univdiagonals[k];
122 	segment_left = segment_univdiagonal - (Univcoord_T) querylength;
123 	pos5 = (segment_univdiagonal >= (Univcoord_T) querylength) ? 0 : (int) -segment_left;
124 	pos3 = (segment_univdiagonal <= genomelength) ? querylength : (int) (genomelength - segment_left);
125 
126 	/* Could use Univ_IIT_update_chrnum here */
127 	chrnum = Univ_IIT_get_chrnum(&chroffset,&chrhigh,&chrlength,chromosome_iit,
128 				     /*low*/segment_left+pos5,/*high*/segment_left+pos3,
129 				     circular_typeint);
130 
131 	debug4e(printf("find_terminals: Checking mismatches at univdiagonal %llu (querypos %d..%d), plusp %d\n",
132 		       (unsigned long long) segment_univdiagonal,first_querypos,last_querypos,plusp));
133 	debug4e(
134 		gbuffer = (char *) CALLOC(querylength+1,sizeof(char));
135 		Genome_fill_buffer_blocks(/*left*/segment_univdiagonal - querylength,querylength,gbuffer);
136 		printf("genome 0..: %s\n",gbuffer);
137 		printf("query  0..: %s\n",queryptr);
138 		);
139 
140 	/* TODO: Consider trimming separately for SENSE_FORWARD and SENSE_ANTI */
141 	pos5_trimmed = Substring_trim_qstart_nosplice(&nmismatches_ignore,mismatch_positions_alloc,
142 						      query_compress,segment_left,chroffset,
143 						      pos5,pos3,querylength,plusp,genestrand);
144 	pos3_trimmed = Substring_trim_qend_nosplice(&nmismatches_ignore,mismatch_positions_alloc,
145 						    query_compress,segment_left,chrhigh,
146 						    pos5,pos3,querylength,plusp,genestrand);
147 	if (plusp == true) {
148 	  querystart = pos5_trimmed;
149 	  queryend = pos3_trimmed;
150 	} else {
151 	  querystart = querylength - pos3_trimmed;
152 	  queryend = querylength - pos5_trimmed;
153 	}
154 
155 	if ((substring = Substring_new(/*nmismatches*/-1,/*ref_nmismatches*/-1,segment_left,
156 				       querystart,queryend,querylength,
157 				       plusp,genestrand,query_compress,chrnum,chroffset,chrhigh,chrlength,
158 				       /*splice5p*/false,/*splicetype5*/NO_SPLICE,/*ambig_prob_5*/0.0,
159 				       /*splice3p*/false,/*splicetype3*/NO_SPLICE,/*ambig_prob_3*/0.0,
160 				       /*orig_sensedir*/SENSE_FORWARD)) != NULL) {
161 	  debug4e(printf("=> %s terminal: (%d mismatches) %d..%d\n",
162 			 plusp == true ? "plus" : "minus",Substring_nmismatches_bothdiff(substring),
163 			 Substring_querystart(substring),Substring_queryend(substring)));
164 	  debug4e(printf("q: %s\ng: %s\n",queryptr,gbuffer));
165 	  *sense_terminals = Listpool_push(*sense_terminals,listpool,(void *) substring);
166 	}
167 
168 	if (splicingp == true) {
169 	  if ((substring = Substring_new(/*nmismatches*/-1,/*ref_nmismatches*/-1,segment_left,
170 					 querystart,queryend,querylength,
171 					 plusp,genestrand,query_compress,chrnum,chroffset,chrhigh,chrlength,
172 					 /*splice5p*/false,/*splicetype5*/NO_SPLICE,/*ambig_prob_5*/0.0,
173 					 /*splice3p*/false,/*splicetype3*/NO_SPLICE,/*ambig_prob_3*/0.0,
174 					 /*orig_sensedir*/SENSE_ANTI)) != NULL) {
175 	    debug4e(printf("=> %s terminal: (%d mismatches) %d..%d\n",
176 			   plusp == true ? "plus" : "minus",Substring_nmismatches_bothdiff(substring),
177 			   Substring_querystart(substring),Substring_queryend(substring)));
178 	    debug4e(printf("q: %s\ng: %s\n",queryptr,gbuffer));
179 	    *antisense_terminals = Listpool_push(*antisense_terminals,listpool,(void *) substring);
180 	  }
181 	}
182 
183 	debug4e(FREE(gbuffer));
184       }
185     }
186 
187     if (first_querypos > index1part /*&& (last_querypos > query_lastpos || segment->spliceable_high_p == true)*/) {
188       /* Find splices on genomic left */
189       for (k = 0; k < elt->n_all_univdiagonals; k++) {
190 	segment_univdiagonal = elt->all_univdiagonals[k];
191 	segment_left = segment_univdiagonal - (Univcoord_T) querylength;
192 	pos5 = (segment_univdiagonal >= (Univcoord_T) querylength) ? 0 : (int) -segment_left;
193 	pos3 = (segment_univdiagonal <= genomelength) ? querylength : (int) (genomelength - segment_left);
194 
195 	/* Could use Univ_IIT_update_chrnum here */
196 	chrnum = Univ_IIT_get_chrnum(&chroffset,&chrhigh,&chrlength,chromosome_iit,
197 				     /*low*/segment_left+pos5,/*high*/segment_left+pos3,
198 				     circular_typeint);
199 
200 	debug4e(printf("find_terminals: Checking mismatches at univdiagonal %llu (querypos %d..%d), plusp %d\n",
201 		       (unsigned long long) segment_univdiagonal,first_querypos,last_querypos,plusp));
202 	debug4e(
203 		gbuffer = (char *) CALLOC(querylength+1,sizeof(char));
204 		Genome_fill_buffer_blocks(/*left*/segment_univdiagonal - querylength,querylength,gbuffer);
205 		printf("genome 0..: %s\n",gbuffer);
206 		printf("query  0..: %s\n",queryptr);
207 		);
208 
209 	/* TODO: Consider trimming separately for SENSE_FORWARD and SENSE_ANTI */
210 	pos5_trimmed = Substring_trim_qstart_nosplice(&nmismatches_ignore,mismatch_positions_alloc,
211 						      query_compress,segment_left,chroffset,
212 						      pos5,pos3,querylength,plusp,genestrand);
213 	pos3_trimmed = Substring_trim_qend_nosplice(&nmismatches_ignore,mismatch_positions_alloc,
214 						    query_compress,segment_left,chrhigh,
215 						    pos5,pos3,querylength,plusp,genestrand);
216 	if (plusp == true) {
217 	  querystart = pos5_trimmed;
218 	  queryend = pos3_trimmed;
219 	} else {
220 	  querystart = querylength - pos3_trimmed;
221 	  queryend = querylength - pos5_trimmed;
222 	}
223 
224 	if ((substring = Substring_new(/*nmismatches*/-1,/*ref_nmismatches*/-1,segment_left,
225 				       querystart,queryend,querylength,
226 				       plusp,genestrand,query_compress,chrnum,chroffset,chrhigh,chrlength,
227 				       /*splice5p*/false,/*splicetype5*/NO_SPLICE,/*ambig_prob_5*/0.0,
228 				       /*splice3p*/false,/*splicetype3*/NO_SPLICE,/*ambig_prob_3*/0.0,
229 				       /*orig_sensedir*/SENSE_FORWARD)) != NULL) {
230 	  debug4e(printf("=> %s terminal: (%d mismatches) %d..%d\n",
231 			 plusp == true ? "plus" : "minus",Substring_nmismatches_bothdiff(substring),
232 			 Substring_querystart(substring),Substring_queryend(substring)));
233 	  debug4e(printf("q: %s\ng: %s\n",queryptr,gbuffer));
234 	  *sense_terminals = Listpool_push(*sense_terminals,listpool,(void *) substring);
235 	}
236 
237 	if (splicingp == true) {
238 	  if ((substring = Substring_new(/*nmismatches*/-1,/*ref_nmismatches*/-1,segment_left,
239 					 querystart,queryend,querylength,
240 					 plusp,genestrand,query_compress,chrnum,chroffset,chrhigh,chrlength,
241 					 /*splice5p*/false,/*splicetype5*/NO_SPLICE,/*ambig_prob_5*/0.0,
242 					 /*splice3p*/false,/*splicetype3*/NO_SPLICE,/*ambig_prob_3*/0.0,
243 					 /*orig_sensedir*/SENSE_ANTI)) != NULL) {
244 	    debug4e(printf("=> %s terminal: (%d mismatches) %d..%d\n",
245 			   plusp == true ? "plus" : "minus",Substring_nmismatches_bothdiff(substring),
246 			   Substring_querystart(substring),Substring_queryend(substring)));
247 	    debug4e(printf("q: %s\ng: %s\n",queryptr,gbuffer));
248 	    *antisense_terminals = Listpool_push(*antisense_terminals,listpool,(void *) substring);
249 	  }
250 	}
251 
252 	debug4e(FREE(gbuffer));
253       }
254     }
255   }
256 
257 
258 #ifdef HAVE_ALLOCA
259   if (querylength <= MAX_STACK_READLENGTH) {
260     FREEA(mismatch_positions);
261     FREEA(positions_alloc);
262   } else {
263     FREE(mismatch_positions);
264     FREE(positions_alloc);
265   }
266 #else
267   FREE(mismatch_positions);
268   FREE(positions_alloc);
269 #endif
270 
271   return;
272 }
273 
274 
275 /* done_level should probably be renamed final_level.  opt_level
276    should probably be renamed found_level or opt_level. */
277 void
Terminal_solve_plus(int * found_score_overall,int * found_score_within_trims,List_T * sense_hits_plus,List_T * antisense_hits_plus,List_T queryfwd_plus_set,List_T queryrev_plus_set,int * mismatch_positions_alloc,Compress_T query_compress_fwd,int querylength,int genestrand,Listpool_T listpool,Hitlistpool_T hitlistpool,int level)278 Terminal_solve_plus (int *found_score_overall, int *found_score_within_trims,
279 		     List_T *sense_hits_plus, List_T *antisense_hits_plus,
280 		     List_T queryfwd_plus_set, List_T queryrev_plus_set,
281 
282 		     int *mismatch_positions_alloc,
283 		     Compress_T query_compress_fwd, int querylength,
284 		     int genestrand, Listpool_T listpool,
285 		     Hitlistpool_T hitlistpool, int level) {
286   List_T sense_terminals_plus = NULL, antisense_terminals_plus = NULL, p;
287   Stage3end_T hit;
288   int nterminals;
289   int query_lastpos = querylength - index1part;
290   Substring_T substring;
291 #ifdef DEBUG13
292   int missing_hit, missing_gmap;
293 #endif
294 
295 
296   /* 9 (Term).  Find terminals */
297   debug(printf("*** Stage 9 (Term).  Terminal_solve, allowing %d mismatches ***\n",max_terminal_mismatches));
298   *sense_hits_plus = *antisense_hits_plus = (List_T) NULL;
299 
300   debug(printf("Starting find_terminals (plus)\n"));
301   find_terminals(&sense_terminals_plus,&antisense_terminals_plus,queryfwd_plus_set,
302 #ifdef DEBUG4E
303 		 /*queryptr*/queryuc_ptr,
304 #endif
305 		 querylength,query_lastpos,mismatch_positions_alloc,
306 		 /*query_compress*/query_compress_fwd,
307 		 listpool,/*plusp*/true,genestrand);
308 
309   find_terminals(&sense_terminals_plus,&antisense_terminals_plus,queryrev_plus_set,
310 #ifdef DEBUG4E
311 		 /*queryptr*/queryuc_ptr,
312 #endif
313 		 querylength,query_lastpos,mismatch_positions_alloc,
314 		 /*query_compress*/query_compress_fwd,
315 		 listpool,/*plusp*/true,genestrand);
316   debug(printf("Finished find_terminals (plus)\n"));
317 
318   debug4e(printf("Terminals: sense plus %d, antisense plus %d\n",
319 		 List_length(*sense_hits_plus),List_length(*antisense_hits_plus)));
320 
321 #if 0
322   opt_level = ((*found_score_within_trims) < opt_level) ? (*found_score_within_trims) : opt_level;
323 #endif
324   /* done_level = (*found_score) + subopt_levels; */
325 
326 #if 0
327   debug4e(printf("Sorting terminals\n"));
328   /* TODO: Prioritize inner terminals */
329   terminals_left = Substring_sort_nmatches(terminals_left);
330   terminals_right = Substring_sort_nmatches(terminals_right);
331 #endif
332 
333   debug(printf("*** Stage 9 (Term)\n"));
334 
335   nterminals = 0;
336   for (p = sense_terminals_plus; p != NULL && nterminals < MAXTERMINALS; p = List_next(p)) {
337     substring = (Substring_T) p->first;
338     if ((hit = Stage3end_new_terminal(&(*found_score_overall),&(*found_score_within_trims),
339 				      substring,querylength,/*gplusp*/true,genestrand,/*sensedir*/SENSE_FORWARD,
340 				      listpool,/*method*/TERMINAL,level)) != NULL) {
341       *sense_hits_plus = Hitlist_push(*sense_hits_plus,hitlistpool,(void *) hit);
342       nterminals++;
343     }
344   }
345   *sense_hits_plus = Stage3end_remove_overlaps(*sense_hits_plus,hitlistpool,querylength,/*finalp*/false);
346 
347   if (splicingp == true) {
348     nterminals = 0;
349     for (p = antisense_terminals_plus; p != NULL && nterminals < MAXTERMINALS; p = List_next(p)) {
350       substring = (Substring_T) p->first;
351       if ((hit = Stage3end_new_terminal(&(*found_score_overall),&(*found_score_within_trims),
352 					substring,querylength,/*gplusp*/true,genestrand,/*sensedir*/SENSE_ANTI,
353 					listpool,/*method*/TERMINAL,level)) != NULL) {
354 	*antisense_hits_plus = Hitlist_push(*antisense_hits_plus,hitlistpool,(void *) hit);
355 	nterminals++;
356       }
357     }
358     *antisense_hits_plus = Stage3end_remove_overlaps(*antisense_hits_plus,hitlistpool,querylength,/*finalp*/false);
359   }
360 
361   /* Excess distant splicing should be freed already in find_splicepairs_rna */
362 
363 #if 0
364   /* Do not filter terminals by optimal score, since criterion is concordance, not length */
365   debug(printf("Entering Stage3end_optimal_score with %d hits\n",List_length(terminals)));
366   terminals = Stage3end_optimal_score(terminals,query_compress_fwd,query_compress_rev,querylength,
367 				      /*keep_gmap_p*/true,/*finalp*/false);
368   debug(printf("Exiting Stage3end_optimal_score with %d hits\n",List_length(terminals)));
369 #endif
370 
371 #if 0
372   if (terminals) {
373 #if 0
374     opt_level = ((*found_score_within_trims) < opt_level) ? (*found_score) : opt_level;
375     if ((done_level = opt_level + subopt_levels) > user_maxlevel) {
376       done_level = user_maxlevel;
377     }
378 #endif
379     /* done_level = (*found_score) + subopt_levels; */
380     debug(printf("9 (Term)> found_score = %d, opt_level %d, done_level %d\n",
381 		 *found_score_within_trims,opt_level,done_level));
382   }
383 #endif
384 
385   Substring_list_gc(&sense_terminals_plus);
386   Substring_list_gc(&antisense_terminals_plus);
387 
388   return;
389 }
390 
391 
392 void
Terminal_solve_minus(int * found_score_overall,int * found_score_within_trims,List_T * sense_hits_minus,List_T * antisense_hits_minus,List_T queryfwd_minus_set,List_T queryrev_minus_set,int * mismatch_positions_alloc,Compress_T query_compress_rev,int querylength,int genestrand,Listpool_T listpool,Hitlistpool_T hitlistpool,int level)393 Terminal_solve_minus (int *found_score_overall, int *found_score_within_trims,
394 		      List_T *sense_hits_minus, List_T *antisense_hits_minus,
395 		      List_T queryfwd_minus_set, List_T queryrev_minus_set,
396 
397 		      int *mismatch_positions_alloc,
398 		      Compress_T query_compress_rev, int querylength,
399 		      int genestrand, Listpool_T listpool,
400 		      Hitlistpool_T hitlistpool, int level) {
401   List_T sense_terminals_minus = NULL, antisense_terminals_minus = NULL, p;
402   Stage3end_T hit;
403   int query_lastpos = querylength - index1part;
404   int nterminals;
405   Substring_T substring;
406 #ifdef DEBUG13
407   int missing_hit, missing_gmap;
408 #endif
409 
410 
411   /* 9 (Term).  Find terminals */
412   debug(printf("*** Stage 9 (Term).  Terminal_solve, allowing %d mismatches ***\n",max_terminal_mismatches));
413   *sense_hits_minus = *antisense_hits_minus = (List_T) NULL;
414 
415   debug(printf("Starting find_terminals (minus)\n"));
416   find_terminals(&sense_terminals_minus,&antisense_terminals_minus,queryfwd_minus_set,
417 #ifdef DEBUG4E
418 		 /*queryptr*/queryrc,
419 #endif
420 		 querylength,query_lastpos,mismatch_positions_alloc,
421 		 /*query_compress*/query_compress_rev,
422 		 listpool,/*plusp*/false,genestrand);
423 
424   find_terminals(&sense_terminals_minus,&antisense_terminals_minus,queryrev_minus_set,
425 #ifdef DEBUG4E
426 		 /*queryptr*/queryrc,
427 #endif
428 		 querylength,query_lastpos,mismatch_positions_alloc,
429 		 /*query_compress*/query_compress_rev,
430 		 listpool,/*plusp*/false,genestrand);
431   debug(printf("Finished find_terminals (minus)\n"));
432 
433   debug4e(printf("Terminals: sense minus %d and antisense minus %d\n",
434 		 List_length(*sense_hits_minus),List_length(*antisense_hits_minus)));
435 
436 #if 0
437   opt_level = ((*found_score_within_trims) < opt_level) ? (*found_score_within_trims) : opt_level;
438 #endif
439   /* done_level = (*found_score_within_trims) + subopt_levels; */
440 
441 #if 0
442   debug4e(printf("Sorting terminals\n"));
443   /* TODO: Prioritize inner terminals */
444   terminals_left = Substring_sort_nmatches(terminals_left);
445   terminals_right = Substring_sort_nmatches(terminals_right);
446 #endif
447 
448   debug(printf("*** Stage 9 (Term)\n"));
449 
450   nterminals = 0;
451   for (p = sense_terminals_minus; p != NULL && nterminals < MAXTERMINALS; p = List_next(p)) {
452     substring = (Substring_T) p->first;
453     if ((hit = Stage3end_new_terminal(&(*found_score_overall),&(*found_score_within_trims),
454 				      substring,querylength,/*gplusp*/false,genestrand,/*sensedir*/SENSE_FORWARD,
455 				      listpool,/*method*/TERMINAL,level)) != NULL) {
456       *sense_hits_minus = Hitlist_push(*sense_hits_minus,hitlistpool,(void *) hit);
457       nterminals++;
458     }
459   }
460   *sense_hits_minus = Stage3end_remove_overlaps(*sense_hits_minus,hitlistpool,querylength,/*finalp*/false);
461 
462   if (splicingp == true) {
463     nterminals = 0;
464     for (p = antisense_terminals_minus; p != NULL && nterminals < MAXTERMINALS; p = List_next(p)) {
465       substring = (Substring_T) p->first;
466       if ((hit = Stage3end_new_terminal(&(*found_score_overall),&(*found_score_within_trims),
467 					substring,querylength,/*gplusp*/false,genestrand,/*sensedir*/SENSE_ANTI,
468 					listpool,/*method*/TERMINAL,level)) != NULL) {
469 	*antisense_hits_minus = Hitlist_push(*antisense_hits_minus,hitlistpool,(void *) hit);
470 	nterminals++;
471       }
472     }
473     *antisense_hits_minus = Stage3end_remove_overlaps(*antisense_hits_minus,hitlistpool,querylength,/*finalp*/false);
474   }
475 
476   /* Excess distant splicing should be freed already in find_splicepairs_rna */
477 
478 #if 0
479   /* Do not filter terminals by optimal score, since criterion is concordance, not length */
480   debug(printf("Entering Stage3end_optimal_score with %d hits\n",List_length(terminals)));
481   terminals = Stage3end_optimal_score(terminals,hitlistpool,querylength,/*finalp*/false);
482   debug(printf("Exiting Stage3end_optimal_score with %d hits\n",List_length(terminals)));
483 #endif
484 
485 #if 0
486   if (terminals) {
487 #if 0
488     opt_level = ((*found_score_within_trims) < opt_level) ? (*found_score_within_trims) : opt_level;
489     if ((done_level = opt_level + subopt_levels) > user_maxlevel) {
490       done_level = user_maxlevel;
491     }
492 #endif
493     /* done_level = (*found_score_within_trims) + subopt_levels; */
494     debug(printf("9 (Term)> found_score = %d, opt_level %d, done_level %d\n",
495 		 *found_score_within_trims,opt_level,done_level));
496   }
497 #endif
498 
499   Substring_list_gc(&sense_terminals_minus);
500   Substring_list_gc(&antisense_terminals_minus);
501 
502   return;
503 }
504 
505 
506 void
Terminal_setup(Univ_IIT_T chromosome_iit_in,Univcoord_T genomelength_in,int circular_typeint_in,Genome_T genomebits_in,Genome_T genomebits_alt_in,bool splicingp_in,int index1part_in,int index1interval_in,int subopt_levels_in)507 Terminal_setup (Univ_IIT_T chromosome_iit_in, Univcoord_T genomelength_in, int circular_typeint_in,
508 		Genome_T genomebits_in, Genome_T genomebits_alt_in,
509 		bool splicingp_in, int index1part_in, int index1interval_in,
510 		int subopt_levels_in) {
511 
512   chromosome_iit = chromosome_iit_in;
513   genomelength = genomelength_in;
514   circular_typeint = circular_typeint_in;
515 
516   genomebits = genomebits_in;
517   genomebits_alt = genomebits_alt_in;
518 
519   splicingp = splicingp_in;
520 
521   index1part = index1part_in;
522   index1interval = index1interval_in;
523 
524   subopt_levels = subopt_levels_in;
525 
526   return;
527 }
528 
529 
530