1 #ifdef _cplusplus
2 extern "C" {
3 #endif
4 #include "genedisplay.h"
5 
6 /** #define DEBUG **/
7 
8 
9 /* Function:  protein2genomic_ascii_display(alb,p,gen,ct,name,main,ofp)
10  *
11  * Descrip:    shows the alignment in alb between protsequence and protname
12  *             with genomic into ofp with pretty formatting
13  *
14  *
15  * Arg:         alb [UNKN ] logical alignment [AlnBlock *]
16  * Arg:           p [UNKN ] protein sequence [Protein *]
17  * Arg:         gen [UNKN ] genomic dna to do the comparison [Genomic *]
18  * Arg:          ct [UNKN ] codon table for translation [CodonTable *]
19  * Arg:        name [UNKN ] length of name block [int]
20  * Arg:        main [UNKN ] length of main block [int]
21  * Arg:         ofp [UNKN ] output file [FILE *]
22  *
23  * Return [UNKN ]  Undocumented return value [boolean]
24  *
25  */
26 # line 34 "genedisplay.dy"
protein2genomic_ascii_display(AlnBlock * alb,Protein * p,Genomic * gen,CodonTable * ct,int name,int main,FILE * ofp)27 boolean protein2genomic_ascii_display(AlnBlock * alb,Protein * p,Genomic * gen,CodonTable * ct,int name,int main,FILE * ofp)
28 {
29   return protgene_ascii_display(alb,p->baseseq->seq,p->baseseq->name,p->baseseq->offset,gen,ct,name,main,FALSE,ofp);
30 }
31 
32 /* Function:  protgene_ascii_display(alb,protsequence,protname,protoff,gen,ct,name,main,mult,ofp)
33  *
34  * Descrip:    shows the alignment in alb between protsequence and protname
35  *             with genomic into ofp with pretty formatting
36  *
37  *
38  * Arg:                 alb [UNKN ] logical alignment [AlnBlock *]
39  * Arg:        protsequence [UNKN ] protein sequence - either real or an artifical consensus [char *]
40  * Arg:            protname [UNKN ] name of the protein [char *]
41  * Arg:             protoff [UNKN ] offset of the alb from the protein [int]
42  * Arg:                 gen [UNKN ] genomic dna to do the comparison [Genomic *]
43  * Arg:                  ct [UNKN ] codon table for translation [CodonTable *]
44  * Arg:                name [UNKN ] length of name block [int]
45  * Arg:                main [UNKN ] length of main block [int]
46  * Arg:                mult [UNKN ] is multi-match [boolean]
47  * Arg:                 ofp [UNKN ] output file [FILE *]
48  *
49  * Return [UNKN ]  Undocumented return value [boolean]
50  *
51  */
52 # line 54 "genedisplay.dy"
protgene_ascii_display(AlnBlock * alb,char * protsequence,char * protname,int protoff,Genomic * gen,CodonTable * ct,int name,int main,boolean mult,FILE * ofp)53 boolean protgene_ascii_display(AlnBlock * alb,char * protsequence,char * protname,int protoff,Genomic * gen,CodonTable * ct,int name,int main,boolean mult,FILE * ofp)
54 {
55   boolean ret;
56   btCanvas * btc;
57 
58   btc = new_Ascii_btCanvas(ofp,name+6,main,0,6);
59   ret = protdna_btc_display(alb,protsequence,protname,protoff,gen->baseseq,ct,name,main,btc,match_central_line_std,mult);
60   free_btCanvas(btc);
61 
62   return ret;
63 }
64 
65 /* Function:  protcdna_ascii_display(alb,protsequence,protname,protoff,cdna,ct,name,main,mult,ofp)
66  *
67  * Descrip:    shows the alignment in alb between protsequence and protname
68  *             with cdna into ofp with pretty formatting
69  *
70  *
71  * Arg:                 alb [UNKN ] logical alignment [AlnBlock *]
72  * Arg:        protsequence [UNKN ] protein sequence - either real or an artifical consensus [char *]
73  * Arg:            protname [UNKN ] name of the protein [char *]
74  * Arg:             protoff [UNKN ] offset of the alb from the protein [int]
75  * Arg:                cdna [UNKN ] cdna of the match [cDNA *]
76  * Arg:                  ct [UNKN ] codon table for translation [CodonTable *]
77  * Arg:                name [UNKN ] length of name block [int]
78  * Arg:                main [UNKN ] length of main block [int]
79  * Arg:                mult [UNKN ] is multi-match [boolean]
80  * Arg:                 ofp [UNKN ] output file [FILE *]
81  *
82  * Return [UNKN ]  Undocumented return value [boolean]
83  *
84  */
85 # line 81 "genedisplay.dy"
protcdna_ascii_display(AlnBlock * alb,char * protsequence,char * protname,int protoff,cDNA * cdna,CodonTable * ct,int name,int main,boolean mult,FILE * ofp)86 boolean protcdna_ascii_display(AlnBlock * alb,char * protsequence,char * protname,int protoff,cDNA * cdna,CodonTable * ct,int name,int main,boolean mult,FILE * ofp)
87 {
88   boolean ret;
89   btCanvas * btc;
90 
91   btc = new_Ascii_btCanvas(ofp,name+6,main,0,6);
92   ret = protdna_btc_display(alb,protsequence,protname,protoff,cdna->baseseq,ct,name,main,btc,match_central_line_std,mult);
93   free_btCanvas(btc);
94   return ret;
95 }
96 
97 # line 92 "genedisplay.dy"
match_central_line_std(char hmm,int score,char seq)98 char match_central_line_std(char hmm,int score,char seq)
99 {
100   if( hmm == seq ) {
101     return hmm;
102   }
103 
104   if( score <= 0 ) {
105     return ' ';
106   }
107 
108   return '+';
109 }
110 
111 # line 105 "genedisplay.dy"
protdna_btc_display(AlnBlock * alb,char * protsequence,char * protname_in,int protoff,Sequence * dna,CodonTable * ct,int name,int main,btCanvas * btc,char (* match_central_line)(char,int,char),boolean multalign)112 boolean protdna_btc_display(AlnBlock * alb,char * protsequence,char * protname_in,int protoff,Sequence * dna,CodonTable * ct,int name,int main,btCanvas * btc,char (*match_central_line)(char,int,char),boolean multalign)
113 {
114   AlnColumn * alc;
115   AlnColumn * alc_temp,*alc_endscore;
116   int a_phase, d_phase;
117   int intron_number = 1;
118   int aln_score;
119   int aln_num = 1;
120   btPasteArea * btp;
121   char tempbuf[2];
122   char protname[60];
123   char dnaname[60];
124   char dnatemp[4];
125   char protc;
126   char transc;
127   boolean is_reversed = FALSE;
128   boolean issplit;
129 
130   if( strlen(protname_in) > name ) {
131     info("Name %s is longer than allowed name block (%d). Truncating\n",protname_in,name);
132     strncpy(protname,protname_in,name);
133     protname[name] = '\0';
134   } else {
135     strcpy(protname,protname_in);
136   }
137 
138   if( strlen(dna->name) > name ) {
139     info("Name %s is longer than allowed name block (%d). Truncating\n",dna->name,name);
140     strncpy(dnaname,dna->name,name);
141     dnaname[name] = '\0';
142   } else {
143     strcpy(dnaname,dna->name);
144   }
145 
146   if( dna->offset > dna->end ) {
147     is_reversed = TRUE;
148   }
149 
150   for(alc=alb->start;alc != NULL;) {
151 
152     if ( strcmp(alc->alu[1]->text_label,"END") == 0 )
153       break; /* end of alignment */
154 
155 
156     for(;alc != NULL && is_random_AlnColumn_genewise(alc) == TRUE;alc = alc->next)
157       ;
158 
159     if( alc == NULL)
160       break; /* end of alignment */
161 
162 
163 
164     if( multalign == TRUE ) {
165       /* get the end score */
166       for(aln_score = 0,alc_endscore=alc;alc_endscore->next != NULL;alc_endscore = alc_endscore->next) {
167 	if( is_random_AlnColumn_genewise(alc_endscore) == TRUE)
168 	  break;
169 	aln_score += alc_endscore->alu[0]->score[0];
170       }
171       /*aln_score += alc_endscore->alu[0]->score[0];*/
172       write_alignment_separator(btc,aln_num++,aln_score);
173     }
174 
175 
176     while( alc != NULL ) {
177 
178 
179       write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc);
180 
181       for(; alc != NULL;alc=alc->next ) {
182 
183 	if( is_random_AlnColumn_genewise(alc) == TRUE )
184 	  break;
185 
186 	if( strcmp(alc->alu[1]->text_label,"INSERT") == 0 ) {
187 	  if( can_get_paste_area_btCanvas(btc,1) == FALSE)
188 	    break;  /* back to upper for, to place names and starts */
189 	  btp = get_paste_area_btCanvas(btc,1);
190 
191 	  paste_char_btPasteArea(btp,0,0,protsequence[alc->alu[0]->start+1],0);
192 	  paste_char_btPasteArea(btp,0,2,'-',0);
193 	  free_btPasteArea(btp);
194 	} else if ( strcmp(alc->alu[1]->text_label,"SEQUENCE_INSERTION") == 0 ||
195 		    strcmp(alc->alu[1]->text_label,"SEQUENCE_DELETION") == 0 ) {
196 	  if( can_get_paste_area_btCanvas(btc,1) == FALSE)
197 	    break;  /* back to upper for, to place names and starts */
198 	  btp = get_paste_area_btCanvas(btc,1);
199 
200 	  if( strcmp(alc->alu[0]->text_label,"INSERT_STATE")== 0 ) {
201 	    paste_char_btPasteArea(btp,0,0,'-',0);
202 	  }
203 	  else {
204 	    paste_char_btPasteArea(btp,0,0,protsequence[alc->alu[0]->end],0);
205 	  }
206 
207 	  sprintf(tempbuf,"%d",alc->alu[1]->end - alc->alu[1]->start);
208 	  paste_char_btPasteArea(btp,0,3,tempbuf[0],0);
209 	  paste_char_btPasteArea(btp,0,2,'!',0);
210 
211 	  free_btPasteArea(btp);
212 
213 	} else if (strcmp(alc->alu[1]->text_label,"END") == 0 && strcmp(alc->alu[0]->text_label,"END") == 0) {
214 	  break; /* end of alignment */
215 	} else if ( strcmp(alc->alu[1]->text_label,"RANDOM_SEQUENCE") == 0 ) {
216 	  break;
217 	} else if( strcmp(alc->alu[1]->text_label,"CODON") == 0 ) {
218 
219 	  if( can_get_paste_area_btCanvas(btc,1) == FALSE)
220 	    break;  /* back to upper for, to place names and starts */
221 
222 	  btp = get_paste_area_btCanvas(btc,1);
223 
224 	  if( strcmp(alc->alu[0]->text_label,"INSERT_STATE")== 0 ) {
225 	    write_codon_match(btp,'-',' ',alc->alu[1]->start+1,aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1),dna->seq+alc->alu[1]->start+1);
226 	  } else if( strcmp(alc->alu[0]->text_label,"BEFORE_MATCH") == 0 ||
227 	             strcmp(alc->alu[0]->text_label,"AFTER_MATCH") == 0 ) {
228 	    write_codon_match(btp,'~',' ',alc->alu[1]->start+1,aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1),dna->seq+alc->alu[1]->start+1);
229 	  } else {
230 	    write_codon_match(btp,protsequence[alc->alu[0]->end],(*match_central_line)(protsequence[alc->alu[0]->end],alc->alu[0]->score[0],aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1)),alc->alu[1]->start+1,aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1),dna->seq+alc->alu[1]->start+1);
231 	  }
232 
233 	  free_btPasteArea(btp);
234 
235 	  continue;
236 	} else if ( strstartcmp(alc->alu[1]->text_label,"5SS") == 0 )  {
237 
238 
239 	  /*
240 	   * intron stuff. Figure out the start and end,
241 	   * then place the 5'SS Central and End.
242 	   *
243 	   * If we can't fit in the intron, loop over
244 	   * in this region before returning to higher loop.
245 	   *
246 	   */
247 
248 	  if( strcmp(alc->alu[1]->text_label,"5SS_PHASE_0") == 0 ) {
249 	    d_phase = 0;
250 	  } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_1") == 0 ) {
251 	    d_phase = 1;
252 	  } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_2") == 0 ) {
253 	    d_phase = 2;
254 	  } else {
255 	    warn("No no no. You have a non 0,1,2 phase intron (god knows how!). Not displaying it %s",alc->alu[1]->text_label);
256 	    advance_line_btCanvas(btc);
257 	    return FALSE;
258 	  }
259 
260 	  alc_temp = alc->next;
261 
262 	  if( strcmp(alc_temp->alu[1]->text_label,"CENTRAL_INTRON") != 0 ) {
263 	    warn("Bad news. I have found a 5SS in your alignment, but it is not followed by a central intron node. Don't like it!");
264 	    advance_line_btCanvas(btc);
265 	    return FALSE;
266 	  }
267 
268 	  for(alc_temp = alc_temp->next ;alc_temp != NULL && strstartcmp(alc_temp->alu[1]->text_label,"3SS") != 0;alc_temp = alc_temp->next)
269 	    ;
270 
271 	  if( alc_temp == NULL ) {
272 	    warn("Got to the end of the alignment in the middle of an intron from %s. Weird!",alc->alu[1]->text_label);
273 	    advance_line_btCanvas(btc);
274 	    return FALSE;
275 	  }
276 
277 	  if( strcmp(alc_temp->alu[1]->text_label,"3SS_PHASE_0") == 0 ) {
278 	    a_phase = 0;
279 	  } else if ( strcmp(alc_temp->alu[1]->text_label,"3SS_PHASE_1") == 0 ) {
280 	    a_phase = 1;
281 	  } else if ( strcmp(alc_temp->alu[1]->text_label,"3SS_PHASE_2") == 0 ) {
282 	    a_phase = 2;
283 	  } else {
284 	    warn("No no no. You have a non 0,1,2 phase intron (god knows how!). Not displaying it %s",alc_temp->alu[1]->text_label);
285 	    advance_line_btCanvas(btc);
286 	    return FALSE;
287 	  }
288 
289 	  /*
290 	   * At this point we have alc on 5SS alc_temp on 3SS.
291 	   *
292 	   * Check to see if we can place 5SS and Central intron piece
293 	   * on the line, if not advance.
294 	   *
295 	   */
296 
297 	  if( can_get_paste_area_btCanvas(btc,d_phase+7+17) == FALSE) {
298 	    advance_line_btCanvas(btc);
299 
300 	    write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc);
301 	  }
302 
303 	  /*** ok, if we can't get it now then we are fucked ***/
304 
305 	  if( can_get_paste_area_btCanvas(btc,d_phase+7+17) == FALSE) {
306 	    warn("You have specified a length of your main canvas too small. I need at least 23 characters long.");
307 	    advance_line_btCanvas(btc);
308 	    return FALSE;
309 	  }
310 
311 	  btp = get_paste_area_btCanvas(btc,d_phase+7);
312 
313 	  /* ? split phase */
314 	  if( a_phase == 0 || (a_phase != d_phase ) ) {
315 	    protc = ' ';
316 	    transc = ' ';
317 	    dnatemp[0]= '\0';
318 	    issplit = FALSE;
319 	  } else {
320 
321 	    if( strcmp(alc_temp->alu[0]->text_label,"INSERT_STATE")== 0 ) {
322 	      protc = '-';
323 	    } else {
324 	      protc = protsequence[alc->alu[0]->start+1];
325 	    }
326 
327 	    dnatemp[0] = tolower((int)dna->seq[alc->alu[1]->start+1]);
328 	    if( d_phase == 2) {
329 	      dnatemp[1] = tolower((int)dna->seq[alc->alu[1]->start+2]);
330 	    } else {
331 	      dnatemp[1] = tolower((int)dna->seq[alc_temp->alu[1]->end-1]);
332 	    }
333 	    dnatemp[2] = tolower((int)dna->seq[alc_temp->alu[1]->end]);
334 	    dnatemp[3] = '\0';
335 
336 	    transc = aminoacid_from_seq(ct,dnatemp);
337 	    issplit = TRUE;
338 	  }
339 
340 	  write_5intron_match(btp,d_phase,7,dna->seq+alc->alu[1]->start+1);
341 	  free_btPasteArea(btp);
342 
343 	  btp = get_paste_area_btCanvas(btc,17);
344 
345 	  if( is_reversed == FALSE )
346 	    write_intron_desc(btp,alc->alu[1]->start+1+d_phase+dna->offset,alc_temp->alu[1]->start+3+dna->offset,intron_number++,issplit,protc,transc,dnatemp);
347 	  else
348 	    write_intron_desc(btp,dna->offset - (alc->alu[1]->start+d_phase+1),dna->offset - (alc_temp->alu[1]->start+3),intron_number++,issplit,protc,transc,dnatemp);
349 
350 	  free_btPasteArea(btp);
351 
352 
353 	  /*
354 	   * written the start of the intron, now to deal with the
355 	   * acceptor. We need to loop here, because we might go over the
356 	   * line length.
357 	   */
358 
359 	  alc = alc->next->next;  /*** move alc forward two columns ***/
360 
361 	  while( alc != alc_temp ) {
362 	    for(; alc != alc_temp;alc = alc->next) { /** alc_temp is 3SS **/
363 	      if( strcmp(alc->alu[1]->text_label,"PYRIMIDINE_TRACT") == 0 ) {
364 		if( can_get_paste_area_btCanvas(btc,1) == FALSE )
365 		  break;
366 		btp = get_paste_area_btCanvas(btc,1);
367 		paste_char_btPasteArea(btp,0,3,dna->seq[alc->alu[1]->start+1],0);
368 		paste_char_btPasteArea(btp,0,4,'+',0);
369 		free_btPasteArea(btp);
370 	      } else if( strcmp(alc->alu[1]->text_label,"SPACER") == 0 ) {
371 		if( can_get_paste_area_btCanvas(btc,1) == FALSE )
372 		  break;
373 		btp = get_paste_area_btCanvas(btc,1);
374 		paste_char_btPasteArea(btp,0,3,dna->seq[alc->alu[1]->start+1],0);
375 		free_btPasteArea(btp);
376 	      } else {
377 		warn("Sorry, don't know how to print %s. Skipping...",alc->alu[1]->text_label);
378 	      }
379 	    }
380 
381 	    /** end for for loop **/
382 
383 	    if ( alc == alc_temp ) {
384 	      break;
385 	    }
386 
387 	    /*** run out of space ***/
388 
389 	    advance_line_btCanvas(btc);
390 
391 	    write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc);
392 
393 	  } /** end of while still in central->3SS **/
394 
395 	  /*
396 	   * Now do 3SS
397 	   *
398 	   */
399 
400 	  if( can_get_paste_area_btCanvas(btc,a_phase == 0 ? 3 : 3- a_phase + 3) == FALSE ) {
401 	    advance_line_btCanvas(btc);
402 	    write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc);
403 	  }
404 
405 	  if( a_phase != 0 ) {
406 	    btp = get_paste_area_btCanvas(btc,3 - a_phase + 3);
407 
408 	    write_3intron_match(btp,a_phase,3,dna->seq + alc->alu[1]->start+1);
409 
410 	    free_btPasteArea(btp);
411 	  } else {
412 	    btp = get_paste_area_btCanvas(btc,3);
413 	    write_3intron_match(btp,a_phase,3,dna->seq + alc->alu[1]->start+1);
414 	    free_btPasteArea(btp);
415 	  }
416 
417 	  /*
418 	   * Finished with intron !!!
419 	   */
420 	} else {
421 	  warn("Sorry, could not print the alignment %s:%s column",alc->alu[0]->text_label,alc->alu[1]->text_label);
422 	}
423 
424       } /*** in this loop ***/
425 
426 
427       advance_line_btCanvas(btc);
428 
429       if( alc == NULL)
430 	break;
431 
432       if ( is_random_AlnColumn_genewise(alc) == TRUE)
433 	break;
434 
435     } /* end of while over alignments */
436   } /* end of foreach alignment */
437 
438 
439   /*** end of print ! **/
440 
441   return TRUE;
442 }
443 
444 # line 437 "genedisplay.dy"
write_alignment_separator(btCanvas * btc,int aln,int score)445 boolean write_alignment_separator(btCanvas * btc,int aln,int score)
446 {
447   char buffer[64];
448   btPasteArea * btp;
449 
450   sprintf(buffer,"Alignment %d Score %4.2f (Bits)",aln,Score2Bits(score));
451 
452   btp = get_paste_area_btCanvas(btc,strlen(buffer));
453 
454   paste_string_btPasteArea(btp,0,5,buffer,BC_RIGHT,0);
455 
456   free_btPasteArea(btp);
457 
458   advance_line_btCanvas(btc);
459 
460   return TRUE;
461 }
462 
463 # line 455 "genedisplay.dy"
write_name_start_stuff(btCanvas * btc,char * protname,int protoff,char * dnaname,Sequence * dna,int name_len,AlnColumn * alc)464 boolean write_name_start_stuff(btCanvas * btc,char * protname,int protoff,char * dnaname,Sequence * dna,int name_len,AlnColumn * alc)
465 {
466   char buffer[64];
467   btPasteArea * btp;
468 
469   btp = get_reserved_left_btCanvas(btc);
470 
471   paste_string_btPasteArea(btp,0,0,protname,BC_RIGHT,0);
472   paste_string_btPasteArea(btp,0,3,dnaname,BC_RIGHT,0);
473 
474   sprintf(buffer,"%d",alc->alu[0]->start+1+protoff);
475   paste_string_btPasteArea(btp,name_len+5-strlen(buffer),0,buffer,BC_RIGHT,0);
476 
477   if( dna->offset < dna->end )
478     sprintf(buffer,"%d",alc->alu[1]->start+1+dna->offset);
479   else
480     sprintf(buffer,"-%d",dna->offset - (alc->alu[1]->start+1));
481 
482   paste_string_btPasteArea(btp,name_len+5-strlen(buffer),3,buffer,BC_RIGHT,0);
483 
484   free_btPasteArea(btp);
485 
486   return TRUE;
487 }
488 
489 
490 # line 481 "genedisplay.dy"
write_intron_desc(btPasteArea * btp,int start,int stop,int in_number,boolean is_split,char prot,char trans,char * dna)491 boolean write_intron_desc(btPasteArea * btp,int start,int stop,int in_number,boolean is_split,char prot,char trans,char * dna)
492 {
493   char buffer[32];
494 
495   if( is_split ) {
496     sprintf(buffer,"  %c:%c[%s]  ",prot,trans,dna);
497     paste_string_btPasteArea(btp,0,2,buffer,BC_RIGHT,0);
498   }
499 
500   if( in_number < 1000 ) {
501     sprintf(buffer,"  Intron %-3d  ",in_number);
502   } else {
503     sprintf(buffer,"  Intron ???  ",in_number);
504   }
505 
506   paste_string_btPasteArea(btp,0,3,buffer,BC_RIGHT,0);
507 
508   if( start < 10000000 && stop < 10000000 )
509     sprintf(buffer,"[%-7d:%7d]",start,stop);
510   else
511     sprintf(buffer,"[???????:???????]");
512 
513   paste_string_btPasteArea(btp,0,4,buffer,BC_RIGHT,0);
514 
515   return TRUE;
516 }
517 
518 
519 # line 509 "genedisplay.dy"
write_3intron_match(btPasteArea * btp,int phase,int length,char * seq)520 boolean write_3intron_match(btPasteArea * btp,int phase,int length,char * seq)
521 {
522   char buf[2];
523   int i;
524   int prl;
525 
526   prl = 3 - phase + length;
527   if( phase == 0 ) {
528     prl = 3;
529   }
530 
531 
532   sprintf(buf,"%d",phase);
533 
534   for(i=0;i<prl;i++) {
535     paste_char_btPasteArea(btp,i,3,toupper((int)seq[i]),0);
536   }
537 
538 
539   for(i=0;i<length-2;i++) {
540     paste_char_btPasteArea(btp,i,4,'-',0);
541   }
542 
543 
544   paste_char_btPasteArea(btp,i++,4,buf[0],0);
545   paste_char_btPasteArea(btp,i,4,'>',0);
546 
547 
548   return TRUE;
549 }
550 
551 
552 # line 541 "genedisplay.dy"
write_5intron_match(btPasteArea * btp,int phase,int length,char * seq)553 boolean write_5intron_match(btPasteArea * btp,int phase,int length,char * seq)
554 {
555   char buf[2];
556   int i;
557 
558   sprintf(buf,"%d",phase);
559 
560   for(i=0;i<phase+length;i++) {
561     paste_char_btPasteArea(btp,i,3,toupper((int)seq[i]),0);
562   }
563 
564   paste_char_btPasteArea(btp,phase,4,'<',0);
565   paste_char_btPasteArea(btp,phase+1,4,buf[0],0);
566 
567   for(i=2;i<length;i++) {
568     paste_char_btPasteArea(btp,i+phase,4,'-',0);
569   }
570 
571   return TRUE;
572 }
573 
574 # line 562 "genedisplay.dy"
write_codon_match(btPasteArea * btp,char match_letter,char midline,int c_start,char aa,char * seq)575 boolean write_codon_match(btPasteArea * btp,char match_letter,char midline,int c_start,char aa,char * seq)
576 {
577   paste_char_btPasteArea(btp,0,0,match_letter,0);
578   paste_char_btPasteArea(btp,0,1,midline,0);
579   paste_char_btPasteArea(btp,0,2,aa,0);
580   if( strchr("ATGCatgc",*seq) != NULL )
581     paste_char_btPasteArea(btp,0,3,tolower((int)*seq),0);
582   else if( !isalpha((int)*seq) ) {
583     warn("Attempting to write a non alpha chacater as part of a dna sequence [%d]",(int)(*seq));
584     paste_char_btPasteArea(btp,0,3,'?',0);
585   } else
586     paste_char_btPasteArea(btp,0,3,toupper((int)*seq),0);
587 
588   seq++;
589 
590   if( strchr("ATGCatgc",*seq) != NULL )
591     paste_char_btPasteArea(btp,0,4,tolower((int)*seq),0);
592   else if( !isalpha((int)*seq) ) {
593     warn("Attempting to write a non alpha chacater as part of a dna sequence [%d]",(int)(*seq));
594     paste_char_btPasteArea(btp,0,3,'?',0);
595   }
596   else
597     paste_char_btPasteArea(btp,0,4,toupper((int)*seq),0);
598 
599   seq++;
600 
601   if( strchr("ATGCatgc",*seq) != NULL )
602     paste_char_btPasteArea(btp,0,5,tolower((int)*seq),0);
603   else if( !isalpha((int)*seq) ) {
604     warn("Attempting to write a non alpha chacater as part of a dna sequence [%d]",(int)(*seq));
605     paste_char_btPasteArea(btp,0,3,'?',0);
606   }
607   else
608     paste_char_btPasteArea(btp,0,5,toupper((int)*seq),0);
609 
610   return TRUE;
611 }
612 
613 
614 
615 
616 
617 # line 610 "genedisplay.c"
618 
619 #ifdef _cplusplus
620 }
621 #endif
622