2 implicit real*8 (a-h,o-z)
9 include 'COMMON.INTERACT'
10 include 'COMMON.IOUNITS'
11 include 'COMMON.DISTFIT'
12 include 'COMMON.SBRIDGE'
13 include 'COMMON.CONTROL'
14 include 'COMMON.FFIELD'
15 include 'COMMON.MINIM'
16 include 'COMMON.CHAIN'
17 double precision time0,time1
18 double precision energy(0:n_ene),ee
19 double precision var(maxvar),var1(maxvar)
21 logical debug,accepted
25 call geom_to_var(nvar,var1)
27 call etotal(energy(0))
30 write(iout,*) 'etot=',0,etot,rms
31 call secondary2(.false.)
33 call write_pdb(0,'first structure',etot)
42 betbol=1.0D0/(1.9858D-3*temp)
45 c phi(jr)=pinorm(phi(jr)+d)
47 call etotal(energy(0))
50 write(iout,*) 'etot=',1,etot0,rms
51 call write_pdb(1,'perturb structure',etot0)
57 phi(jr)=pinorm(phi(jr)+d)
59 call etotal(energy(0))
62 if (etot.lt.etot0) then
66 xxr=ran_number(0.0D0,1.0D0)
67 xxh=betbol*(etot-etot0)
68 if (xxh.lt.50.0D0) then
70 if (xxh.gt.xxr) accepted=.true.
74 c print *,etot0,etot,accepted
78 write(iout,*) 'etot=',i,etot,rms
79 call write_pdb(i,'MC structure',etot)
81 c call geom_to_var(nvar,var1)
82 call sc_move(2,nres-1,1,10d0,nft_sc,etot)
83 call geom_to_var(nvar,var)
84 call minimize(etot,var,iretcode,nfun)
85 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun
86 call var_to_geom(nvar,var)
89 write(iout,*) 'etot mcm=',i,etot,rms
90 call write_pdb(i+1,'MCM structure',etot)
91 call var_to_geom(nvar,var1)
99 c call sc_move(2,nres-1,1,10d0,nft_sc,etot)
100 c call geom_to_var(nvar,var)
103 c call write_pdb(998 ,'sc min',etot)
105 c call minimize(etot,var,iretcode,nfun)
106 c write(iout,*)'------------------------------------------------'
107 c write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun
109 c call var_to_geom(nvar,var)
111 c call write_pdb(999,'full min',etot)
119 implicit real*8 (a-h,o-z)
126 include 'COMMON.INTERACT'
127 include 'COMMON.IOUNITS'
128 include 'COMMON.DISTFIT'
129 include 'COMMON.SBRIDGE'
130 include 'COMMON.CONTROL'
131 include 'COMMON.FFIELD'
132 include 'COMMON.MINIM'
133 include 'COMMON.CHAIN'
134 double precision time0,time1
135 double precision energy(0:n_ene),ee
136 double precision var(maxvar),var1(maxvar)
142 call geom_to_var(nvar,var1)
144 call etotal(energy(0))
146 write(iout,*) nnt,nct,etot
147 call write_pdb(1,'first structure',etot)
148 call secondary2(.true.)
157 call var_to_geom(nvar,var1)
158 write(iout,*) 'N16 test',(jdata(i),i=1,5)
159 call beta_slide(jdata(1),jdata(2),jdata(3),jdata(4),jdata(5)
161 call geom_to_var(nvar,var)
169 call minimize(etot,var,iretcode,nfun)
170 write(iout,*)'------------------------------------------------'
171 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
172 & '+ DIST eval',ieval
178 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
179 & nfun/(time1-time0),' eval/s'
181 call var_to_geom(nvar,var)
183 call write_pdb(ij*100+99,'full min',etot)
193 subroutine test_local
194 implicit real*8 (a-h,o-z)
198 include 'COMMON.INTERACT'
199 include 'COMMON.IOUNITS'
200 double precision time0,time1
201 double precision energy(0:n_ene),ee
202 double precision varia(maxvar)
205 c call geom_to_var(nvar,varia)
206 call write_pdb(1,'first structure',0d0)
208 call etotal(energy(0))
210 write(iout,*) nnt,nct,etot
212 write(iout,*) 'calling sc_move'
213 call sc_move(nnt,nct,5,10d0,nft_sc,etot)
214 write(iout,*) nft_sc,etot
215 call write_pdb(2,'second structure',etot)
217 write(iout,*) 'calling local_move'
218 call local_move_init(.false.)
219 call local_move(24,29,20d0,50d0)
221 call write_pdb(3,'third structure',etot)
223 write(iout,*) 'calling sc_move'
224 call sc_move(24,29,5,10d0,nft_sc,etot)
225 write(iout,*) nft_sc,etot
226 call write_pdb(2,'last structure',etot)
233 implicit real*8 (a-h,o-z)
237 include 'COMMON.INTERACT'
238 include 'COMMON.IOUNITS'
239 double precision time0,time1
240 double precision energy(0:n_ene),ee
241 double precision varia(maxvar)
244 c call geom_to_var(nvar,varia)
245 call write_pdb(1,'first structure',0d0)
247 call etotal(energy(0))
249 write(iout,*) nnt,nct,etot
251 write(iout,*) 'calling sc_move'
253 call sc_move(nnt,nct,5,10d0,nft_sc,etot)
254 write(iout,*) nft_sc,etot
255 call write_pdb(2,'second structure',etot)
257 write(iout,*) 'calling sc_move 2nd time'
259 call sc_move(nnt,nct,5,1d0,nft_sc,etot)
260 write(iout,*) nft_sc,etot
261 call write_pdb(3,'last structure',etot)
264 c--------------------------------------------------------
265 subroutine bgrow(bstrand,nbstrand,in,ind,new)
266 implicit real*8 (a-h,o-z)
268 include 'COMMON.CHAIN'
269 integer bstrand(maxres/3,6)
271 ishift=iabs(bstrand(in,ind+4)-new)
273 print *,'bgrow',bstrand(in,ind+4),new,ishift
278 bstrand(nbstrand,5)=bstrand(nbstrand,1)
280 IF (bstrand(nbstrand,3).eq.bstrand(i,3)) THEN
281 if (bstrand(i,5).lt.bstrand(i,6)) then
282 bstrand(i,5)=bstrand(i,5)-ishift
284 bstrand(i,5)=bstrand(i,5)+ishift
289 bstrand(nbstrand,6)=bstrand(nbstrand,2)
291 IF (bstrand(nbstrand,3).eq.bstrand(i,3)) THEN
292 if (bstrand(i,6).lt.bstrand(i,5)) then
293 bstrand(i,6)=bstrand(i,6)-ishift
295 bstrand(i,6)=bstrand(i,6)+ishift
306 c------------------------------------------
308 implicit real*8 (a-h,o-z)
314 include 'COMMON.CHAIN'
315 include 'COMMON.IOUNITS'
317 include 'COMMON.CONTROL'
318 include 'COMMON.SBRIDGE'
319 include 'COMMON.FFIELD'
320 include 'COMMON.MINIM'
322 include 'COMMON.DISTFIT'
323 integer if(20,maxres),nif,ifa(20)
324 integer ibc(0:maxres,0:maxres),istrand(20)
325 integer ibd(maxres),ifb(10,2),nifb,lifb(10),lifb0
326 integer itmp(20,maxres)
327 double precision time0,time1
328 double precision energy(0:n_ene),ee
329 double precision varia(maxvar),vorg(maxvar)
331 logical debug,ltest,usedbfrag(maxres/3)
334 integer betasheet(maxres),ibetasheet(maxres),nbetasheet
335 integer bstrand(maxres/3,6),nbstrand
337 c------------------------
340 c------------------------
347 call geom_to_var(nvar,vorg)
348 call secondary2(debug)
350 if (nbfrag.le.1) return
357 nbetasheet=nbetasheet+1
359 bstrand(1,1)=bfrag(1,1)
360 bstrand(1,2)=bfrag(2,1)
361 bstrand(1,3)=nbetasheet
363 bstrand(1,5)=bfrag(1,1)
364 bstrand(1,6)=bfrag(2,1)
365 do i=bfrag(1,1),bfrag(2,1)
366 betasheet(i)=nbetasheet
370 bstrand(2,1)=bfrag(3,1)
371 bstrand(2,2)=bfrag(4,1)
372 bstrand(2,3)=nbetasheet
373 bstrand(2,5)=bfrag(3,1)
374 bstrand(2,6)=bfrag(4,1)
376 if (bfrag(3,1).le.bfrag(4,1)) then
378 do i=bfrag(3,1),bfrag(4,1)
379 betasheet(i)=nbetasheet
384 do i=bfrag(4,1),bfrag(3,1)
385 betasheet(i)=nbetasheet
392 do while (iused_nbfrag.ne.nbfrag)
396 IF (.not.usedbfrag(j)) THEN
398 write (*,*) j,(bfrag(i,j),i=1,4)
400 write (*,'(i4,a3,10i4)') jk,'B',(bstrand(i,jk),i=1,nbstrand)
402 write (*,*) '------------------'
405 if (bfrag(3,j).le.bfrag(4,j)) then
406 do i=bfrag(3,j),bfrag(4,j)
407 if(betasheet(i).eq.nbetasheet) then
409 do k=bfrag(3,j),bfrag(4,j)
410 betasheet(k)=nbetasheet
415 iused_nbfrag=iused_nbfrag+1
416 do k=bfrag(1,j),bfrag(2,j)
417 betasheet(k)=nbetasheet
418 ibetasheet(k)=nbstrand
420 if (bstrand(in,4).lt.0) then
421 bstrand(nbstrand,1)=bfrag(2,j)
422 bstrand(nbstrand,2)=bfrag(1,j)
423 bstrand(nbstrand,3)=nbetasheet
424 bstrand(nbstrand,4)=-nbstrand
425 bstrand(nbstrand,5)=bstrand(nbstrand,1)
426 bstrand(nbstrand,6)=bstrand(nbstrand,2)
427 if(bstrand(in,1).lt.bfrag(4,j)) then
428 call bgrow(bstrand,nbstrand,in,1,bfrag(4,j))
430 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
431 & (bstrand(in,5)-bfrag(4,j))
433 if(bstrand(in,2).gt.bfrag(3,j)) then
434 call bgrow(bstrand,nbstrand,in,2,bfrag(3,j))
436 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
437 & (-bstrand(in,6)+bfrag(3,j))
440 bstrand(nbstrand,1)=bfrag(1,j)
441 bstrand(nbstrand,2)=bfrag(2,j)
442 bstrand(nbstrand,3)=nbetasheet
443 bstrand(nbstrand,4)=nbstrand
444 bstrand(nbstrand,5)=bstrand(nbstrand,1)
445 bstrand(nbstrand,6)=bstrand(nbstrand,2)
446 if(bstrand(in,1).gt.bfrag(3,j)) then
447 call bgrow(bstrand,nbstrand,in,1,bfrag(3,j))
449 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
450 & (-bstrand(in,5)+bfrag(3,j))
452 if(bstrand(in,2).lt.bfrag(4,j)) then
453 call bgrow(bstrand,nbstrand,in,2,bfrag(4,j))
455 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
456 & (bstrand(in,6)-bfrag(4,j))
461 if(betasheet(bfrag(1,j)+i-bfrag(3,j)).eq.nbetasheet) then
462 in=ibetasheet(bfrag(1,j)+i-bfrag(3,j))
463 do k=bfrag(1,j),bfrag(2,j)
464 betasheet(k)=nbetasheet
469 iused_nbfrag=iused_nbfrag+1
470 do k=bfrag(3,1),bfrag(4,1)
471 betasheet(k)=nbetasheet
472 ibetasheet(k)=nbstrand
474 if (bstrand(in,4).lt.0) then
475 bstrand(nbstrand,1)=bfrag(4,j)
476 bstrand(nbstrand,2)=bfrag(3,j)
477 bstrand(nbstrand,3)=nbetasheet
478 bstrand(nbstrand,4)=-nbstrand
479 bstrand(nbstrand,5)=bstrand(nbstrand,1)
480 bstrand(nbstrand,6)=bstrand(nbstrand,2)
481 if(bstrand(in,1).lt.bfrag(2,j)) then
482 call bgrow(bstrand,nbstrand,in,1,bfrag(2,j))
484 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
485 & (bstrand(in,5)-bfrag(2,j))
487 if(bstrand(in,2).gt.bfrag(1,j)) then
488 call bgrow(bstrand,nbstrand,in,2,bfrag(1,j))
490 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
491 & (-bstrand(in,6)+bfrag(1,j))
494 bstrand(nbstrand,1)=bfrag(3,j)
495 bstrand(nbstrand,2)=bfrag(4,j)
496 bstrand(nbstrand,3)=nbetasheet
497 bstrand(nbstrand,4)=nbstrand
498 bstrand(nbstrand,5)=bstrand(nbstrand,1)
499 bstrand(nbstrand,6)=bstrand(nbstrand,2)
500 if(bstrand(in,1).gt.bfrag(1,j)) then
501 call bgrow(bstrand,nbstrand,in,1,bfrag(1,j))
503 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
504 & (-bstrand(in,5)+bfrag(1,j))
506 if(bstrand(in,2).lt.bfrag(2,j)) then
507 call bgrow(bstrand,nbstrand,in,2,bfrag(2,j))
509 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
510 & (bstrand(in,6)-bfrag(2,j))
517 do i=bfrag(4,j),bfrag(3,j)
518 if(betasheet(i).eq.nbetasheet) then
520 do k=bfrag(4,j),bfrag(3,j)
521 betasheet(k)=nbetasheet
526 iused_nbfrag=iused_nbfrag+1
527 do k=bfrag(1,j),bfrag(2,j)
528 betasheet(k)=nbetasheet
529 ibetasheet(k)=nbstrand
531 if (bstrand(in,4).lt.0) then
532 bstrand(nbstrand,1)=bfrag(1,j)
533 bstrand(nbstrand,2)=bfrag(2,j)
534 bstrand(nbstrand,3)=nbetasheet
535 bstrand(nbstrand,4)=nbstrand
536 bstrand(nbstrand,5)=bstrand(nbstrand,1)
537 bstrand(nbstrand,6)=bstrand(nbstrand,2)
538 if(bstrand(in,1).lt.bfrag(3,j)) then
539 call bgrow(bstrand,nbstrand,in,1,bfrag(3,j))
541 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
542 & (bstrand(in,5)-bfrag(3,j))
544 if(bstrand(in,2).gt.bfrag(4,j)) then
545 call bgrow(bstrand,nbstrand,in,2,bfrag(4,j))
547 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
548 & (-bstrand(in,6)+bfrag(4,j))
551 bstrand(nbstrand,1)=bfrag(2,j)
552 bstrand(nbstrand,2)=bfrag(1,j)
553 bstrand(nbstrand,3)=nbetasheet
554 bstrand(nbstrand,4)=-nbstrand
555 bstrand(nbstrand,5)=bstrand(nbstrand,1)
556 bstrand(nbstrand,6)=bstrand(nbstrand,2)
557 if(bstrand(in,1).gt.bfrag(4,j)) then
558 call bgrow(bstrand,nbstrand,in,1,bfrag(4,j))
560 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
561 & (-bstrand(in,5)+bfrag(4,j))
563 if(bstrand(in,2).lt.bfrag(3,j)) then
564 call bgrow(bstrand,nbstrand,in,2,bfrag(3,j))
566 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
567 & (bstrand(in,6)-bfrag(3,j))
572 if(betasheet(bfrag(2,j)-i+bfrag(4,j)).eq.nbetasheet) then
573 in=ibetasheet(bfrag(2,j)-i+bfrag(4,j))
574 do k=bfrag(1,j),bfrag(2,j)
575 betasheet(k)=nbetasheet
580 iused_nbfrag=iused_nbfrag+1
581 do k=bfrag(4,j),bfrag(3,j)
582 betasheet(k)=nbetasheet
583 ibetasheet(k)=nbstrand
585 if (bstrand(in,4).lt.0) then
586 bstrand(nbstrand,1)=bfrag(4,j)
587 bstrand(nbstrand,2)=bfrag(3,j)
588 bstrand(nbstrand,3)=nbetasheet
589 bstrand(nbstrand,4)=nbstrand
590 bstrand(nbstrand,5)=bstrand(nbstrand,1)
591 bstrand(nbstrand,6)=bstrand(nbstrand,2)
592 if(bstrand(in,1).lt.bfrag(2,j)) then
593 call bgrow(bstrand,nbstrand,in,1,bfrag(2,j))
595 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
596 & (bstrand(in,5)-bfrag(2,j))
598 if(bstrand(in,2).gt.bfrag(1,j)) then
599 call bgrow(bstrand,nbstrand,in,2,bfrag(1,j))
601 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
602 & (-bstrand(in,6)+bfrag(1,j))
605 bstrand(nbstrand,1)=bfrag(3,j)
606 bstrand(nbstrand,2)=bfrag(4,j)
607 bstrand(nbstrand,3)=nbetasheet
608 bstrand(nbstrand,4)=-nbstrand
609 bstrand(nbstrand,5)=bstrand(nbstrand,1)
610 bstrand(nbstrand,6)=bstrand(nbstrand,2)
611 if(bstrand(in,1).gt.bfrag(1,j)) then
612 call bgrow(bstrand,nbstrand,in,1,bfrag(1,j))
614 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
615 & (-bstrand(in,5)+bfrag(1,j))
617 if(bstrand(in,2).lt.bfrag(2,j)) then
618 call bgrow(bstrand,nbstrand,in,2,bfrag(2,j))
620 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
621 & (bstrand(in,6)-bfrag(2,j))
635 do while (usedbfrag(j))
640 nbetasheet=nbetasheet+1
641 bstrand(nbstrand,1)=bfrag(1,j)
642 bstrand(nbstrand,2)=bfrag(2,j)
643 bstrand(nbstrand,3)=nbetasheet
644 bstrand(nbstrand,5)=bfrag(1,j)
645 bstrand(nbstrand,6)=bfrag(2,j)
647 bstrand(nbstrand,4)=nbstrand
648 do i=bfrag(1,j),bfrag(2,j)
649 betasheet(i)=nbetasheet
650 ibetasheet(i)=nbstrand
654 bstrand(nbstrand,1)=bfrag(3,j)
655 bstrand(nbstrand,2)=bfrag(4,j)
656 bstrand(nbstrand,3)=nbetasheet
657 bstrand(nbstrand,5)=bfrag(3,j)
658 bstrand(nbstrand,6)=bfrag(4,j)
660 if (bfrag(3,j).le.bfrag(4,j)) then
661 bstrand(nbstrand,4)=nbstrand
662 do i=bfrag(3,j),bfrag(4,j)
663 betasheet(i)=nbetasheet
664 ibetasheet(i)=nbstrand
667 bstrand(nbstrand,4)=-nbstrand
668 do i=bfrag(4,j),bfrag(3,j)
669 betasheet(i)=nbetasheet
670 ibetasheet(i)=nbstrand
674 iused_nbfrag=iused_nbfrag+1
680 write (*,'(i4,a3,10i4)') jk,'A',(bstrand(i,jk),i=1,nbstrand)
687 if (betasheet(i).ne.0) write(*,*) i,betasheet(i),ibetasheet(i)
691 write (*,'(i4,a3,10i4)') j,':',(bstrand(i,j),i=1,nbstrand)
694 c------------------------
698 if(iabs(bstrand(i,5)-bstrand(j,5)).le.5 .or.
699 & iabs(bstrand(i,6)-bstrand(j,6)).le.5 ) then
701 ifb(nifb,1)=bstrand(i,4)
702 ifb(nifb,2)=bstrand(j,4)
709 write (*,'(a3,20i4)') "ifb",i,ifb(i,1),ifb(i,2)
715 write (*,'(a3,20i4)') "ifa",(ifa(i),i=1,nbstrand)
717 nif=iabs(bstrand(1,6)-bstrand(1,5))+1
719 if (iabs(bstrand(j,6)-bstrand(j,5))+1.gt.nif)
720 & nif=iabs(bstrand(j,6)-bstrand(j,5))+1
726 if(j,i)=bstrand(j,6)+(i-1)*sign(1,bstrand(j,5)-bstrand(j,6))
727 if (if(j,i).gt.0) then
728 if(betasheet(if(j,i)).eq.0 .or.
729 & ibetasheet(if(j,i)).ne.iabs(bstrand(j,4))) if(j,i)=0
734 write(*,'(a3,10i4)') 'if ',(if(j,i),j=1,nbstrand)
737 c read (inp,*) (ifa(i),i=1,4)
739 c read (inp,*,err=20,end=20) (if(j,i),j=1,4)
743 c------------------------
748 cccccccccccccccccccccccccccccccccc
750 cccccccccccccccccccccccccccccccccc
754 istrand(is-j+1)=int(ii/is**(is-j))
755 ii=ii-istrand(is-j+1)*is**(is-j)
759 istrand(k)=istrand(k)+1
760 if(istrand(k).gt.isa) istrand(k)=istrand(k)-2*isa-1
764 if(istrand(k).eq.istrand(l).and.k.ne.l.or.
765 & istrand(k).eq.-istrand(l).and.k.ne.l) ltest=.false.
774 & ifb(m,1).eq.istrand(k).and.ifb(m,2).eq.istrand(k+1).or.
775 & ifb(m,2).eq.istrand(k).and.ifb(m,1).eq.istrand(k+1).or.
776 & -ifb(m,1).eq.istrand(k).and.-ifb(m,2).eq.istrand(k+1).or.
777 & -ifb(m,2).eq.istrand(k).and.-ifb(m,1).eq.istrand(k+1))
783 if (mod(isa,2).eq.0) then
785 if (istrand(k).eq.1) ltest=.false.
789 if (istrand(k).eq.1) ltest=.false.
793 IF (ltest.and.lifb0.eq.1) THEN
796 call var_to_geom(nvar,vorg)
798 write (*,'(i5,i10,10i3)') iconf,ig,(istrand(k),k=1,isa)
799 write (iout,'(i5,i10,10i3)') iconf,ig,(istrand(k),k=1,isa)
800 write (linia,'(10i3)') (istrand(k),k=1,isa)
810 if ( sign(1,istrand(i)).eq.sign(1,ifa(iabs(istrand(i)))) ) then
812 itmp(iabs(istrand(i)),j)=if(iabs(ifa(iabs(istrand(i)))),j)
816 itmp(iabs(istrand(i)),j)=if(iabs(ifa(iabs(istrand(i)))),nif-j+1)
822 write(*,*) (itmp(j,i),j=1,4)
826 c ifa(1),ifa(2),ifa(3),ifa(4)
827 c if(1,i),if(2,i),if(3,i),if(4,i)
832 & ifb(m,1).eq.istrand(k).and.ifb(m,2).eq.istrand(k+1).or.
833 & ifb(m,2).eq.istrand(k).and.ifb(m,1).eq.istrand(k+1).or.
834 & -ifb(m,1).eq.istrand(k).and.-ifb(m,2).eq.istrand(k+1).or.
835 & -ifb(m,2).eq.istrand(k).and.-ifb(m,1).eq.istrand(k+1))
843 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+1)),i))=-1
845 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+1)),i))=-2
849 & ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+2)),i))=-3
851 & ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+3)),i))=-4
854 c------------------------
857 c freeze sec.elements
867 do i=bfrag(1,j),bfrag(2,j)
872 if (bfrag(3,j).le.bfrag(4,j)) then
873 do i=bfrag(3,j),bfrag(4,j)
879 do i=bfrag(4,j),bfrag(3,j)
887 do i=hfrag(1,j),hfrag(2,j)
895 c------------------------
896 c generate constrains
904 if ( ibc(i,j).eq.-1 .or. ibc(j,i).eq.-1) then
912 else if ( ibc(i,j).eq.-2 .or. ibc(j,i).eq.-2) then
920 else if ( ibc(i,j).eq.-3 .or. ibc(j,i).eq.-3) then
928 else if ( ibc(i,j).eq.-4 .or. ibc(j,i).eq.-4) then
936 else if ( ibc(i,j).gt.0 ) then
937 d0(ind)=DIST(i,ibc(i,j))
944 else if ( ibc(j,i).gt.0 ) then
945 d0(ind)=DIST(ibc(j,i),j)
959 cd--------------------------
961 write(iout,'(i3,2i4,a3,2i4,f7.2)') (i,ibc(ihpb(i),jhpb(i)),
962 & ibc(jhpb(i),ihpb(i)),' --',
963 & ihpb(i),jhpb(i),dhpb(i),i=1,nhpb)
969 call contact_cp_min(varia,ifun,iconf,linia,debug)
976 call minimize(etot,varia,iretcode,nfun)
977 write(iout,*)'------------------------------------------------'
978 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
985 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
986 & nfun/(time1-time0),' eval/s'
988 write (linia,'(a10,10i3)') 'full_min',(istrand(k),k=1,isa)
989 call var_to_geom(nvar,varia)
991 call write_pdb(900+iconf,linia,etot)
994 call etotal(energy(0))
996 call enerprint(energy(0))
998 cd call briefout(0,etot)
999 cd call secondary2(.true.)
1003 cccccccccccccccccccccccccccccccccccc
1006 cccccccccccccccccccccccccccccccccccc
1009 10 write (iout,'(a)') 'Error reading test structure.'
1012 c--------------------------------------------------------
1015 implicit real*8 (a-h,o-z)
1016 include 'DIMENSIONS'
1020 include 'COMMON.GEO'
1021 include 'COMMON.CHAIN'
1022 include 'COMMON.IOUNITS'
1023 include 'COMMON.VAR'
1024 include 'COMMON.CONTROL'
1025 include 'COMMON.SBRIDGE'
1026 include 'COMMON.FFIELD'
1027 include 'COMMON.MINIM'
1029 include 'COMMON.DISTFIT'
1030 integer if(3,maxres),nif
1031 integer ibc(maxres,maxres),istrand(20)
1032 integer ibd(maxres),ifb(10,2),nifb,lifb(10),lifb0
1033 double precision time0,time1
1034 double precision energy(0:n_ene),ee
1035 double precision varia(maxvar)
1041 read (inp,*,err=20,end=20) if(1,i),if(2,i),if(3,i)
1044 write (*,'(a4,3i5)') ('if =',if(1,i),if(2,i),if(3,i),
1048 c------------------------
1049 call secondary2(debug)
1050 c------------------------
1058 c freeze sec.elements and store indexes for beta constrains
1068 do i=bfrag(1,j),bfrag(2,j)
1073 if (bfrag(3,j).le.bfrag(4,j)) then
1074 do i=bfrag(3,j),bfrag(4,j)
1078 ibc(bfrag(1,j)+i-bfrag(3,j),i)=-1
1081 do i=bfrag(4,j),bfrag(3,j)
1085 ibc(bfrag(2,j)-i+bfrag(4,j),i)=-1
1090 do i=hfrag(1,j),hfrag(2,j)
1099 c ---------------- test --------------
1101 if (ibc(if(1,i),if(2,i)).eq.-1) then
1102 ibc(if(1,i),if(2,i))=if(3,i)
1103 ibc(if(1,i),if(3,i))=if(2,i)
1104 else if (ibc(if(2,i),if(1,i)).eq.-1) then
1105 ibc(if(2,i),if(1,i))=0
1106 ibc(if(1,i),if(2,i))=if(3,i)
1107 ibc(if(1,i),if(3,i))=if(2,i)
1109 ibc(if(1,i),if(2,i))=if(3,i)
1110 ibc(if(1,i),if(3,i))=if(2,i)
1116 if (ibc(i,j).ne.0) write(*,'(3i5)') i,j,ibc(i,j)
1119 c------------------------
1125 if ( ibc(i,j).eq.-1 ) then
1133 else if ( ibc(i,j).gt.0 ) then
1134 d0(ind)=DIST(i,ibc(i,j))
1141 else if ( ibc(j,i).gt.0 ) then
1142 d0(ind)=DIST(ibc(j,i),j)
1156 cd--------------------------
1157 write(*,'(i3,2i4,a3,2i4,f7.2)') (i,ibc(ihpb(i),jhpb(i)),
1158 & ibc(jhpb(i),ihpb(i)),' --',
1159 & ihpb(i),jhpb(i),dhpb(i),i=1,nhpb)
1166 call contact_cp_min(varia,ieval,in_pdb,linia,debug)
1173 call minimize(etot,varia,iretcode,nfun)
1174 write(iout,*)'------------------------------------------------'
1175 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
1176 & '+ DIST eval',ieval
1182 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
1183 & nfun/(time1-time0),' eval/s'
1186 call var_to_geom(nvar,varia)
1188 call write_pdb(999,'full min',etot)
1191 call etotal(energy(0))
1193 call enerprint(energy(0))
1195 call briefout(0,etot)
1196 call secondary2(.true.)
1199 10 write (iout,'(a)') 'Error reading test structure.'
1207 implicit real*8 (a-h,o-z)
1208 include 'DIMENSIONS'
1212 include 'COMMON.GEO'
1213 include 'COMMON.CHAIN'
1214 include 'COMMON.IOUNITS'
1215 include 'COMMON.VAR'
1216 include 'COMMON.CONTROL'
1217 include 'COMMON.SBRIDGE'
1218 include 'COMMON.FFIELD'
1219 include 'COMMON.MINIM'
1221 include 'COMMON.DISTFIT'
1224 double precision time0,time1
1225 double precision energy(0:n_ene),ee
1226 double precision theta2(maxres),phi2(maxres),alph2(maxres),
1228 & theta1(maxres),phi1(maxres),alph1(maxres),
1230 double precision varia(maxvar),varia2(maxvar)
1234 read (inp,*,err=10,end=10) if(1,1),if(1,2),if(2,1),if(2,2)
1235 write (iout,'(a4,4i5)') 'if =',if(1,1),if(1,2),if(2,1),if(2,2)
1236 read (inp,*,err=10,end=10) (theta2(i),i=3,nres)
1237 read (inp,*,err=10,end=10) (phi2(i),i=4,nres)
1238 read (inp,*,err=10,end=10) (alph2(i),i=2,nres-1)
1239 read (inp,*,err=10,end=10) (omeg2(i),i=2,nres-1)
1241 theta2(i)=deg2rad*theta2(i)
1242 phi2(i)=deg2rad*phi2(i)
1243 alph2(i)=deg2rad*alph2(i)
1244 omeg2(i)=deg2rad*omeg2(i)
1258 c------------------------
1263 do i=if(j,1),if(j,2)
1269 call geom_to_var(nvar,varia)
1270 call write_pdb(1,'first structure',0d0)
1272 call secondary(.true.)
1274 call secondary2(.true.)
1277 if ( (bfrag(3,j).lt.bfrag(4,j) .or.
1278 & bfrag(4,j)-bfrag(2,j).gt.4) .and.
1279 & bfrag(2,j)-bfrag(1,j).gt.3 ) then
1282 if (bfrag(3,j).lt.bfrag(4,j)) then
1283 write(iout,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1284 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
1285 & ,",",bfrag(3,j)-1,"-",bfrag(4,j)-1
1287 write(iout,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1288 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
1289 & ,",",bfrag(4,j)-1,"-",bfrag(3,j)-1
1302 call geom_to_var(nvar,varia2)
1303 call write_pdb(2,'second structure',0d0)
1307 c-------------------------------------------------------
1310 call contact_cp(varia,varia2,iff,ifun,7)
1317 call minimize(etot,varia,iretcode,nfun)
1318 write(iout,*)'------------------------------------------------'
1319 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
1320 & '+ DIST eval',ifun
1326 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
1327 & nfun/(time1-time0),' eval/s'
1330 call var_to_geom(nvar,varia)
1332 call write_pdb(999,'full min',etot)
1335 call etotal(energy(0))
1337 call enerprint(energy(0))
1339 call briefout(0,etot)
1342 10 write (iout,'(a)') 'Error reading test structure.'
1346 c-------------------------------------------------
1347 c-------------------------------------------------
1349 subroutine secondary(lprint)
1350 implicit real*8 (a-h,o-z)
1351 include 'DIMENSIONS'
1352 include 'COMMON.CHAIN'
1353 include 'COMMON.IOUNITS'
1354 include 'COMMON.DISTFIT'
1356 integer ncont,icont(2,maxres*maxres/2),isec(maxres,3)
1357 logical lprint,not_done
1358 real dcont(maxres*maxres/2),d
1363 double precision xpi(3),xpj(3)
1368 cd call write_pdb(99,'sec structure',0d0)
1380 xpi(k)=0.5d0*(c(k,i-1)+c(k,i))
1384 xpj(k)=0.5d0*(c(k,j-1)+c(k,j))
1386 cd d = (c(1,i)-c(1,j))*(c(1,i)-c(1,j)) +
1387 cd & (c(2,i)-c(2,j))*(c(2,i)-c(2,j)) +
1388 cd & (c(3,i)-c(3,j))*(c(3,i)-c(3,j))
1389 cd print *,'CA',i,j,d
1390 d = (xpi(1)-xpj(1))*(xpi(1)-xpj(1)) +
1391 & (xpi(2)-xpj(2))*(xpi(2)-xpj(2)) +
1392 & (xpi(3)-xpj(3))*(xpi(3)-xpj(3))
1393 if ( d.lt.rcomp*rcomp) then
1397 dcont(ncont)=sqrt(d)
1403 write (iout,'(a)') '#PP contact map distances:'
1405 write (iout,'(3i4,f10.5)')
1406 & i,icont(1,i),icont(2,i),dcont(i)
1410 c finding parallel beta
1411 cd write (iout,*) '------- looking for parallel beta -----------'
1417 if(dcont(i).le.rbeta .and. j1-i1.gt.4 .and.
1418 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1419 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1420 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1421 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1422 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1426 cd write (iout,*) i1,j1,dcont(i)
1432 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)
1433 & .and. dcont(j).le.rbeta .and.
1434 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1435 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1436 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1437 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1438 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1443 cd write (iout,*) i1,j1,dcont(j),not_done
1447 if (i1-ii1.gt.1) then
1451 if(lprint)write(iout,*)'parallel beta',nbeta,ii1,i1,jj1,j1
1460 isec(ij,1)=isec(ij,1)+1
1461 isec(ij,1+isec(ij,1))=nbeta
1464 isec(ij,1)=isec(ij,1)+1
1465 isec(ij,1+isec(ij,1))=nbeta
1470 if (nbeta.le.9) then
1471 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1472 & "DefPropRes 'strand",nstrand,
1473 & "' 'num = ",ii1-1,"..",i1-1,"'"
1475 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1476 & "DefPropRes 'strand",nstrand,
1477 & "' 'num = ",ii1-1,"..",i1-1,"'"
1480 if (nbeta.le.9) then
1481 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1482 & "DefPropRes 'strand",nstrand,
1483 & "' 'num = ",jj1-1,"..",j1-1,"'"
1485 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1486 & "DefPropRes 'strand",nstrand,
1487 & "' 'num = ",jj1-1,"..",j1-1,"'"
1489 write(12,'(a8,4i4)')
1490 & "SetNeigh",ii1-1,i1-1,jj1-1,j1-1
1496 c finding antiparallel beta
1497 cd write (iout,*) '--------- looking for antiparallel beta ---------'
1502 if (dcont(i).le.rbeta.and.
1503 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1504 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1505 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1506 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1507 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1511 cd write (iout,*) i1,j1,dcont(i)
1518 if (i1.eq.icont(1,j).and.j1.eq.icont(2,j) .and.
1519 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1520 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1521 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1522 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1523 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1524 & .and. dcont(j).le.rbeta ) goto 6
1528 cd write (iout,*) i1,j1,dcont(j),not_done
1532 if (i1-ii1.gt.1) then
1533 if(lprint)write (iout,*)'antiparallel beta',
1534 & nbeta,ii1-1,i1,jj1,j1-1
1537 bfrag(1,nbfrag)=max0(ii1-1,1)
1540 bfrag(4,nbfrag)=max0(j1-1,1)
1545 isec(ij,1)=isec(ij,1)+1
1546 isec(ij,1+isec(ij,1))=nbeta
1550 isec(ij,1)=isec(ij,1)+1
1551 isec(ij,1+isec(ij,1))=nbeta
1557 if (nstrand.le.9) then
1558 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1559 & "DefPropRes 'strand",nstrand,
1560 & "' 'num = ",ii1-2,"..",i1-1,"'"
1562 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1563 & "DefPropRes 'strand",nstrand,
1564 & "' 'num = ",ii1-2,"..",i1-1,"'"
1567 if (nstrand.le.9) then
1568 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1569 & "DefPropRes 'strand",nstrand,
1570 & "' 'num = ",j1-2,"..",jj1-1,"'"
1572 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1573 & "DefPropRes 'strand",nstrand,
1574 & "' 'num = ",j1-2,"..",jj1-1,"'"
1576 write(12,'(a8,4i4)')
1577 & "SetNeigh",ii1-2,i1-1,jj1-1,j1-2
1583 if (nstrand.gt.0.and.lprint) then
1584 write(12,'(a27,$)') "DefPropRes 'sheet' 'strand1"
1587 write(12,'(a9,i1,$)') " | strand",i
1589 write(12,'(a9,i2,$)') " | strand",i
1592 write(12,'(a1)') "'"
1596 c finding alpha or 310 helix
1602 if (j1.eq.i1+3.and.dcont(i).le.r310
1603 & .or.j1.eq.i1+4.and.dcont(i).le.ralfa ) then
1604 cd if (j1.eq.i1+3) write (iout,*) "found 1-4 ",i1,j1,dcont(i)
1605 cd if (j1.eq.i1+4) write (iout,*) "found 1-5 ",i1,j1,dcont(i)
1608 if (isec(ii1,1).eq.0) then
1617 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)) goto 10
1621 cd write (iout,*) i1,j1,not_done
1624 if (j1-ii1.gt.4) then
1626 cd write (iout,*)'helix',nhelix,ii1,j1
1630 hfrag(2,nhfrag)=max0(j1-1,1)
1636 write (iout,'(a6,i3,2i4)') "Helix",nhelix,ii1-1,j1-2
1637 if (nhelix.le.9) then
1638 write(12,'(a17,i1,a9,i3,a2,i3,a1)')
1639 & "DefPropRes 'helix",nhelix,
1640 & "' 'num = ",ii1-1,"..",j1-2,"'"
1642 write(12,'(a17,i2,a9,i3,a2,i3,a1)')
1643 & "DefPropRes 'helix",nhelix,
1644 & "' 'num = ",ii1-1,"..",j1-2,"'"
1651 if (nhelix.gt.0.and.lprint) then
1652 write(12,'(a26,$)') "DefPropRes 'helix' 'helix1"
1654 if (nhelix.le.9) then
1655 write(12,'(a8,i1,$)') " | helix",i
1657 write(12,'(a8,i2,$)') " | helix",i
1660 write(12,'(a1)') "'"
1664 write(12,'(a37)') "DefPropRes 'coil' '! (helix | sheet)'"
1665 write(12,'(a20)') "XMacStand ribbon.mac"
1671 c----------------------------------------------------------------------------
1673 subroutine write_pdb(npdb,titelloc,ee)
1674 implicit real*8 (a-h,o-z)
1675 include 'DIMENSIONS'
1676 include 'COMMON.IOUNITS'
1677 character*50 titelloc1
1678 character*(*) titelloc
1687 if (npdb.lt.1000) then
1688 call numstr(npdb,zahl)
1689 open(ipdb,file=prefix(:lenpre)//'@@'//zahl//'.pdb')
1691 if (npdb.lt.10000) then
1692 write(liczba5,'(i1,i4)') 0,npdb
1694 write(liczba5,'(i5)') npdb
1696 open(ipdb,file=prefix(:lenpre)//'@@'//liczba5//'.pdb')
1698 call pdbout(ee,titelloc1,ipdb)
1703 c-----------------------------------------------------------
1704 subroutine contact_cp2(var,var2,iff,ieval,in_pdb)
1705 implicit real*8 (a-h,o-z)
1706 include 'DIMENSIONS'
1710 include 'COMMON.SBRIDGE'
1711 include 'COMMON.FFIELD'
1712 include 'COMMON.IOUNITS'
1713 include 'COMMON.DISTFIT'
1714 include 'COMMON.VAR'
1715 include 'COMMON.CHAIN'
1716 include 'COMMON.MINIM'
1720 double precision var(maxvar),var2(maxvar)
1721 double precision time0,time1
1722 integer iff(maxres),ieval
1723 double precision theta1(maxres),phi1(maxres),alph1(maxres),
1727 call var_to_geom(nvar,var)
1734 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
1756 call var_to_geom(nvar,var2)
1759 if ( iff(i).eq.1 ) then
1768 cd call write_pdb(3,'combined structure',0d0)
1769 cd time0=MPI_WTIME()
1772 NY=((NRES-4)*(NRES-5))/2
1773 call distfit(.true.,200)
1775 cd time1=MPI_WTIME()
1776 cd write (iout,'(a,f6.2,a)') ' Time for distfit ',time1-time0,' sec'
1786 call geom_to_var(nvar,var)
1787 cd time0=MPI_WTIME()
1788 call minimize(etot,var,iretcode,nfun)
1789 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
1791 cd time1=MPI_WTIME()
1792 cd write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
1793 cd & nfun/(time1-time0),' SOFT eval/s'
1794 call var_to_geom(nvar,var)
1800 if (iff(1).eq.1) then
1806 if ( iwsk.eq.0.and.iff(i-1).eq.0.and.iff(i).eq.1 ) then
1811 if ( iwsk.eq.1.and.iff(i-1).eq.1.and.iff(i).eq.0 ) then
1817 if (iff(nres).eq.1) then
1823 cd write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1824 cd & "select",ij(1),"-",ij(2),
1825 cd & ",",ij(3),"-",ij(4)
1826 cd call write_pdb(in_pdb,linia,etot)
1832 cd time0=MPI_WTIME()
1833 call minimize(etot,var,iretcode,nfun)
1834 cd write(iout,*)'SUMSL DIST return code is',iretcode,' eval ',nfun
1837 cd time1=MPI_WTIME()
1838 cd write (iout,'(a,f6.2,f8.2,a)')' Time for DIST min.',time1-time0,
1839 cd & nfun/(time1-time0),' eval/s'
1840 cd call var_to_geom(nvar,var)
1842 cd call write_pdb(6,'dist structure',etot)
1852 c-----------------------------------------------------------
1853 subroutine contact_cp(var,var2,iff,ieval,in_pdb)
1854 implicit real*8 (a-h,o-z)
1855 include 'DIMENSIONS'
1856 include 'COMMON.SBRIDGE'
1857 include 'COMMON.FFIELD'
1858 include 'COMMON.IOUNITS'
1859 include 'COMMON.DISTFIT'
1860 include 'COMMON.VAR'
1861 include 'COMMON.CHAIN'
1862 include 'COMMON.MINIM'
1866 double precision energy(0:n_ene)
1867 double precision var(maxvar),var2(maxvar)
1868 double precision time0,time1
1869 integer iff(maxres),ieval
1870 double precision theta1(maxres),phi1(maxres),alph1(maxres),
1876 if (ieval.eq.-1) debug=.true.
1880 c store selected dist. constrains from 1st structure
1883 c Intercept NaNs in the coordinates
1884 c write(iout,*) (var(i),i=1,nvar)
1889 if (x_sum.ne.x_sum) then
1890 write(iout,*)" *** contact_cp : Found NaN in coordinates"
1892 print *," *** contact_cp : Found NaN in coordinates"
1898 call var_to_geom(nvar,var)
1905 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
1928 c freeze sec.elements from 2nd structure
1936 call var_to_geom(nvar,var2)
1937 call secondary2(debug)
1939 do i=bfrag(1,j),bfrag(2,j)
1944 if (bfrag(3,j).le.bfrag(4,j)) then
1945 do i=bfrag(3,j),bfrag(4,j)
1951 do i=bfrag(4,j),bfrag(3,j)
1959 do i=hfrag(1,j),hfrag(2,j)
1968 c copy selected res from 1st to 2nd structure
1972 if ( iff(i).eq.1 ) then
1982 c prepare description in linia variable
1986 if (iff(1).eq.1) then
1992 if ( iwsk.eq.0.and.iff(i-1).eq.0.and.iff(i).eq.1 ) then
1997 if ( iwsk.eq.1.and.iff(i-1).eq.1.and.iff(i).eq.0 ) then
2003 if (iff(nres).eq.1) then
2008 write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
2009 & "SELECT",ij(1)-1,"-",ij(2)-1,
2010 & ",",ij(3)-1,"-",ij(4)-1
2016 call contact_cp_min(var,ieval,in_pdb,linia,debug)
2021 subroutine contact_cp_min(var,ieval,in_pdb,linia,debug)
2023 c input : theta,phi,alph,omeg,in_pdb,linia,debug
2024 c output : var,ieval
2026 implicit real*8 (a-h,o-z)
2027 include 'DIMENSIONS'
2031 include 'COMMON.SBRIDGE'
2032 include 'COMMON.FFIELD'
2033 include 'COMMON.IOUNITS'
2034 include 'COMMON.DISTFIT'
2035 include 'COMMON.VAR'
2036 include 'COMMON.CHAIN'
2037 include 'COMMON.MINIM'
2041 double precision energy(0:n_ene)
2042 double precision var(maxvar)
2043 double precision time0,time1
2044 integer ieval,info(3)
2045 logical debug,fail,check_var,reduce,change
2047 write(iout,'(a20,i6,a20)')
2048 & '------------------',in_pdb,'-------------------'
2052 call write_pdb(1000+in_pdb,'combined structure',0d0)
2061 c run optimization of distances
2063 c uses d0(),w() and mask() for frozen 2D
2065 ctest---------------------------------------------
2067 ctest NY=((NRES-4)*(NRES-5))/2
2068 ctest call distfit(debug,5000)
2100 call geom_to_var(nvar,var)
2101 cde change=reduce(var)
2102 if (check_var(var,info)) then
2103 write(iout,*) 'cp_min error in input'
2104 print *,'cp_min error in input'
2108 cd call etotal(energy(0))
2109 cd call enerprint(energy(0))
2117 cdtest call minimize(etot,var,iretcode,nfun)
2118 cdtest write(iout,*)'SUMSL return code is',iretcode,' eval SDIST',nfun
2124 cd call etotal(energy(0))
2125 cd call enerprint(energy(0))
2144 ctest--------------------------------------------------
2152 write (iout,'(a,f6.2,a)')' Time for distfit ',time1-time0,' sec'
2153 call write_pdb(2000+in_pdb,'distfit structure',0d0)
2162 c run soft pot. optimization
2164 c nhpb,ihpb(),jhpb(),forcon(),dhpb() and hpb_partition
2166 c mask_phi(),mask_theta(),mask_side(),mask_r
2172 cde change=reduce(var)
2173 cde if (check_var(var,info)) write(iout,*) 'error before soft'
2179 call minimize(etot,var,iretcode,nfun)
2181 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
2187 write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
2188 & nfun/(time1-time0),' SOFT eval/s'
2190 call var_to_geom(nvar,var)
2192 call write_pdb(3000+in_pdb,'soft structure',etot)
2195 c run full UNRES optimization with constrains and frozen 2D
2196 c the same variables as soft pot. optimizatio
2202 c check overlaps before calling full UNRES minim
2204 call var_to_geom(nvar,var)
2206 call etotal(energy(0))
2208 write(iout,*) 'N7 ',energy(0)
2209 if (energy(0).ne.energy(0)) then
2210 write(iout,*) 'N7 error - gives NaN',energy(0)
2214 if (energy(1).eq.1.0d20) then
2215 write (iout,'(a,1pe14.5)')'#N7_OVERLAP evdw=1d20',energy(1)
2216 call overlap_sc(fail)
2218 call etotal(energy(0))
2220 write (iout,'(a,1pe14.5)')'#N7_OVERLAP evdw after',energy(1)
2232 cdte time0=MPI_WTIME()
2233 cde change=reduce(var)
2234 cde if (check_var(var,info)) then
2235 cde write(iout,*) 'error before mask dist'
2236 cde call var_to_geom(nvar,var)
2238 cde call write_pdb(10000+in_pdb,'before mask dist',etot)
2240 cdte call minimize(etot,var,iretcode,nfun)
2241 cdte write(iout,*)'SUMSL MASK DIST return code is',iretcode,
2242 cdte & ' eval ',nfun
2243 cdte ieval=ieval+nfun
2245 cdte time1=MPI_WTIME()
2246 cdte write (iout,'(a,f6.2,f8.2,a)')
2247 cdte & ' Time for mask dist min.',time1-time0,
2248 cdte & nfun/(time1-time0),' eval/s'
2249 cdte call flush(iout)
2251 call var_to_geom(nvar,var)
2253 call write_pdb(4000+in_pdb,'mask dist',etot)
2256 c switch off freezing of 2D and
2257 c run full UNRES optimization with constrains
2265 cde change=reduce(var)
2266 cde if (check_var(var,info)) then
2267 cde write(iout,*) 'error before dist'
2268 cde call var_to_geom(nvar,var)
2270 cde call write_pdb(11000+in_pdb,'before dist',etot)
2273 call minimize(etot,var,iretcode,nfun)
2275 cde change=reduce(var)
2276 cde if (check_var(var,info)) then
2277 cde write(iout,*) 'error after dist',ico
2278 cde call var_to_geom(nvar,var)
2280 cde call write_pdb(12000+in_pdb+ico*1000,'after dist',etot)
2282 write(iout,*)'SUMSL DIST return code is',iretcode,' eval ',nfun
2289 write (iout,'(a,f6.2,f8.2,a)')' Time for dist min.',time1-time0,
2290 & nfun/(time1-time0),' eval/s'
2291 cde call etotal(energy(0))
2292 cde write(iout,*) 'N7 after dist',energy(0)
2296 call var_to_geom(nvar,var)
2298 call write_pdb(in_pdb,linia,etot)
2310 c--------------------------------------------------------
2312 implicit real*8 (a-h,o-z)
2313 include 'DIMENSIONS'
2317 include 'COMMON.GEO'
2318 include 'COMMON.CHAIN'
2319 include 'COMMON.IOUNITS'
2320 include 'COMMON.VAR'
2321 include 'COMMON.CONTROL'
2322 include 'COMMON.SBRIDGE'
2323 include 'COMMON.FFIELD'
2324 include 'COMMON.MINIM'
2325 include 'COMMON.INTERACT'
2327 include 'COMMON.DISTFIT'
2329 double precision time0,time1
2330 double precision energy(0:n_ene),ee
2331 double precision var(maxvar)
2334 logical debug,ltest,fail
2343 c------------------------
2345 c freeze sec.elements
2355 do i=bfrag(1,j),bfrag(2,j)
2360 if (bfrag(3,j).le.bfrag(4,j)) then
2361 do i=bfrag(3,j),bfrag(4,j)
2367 do i=bfrag(4,j),bfrag(3,j)
2375 do i=hfrag(1,j),hfrag(2,j)
2387 c store dist. constrains
2391 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
2396 dhpb(nhpb)=DIST(i,j)
2404 call write_pdb(100+in_pdb,'input reg. structure',0d0)
2414 c run soft pot. optimization
2420 call geom_to_var(nvar,var)
2426 call minimize(etot,var,iretcode,nfun)
2428 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
2434 write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
2435 & nfun/(time1-time0),' SOFT eval/s'
2437 call var_to_geom(nvar,var)
2439 call write_pdb(300+in_pdb,'soft structure',etot)
2442 c run full UNRES optimization with constrains and frozen 2D
2443 c the same variables as soft pot. optimizatio
2454 call minimize(etot,var,iretcode,nfun)
2455 write(iout,*)'SUMSL MASK DIST return code is',iretcode,
2463 write (iout,'(a,f6.2,f8.2,a)')
2464 & ' Time for mask dist min.',time1-time0,
2465 & nfun/(time1-time0),' eval/s'
2467 call var_to_geom(nvar,var)
2469 call write_pdb(400+in_pdb,'mask & dist',etot)
2472 c switch off constrains and
2473 c run full UNRES optimization with frozen 2D
2490 call minimize(etot,var,iretcode,nfun)
2491 write(iout,*)'SUMSL MASK return code is',iretcode,' eval ',nfun
2498 write (iout,'(a,f6.2,f8.2,a)')' Time for mask min.',time1-time0,
2499 & nfun/(time1-time0),' eval/s'
2503 call var_to_geom(nvar,var)
2505 call write_pdb(500+in_pdb,'mask 2d frozen',etot)
2512 c run full UNRES optimization with constrains and NO frozen 2D
2522 wstrain=wstrain0/ico
2528 call minimize(etot,var,iretcode,nfun)
2529 write(iout,'(a10,f6.3,a14,i3,a6,i5)')
2530 & ' SUMSL DIST',wstrain,' return code is',iretcode,
2538 write (iout,'(a,f6.2,f8.2,a)')
2539 & ' Time for dist min.',time1-time0,
2540 & nfun/(time1-time0),' eval/s'
2542 call var_to_geom(nvar,var)
2544 call write_pdb(600+in_pdb+ico,'dist cons',etot)
2563 call minimize(etot,var,iretcode,nfun)
2564 write(iout,*)'------------------------------------------------'
2565 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
2566 & '+ DIST eval',ieval
2572 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
2573 & nfun/(time1-time0),' eval/s'
2576 call var_to_geom(nvar,var)
2578 call write_pdb(999,'full min',etot)
2585 subroutine beta_slide(i1,i2,i3,i4,i5,ieval,ij)
2586 implicit real*8 (a-h,o-z)
2587 include 'DIMENSIONS'
2591 include 'COMMON.GEO'
2592 include 'COMMON.VAR'
2593 include 'COMMON.INTERACT'
2594 include 'COMMON.IOUNITS'
2595 include 'COMMON.DISTFIT'
2596 include 'COMMON.SBRIDGE'
2597 include 'COMMON.CONTROL'
2598 include 'COMMON.FFIELD'
2599 include 'COMMON.MINIM'
2600 include 'COMMON.CHAIN'
2601 double precision time0,time1
2602 double precision energy(0:n_ene),ee
2603 double precision var(maxvar)
2604 integer jdata(5),isec(maxres)
2612 call secondary2(.false.)
2618 do i=bfrag(1,j),bfrag(2,j)
2621 do i=bfrag(4,j),bfrag(3,j),sign(1,bfrag(3,j)-bfrag(4,j))
2626 do i=hfrag(1,j),hfrag(2,j)
2632 c cut strands at the ends
2634 if (jdata(2)-jdata(1).gt.3) then
2637 if (jdata(3).lt.jdata(4)) then
2647 cv call etotal(energy(0))
2649 cv write(iout,*) nnt,nct,etot
2650 cv call write_pdb(ij*100,'first structure',etot)
2651 cv write(iout,*) 'N16 test',(jdata(i),i=1,5)
2653 c------------------------
2654 c generate constrains
2657 if(ishift.eq.0) ishift=-2
2660 do i=jdata(1),jdata(2)
2662 if(jdata(4).gt.jdata(3))then
2663 do j=jdata(3)+i-jdata(1)-2,jdata(3)+i-jdata(1)+2
2665 cd print *,i,j,j+ishift
2670 dhpb(nhpb)=DIST(i,j+ishift)
2673 do j=jdata(3)-i+jdata(1)+2,jdata(3)-i+jdata(1)-2,-1
2675 cd print *,i,j,j+ishift
2680 dhpb(nhpb)=DIST(i,j+ishift)
2687 if(isec(i).gt.0.or.isec(j).gt.0) then
2693 dhpb(nhpb)=DIST(i,j)
2700 call geom_to_var(nvar,var)
2707 wstrain=wstrain0/ico
2709 cv time0=MPI_WTIME()
2710 call minimize(etot,var,iretcode,nfun)
2711 write(iout,'(a10,f6.3,a14,i3,a6,i5)')
2712 & ' SUMSL DIST',wstrain,' return code is',iretcode,
2715 cv time1=MPI_WTIME()
2716 cv write (iout,'(a,f6.2,f8.2,a)')
2717 cv & ' Time for dist min.',time1-time0,
2718 cv & nfun/(time1-time0),' eval/s'
2719 cv call var_to_geom(nvar,var)
2721 cv call write_pdb(ij*100+ico,'dist cons',etot)
2733 call sc_move(nnt,nct,100,100d0,nft_sc,etot)
2736 cv call etotal(energy(0))
2738 cv call write_pdb(ij*100+10,'sc_move',etot)
2740 cd print *,nft_sc,etot
2745 subroutine beta_zip(i1,i2,ieval,ij)
2746 implicit real*8 (a-h,o-z)
2747 include 'DIMENSIONS'
2751 include 'COMMON.GEO'
2752 include 'COMMON.VAR'
2753 include 'COMMON.INTERACT'
2754 include 'COMMON.IOUNITS'
2755 include 'COMMON.DISTFIT'
2756 include 'COMMON.SBRIDGE'
2757 include 'COMMON.CONTROL'
2758 include 'COMMON.FFIELD'
2759 include 'COMMON.MINIM'
2760 include 'COMMON.CHAIN'
2761 double precision time0,time1
2762 double precision energy(0:n_ene),ee
2763 double precision var(maxvar)
2767 cv call etotal(energy(0))
2769 cv write(test,'(2i5)') i1,i2
2770 cv call write_pdb(ij*100,test,etot)
2771 cv write(iout,*) 'N17 test',i1,i2,etot,ij
2774 c generate constrains
2785 call geom_to_var(nvar,var)
2791 wstrain=wstrain0/ico
2792 cv time0=MPI_WTIME()
2793 call minimize(etot,var,iretcode,nfun)
2794 write(iout,'(a10,f6.3,a14,i3,a6,i5)')
2795 & ' SUMSL DIST',wstrain,' return code is',iretcode,
2798 cv time1=MPI_WTIME()
2799 cv write (iout,'(a,f6.2,f8.2,a)')
2800 cv & ' Time for dist min.',time1-time0,
2801 cv & nfun/(time1-time0),' eval/s'
2802 c do not comment the next line
2803 call var_to_geom(nvar,var)
2805 cv call write_pdb(ij*100+ico,'dist cons',etot)
2813 cv call etotal(energy(0))
2815 cv write(iout,*) 'N17 test end',i1,i2,etot,ij