1 | #include <stdio.h> |
---|
2 | #include <xview/xview.h> |
---|
3 | #include <xview/canvas.h> |
---|
4 | #include <xview/cursor.h> |
---|
5 | #include <xview/panel.h> |
---|
6 | #include <string.h> |
---|
7 | #include <malloc.h> |
---|
8 | #include "loop.h" |
---|
9 | #include "globals.h" |
---|
10 | |
---|
11 | DrawPair(base1,base2,pw) |
---|
12 | Base base1,base2; |
---|
13 | Pixwin *pw; |
---|
14 | { |
---|
15 | char a,b; |
---|
16 | int i,j,x,y; |
---|
17 | double x1,y1,x2,y2; |
---|
18 | |
---|
19 | a=base1.nuc | 32; |
---|
20 | b=base2.nuc | 32; |
---|
21 | x1=base1.x+(double)CWID/xscale*.5; |
---|
22 | y1=base1.y-(double)CHT/yscale*.5; |
---|
23 | x2=base2.x+(double)CWID/xscale*.5; |
---|
24 | y2=base2.y-(double)CHT/yscale*.5; |
---|
25 | |
---|
26 | if( a=='u' && b=='a' || |
---|
27 | a=='t' && b=='a' || |
---|
28 | a=='a' && b=='u' || |
---|
29 | a=='a' && b=='t' || |
---|
30 | a=='c' && b=='g' || |
---|
31 | a=='g' && b=='c' |
---|
32 | ) |
---|
33 | { |
---|
34 | line(x2+0.35*(x1-x2),y2+0.35*(y1-y2), |
---|
35 | x2+0.65*(x1-x2),y2+0.65*(y1-y2),6,pw); |
---|
36 | } |
---|
37 | else if( a=='u' && b=='g' || |
---|
38 | a=='t' && b=='g' || |
---|
39 | a=='g' && b=='u' || |
---|
40 | a=='g' && b=='t' |
---|
41 | ) |
---|
42 | { |
---|
43 | x=(int)((x1+x2)*.5*xscale+xoffset); |
---|
44 | y=(int)((y1+y2)*.5*yscale+yoffset); |
---|
45 | pw_vector(pw,x-1,y-1,x+1,y-1,(PIX_SRC),1); |
---|
46 | pw_vector(pw,x-1,y,x+1,y,(PIX_SRC),1); |
---|
47 | pw_vector(pw,x-1,y+1,x+1,y+1,(PIX_SRC),1); |
---|
48 | } |
---|
49 | else if( a=='a' && b=='g' || |
---|
50 | a=='u' && b=='u' || |
---|
51 | a=='u' && b=='u' ) |
---|
52 | { |
---|
53 | x=(int)((x1+x2)*.5*xscale+xoffset); |
---|
54 | y=(int)((y1+y2)*.5*yscale+yoffset); |
---|
55 | pw_vector(pw,x-1,y-1,x+1,y-1,(PIX_SRC),1); |
---|
56 | pw_vector(pw,x-1,y-1,x-1,y+1,(PIX_SRC),1); |
---|
57 | pw_vector(pw,x+1,y-1,x+1,y+1,(PIX_SRC),1); |
---|
58 | pw_vector(pw,x-1,y+1,x+1,y+1,(PIX_SRC),1); |
---|
59 | } |
---|
60 | return; |
---|
61 | |
---|
62 | } |
---|
63 | |
---|
64 | line(x1,y1,x2,y2,color,pw) |
---|
65 | double x1,y1,x2,y2; |
---|
66 | int color; |
---|
67 | Pixwin *pw; |
---|
68 | { |
---|
69 | pw_vector(pw,(int)(x1* xscale +xoffset), |
---|
70 | (int)(y1* yscale + yoffset), |
---|
71 | (int)(x2* xscale +xoffset), |
---|
72 | (int)(y2* yscale + yoffset), |
---|
73 | (PIX_SRC | (color<<5)),color ); |
---|
74 | return; |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | gputc(x,y,c,pw) |
---|
79 | double x,y; |
---|
80 | char c; |
---|
81 | Pixwin *pw; |
---|
82 | { |
---|
83 | pw_char(pw,(int)(x*xscale+xoffset), |
---|
84 | (int)(y*yscale+yoffset), |
---|
85 | PIX_SRC,NULL,c); |
---|
86 | return; |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | void EventHandler(window,event,arg) |
---|
91 | Xv_window window; |
---|
92 | Event *event; |
---|
93 | caddr_t arg; |
---|
94 | { |
---|
95 | double x,y; |
---|
96 | int nuc,i,start,endd; |
---|
97 | extern void ReDraw(); |
---|
98 | if(event_id(event) == WIN_RESIZE) |
---|
99 | { |
---|
100 | modified = TRUE; |
---|
101 | ReDraw(pagecan,canvas_paint_window(pagecan),NULL); |
---|
102 | } |
---|
103 | x = (double)(event_x(event)-xoffset); |
---|
104 | x /= xscale; |
---|
105 | y = (double)(event_y(event)-yoffset); |
---|
106 | y /= yscale; |
---|
107 | x = x-(double)CWID/xscale*.5; |
---|
108 | y = y+(double)CHT/yscale*.5; |
---|
109 | |
---|
110 | if(event_id(event) == BUT(1) && event_is_down(event)) |
---|
111 | { |
---|
112 | nuc=FindNuc(x,y); |
---|
113 | |
---|
114 | |
---|
115 | if(nuc== -1) |
---|
116 | { |
---|
117 | if(select_state == 3) |
---|
118 | { |
---|
119 | start=Min(nuc_sel1,nuc_sel2); |
---|
120 | endd=Max(nuc_sel1,nuc_sel2); |
---|
121 | for(i=start; i<=endd;i++) |
---|
122 | UnHiLite(i); |
---|
123 | } |
---|
124 | else |
---|
125 | { |
---|
126 | UnHiLite(nuc_sel1); |
---|
127 | UnHiLite(nuc_sel2); |
---|
128 | } |
---|
129 | nuc_sel1= -1; |
---|
130 | nuc_sel2= -1; |
---|
131 | select_state=0; |
---|
132 | return; |
---|
133 | } |
---|
134 | switch(select_state) |
---|
135 | { |
---|
136 | case 0: |
---|
137 | nuc_sel1=nuc; |
---|
138 | HiLite(nuc); |
---|
139 | select_state=1; |
---|
140 | break; |
---|
141 | case 1: |
---|
142 | nuc_sel2=nuc; |
---|
143 | HiLite(nuc); |
---|
144 | select_state=2; |
---|
145 | break; |
---|
146 | case 2: |
---|
147 | UnHiLite(nuc_sel1); |
---|
148 | UnHiLite(nuc_sel2); |
---|
149 | select_state=0; |
---|
150 | nuc_sel1= -1; |
---|
151 | nuc_sel2= -1; |
---|
152 | break; |
---|
153 | case 3: |
---|
154 | start=Min(nuc_sel1,nuc_sel2); |
---|
155 | endd=Max(nuc_sel1,nuc_sel2); |
---|
156 | for(i=start; i<=endd;i++) |
---|
157 | UnHiLite(i); |
---|
158 | nuc_sel1= -1; |
---|
159 | nuc_sel2= -1; |
---|
160 | select_state=0; |
---|
161 | break; |
---|
162 | default: |
---|
163 | select_state=0; |
---|
164 | break; |
---|
165 | }; |
---|
166 | } |
---|
167 | else if(event_id(event) == BUT(1) && event_is_up(event)) |
---|
168 | { |
---|
169 | nuc=FindNuc(x,y); |
---|
170 | if(nuc== -1 && select_state != 2) |
---|
171 | { |
---|
172 | if(select_state == 3) |
---|
173 | { |
---|
174 | start=Min(nuc_sel1,nuc_sel2); |
---|
175 | endd=Max(nuc_sel1,nuc_sel2); |
---|
176 | for(i=start; i<=endd;i++) |
---|
177 | UnHiLite(i); |
---|
178 | } |
---|
179 | else |
---|
180 | { |
---|
181 | UnHiLite(nuc_sel1); |
---|
182 | UnHiLite(nuc_sel2); |
---|
183 | } |
---|
184 | nuc_sel1= -1; |
---|
185 | nuc_sel2= -1; |
---|
186 | select_state=0; |
---|
187 | return; |
---|
188 | } |
---|
189 | if(nuc!=nuc_sel1) |
---|
190 | switch(select_state) |
---|
191 | { |
---|
192 | case 1: |
---|
193 | nuc_sel2=nuc; |
---|
194 | start=Min(nuc_sel1,nuc_sel2); |
---|
195 | endd=Max(nuc_sel1,nuc_sel2); |
---|
196 | for(i=start;i<=endd;i++) |
---|
197 | HiLite(i); |
---|
198 | select_state=3; |
---|
199 | break; |
---|
200 | case 2: |
---|
201 | if(IsLoop(nuc_sel1,nuc_sel2)) |
---|
202 | switch (constraint_state) |
---|
203 | { |
---|
204 | case POSITIONAL: |
---|
205 | SetPos(nuc_sel1,nuc_sel2,x,y); |
---|
206 | break; |
---|
207 | |
---|
208 | case ANGULAR: |
---|
209 | SetAng(nuc_sel1,nuc_sel2,x,y); |
---|
210 | break; |
---|
211 | |
---|
212 | case DISTANCE: |
---|
213 | SetDist(nuc_sel1,nuc_sel2,x,y); |
---|
214 | break; |
---|
215 | } |
---|
216 | else |
---|
217 | { |
---|
218 | fprintf(stderr,"%c",7); |
---|
219 | fflush(stderr); |
---|
220 | } |
---|
221 | |
---|
222 | UnHiLite(nuc_sel1); |
---|
223 | UnHiLite(nuc_sel2); |
---|
224 | select_state=0; |
---|
225 | nuc_sel1= -1; |
---|
226 | nuc_sel2= -1; |
---|
227 | select_state=0; |
---|
228 | break; |
---|
229 | default: |
---|
230 | break; |
---|
231 | }; |
---|
232 | } |
---|
233 | if(modified) |
---|
234 | ReDraw(pagecan,canvas_paint_window(pagecan),NULL); |
---|
235 | return; |
---|
236 | } |
---|
237 | |
---|
238 | HiLite(nuc) |
---|
239 | int nuc; |
---|
240 | { |
---|
241 | if(nuc == -1) return; |
---|
242 | baselist[nuc].attr |= HILITE; |
---|
243 | if(baselist[nuc].depth<ddepth) |
---|
244 | gprint(baselist[nuc],canvas_paint_window(pagecan)); |
---|
245 | return; |
---|
246 | } |
---|
247 | |
---|
248 | UnHiLite(nuc) |
---|
249 | int nuc; |
---|
250 | { |
---|
251 | if(nuc == -1) return; |
---|
252 | baselist[nuc].attr &= ~HILITE; |
---|
253 | if(baselist[nuc].depth<ddepth) |
---|
254 | gprint(baselist[nuc],canvas_paint_window(pagecan)); |
---|
255 | return; |
---|
256 | } |
---|
257 | |
---|
258 | FindNuc(x,y) |
---|
259 | double x,y; |
---|
260 | { |
---|
261 | double sqrt(); |
---|
262 | int i,best=0; |
---|
263 | double d,dmin=999.999; |
---|
264 | |
---|
265 | for(i=0;i<seqlen;i++) |
---|
266 | { |
---|
267 | d=distance(x,y,baselist[i].x,baselist[i].y); |
---|
268 | if (d<dmin && baselist[i].depth<ddepth) |
---|
269 | { |
---|
270 | dmin=d; |
---|
271 | best=i; |
---|
272 | } |
---|
273 | } |
---|
274 | if(dmin>3.0) best= -1; |
---|
275 | return(best); |
---|
276 | } |
---|
277 | |
---|
278 | |
---|
279 | SetDist(nuc1,nuc2,x,y) |
---|
280 | int nuc1,nuc2; |
---|
281 | double x,y; |
---|
282 | { |
---|
283 | int i,n1,n2; |
---|
284 | double d,sqrt(); |
---|
285 | |
---|
286 | n1=Min(nuc1,nuc2); |
---|
287 | n2=Max(nuc1,nuc2); |
---|
288 | |
---|
289 | if(n1==nuc1) |
---|
290 | { |
---|
291 | d = distance(x,y,baselist[n1].x,baselist[n1].y); |
---|
292 | } |
---|
293 | else |
---|
294 | { |
---|
295 | d = distance(x,y,baselist[n2].x,baselist[n2].y); |
---|
296 | } |
---|
297 | |
---|
298 | baselist[n1].dforw.pair=n2; |
---|
299 | baselist[n1].dforw.dist=d; |
---|
300 | |
---|
301 | baselist[n2].dback.pair=n1; |
---|
302 | baselist[n2].dback.dist= -d; |
---|
303 | modified = TRUE; |
---|
304 | } |
---|
305 | |
---|
306 | |
---|
307 | |
---|
308 | |
---|
309 | SetPos(nuc1,nuc2,x,y) |
---|
310 | int nuc1,nuc2; |
---|
311 | double x,y; |
---|
312 | { |
---|
313 | int i,nuc,pair; |
---|
314 | double dx,dy,sqrt(); |
---|
315 | |
---|
316 | dx = x-baselist[nuc1].x; |
---|
317 | dy = y-baselist[nuc1].y; |
---|
318 | |
---|
319 | nuc=nuc1; |
---|
320 | pair=nuc2; |
---|
321 | |
---|
322 | if(baselist[nuc].posnum < 0) |
---|
323 | { |
---|
324 | baselist[nuc].posnum = 0; |
---|
325 | baselist[nuc].pos = (Pcon*)calloc(sizeof(Pcon),10); |
---|
326 | } |
---|
327 | if(baselist[nuc].posnum < 10) |
---|
328 | { |
---|
329 | baselist[nuc].pos[baselist[nuc].posnum].pair=pair; |
---|
330 | baselist[nuc].pos[baselist[nuc].posnum].dx=dx; |
---|
331 | baselist[nuc].pos[baselist[nuc].posnum++].dy=dy; |
---|
332 | modified = TRUE; |
---|
333 | } |
---|
334 | else |
---|
335 | { |
---|
336 | fprintf(stderr,"%d Only 10 positional constraints per base\n" |
---|
337 | ,nuc); |
---|
338 | } |
---|
339 | return; |
---|
340 | } |
---|
341 | |
---|
342 | |
---|
343 | |
---|
344 | |
---|
345 | SetAng(nuc1,nuc2,x,y) |
---|
346 | int nuc1,nuc2; |
---|
347 | double x,y; |
---|
348 | { |
---|
349 | int i,j; |
---|
350 | double dist,theta; |
---|
351 | double sqrt(),sin(),cos(),atan2(); |
---|
352 | |
---|
353 | dist = distance(baselist[nuc1].x,baselist[nuc1].y, |
---|
354 | baselist[nuc2].x,baselist[nuc2].y); |
---|
355 | |
---|
356 | theta = atan2(y-baselist[nuc1].y,x-baselist[nuc1].x); |
---|
357 | |
---|
358 | x=baselist[nuc1].x + dist*cos(theta); |
---|
359 | y=baselist[nuc1].y + dist*sin(theta); |
---|
360 | |
---|
361 | SetPos(nuc1,nuc2,x,y); |
---|
362 | |
---|
363 | return; |
---|
364 | } |
---|
365 | |
---|
366 | |
---|
367 | PosConFix(base) |
---|
368 | Base base; |
---|
369 | { |
---|
370 | int i; |
---|
371 | |
---|
372 | for(i=0;i<base.posnum;i++) |
---|
373 | { |
---|
374 | baselist[base.pos[i].pair].x = base.x+base.pos[i].dx; |
---|
375 | baselist[base.pos[i].pair].y = base.y+base.pos[i].dy; |
---|
376 | baselist[base.pos[i].pair].known = TRUE; |
---|
377 | if(baselist[base.pos[i].pair].posnum >0) |
---|
378 | PosConFix(baselist[base.pos[i].pair]); |
---|
379 | } |
---|
380 | return; |
---|
381 | } |
---|
382 | |
---|
383 | |
---|
384 | UnTangle(n1,n2) |
---|
385 | int n1,n2; |
---|
386 | { |
---|
387 | int j,pair,nhelix=0,helx[25]; |
---|
388 | double dist,sqrt(),atan2(),sin(),cos(),theta,dtheta,theta1; |
---|
389 | double dist2,dx,dy; |
---|
390 | Base *b1,*b2,*b3,*b4; |
---|
391 | |
---|
392 | |
---|
393 | b1 = &(baselist[n1]); |
---|
394 | b2 = &(baselist[n2]); |
---|
395 | for(j=n1+1;j < n2;) |
---|
396 | { |
---|
397 | pair=baselist[j].pair; |
---|
398 | if(pair>j) |
---|
399 | { |
---|
400 | helx[nhelix++]=j; |
---|
401 | UnTangle(j,pair); |
---|
402 | j=pair; |
---|
403 | } |
---|
404 | else |
---|
405 | j++; |
---|
406 | } |
---|
407 | if(nhelix < 2) return; |
---|
408 | |
---|
409 | for(j=0;j<nhelix;j++) |
---|
410 | { |
---|
411 | b3 = &(baselist[helx[j]]); |
---|
412 | b4 = &(baselist[b3->pair]); |
---|
413 | |
---|
414 | dist = distance(b2->x,b2->y,b4->x,b4->y); |
---|
415 | dist2 = distance(b3->x,b3->y,b2->x,b2->y); |
---|
416 | if(j<(nhelix/2)) |
---|
417 | { |
---|
418 | b4->dforw.dist = dist2; |
---|
419 | b4->dforw.pair = n2; |
---|
420 | } |
---|
421 | else |
---|
422 | { |
---|
423 | if(b3->pair != n2) |
---|
424 | { |
---|
425 | b3->dforw.dist = dist; |
---|
426 | b3->dforw.pair = n2; |
---|
427 | } |
---|
428 | else |
---|
429 | { |
---|
430 | b1->dforw.dist = dist2; |
---|
431 | b1->dforw.pair = helx[j]; |
---|
432 | } |
---|
433 | } |
---|
434 | |
---|
435 | } |
---|
436 | return; |
---|
437 | } |
---|
438 | |
---|
439 | RemoveCon(nuc1,nuc2) |
---|
440 | int nuc1,nuc2; |
---|
441 | { |
---|
442 | int i,j; |
---|
443 | Base *b1; |
---|
444 | |
---|
445 | b1 = &(baselist[nuc1==(-1) ? nuc2:nuc1]); |
---|
446 | switch(select_state) |
---|
447 | { |
---|
448 | case 1: |
---|
449 | b1->dforw.pair = -1; |
---|
450 | b1->dforw.dist=0.0; |
---|
451 | b1->posnum = -1; |
---|
452 | cfree(b1->pos); |
---|
453 | break; |
---|
454 | |
---|
455 | case 2: |
---|
456 | break; |
---|
457 | |
---|
458 | case 3: |
---|
459 | for(j=nuc1;j<=nuc2;j++) |
---|
460 | { |
---|
461 | b1 = &(baselist[j]); |
---|
462 | b1->dforw.pair = -1; |
---|
463 | b1->dforw.dist = 0.0; |
---|
464 | b1->posnum = -1; |
---|
465 | cfree(b1->pos); |
---|
466 | } |
---|
467 | break; |
---|
468 | |
---|
469 | default: |
---|
470 | break; |
---|
471 | |
---|
472 | }; |
---|
473 | modified = TRUE; |
---|
474 | return; |
---|
475 | } |
---|
476 | |
---|
477 | |
---|
478 | StackHel(nuc1,nuc2) |
---|
479 | int nuc1,nuc2; |
---|
480 | { |
---|
481 | int j,k,branches=0,other_end,start,end; |
---|
482 | Base *base,*next; |
---|
483 | double dist1,dist2,sqrt(),fabs(); |
---|
484 | |
---|
485 | start=Min(nuc_sel1,nuc_sel2); |
---|
486 | end=Max(nuc_sel1,nuc_sel2); |
---|
487 | for(j=start;j<=end;j++) |
---|
488 | { |
---|
489 | base = &baselist[j]; |
---|
490 | if(base -> pair > j ) |
---|
491 | { |
---|
492 | branches=0; |
---|
493 | for(k=j+1;k!= base->pair;) |
---|
494 | { |
---|
495 | if(baselist[k].pair <k) |
---|
496 | k++; |
---|
497 | else |
---|
498 | { |
---|
499 | branches++; |
---|
500 | other_end=k; |
---|
501 | k=baselist[k].pair; |
---|
502 | } |
---|
503 | } |
---|
504 | |
---|
505 | if(branches == 1) |
---|
506 | { |
---|
507 | next = &baselist[other_end]; |
---|
508 | dist1=distance(base->x,base->y, |
---|
509 | next->x,next->y); |
---|
510 | |
---|
511 | next = &(baselist[next->pair]); |
---|
512 | base = &(baselist[base->pair]); |
---|
513 | dist2=distance(base->x,base->y, |
---|
514 | next->x,next->y); |
---|
515 | |
---|
516 | if(fabs(dist1-dist2)>.001) |
---|
517 | { |
---|
518 | if(dist1>dist2) |
---|
519 | dist1=dist2; |
---|
520 | |
---|
521 | if(dist1 < BASE_TO_BASE_DIST * 1.5) |
---|
522 | dist1*= 1.5; |
---|
523 | |
---|
524 | next->dforw.pair = baselist[j].pair; |
---|
525 | next->dforw.dist = dist1; |
---|
526 | next = &baselist[other_end]; |
---|
527 | base = &baselist[j]; |
---|
528 | base->dforw.pair = other_end; |
---|
529 | base->dforw.dist = dist1; |
---|
530 | modified = TRUE; |
---|
531 | |
---|
532 | } |
---|
533 | } |
---|
534 | base = &baselist[j]; |
---|
535 | } |
---|
536 | } |
---|
537 | return; |
---|
538 | } |
---|
539 | |
---|
540 | |
---|
541 | PlaceLabel(label,nucnum,pw) |
---|
542 | Label *label; |
---|
543 | int nucnum; |
---|
544 | Pixwin *pw; |
---|
545 | { |
---|
546 | Base *b; |
---|
547 | int j; |
---|
548 | double x,y,theta,xc,yc,sin(),cos(),atan2(); |
---|
549 | |
---|
550 | b = &(baselist[nucnum]); |
---|
551 | xc = (double)(CWID*strlen(label->text))*.5 / xscale; |
---|
552 | yc = (double)(CHT) *.5 / yscale; |
---|
553 | |
---|
554 | if(label -> distflag ==FALSE) |
---|
555 | { |
---|
556 | printf("error.\n"); |
---|
557 | x = b->x-xc+label->dx; |
---|
558 | y = b->y+yc+label->dy; |
---|
559 | } |
---|
560 | else |
---|
561 | { |
---|
562 | if(nucnum == 0) |
---|
563 | theta = atan2(b->y - baselist[1].y, |
---|
564 | b->x - baselist[1].x); |
---|
565 | else if(nucnum == seqlen-1) |
---|
566 | theta = atan2(baselist[seqlen-2].y - b->y, |
---|
567 | baselist[seqlen-2].x - b->x); |
---|
568 | else |
---|
569 | { |
---|
570 | theta = atan2(baselist[nucnum-1].y - |
---|
571 | baselist[nucnum+1].y, |
---|
572 | baselist[nucnum-1].x - |
---|
573 | baselist[nucnum+1].x); |
---|
574 | theta += (baselist[nucnum].dir == CW)? |
---|
575 | PI_o2 : -PI_o2; |
---|
576 | } |
---|
577 | |
---|
578 | x = b->x+label->dist*cos(theta)-xc; |
---|
579 | y = b->y+label->dist*sin(theta)-yc; |
---|
580 | } |
---|
581 | label -> x=x; |
---|
582 | label -> y=y; |
---|
583 | x = x*xscale+xoffset; |
---|
584 | y = y*yscale+yoffset; |
---|
585 | pw_text(pw,(int)x,(int)y,(PIX_SRC|PIX_DST),NULL,label->text); |
---|
586 | |
---|
587 | x = b->x+label->dist*cos(theta)-xc; |
---|
588 | y = b->y+label->dist*sin(theta)-yc; |
---|
589 | |
---|
590 | /* |
---|
591 | line((x+.15*(b->x-x)),(y+.15*(b->y-y)), |
---|
592 | (x+.85*(b->x-x)),(y+.85*(b->y-y)),1,pw); |
---|
593 | */ |
---|
594 | return; |
---|
595 | } |
---|
596 | |
---|
597 | |
---|
598 | IsLoop(n1,n2) |
---|
599 | int n1,n2; |
---|
600 | { |
---|
601 | int j, success = FALSE, last,step = 1; |
---|
602 | |
---|
603 | if(n1>n2) |
---|
604 | { |
---|
605 | j=n2; |
---|
606 | n2=n1; |
---|
607 | n1=j; |
---|
608 | } |
---|
609 | |
---|
610 | if(baselist[n1].pair != -1) |
---|
611 | { |
---|
612 | last = n1; |
---|
613 | j = baselist[n1].pair; |
---|
614 | for(;(j!=n1) && (success == FALSE);) |
---|
615 | { |
---|
616 | if(j==n2) |
---|
617 | success = TRUE; |
---|
618 | else |
---|
619 | { |
---|
620 | if(baselist[j].pair != -1 && |
---|
621 | baselist[j].pair != last) |
---|
622 | { |
---|
623 | last = j; |
---|
624 | j = baselist[j].pair; |
---|
625 | } |
---|
626 | else |
---|
627 | { |
---|
628 | last = j; |
---|
629 | j++; |
---|
630 | } |
---|
631 | } |
---|
632 | } |
---|
633 | } |
---|
634 | |
---|
635 | j = n1+1; |
---|
636 | for(;(j!=n1) && (success == FALSE);) |
---|
637 | { |
---|
638 | if(j==n2) |
---|
639 | success = TRUE; |
---|
640 | else |
---|
641 | { |
---|
642 | if(baselist[j].pair != -1 && |
---|
643 | baselist[j].pair != last) |
---|
644 | { |
---|
645 | last = j; |
---|
646 | j = baselist[j].pair; |
---|
647 | } |
---|
648 | else |
---|
649 | { |
---|
650 | last = j; |
---|
651 | j++; |
---|
652 | } |
---|
653 | } |
---|
654 | } |
---|
655 | return(success); |
---|
656 | } |
---|
657 | |
---|
658 | ShoCon() |
---|
659 | { |
---|
660 | int i,j; |
---|
661 | double x1,x2,y1,y2; |
---|
662 | Base b; |
---|
663 | |
---|
664 | for (i=0;i<seqlen;i++) |
---|
665 | { |
---|
666 | b=baselist[i]; |
---|
667 | if(b.dforw.pair != -1 && b.depth < ddepth) |
---|
668 | { |
---|
669 | x1 = b.x+(double)CWID/xscale*.5; |
---|
670 | y1 = b.y-(double)CHT/yscale*.5; |
---|
671 | x2 = baselist[b.dforw.pair].x+(double)CWID/xscale*.5; |
---|
672 | y2 = baselist[b.dforw.pair].y-(double)CHT/yscale*.5; |
---|
673 | |
---|
674 | line(x2+0.05*(x1-x2),y2+0.05*(y1-y2), |
---|
675 | x2+0.95*(x1-x2),y2+0.95*(y1-y2),3,canvas_paint_window(pagecan)); |
---|
676 | } |
---|
677 | if(b.posnum > 0 && b.depth < ddepth) |
---|
678 | { |
---|
679 | x1 = b.x+(double)CWID/xscale*.5; |
---|
680 | y1 = b.y-(double)CHT/yscale*.5; |
---|
681 | |
---|
682 | for(j=0;j<b.posnum;j++) |
---|
683 | { |
---|
684 | x2 = baselist[b.pos[j].pair].x+ |
---|
685 | (double)CWID/xscale*.5; |
---|
686 | |
---|
687 | y2 = baselist[b.pos[j].pair].y- |
---|
688 | (double)CHT/yscale*.5; |
---|
689 | |
---|
690 | line(x2+0.05*(x1-x2),y2+0.05*(y1-y2), |
---|
691 | x2+0.95*(x1-x2),y2+0.95*(y1-y2),6,canvas_paint_window(pagecan)); |
---|
692 | } |
---|
693 | } |
---|
694 | } |
---|
695 | return; |
---|
696 | } |
---|