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
179 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
180 & nfun/(time1-time0),' eval/s'
182 call var_to_geom(nvar,var)
184 call write_pdb(ij*100+99,'full min',etot)
194 subroutine test_local
195 implicit real*8 (a-h,o-z)
199 include 'COMMON.INTERACT'
200 include 'COMMON.IOUNITS'
201 double precision time0,time1
202 double precision energy(0:n_ene),ee
203 double precision varia(maxvar)
206 c call geom_to_var(nvar,varia)
207 call write_pdb(1,'first structure',0d0)
209 call etotal(energy(0))
211 write(iout,*) nnt,nct,etot
213 write(iout,*) 'calling sc_move'
214 call sc_move(nnt,nct,5,10d0,nft_sc,etot)
215 write(iout,*) nft_sc,etot
216 call write_pdb(2,'second structure',etot)
218 write(iout,*) 'calling local_move'
219 call local_move_init(.false.)
220 call local_move(24,29,20d0,50d0)
222 call write_pdb(3,'third structure',etot)
224 write(iout,*) 'calling sc_move'
225 call sc_move(24,29,5,10d0,nft_sc,etot)
226 write(iout,*) nft_sc,etot
227 call write_pdb(2,'last structure',etot)
234 implicit real*8 (a-h,o-z)
238 include 'COMMON.INTERACT'
239 include 'COMMON.IOUNITS'
240 double precision time0,time1
241 double precision energy(0:n_ene),ee
242 double precision varia(maxvar)
245 c call geom_to_var(nvar,varia)
246 call write_pdb(1,'first structure',0d0)
248 call etotal(energy(0))
250 write(iout,*) nnt,nct,etot
252 write(iout,*) 'calling sc_move'
254 call sc_move(nnt,nct,5,10d0,nft_sc,etot)
255 write(iout,*) nft_sc,etot
256 call write_pdb(2,'second structure',etot)
258 write(iout,*) 'calling sc_move 2nd time'
260 call sc_move(nnt,nct,5,1d0,nft_sc,etot)
261 write(iout,*) nft_sc,etot
262 call write_pdb(3,'last structure',etot)
265 c--------------------------------------------------------
266 subroutine bgrow(bstrand,nbstrand,in,ind,new)
267 implicit real*8 (a-h,o-z)
269 include 'COMMON.CHAIN'
270 integer bstrand(maxres/3,6)
272 ishift=iabs(bstrand(in,ind+4)-new)
274 print *,'bgrow',bstrand(in,ind+4),new,ishift
279 bstrand(nbstrand,5)=bstrand(nbstrand,1)
281 IF (bstrand(nbstrand,3).eq.bstrand(i,3)) THEN
282 if (bstrand(i,5).lt.bstrand(i,6)) then
283 bstrand(i,5)=bstrand(i,5)-ishift
285 bstrand(i,5)=bstrand(i,5)+ishift
290 bstrand(nbstrand,6)=bstrand(nbstrand,2)
292 IF (bstrand(nbstrand,3).eq.bstrand(i,3)) THEN
293 if (bstrand(i,6).lt.bstrand(i,5)) then
294 bstrand(i,6)=bstrand(i,6)-ishift
296 bstrand(i,6)=bstrand(i,6)+ishift
307 c------------------------------------------
309 implicit real*8 (a-h,o-z)
315 include 'COMMON.CHAIN'
316 include 'COMMON.IOUNITS'
318 include 'COMMON.CONTROL'
319 include 'COMMON.SBRIDGE'
320 include 'COMMON.FFIELD'
321 include 'COMMON.MINIM'
323 include 'COMMON.DISTFIT'
324 integer if(20,maxres),nif,ifa(20)
325 integer ibc(0:maxres,0:maxres),istrand(20)
326 integer ibd(maxres),ifb(10,2),nifb,lifb(10),lifb0
327 integer itmp(20,maxres)
328 double precision time0,time1
329 double precision energy(0:n_ene),ee
330 double precision varia(maxvar),vorg(maxvar)
332 logical debug,ltest,usedbfrag(maxres/3)
335 integer betasheet(maxres),ibetasheet(maxres),nbetasheet
336 integer bstrand(maxres/3,6),nbstrand
338 c------------------------
341 c------------------------
348 call geom_to_var(nvar,vorg)
349 call secondary2(debug)
351 if (nbfrag.le.1) return
358 nbetasheet=nbetasheet+1
360 bstrand(1,1)=bfrag(1,1)
361 bstrand(1,2)=bfrag(2,1)
362 bstrand(1,3)=nbetasheet
364 bstrand(1,5)=bfrag(1,1)
365 bstrand(1,6)=bfrag(2,1)
366 do i=bfrag(1,1),bfrag(2,1)
367 betasheet(i)=nbetasheet
371 bstrand(2,1)=bfrag(3,1)
372 bstrand(2,2)=bfrag(4,1)
373 bstrand(2,3)=nbetasheet
374 bstrand(2,5)=bfrag(3,1)
375 bstrand(2,6)=bfrag(4,1)
377 if (bfrag(3,1).le.bfrag(4,1)) then
379 do i=bfrag(3,1),bfrag(4,1)
380 betasheet(i)=nbetasheet
385 do i=bfrag(4,1),bfrag(3,1)
386 betasheet(i)=nbetasheet
393 do while (iused_nbfrag.ne.nbfrag)
397 IF (.not.usedbfrag(j)) THEN
399 write (*,*) j,(bfrag(i,j),i=1,4)
401 write (*,'(i4,a3,10i4)') jk,'B',(bstrand(i,jk),i=1,nbstrand)
403 write (*,*) '------------------'
406 if (bfrag(3,j).le.bfrag(4,j)) then
407 do i=bfrag(3,j),bfrag(4,j)
408 if(betasheet(i).eq.nbetasheet) then
410 do k=bfrag(3,j),bfrag(4,j)
411 betasheet(k)=nbetasheet
416 iused_nbfrag=iused_nbfrag+1
417 do k=bfrag(1,j),bfrag(2,j)
418 betasheet(k)=nbetasheet
419 ibetasheet(k)=nbstrand
421 if (bstrand(in,4).lt.0) then
422 bstrand(nbstrand,1)=bfrag(2,j)
423 bstrand(nbstrand,2)=bfrag(1,j)
424 bstrand(nbstrand,3)=nbetasheet
425 bstrand(nbstrand,4)=-nbstrand
426 bstrand(nbstrand,5)=bstrand(nbstrand,1)
427 bstrand(nbstrand,6)=bstrand(nbstrand,2)
428 if(bstrand(in,1).lt.bfrag(4,j)) then
429 call bgrow(bstrand,nbstrand,in,1,bfrag(4,j))
431 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
432 & (bstrand(in,5)-bfrag(4,j))
434 if(bstrand(in,2).gt.bfrag(3,j)) then
435 call bgrow(bstrand,nbstrand,in,2,bfrag(3,j))
437 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
438 & (-bstrand(in,6)+bfrag(3,j))
441 bstrand(nbstrand,1)=bfrag(1,j)
442 bstrand(nbstrand,2)=bfrag(2,j)
443 bstrand(nbstrand,3)=nbetasheet
444 bstrand(nbstrand,4)=nbstrand
445 bstrand(nbstrand,5)=bstrand(nbstrand,1)
446 bstrand(nbstrand,6)=bstrand(nbstrand,2)
447 if(bstrand(in,1).gt.bfrag(3,j)) then
448 call bgrow(bstrand,nbstrand,in,1,bfrag(3,j))
450 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
451 & (-bstrand(in,5)+bfrag(3,j))
453 if(bstrand(in,2).lt.bfrag(4,j)) then
454 call bgrow(bstrand,nbstrand,in,2,bfrag(4,j))
456 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
457 & (bstrand(in,6)-bfrag(4,j))
462 if(betasheet(bfrag(1,j)+i-bfrag(3,j)).eq.nbetasheet) then
463 in=ibetasheet(bfrag(1,j)+i-bfrag(3,j))
464 do k=bfrag(1,j),bfrag(2,j)
465 betasheet(k)=nbetasheet
470 iused_nbfrag=iused_nbfrag+1
471 do k=bfrag(3,1),bfrag(4,1)
472 betasheet(k)=nbetasheet
473 ibetasheet(k)=nbstrand
475 if (bstrand(in,4).lt.0) then
476 bstrand(nbstrand,1)=bfrag(4,j)
477 bstrand(nbstrand,2)=bfrag(3,j)
478 bstrand(nbstrand,3)=nbetasheet
479 bstrand(nbstrand,4)=-nbstrand
480 bstrand(nbstrand,5)=bstrand(nbstrand,1)
481 bstrand(nbstrand,6)=bstrand(nbstrand,2)
482 if(bstrand(in,1).lt.bfrag(2,j)) then
483 call bgrow(bstrand,nbstrand,in,1,bfrag(2,j))
485 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
486 & (bstrand(in,5)-bfrag(2,j))
488 if(bstrand(in,2).gt.bfrag(1,j)) then
489 call bgrow(bstrand,nbstrand,in,2,bfrag(1,j))
491 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
492 & (-bstrand(in,6)+bfrag(1,j))
495 bstrand(nbstrand,1)=bfrag(3,j)
496 bstrand(nbstrand,2)=bfrag(4,j)
497 bstrand(nbstrand,3)=nbetasheet
498 bstrand(nbstrand,4)=nbstrand
499 bstrand(nbstrand,5)=bstrand(nbstrand,1)
500 bstrand(nbstrand,6)=bstrand(nbstrand,2)
501 if(bstrand(in,1).gt.bfrag(1,j)) then
502 call bgrow(bstrand,nbstrand,in,1,bfrag(1,j))
504 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
505 & (-bstrand(in,5)+bfrag(1,j))
507 if(bstrand(in,2).lt.bfrag(2,j)) then
508 call bgrow(bstrand,nbstrand,in,2,bfrag(2,j))
510 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
511 & (bstrand(in,6)-bfrag(2,j))
518 do i=bfrag(4,j),bfrag(3,j)
519 if(betasheet(i).eq.nbetasheet) then
521 do k=bfrag(4,j),bfrag(3,j)
522 betasheet(k)=nbetasheet
527 iused_nbfrag=iused_nbfrag+1
528 do k=bfrag(1,j),bfrag(2,j)
529 betasheet(k)=nbetasheet
530 ibetasheet(k)=nbstrand
532 if (bstrand(in,4).lt.0) then
533 bstrand(nbstrand,1)=bfrag(1,j)
534 bstrand(nbstrand,2)=bfrag(2,j)
535 bstrand(nbstrand,3)=nbetasheet
536 bstrand(nbstrand,4)=nbstrand
537 bstrand(nbstrand,5)=bstrand(nbstrand,1)
538 bstrand(nbstrand,6)=bstrand(nbstrand,2)
539 if(bstrand(in,1).lt.bfrag(3,j)) then
540 call bgrow(bstrand,nbstrand,in,1,bfrag(3,j))
542 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
543 & (bstrand(in,5)-bfrag(3,j))
545 if(bstrand(in,2).gt.bfrag(4,j)) then
546 call bgrow(bstrand,nbstrand,in,2,bfrag(4,j))
548 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
549 & (-bstrand(in,6)+bfrag(4,j))
552 bstrand(nbstrand,1)=bfrag(2,j)
553 bstrand(nbstrand,2)=bfrag(1,j)
554 bstrand(nbstrand,3)=nbetasheet
555 bstrand(nbstrand,4)=-nbstrand
556 bstrand(nbstrand,5)=bstrand(nbstrand,1)
557 bstrand(nbstrand,6)=bstrand(nbstrand,2)
558 if(bstrand(in,1).gt.bfrag(4,j)) then
559 call bgrow(bstrand,nbstrand,in,1,bfrag(4,j))
561 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
562 & (-bstrand(in,5)+bfrag(4,j))
564 if(bstrand(in,2).lt.bfrag(3,j)) then
565 call bgrow(bstrand,nbstrand,in,2,bfrag(3,j))
567 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
568 & (bstrand(in,6)-bfrag(3,j))
573 if(betasheet(bfrag(2,j)-i+bfrag(4,j)).eq.nbetasheet) then
574 in=ibetasheet(bfrag(2,j)-i+bfrag(4,j))
575 do k=bfrag(1,j),bfrag(2,j)
576 betasheet(k)=nbetasheet
581 iused_nbfrag=iused_nbfrag+1
582 do k=bfrag(4,j),bfrag(3,j)
583 betasheet(k)=nbetasheet
584 ibetasheet(k)=nbstrand
586 if (bstrand(in,4).lt.0) then
587 bstrand(nbstrand,1)=bfrag(4,j)
588 bstrand(nbstrand,2)=bfrag(3,j)
589 bstrand(nbstrand,3)=nbetasheet
590 bstrand(nbstrand,4)=nbstrand
591 bstrand(nbstrand,5)=bstrand(nbstrand,1)
592 bstrand(nbstrand,6)=bstrand(nbstrand,2)
593 if(bstrand(in,1).lt.bfrag(2,j)) then
594 call bgrow(bstrand,nbstrand,in,1,bfrag(2,j))
596 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
597 & (bstrand(in,5)-bfrag(2,j))
599 if(bstrand(in,2).gt.bfrag(1,j)) then
600 call bgrow(bstrand,nbstrand,in,2,bfrag(1,j))
602 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
603 & (-bstrand(in,6)+bfrag(1,j))
606 bstrand(nbstrand,1)=bfrag(3,j)
607 bstrand(nbstrand,2)=bfrag(4,j)
608 bstrand(nbstrand,3)=nbetasheet
609 bstrand(nbstrand,4)=-nbstrand
610 bstrand(nbstrand,5)=bstrand(nbstrand,1)
611 bstrand(nbstrand,6)=bstrand(nbstrand,2)
612 if(bstrand(in,1).gt.bfrag(1,j)) then
613 call bgrow(bstrand,nbstrand,in,1,bfrag(1,j))
615 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
616 & (-bstrand(in,5)+bfrag(1,j))
618 if(bstrand(in,2).lt.bfrag(2,j)) then
619 call bgrow(bstrand,nbstrand,in,2,bfrag(2,j))
621 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
622 & (bstrand(in,6)-bfrag(2,j))
636 do while (usedbfrag(j))
641 nbetasheet=nbetasheet+1
642 bstrand(nbstrand,1)=bfrag(1,j)
643 bstrand(nbstrand,2)=bfrag(2,j)
644 bstrand(nbstrand,3)=nbetasheet
645 bstrand(nbstrand,5)=bfrag(1,j)
646 bstrand(nbstrand,6)=bfrag(2,j)
648 bstrand(nbstrand,4)=nbstrand
649 do i=bfrag(1,j),bfrag(2,j)
650 betasheet(i)=nbetasheet
651 ibetasheet(i)=nbstrand
655 bstrand(nbstrand,1)=bfrag(3,j)
656 bstrand(nbstrand,2)=bfrag(4,j)
657 bstrand(nbstrand,3)=nbetasheet
658 bstrand(nbstrand,5)=bfrag(3,j)
659 bstrand(nbstrand,6)=bfrag(4,j)
661 if (bfrag(3,j).le.bfrag(4,j)) then
662 bstrand(nbstrand,4)=nbstrand
663 do i=bfrag(3,j),bfrag(4,j)
664 betasheet(i)=nbetasheet
665 ibetasheet(i)=nbstrand
668 bstrand(nbstrand,4)=-nbstrand
669 do i=bfrag(4,j),bfrag(3,j)
670 betasheet(i)=nbetasheet
671 ibetasheet(i)=nbstrand
675 iused_nbfrag=iused_nbfrag+1
681 write (*,'(i4,a3,10i4)') jk,'A',(bstrand(i,jk),i=1,nbstrand)
688 if (betasheet(i).ne.0) write(*,*) i,betasheet(i),ibetasheet(i)
692 write (*,'(i4,a3,10i4)') j,':',(bstrand(i,j),i=1,nbstrand)
695 c------------------------
699 if(iabs(bstrand(i,5)-bstrand(j,5)).le.5 .or.
700 & iabs(bstrand(i,6)-bstrand(j,6)).le.5 ) then
702 ifb(nifb,1)=bstrand(i,4)
703 ifb(nifb,2)=bstrand(j,4)
710 write (*,'(a3,20i4)') "ifb",i,ifb(i,1),ifb(i,2)
716 write (*,'(a3,20i4)') "ifa",(ifa(i),i=1,nbstrand)
718 nif=iabs(bstrand(1,6)-bstrand(1,5))+1
720 if (iabs(bstrand(j,6)-bstrand(j,5))+1.gt.nif)
721 & nif=iabs(bstrand(j,6)-bstrand(j,5))+1
727 if(j,i)=bstrand(j,6)+(i-1)*sign(1,bstrand(j,5)-bstrand(j,6))
728 if (if(j,i).gt.0) then
729 if(betasheet(if(j,i)).eq.0 .or.
730 & ibetasheet(if(j,i)).ne.iabs(bstrand(j,4))) if(j,i)=0
735 write(*,'(a3,10i4)') 'if ',(if(j,i),j=1,nbstrand)
738 c read (inp,*) (ifa(i),i=1,4)
740 c read (inp,*,err=20,end=20) (if(j,i),j=1,4)
744 c------------------------
749 cccccccccccccccccccccccccccccccccc
751 cccccccccccccccccccccccccccccccccc
755 istrand(is-j+1)=int(ii/is**(is-j))
756 ii=ii-istrand(is-j+1)*is**(is-j)
760 istrand(k)=istrand(k)+1
761 if(istrand(k).gt.isa) istrand(k)=istrand(k)-2*isa-1
765 if(istrand(k).eq.istrand(l).and.k.ne.l.or.
766 & istrand(k).eq.-istrand(l).and.k.ne.l) ltest=.false.
775 & ifb(m,1).eq.istrand(k).and.ifb(m,2).eq.istrand(k+1).or.
776 & ifb(m,2).eq.istrand(k).and.ifb(m,1).eq.istrand(k+1).or.
777 & -ifb(m,1).eq.istrand(k).and.-ifb(m,2).eq.istrand(k+1).or.
778 & -ifb(m,2).eq.istrand(k).and.-ifb(m,1).eq.istrand(k+1))
784 if (mod(isa,2).eq.0) then
786 if (istrand(k).eq.1) ltest=.false.
790 if (istrand(k).eq.1) ltest=.false.
794 IF (ltest.and.lifb0.eq.1) THEN
797 call var_to_geom(nvar,vorg)
799 write (*,'(i5,i10,10i3)') iconf,ig,(istrand(k),k=1,isa)
800 write (iout,'(i5,i10,10i3)') iconf,ig,(istrand(k),k=1,isa)
801 write (linia,'(10i3)') (istrand(k),k=1,isa)
811 if ( sign(1,istrand(i)).eq.sign(1,ifa(iabs(istrand(i)))) ) then
813 itmp(iabs(istrand(i)),j)=if(iabs(ifa(iabs(istrand(i)))),j)
817 itmp(iabs(istrand(i)),j)=if(iabs(ifa(iabs(istrand(i)))),nif-j+1)
823 write(*,*) (itmp(j,i),j=1,4)
827 c ifa(1),ifa(2),ifa(3),ifa(4)
828 c if(1,i),if(2,i),if(3,i),if(4,i)
833 & ifb(m,1).eq.istrand(k).and.ifb(m,2).eq.istrand(k+1).or.
834 & ifb(m,2).eq.istrand(k).and.ifb(m,1).eq.istrand(k+1).or.
835 & -ifb(m,1).eq.istrand(k).and.-ifb(m,2).eq.istrand(k+1).or.
836 & -ifb(m,2).eq.istrand(k).and.-ifb(m,1).eq.istrand(k+1))
844 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+1)),i))=-1
846 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+1)),i))=-2
850 & ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+2)),i))=-3
852 & ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+3)),i))=-4
855 c------------------------
858 c freeze sec.elements
868 do i=bfrag(1,j),bfrag(2,j)
873 if (bfrag(3,j).le.bfrag(4,j)) then
874 do i=bfrag(3,j),bfrag(4,j)
880 do i=bfrag(4,j),bfrag(3,j)
888 do i=hfrag(1,j),hfrag(2,j)
896 c------------------------
897 c generate constrains
905 if ( ibc(i,j).eq.-1 .or. ibc(j,i).eq.-1) then
913 else if ( ibc(i,j).eq.-2 .or. ibc(j,i).eq.-2) then
921 else if ( ibc(i,j).eq.-3 .or. ibc(j,i).eq.-3) then
929 else if ( ibc(i,j).eq.-4 .or. ibc(j,i).eq.-4) then
937 else if ( ibc(i,j).gt.0 ) then
938 d0(ind)=DIST(i,ibc(i,j))
945 else if ( ibc(j,i).gt.0 ) then
946 d0(ind)=DIST(ibc(j,i),j)
960 cd--------------------------
962 write(iout,'(i3,2i4,a3,2i4,f7.2)') (i,ibc(ihpb(i),jhpb(i)),
963 & ibc(jhpb(i),ihpb(i)),' --',
964 & ihpb(i),jhpb(i),dhpb(i),i=1,nhpb)
970 call contact_cp_min(varia,ifun,iconf,linia,debug)
977 call minimize(etot,varia,iretcode,nfun)
978 write(iout,*)'------------------------------------------------'
979 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
987 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
988 & nfun/(time1-time0),' eval/s'
990 write (linia,'(a10,10i3)') 'full_min',(istrand(k),k=1,isa)
991 call var_to_geom(nvar,varia)
993 call write_pdb(900+iconf,linia,etot)
996 call etotal(energy(0))
998 call enerprint(energy(0))
1000 cd call briefout(0,etot)
1001 cd call secondary2(.true.)
1005 cccccccccccccccccccccccccccccccccccc
1008 cccccccccccccccccccccccccccccccccccc
1011 10 write (iout,'(a)') 'Error reading test structure.'
1014 c--------------------------------------------------------
1017 implicit real*8 (a-h,o-z)
1018 include 'DIMENSIONS'
1022 include 'COMMON.GEO'
1023 include 'COMMON.CHAIN'
1024 include 'COMMON.IOUNITS'
1025 include 'COMMON.VAR'
1026 include 'COMMON.CONTROL'
1027 include 'COMMON.SBRIDGE'
1028 include 'COMMON.FFIELD'
1029 include 'COMMON.MINIM'
1031 include 'COMMON.DISTFIT'
1032 integer if(3,maxres),nif
1033 integer ibc(maxres,maxres),istrand(20)
1034 integer ibd(maxres),ifb(10,2),nifb,lifb(10),lifb0
1035 double precision time0,time1
1036 double precision energy(0:n_ene),ee
1037 double precision varia(maxvar)
1043 read (inp,*,err=20,end=20) if(1,i),if(2,i),if(3,i)
1046 write (*,'(a4,3i5)') ('if =',if(1,i),if(2,i),if(3,i),
1050 c------------------------
1051 call secondary2(debug)
1052 c------------------------
1060 c freeze sec.elements and store indexes for beta constrains
1070 do i=bfrag(1,j),bfrag(2,j)
1075 if (bfrag(3,j).le.bfrag(4,j)) then
1076 do i=bfrag(3,j),bfrag(4,j)
1080 ibc(bfrag(1,j)+i-bfrag(3,j),i)=-1
1083 do i=bfrag(4,j),bfrag(3,j)
1087 ibc(bfrag(2,j)-i+bfrag(4,j),i)=-1
1092 do i=hfrag(1,j),hfrag(2,j)
1101 c ---------------- test --------------
1103 if (ibc(if(1,i),if(2,i)).eq.-1) then
1104 ibc(if(1,i),if(2,i))=if(3,i)
1105 ibc(if(1,i),if(3,i))=if(2,i)
1106 else if (ibc(if(2,i),if(1,i)).eq.-1) then
1107 ibc(if(2,i),if(1,i))=0
1108 ibc(if(1,i),if(2,i))=if(3,i)
1109 ibc(if(1,i),if(3,i))=if(2,i)
1111 ibc(if(1,i),if(2,i))=if(3,i)
1112 ibc(if(1,i),if(3,i))=if(2,i)
1118 if (ibc(i,j).ne.0) write(*,'(3i5)') i,j,ibc(i,j)
1121 c------------------------
1127 if ( ibc(i,j).eq.-1 ) then
1135 else if ( ibc(i,j).gt.0 ) then
1136 d0(ind)=DIST(i,ibc(i,j))
1143 else if ( ibc(j,i).gt.0 ) then
1144 d0(ind)=DIST(ibc(j,i),j)
1158 cd--------------------------
1159 write(*,'(i3,2i4,a3,2i4,f7.2)') (i,ibc(ihpb(i),jhpb(i)),
1160 & ibc(jhpb(i),ihpb(i)),' --',
1161 & ihpb(i),jhpb(i),dhpb(i),i=1,nhpb)
1168 call contact_cp_min(varia,ieval,in_pdb,linia,debug)
1175 call minimize(etot,varia,iretcode,nfun)
1176 write(iout,*)'------------------------------------------------'
1177 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
1178 & '+ DIST eval',ieval
1185 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
1186 & nfun/(time1-time0),' eval/s'
1189 call var_to_geom(nvar,varia)
1191 call write_pdb(999,'full min',etot)
1194 call etotal(energy(0))
1196 call enerprint(energy(0))
1198 call briefout(0,etot)
1199 call secondary2(.true.)
1202 10 write (iout,'(a)') 'Error reading test structure.'
1210 implicit real*8 (a-h,o-z)
1211 include 'DIMENSIONS'
1215 include 'COMMON.GEO'
1216 include 'COMMON.CHAIN'
1217 include 'COMMON.IOUNITS'
1218 include 'COMMON.VAR'
1219 include 'COMMON.CONTROL'
1220 include 'COMMON.SBRIDGE'
1221 include 'COMMON.FFIELD'
1222 include 'COMMON.MINIM'
1224 include 'COMMON.DISTFIT'
1227 double precision time0,time1
1228 double precision energy(0:n_ene),ee
1229 double precision theta2(maxres),phi2(maxres),alph2(maxres),
1231 & theta1(maxres),phi1(maxres),alph1(maxres),
1233 double precision varia(maxvar),varia2(maxvar)
1237 read (inp,*,err=10,end=10) if(1,1),if(1,2),if(2,1),if(2,2)
1238 write (iout,'(a4,4i5)') 'if =',if(1,1),if(1,2),if(2,1),if(2,2)
1239 read (inp,*,err=10,end=10) (theta2(i),i=3,nres)
1240 read (inp,*,err=10,end=10) (phi2(i),i=4,nres)
1241 read (inp,*,err=10,end=10) (alph2(i),i=2,nres-1)
1242 read (inp,*,err=10,end=10) (omeg2(i),i=2,nres-1)
1244 theta2(i)=deg2rad*theta2(i)
1245 phi2(i)=deg2rad*phi2(i)
1246 alph2(i)=deg2rad*alph2(i)
1247 omeg2(i)=deg2rad*omeg2(i)
1261 c------------------------
1266 do i=if(j,1),if(j,2)
1272 call geom_to_var(nvar,varia)
1273 call write_pdb(1,'first structure',0d0)
1275 call secondary(.true.)
1277 call secondary2(.true.)
1280 if ( (bfrag(3,j).lt.bfrag(4,j) .or.
1281 & bfrag(4,j)-bfrag(2,j).gt.4) .and.
1282 & bfrag(2,j)-bfrag(1,j).gt.3 ) then
1285 if (bfrag(3,j).lt.bfrag(4,j)) then
1286 write(iout,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1287 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
1288 & ,",",bfrag(3,j)-1,"-",bfrag(4,j)-1
1290 write(iout,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1291 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
1292 & ,",",bfrag(4,j)-1,"-",bfrag(3,j)-1
1305 call geom_to_var(nvar,varia2)
1306 call write_pdb(2,'second structure',0d0)
1310 c-------------------------------------------------------
1313 call contact_cp(varia,varia2,iff,ifun,7)
1320 call minimize(etot,varia,iretcode,nfun)
1321 write(iout,*)'------------------------------------------------'
1322 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
1323 & '+ DIST eval',ifun
1330 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
1331 & nfun/(time1-time0),' eval/s'
1334 call var_to_geom(nvar,varia)
1336 call write_pdb(999,'full min',etot)
1339 call etotal(energy(0))
1341 call enerprint(energy(0))
1343 call briefout(0,etot)
1346 10 write (iout,'(a)') 'Error reading test structure.'
1350 c-------------------------------------------------
1351 c-------------------------------------------------
1353 subroutine secondary(lprint)
1354 implicit real*8 (a-h,o-z)
1355 include 'DIMENSIONS'
1356 include 'COMMON.CHAIN'
1357 include 'COMMON.IOUNITS'
1358 include 'COMMON.DISTFIT'
1360 integer ncont,icont(2,maxres*maxres/2),isec(maxres,3)
1361 logical lprint,not_done
1362 real dcont(maxres*maxres/2),d
1367 double precision xpi(3),xpj(3)
1372 cd call write_pdb(99,'sec structure',0d0)
1384 xpi(k)=0.5d0*(c(k,i-1)+c(k,i))
1388 xpj(k)=0.5d0*(c(k,j-1)+c(k,j))
1390 cd d = (c(1,i)-c(1,j))*(c(1,i)-c(1,j)) +
1391 cd & (c(2,i)-c(2,j))*(c(2,i)-c(2,j)) +
1392 cd & (c(3,i)-c(3,j))*(c(3,i)-c(3,j))
1393 cd print *,'CA',i,j,d
1394 d = (xpi(1)-xpj(1))*(xpi(1)-xpj(1)) +
1395 & (xpi(2)-xpj(2))*(xpi(2)-xpj(2)) +
1396 & (xpi(3)-xpj(3))*(xpi(3)-xpj(3))
1397 if ( d.lt.rcomp*rcomp) then
1401 dcont(ncont)=sqrt(d)
1407 write (iout,'(a)') '#PP contact map distances:'
1409 write (iout,'(3i4,f10.5)')
1410 & i,icont(1,i),icont(2,i),dcont(i)
1414 c finding parallel beta
1415 cd write (iout,*) '------- looking for parallel beta -----------'
1421 if(dcont(i).le.rbeta .and. j1-i1.gt.4 .and.
1422 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1423 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1424 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1425 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1426 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1430 cd write (iout,*) i1,j1,dcont(i)
1436 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)
1437 & .and. dcont(j).le.rbeta .and.
1438 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1439 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1440 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1441 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1442 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1447 cd write (iout,*) i1,j1,dcont(j),not_done
1451 if (i1-ii1.gt.1) then
1455 if(lprint)write(iout,*)'parallel beta',nbeta,ii1,i1,jj1,j1
1464 isec(ij,1)=isec(ij,1)+1
1465 isec(ij,1+isec(ij,1))=nbeta
1468 isec(ij,1)=isec(ij,1)+1
1469 isec(ij,1+isec(ij,1))=nbeta
1474 if (nbeta.le.9) then
1475 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1476 & "DefPropRes 'strand",nstrand,
1477 & "' 'num = ",ii1-1,"..",i1-1,"'"
1479 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1480 & "DefPropRes 'strand",nstrand,
1481 & "' 'num = ",ii1-1,"..",i1-1,"'"
1484 if (nbeta.le.9) then
1485 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1486 & "DefPropRes 'strand",nstrand,
1487 & "' 'num = ",jj1-1,"..",j1-1,"'"
1489 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1490 & "DefPropRes 'strand",nstrand,
1491 & "' 'num = ",jj1-1,"..",j1-1,"'"
1493 write(12,'(a8,4i4)')
1494 & "SetNeigh",ii1-1,i1-1,jj1-1,j1-1
1500 c finding antiparallel beta
1501 cd write (iout,*) '--------- looking for antiparallel beta ---------'
1506 if (dcont(i).le.rbeta.and.
1507 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1508 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1509 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1510 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1511 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1515 cd write (iout,*) i1,j1,dcont(i)
1522 if (i1.eq.icont(1,j).and.j1.eq.icont(2,j) .and.
1523 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1524 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1525 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1526 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1527 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1528 & .and. dcont(j).le.rbeta ) goto 6
1532 cd write (iout,*) i1,j1,dcont(j),not_done
1536 if (i1-ii1.gt.1) then
1537 if(lprint)write (iout,*)'antiparallel beta',
1538 & nbeta,ii1-1,i1,jj1,j1-1
1541 bfrag(1,nbfrag)=max0(ii1-1,1)
1544 bfrag(4,nbfrag)=max0(j1-1,1)
1549 isec(ij,1)=isec(ij,1)+1
1550 isec(ij,1+isec(ij,1))=nbeta
1554 isec(ij,1)=isec(ij,1)+1
1555 isec(ij,1+isec(ij,1))=nbeta
1561 if (nstrand.le.9) then
1562 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1563 & "DefPropRes 'strand",nstrand,
1564 & "' 'num = ",ii1-2,"..",i1-1,"'"
1566 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1567 & "DefPropRes 'strand",nstrand,
1568 & "' 'num = ",ii1-2,"..",i1-1,"'"
1571 if (nstrand.le.9) then
1572 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1573 & "DefPropRes 'strand",nstrand,
1574 & "' 'num = ",j1-2,"..",jj1-1,"'"
1576 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1577 & "DefPropRes 'strand",nstrand,
1578 & "' 'num = ",j1-2,"..",jj1-1,"'"
1580 write(12,'(a8,4i4)')
1581 & "SetNeigh",ii1-2,i1-1,jj1-1,j1-2
1587 if (nstrand.gt.0.and.lprint) then
1588 write(12,'(a27,$)') "DefPropRes 'sheet' 'strand1"
1591 write(12,'(a9,i1,$)') " | strand",i
1593 write(12,'(a9,i2,$)') " | strand",i
1596 write(12,'(a1)') "'"
1600 c finding alpha or 310 helix
1606 if (j1.eq.i1+3.and.dcont(i).le.r310
1607 & .or.j1.eq.i1+4.and.dcont(i).le.ralfa ) then
1608 cd if (j1.eq.i1+3) write (iout,*) "found 1-4 ",i1,j1,dcont(i)
1609 cd if (j1.eq.i1+4) write (iout,*) "found 1-5 ",i1,j1,dcont(i)
1612 if (isec(ii1,1).eq.0) then
1621 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)) goto 10
1625 cd write (iout,*) i1,j1,not_done
1628 if (j1-ii1.gt.4) then
1630 cd write (iout,*)'helix',nhelix,ii1,j1
1634 hfrag(2,nhfrag)=max0(j1-1,1)
1640 write (iout,'(a6,i3,2i4)') "Helix",nhelix,ii1-1,j1-2
1641 if (nhelix.le.9) then
1642 write(12,'(a17,i1,a9,i3,a2,i3,a1)')
1643 & "DefPropRes 'helix",nhelix,
1644 & "' 'num = ",ii1-1,"..",j1-2,"'"
1646 write(12,'(a17,i2,a9,i3,a2,i3,a1)')
1647 & "DefPropRes 'helix",nhelix,
1648 & "' 'num = ",ii1-1,"..",j1-2,"'"
1655 if (nhelix.gt.0.and.lprint) then
1656 write(12,'(a26,$)') "DefPropRes 'helix' 'helix1"
1658 if (nhelix.le.9) then
1659 write(12,'(a8,i1,$)') " | helix",i
1661 write(12,'(a8,i2,$)') " | helix",i
1664 write(12,'(a1)') "'"
1668 write(12,'(a37)') "DefPropRes 'coil' '! (helix | sheet)'"
1669 write(12,'(a20)') "XMacStand ribbon.mac"
1675 c----------------------------------------------------------------------------
1677 subroutine write_pdb(npdb,titelloc,ee)
1678 implicit real*8 (a-h,o-z)
1679 include 'DIMENSIONS'
1680 include 'COMMON.IOUNITS'
1681 character*50 titelloc1
1682 character*(*) titelloc
1691 if (npdb.lt.1000) then
1692 call numstr(npdb,zahl)
1693 open(ipdb,file=prefix(:lenpre)//'@@'//zahl//'.pdb')
1695 if (npdb.lt.10000) then
1696 write(liczba5,'(i1,i4)') 0,npdb
1698 write(liczba5,'(i5)') npdb
1700 open(ipdb,file=prefix(:lenpre)//'@@'//liczba5//'.pdb')
1702 call pdbout(ee,titelloc1,ipdb)
1707 c-----------------------------------------------------------
1708 subroutine contact_cp2(var,var2,iff,ieval,in_pdb)
1709 implicit real*8 (a-h,o-z)
1710 include 'DIMENSIONS'
1714 include 'COMMON.SBRIDGE'
1715 include 'COMMON.FFIELD'
1716 include 'COMMON.IOUNITS'
1717 include 'COMMON.DISTFIT'
1718 include 'COMMON.VAR'
1719 include 'COMMON.CHAIN'
1720 include 'COMMON.MINIM'
1724 double precision var(maxvar),var2(maxvar)
1725 double precision time0,time1
1726 integer iff(maxres),ieval
1727 double precision theta1(maxres),phi1(maxres),alph1(maxres),
1731 call var_to_geom(nvar,var)
1738 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
1760 call var_to_geom(nvar,var2)
1763 if ( iff(i).eq.1 ) then
1772 cd call write_pdb(3,'combined structure',0d0)
1773 cd time0=MPI_WTIME()
1776 NY=((NRES-4)*(NRES-5))/2
1777 call distfit(.true.,200)
1779 cd time1=MPI_WTIME()
1780 cd write (iout,'(a,f6.2,a)') ' Time for distfit ',time1-time0,' sec'
1790 call geom_to_var(nvar,var)
1791 cd time0=MPI_WTIME()
1792 call minimize(etot,var,iretcode,nfun)
1793 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
1795 cd time1=MPI_WTIME()
1796 cd write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
1797 cd & nfun/(time1-time0),' SOFT eval/s'
1798 call var_to_geom(nvar,var)
1804 if (iff(1).eq.1) then
1810 if ( iwsk.eq.0.and.iff(i-1).eq.0.and.iff(i).eq.1 ) then
1815 if ( iwsk.eq.1.and.iff(i-1).eq.1.and.iff(i).eq.0 ) then
1821 if (iff(nres).eq.1) then
1827 cd write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1828 cd & "select",ij(1),"-",ij(2),
1829 cd & ",",ij(3),"-",ij(4)
1830 cd call write_pdb(in_pdb,linia,etot)
1836 cd time0=MPI_WTIME()
1837 call minimize(etot,var,iretcode,nfun)
1838 cd write(iout,*)'SUMSL DIST return code is',iretcode,' eval ',nfun
1841 cd time1=MPI_WTIME()
1842 cd write (iout,'(a,f6.2,f8.2,a)')' Time for DIST min.',time1-time0,
1843 cd & nfun/(time1-time0),' eval/s'
1844 cd call var_to_geom(nvar,var)
1846 cd call write_pdb(6,'dist structure',etot)
1856 c-----------------------------------------------------------
1857 subroutine contact_cp(var,var2,iff,ieval,in_pdb)
1858 implicit real*8 (a-h,o-z)
1859 include 'DIMENSIONS'
1860 include 'COMMON.SBRIDGE'
1861 include 'COMMON.FFIELD'
1862 include 'COMMON.IOUNITS'
1863 include 'COMMON.DISTFIT'
1864 include 'COMMON.VAR'
1865 include 'COMMON.CHAIN'
1866 include 'COMMON.MINIM'
1870 double precision energy(0:n_ene)
1871 double precision var(maxvar),var2(maxvar)
1872 double precision time0,time1
1873 integer iff(maxres),ieval
1874 double precision theta1(maxres),phi1(maxres),alph1(maxres),
1880 if (ieval.eq.-1) debug=.true.
1884 c store selected dist. constrains from 1st structure
1887 c Intercept NaNs in the coordinates
1888 c write(iout,*) (var(i),i=1,nvar)
1893 if (x_sum.ne.x_sum) then
1894 write(iout,*)" *** contact_cp : Found NaN in coordinates"
1896 print *," *** contact_cp : Found NaN in coordinates"
1902 call var_to_geom(nvar,var)
1909 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
1932 c freeze sec.elements from 2nd structure
1940 call var_to_geom(nvar,var2)
1941 call secondary2(debug)
1943 do i=bfrag(1,j),bfrag(2,j)
1948 if (bfrag(3,j).le.bfrag(4,j)) then
1949 do i=bfrag(3,j),bfrag(4,j)
1955 do i=bfrag(4,j),bfrag(3,j)
1963 do i=hfrag(1,j),hfrag(2,j)
1972 c copy selected res from 1st to 2nd structure
1976 if ( iff(i).eq.1 ) then
1986 c prepare description in linia variable
1990 if (iff(1).eq.1) then
1996 if ( iwsk.eq.0.and.iff(i-1).eq.0.and.iff(i).eq.1 ) then
2001 if ( iwsk.eq.1.and.iff(i-1).eq.1.and.iff(i).eq.0 ) then
2007 if (iff(nres).eq.1) then
2012 write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
2013 & "SELECT",ij(1)-1,"-",ij(2)-1,
2014 & ",",ij(3)-1,"-",ij(4)-1
2020 call contact_cp_min(var,ieval,in_pdb,linia,debug)
2025 subroutine contact_cp_min(var,ieval,in_pdb,linia,debug)
2027 c input : theta,phi,alph,omeg,in_pdb,linia,debug
2028 c output : var,ieval
2030 implicit real*8 (a-h,o-z)
2031 include 'DIMENSIONS'
2035 include 'COMMON.SBRIDGE'
2036 include 'COMMON.FFIELD'
2037 include 'COMMON.IOUNITS'
2038 include 'COMMON.DISTFIT'
2039 include 'COMMON.VAR'
2040 include 'COMMON.CHAIN'
2041 include 'COMMON.MINIM'
2045 double precision energy(0:n_ene)
2046 double precision var(maxvar)
2047 double precision time0,time1
2048 integer ieval,info(3)
2049 logical debug,fail,check_var,reduce,change
2051 write(iout,'(a20,i6,a20)')
2052 & '------------------',in_pdb,'-------------------'
2056 call write_pdb(1000+in_pdb,'combined structure',0d0)
2065 c run optimization of distances
2067 c uses d0(),w() and mask() for frozen 2D
2069 ctest---------------------------------------------
2071 ctest NY=((NRES-4)*(NRES-5))/2
2072 ctest call distfit(debug,5000)
2104 call geom_to_var(nvar,var)
2105 cde change=reduce(var)
2106 if (check_var(var,info)) then
2107 write(iout,*) 'cp_min error in input'
2108 print *,'cp_min error in input'
2112 cd call etotal(energy(0))
2113 cd call enerprint(energy(0))
2121 cdtest call minimize(etot,var,iretcode,nfun)
2122 cdtest write(iout,*)'SUMSL return code is',iretcode,' eval SDIST',nfun
2129 cd call etotal(energy(0))
2130 cd call enerprint(energy(0))
2149 ctest--------------------------------------------------
2157 write (iout,'(a,f6.2,a)')' Time for distfit ',time1-time0,' sec'
2158 call write_pdb(2000+in_pdb,'distfit structure',0d0)
2167 c run soft pot. optimization
2169 c nhpb,ihpb(),jhpb(),forcon(),dhpb() and hpb_partition
2171 c mask_phi(),mask_theta(),mask_side(),mask_r
2177 cde change=reduce(var)
2178 cde if (check_var(var,info)) write(iout,*) 'error before soft'
2184 call minimize(etot,var,iretcode,nfun)
2186 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
2192 write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
2193 & nfun/(time1-time0),' SOFT eval/s'
2195 call var_to_geom(nvar,var)
2197 call write_pdb(3000+in_pdb,'soft structure',etot)
2200 c run full UNRES optimization with constrains and frozen 2D
2201 c the same variables as soft pot. optimizatio
2207 c check overlaps before calling full UNRES minim
2209 call var_to_geom(nvar,var)
2211 call etotal(energy(0))
2213 write(iout,*) 'N7 ',energy(0)
2214 if (energy(0).ne.energy(0)) then
2215 write(iout,*) 'N7 error - gives NaN',energy(0)
2219 if (energy(1).eq.1.0d20) then
2220 write (iout,'(a,1pe14.5)')'#N7_OVERLAP evdw=1d20',energy(1)
2221 call overlap_sc(fail)
2223 call etotal(energy(0))
2225 write (iout,'(a,1pe14.5)')'#N7_OVERLAP evdw after',energy(1)
2237 cdte time0=MPI_WTIME()
2238 cde change=reduce(var)
2239 cde if (check_var(var,info)) then
2240 cde write(iout,*) 'error before mask dist'
2241 cde call var_to_geom(nvar,var)
2243 cde call write_pdb(10000+in_pdb,'before mask dist',etot)
2245 cdte call minimize(etot,var,iretcode,nfun)
2246 cdte write(iout,*)'SUMSL MASK DIST return code is',iretcode,
2247 cdte & ' eval ',nfun
2248 cdte ieval=ieval+nfun
2250 cdte time1=MPI_WTIME()
2251 cdte write (iout,'(a,f6.2,f8.2,a)')
2252 cdte & ' Time for mask dist min.',time1-time0,
2253 cdte & nfun/(time1-time0),' eval/s'
2254 cdte call flush(iout)
2256 call var_to_geom(nvar,var)
2258 call write_pdb(4000+in_pdb,'mask dist',etot)
2261 c switch off freezing of 2D and
2262 c run full UNRES optimization with constrains
2270 cde change=reduce(var)
2271 cde if (check_var(var,info)) then
2272 cde write(iout,*) 'error before dist'
2273 cde call var_to_geom(nvar,var)
2275 cde call write_pdb(11000+in_pdb,'before dist',etot)
2278 call minimize(etot,var,iretcode,nfun)
2280 cde change=reduce(var)
2281 cde if (check_var(var,info)) then
2282 cde write(iout,*) 'error after dist',ico
2283 cde call var_to_geom(nvar,var)
2285 cde call write_pdb(12000+in_pdb+ico*1000,'after dist',etot)
2287 write(iout,*)'SUMSL DIST return code is',iretcode,' eval ',nfun
2295 write (iout,'(a,f6.2,f8.2,a)')' Time for dist min.',time1-time0,
2296 & nfun/(time1-time0),' eval/s'
2297 cde call etotal(energy(0))
2298 cde write(iout,*) 'N7 after dist',energy(0)
2302 call var_to_geom(nvar,var)
2304 call write_pdb(in_pdb,linia,etot)
2316 c--------------------------------------------------------
2318 implicit real*8 (a-h,o-z)
2319 include 'DIMENSIONS'
2323 include 'COMMON.GEO'
2324 include 'COMMON.CHAIN'
2325 include 'COMMON.IOUNITS'
2326 include 'COMMON.VAR'
2327 include 'COMMON.CONTROL'
2328 include 'COMMON.SBRIDGE'
2329 include 'COMMON.FFIELD'
2330 include 'COMMON.MINIM'
2331 include 'COMMON.INTERACT'
2333 include 'COMMON.DISTFIT'
2335 double precision time0,time1
2336 double precision energy(0:n_ene),ee
2337 double precision var(maxvar)
2340 logical debug,ltest,fail
2349 c------------------------
2351 c freeze sec.elements
2361 do i=bfrag(1,j),bfrag(2,j)
2366 if (bfrag(3,j).le.bfrag(4,j)) then
2367 do i=bfrag(3,j),bfrag(4,j)
2373 do i=bfrag(4,j),bfrag(3,j)
2381 do i=hfrag(1,j),hfrag(2,j)
2393 c store dist. constrains
2397 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
2402 dhpb(nhpb)=DIST(i,j)
2410 call write_pdb(100+in_pdb,'input reg. structure',0d0)
2420 c run soft pot. optimization
2426 call geom_to_var(nvar,var)
2432 call minimize(etot,var,iretcode,nfun)
2434 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
2440 write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
2441 & nfun/(time1-time0),' SOFT eval/s'
2443 call var_to_geom(nvar,var)
2445 call write_pdb(300+in_pdb,'soft structure',etot)
2448 c run full UNRES optimization with constrains and frozen 2D
2449 c the same variables as soft pot. optimizatio
2460 call minimize(etot,var,iretcode,nfun)
2461 write(iout,*)'SUMSL MASK DIST return code is',iretcode,
2470 write (iout,'(a,f6.2,f8.2,a)')
2471 & ' Time for mask dist min.',time1-time0,
2472 & nfun/(time1-time0),' eval/s'
2474 call var_to_geom(nvar,var)
2476 call write_pdb(400+in_pdb,'mask & dist',etot)
2479 c switch off constrains and
2480 c run full UNRES optimization with frozen 2D
2498 call minimize(etot,var,iretcode,nfun)
2499 write(iout,*)'SUMSL MASK return code is',iretcode,' eval ',nfun
2507 write (iout,'(a,f6.2,f8.2,a)')' Time for mask min.',time1-time0,
2508 & nfun/(time1-time0),' eval/s'
2512 call var_to_geom(nvar,var)
2514 call write_pdb(500+in_pdb,'mask 2d frozen',etot)
2521 c run full UNRES optimization with constrains and NO frozen 2D
2531 wstrain=wstrain0/ico
2538 call minimize(etot,var,iretcode,nfun)
2539 write(iout,'(a10,f6.3,a14,i3,a6,i5)')
2540 & ' SUMSL DIST',wstrain,' return code is',iretcode,
2549 write (iout,'(a,f6.2,f8.2,a)')
2550 & ' Time for dist min.',time1-time0,
2551 & nfun/(time1-time0),' eval/s'
2553 call var_to_geom(nvar,var)
2555 call write_pdb(600+in_pdb+ico,'dist cons',etot)
2574 call minimize(etot,var,iretcode,nfun)
2575 write(iout,*)'------------------------------------------------'
2576 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
2577 & '+ DIST eval',ieval
2584 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
2585 & nfun/(time1-time0),' eval/s'
2588 call var_to_geom(nvar,var)
2590 call write_pdb(999,'full min',etot)
2597 subroutine beta_slide(i1,i2,i3,i4,i5,ieval,ij)
2598 implicit real*8 (a-h,o-z)
2599 include 'DIMENSIONS'
2603 include 'COMMON.GEO'
2604 include 'COMMON.VAR'
2605 include 'COMMON.INTERACT'
2606 include 'COMMON.IOUNITS'
2607 include 'COMMON.DISTFIT'
2608 include 'COMMON.SBRIDGE'
2609 include 'COMMON.CONTROL'
2610 include 'COMMON.FFIELD'
2611 include 'COMMON.MINIM'
2612 include 'COMMON.CHAIN'
2613 double precision time0,time1
2614 double precision energy(0:n_ene),ee
2615 double precision var(maxvar)
2616 integer jdata(5),isec(maxres)
2624 call secondary2(.false.)
2630 do i=bfrag(1,j),bfrag(2,j)
2633 do i=bfrag(4,j),bfrag(3,j),sign(1,bfrag(3,j)-bfrag(4,j))
2638 do i=hfrag(1,j),hfrag(2,j)
2644 c cut strands at the ends
2646 if (jdata(2)-jdata(1).gt.3) then
2649 if (jdata(3).lt.jdata(4)) then
2659 cv call etotal(energy(0))
2661 cv write(iout,*) nnt,nct,etot
2662 cv call write_pdb(ij*100,'first structure',etot)
2663 cv write(iout,*) 'N16 test',(jdata(i),i=1,5)
2665 c------------------------
2666 c generate constrains
2669 if(ishift.eq.0) ishift=-2
2672 do i=jdata(1),jdata(2)
2674 if(jdata(4).gt.jdata(3))then
2675 do j=jdata(3)+i-jdata(1)-2,jdata(3)+i-jdata(1)+2
2677 cd print *,i,j,j+ishift
2682 dhpb(nhpb)=DIST(i,j+ishift)
2685 do j=jdata(3)-i+jdata(1)+2,jdata(3)-i+jdata(1)-2,-1
2687 cd print *,i,j,j+ishift
2692 dhpb(nhpb)=DIST(i,j+ishift)
2699 if(isec(i).gt.0.or.isec(j).gt.0) then
2705 dhpb(nhpb)=DIST(i,j)
2712 call geom_to_var(nvar,var)
2719 wstrain=wstrain0/ico
2721 cv time0=MPI_WTIME()
2722 call minimize(etot,var,iretcode,nfun)
2723 write(iout,'(a10,f6.3,a14,i3,a6,i5)')
2724 & ' SUMSL DIST',wstrain,' return code is',iretcode,
2727 cv time1=MPI_WTIME()
2728 cv write (iout,'(a,f6.2,f8.2,a)')
2729 cv & ' Time for dist min.',time1-time0,
2730 cv & nfun/(time1-time0),' eval/s'
2731 cv call var_to_geom(nvar,var)
2733 cv call write_pdb(ij*100+ico,'dist cons',etot)
2745 call sc_move(nnt,nct,100,100d0,nft_sc,etot)
2748 cv call etotal(energy(0))
2750 cv call write_pdb(ij*100+10,'sc_move',etot)
2752 cd print *,nft_sc,etot
2757 subroutine beta_zip(i1,i2,ieval,ij)
2758 implicit real*8 (a-h,o-z)
2759 include 'DIMENSIONS'
2763 include 'COMMON.GEO'
2764 include 'COMMON.VAR'
2765 include 'COMMON.INTERACT'
2766 include 'COMMON.IOUNITS'
2767 include 'COMMON.DISTFIT'
2768 include 'COMMON.SBRIDGE'
2769 include 'COMMON.CONTROL'
2770 include 'COMMON.FFIELD'
2771 include 'COMMON.MINIM'
2772 include 'COMMON.CHAIN'
2773 double precision time0,time1
2774 double precision energy(0:n_ene),ee
2775 double precision var(maxvar)
2779 cv call etotal(energy(0))
2781 cv write(test,'(2i5)') i1,i2
2782 cv call write_pdb(ij*100,test,etot)
2783 cv write(iout,*) 'N17 test',i1,i2,etot,ij
2786 c generate constrains
2797 call geom_to_var(nvar,var)
2803 wstrain=wstrain0/ico
2804 cv time0=MPI_WTIME()
2805 call minimize(etot,var,iretcode,nfun)
2806 write(iout,'(a10,f6.3,a14,i3,a6,i5)')
2807 & ' SUMSL DIST',wstrain,' return code is',iretcode,
2810 cv time1=MPI_WTIME()
2811 cv write (iout,'(a,f6.2,f8.2,a)')
2812 cv & ' Time for dist min.',time1-time0,
2813 cv & nfun/(time1-time0),' eval/s'
2814 c do not comment the next line
2815 call var_to_geom(nvar,var)
2817 cv call write_pdb(ij*100+ico,'dist cons',etot)
2825 cv call etotal(energy(0))
2827 cv write(iout,*) 'N17 test end',i1,i2,etot,ij