2 implicit real*8 (a-h,o-z)
7 include 'COMMON.INTERACT'
8 include 'COMMON.IOUNITS'
9 include 'COMMON.DISTFIT'
10 include 'COMMON.SBRIDGE'
11 include 'COMMON.CONTROL'
12 include 'COMMON.FFIELD'
13 include 'COMMON.MINIM'
14 include 'COMMON.CHAIN'
15 double precision time0,time1
16 double precision energy(0:n_ene),ee
17 double precision var(maxvar),var1(maxvar)
19 logical debug,accepted
23 call geom_to_var(nvar,var1)
25 call etotal(energy(0))
28 write(iout,*) 'etot=',0,etot,rms
29 call secondary2(.false.)
31 call write_pdb(0,'first structure',etot)
40 betbol=1.0D0/(1.9858D-3*temp)
43 c phi(jr)=pinorm(phi(jr)+d)
45 call etotal(energy(0))
48 write(iout,*) 'etot=',1,etot0,rms
49 call write_pdb(1,'perturb structure',etot0)
55 phi(jr)=pinorm(phi(jr)+d)
57 call etotal(energy(0))
60 if (etot.lt.etot0) then
64 xxr=ran_number(0.0D0,1.0D0)
65 xxh=betbol*(etot-etot0)
66 if (xxh.lt.50.0D0) then
68 if (xxh.gt.xxr) accepted=.true.
72 c print *,etot0,etot,accepted
76 write(iout,*) 'etot=',i,etot,rms
77 call write_pdb(i,'MC structure',etot)
79 c call geom_to_var(nvar,var1)
80 call sc_move(2,nres-1,1,10d0,nft_sc,etot)
81 call geom_to_var(nvar,var)
82 call minimize(etot,var,iretcode,nfun)
83 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun
84 call var_to_geom(nvar,var)
87 write(iout,*) 'etot mcm=',i,etot,rms
88 call write_pdb(i+1,'MCM structure',etot)
89 call var_to_geom(nvar,var1)
97 c call sc_move(2,nres-1,1,10d0,nft_sc,etot)
98 c call geom_to_var(nvar,var)
101 c call write_pdb(998 ,'sc min',etot)
103 c call minimize(etot,var,iretcode,nfun)
104 c write(iout,*)'------------------------------------------------'
105 c write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun
107 c call var_to_geom(nvar,var)
109 c call write_pdb(999,'full min',etot)
117 implicit real*8 (a-h,o-z)
122 include 'COMMON.INTERACT'
123 include 'COMMON.IOUNITS'
124 include 'COMMON.DISTFIT'
125 include 'COMMON.SBRIDGE'
126 include 'COMMON.CONTROL'
127 include 'COMMON.FFIELD'
128 include 'COMMON.MINIM'
129 include 'COMMON.CHAIN'
130 double precision time0,time1
131 double precision energy(0:n_ene),ee
132 double precision var(maxvar),var1(maxvar)
138 call geom_to_var(nvar,var1)
140 call etotal(energy(0))
142 write(iout,*) nnt,nct,etot
143 call write_pdb(1,'first structure',etot)
144 call secondary2(.true.)
153 call var_to_geom(nvar,var1)
154 write(iout,*) 'N16 test',(jdata(i),i=1,5)
155 call beta_slide(jdata(1),jdata(2),jdata(3),jdata(4),jdata(5)
157 call geom_to_var(nvar,var)
161 call minimize(etot,var,iretcode,nfun)
162 write(iout,*)'------------------------------------------------'
163 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
164 & '+ DIST eval',ieval
167 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
168 & nfun/(time1-time0),' eval/s'
170 call var_to_geom(nvar,var)
172 call write_pdb(ij*100+99,'full min',etot)
182 subroutine test_local
183 implicit real*8 (a-h,o-z)
187 include 'COMMON.INTERACT'
188 include 'COMMON.IOUNITS'
189 double precision time0,time1
190 double precision energy(0:n_ene),ee
191 double precision varia(maxvar)
194 c call geom_to_var(nvar,varia)
195 call write_pdb(1,'first structure',0d0)
197 call etotal(energy(0))
199 write(iout,*) nnt,nct,etot
201 write(iout,*) 'calling sc_move'
202 call sc_move(nnt,nct,5,10d0,nft_sc,etot)
203 write(iout,*) nft_sc,etot
204 call write_pdb(2,'second structure',etot)
206 write(iout,*) 'calling local_move'
207 call local_move_init(.false.)
208 call local_move(24,29,20d0,50d0)
210 call write_pdb(3,'third structure',etot)
212 write(iout,*) 'calling sc_move'
213 call sc_move(24,29,5,10d0,nft_sc,etot)
214 write(iout,*) nft_sc,etot
215 call write_pdb(2,'last structure',etot)
222 implicit real*8 (a-h,o-z)
226 include 'COMMON.INTERACT'
227 include 'COMMON.IOUNITS'
228 double precision time0,time1
229 double precision energy(0:n_ene),ee
230 double precision varia(maxvar)
233 c call geom_to_var(nvar,varia)
234 call write_pdb(1,'first structure',0d0)
236 call etotal(energy(0))
238 write(iout,*) nnt,nct,etot
240 write(iout,*) 'calling sc_move'
242 call sc_move(nnt,nct,5,10d0,nft_sc,etot)
243 write(iout,*) nft_sc,etot
244 call write_pdb(2,'second structure',etot)
246 write(iout,*) 'calling sc_move 2nd time'
248 call sc_move(nnt,nct,5,1d0,nft_sc,etot)
249 write(iout,*) nft_sc,etot
250 call write_pdb(3,'last structure',etot)
253 c--------------------------------------------------------
254 subroutine bgrow(bstrand,nbstrand,in,ind,new)
255 implicit real*8 (a-h,o-z)
257 include 'COMMON.CHAIN'
258 integer bstrand(maxres/3,6)
260 ishift=iabs(bstrand(in,ind+4)-new)
262 print *,'bgrow',bstrand(in,ind+4),new,ishift
267 bstrand(nbstrand,5)=bstrand(nbstrand,1)
269 IF (bstrand(nbstrand,3).eq.bstrand(i,3)) THEN
270 if (bstrand(i,5).lt.bstrand(i,6)) then
271 bstrand(i,5)=bstrand(i,5)-ishift
273 bstrand(i,5)=bstrand(i,5)+ishift
278 bstrand(nbstrand,6)=bstrand(nbstrand,2)
280 IF (bstrand(nbstrand,3).eq.bstrand(i,3)) THEN
281 if (bstrand(i,6).lt.bstrand(i,5)) then
282 bstrand(i,6)=bstrand(i,6)-ishift
284 bstrand(i,6)=bstrand(i,6)+ishift
295 c------------------------------------------
297 implicit real*8 (a-h,o-z)
301 include 'COMMON.CHAIN'
302 include 'COMMON.IOUNITS'
304 include 'COMMON.CONTROL'
305 include 'COMMON.SBRIDGE'
306 include 'COMMON.FFIELD'
307 include 'COMMON.MINIM'
309 include 'COMMON.DISTFIT'
310 integer if(20,maxres),nif,ifa(20)
311 integer ibc(0:maxres,0:maxres),istrand(20)
312 integer ibd(maxres),ifb(10,2),nifb,lifb(10),lifb0
313 integer itmp(20,maxres)
314 double precision time0,time1
315 double precision energy(0:n_ene),ee
316 double precision varia(maxvar),vorg(maxvar)
318 logical debug,ltest,usedbfrag(maxres/3)
321 integer betasheet(maxres),ibetasheet(maxres),nbetasheet
322 integer bstrand(maxres/3,6),nbstrand
324 c------------------------
327 c------------------------
334 call geom_to_var(nvar,vorg)
335 call secondary2(debug)
337 if (nbfrag.le.1) return
344 nbetasheet=nbetasheet+1
346 bstrand(1,1)=bfrag(1,1)
347 bstrand(1,2)=bfrag(2,1)
348 bstrand(1,3)=nbetasheet
350 bstrand(1,5)=bfrag(1,1)
351 bstrand(1,6)=bfrag(2,1)
352 do i=bfrag(1,1),bfrag(2,1)
353 betasheet(i)=nbetasheet
357 bstrand(2,1)=bfrag(3,1)
358 bstrand(2,2)=bfrag(4,1)
359 bstrand(2,3)=nbetasheet
360 bstrand(2,5)=bfrag(3,1)
361 bstrand(2,6)=bfrag(4,1)
363 if (bfrag(3,1).le.bfrag(4,1)) then
365 do i=bfrag(3,1),bfrag(4,1)
366 betasheet(i)=nbetasheet
371 do i=bfrag(4,1),bfrag(3,1)
372 betasheet(i)=nbetasheet
379 do while (iused_nbfrag.ne.nbfrag)
383 IF (.not.usedbfrag(j)) THEN
385 write (*,*) j,(bfrag(i,j),i=1,4)
387 write (*,'(i4,a3,10i4)') jk,'B',(bstrand(i,jk),i=1,nbstrand)
389 write (*,*) '------------------'
392 if (bfrag(3,j).le.bfrag(4,j)) then
393 do i=bfrag(3,j),bfrag(4,j)
394 if(betasheet(i).eq.nbetasheet) then
396 do k=bfrag(3,j),bfrag(4,j)
397 betasheet(k)=nbetasheet
402 iused_nbfrag=iused_nbfrag+1
403 do k=bfrag(1,j),bfrag(2,j)
404 betasheet(k)=nbetasheet
405 ibetasheet(k)=nbstrand
407 if (bstrand(in,4).lt.0) then
408 bstrand(nbstrand,1)=bfrag(2,j)
409 bstrand(nbstrand,2)=bfrag(1,j)
410 bstrand(nbstrand,3)=nbetasheet
411 bstrand(nbstrand,4)=-nbstrand
412 bstrand(nbstrand,5)=bstrand(nbstrand,1)
413 bstrand(nbstrand,6)=bstrand(nbstrand,2)
414 if(bstrand(in,1).lt.bfrag(4,j)) then
415 call bgrow(bstrand,nbstrand,in,1,bfrag(4,j))
417 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
418 & (bstrand(in,5)-bfrag(4,j))
420 if(bstrand(in,2).gt.bfrag(3,j)) then
421 call bgrow(bstrand,nbstrand,in,2,bfrag(3,j))
423 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
424 & (-bstrand(in,6)+bfrag(3,j))
427 bstrand(nbstrand,1)=bfrag(1,j)
428 bstrand(nbstrand,2)=bfrag(2,j)
429 bstrand(nbstrand,3)=nbetasheet
430 bstrand(nbstrand,4)=nbstrand
431 bstrand(nbstrand,5)=bstrand(nbstrand,1)
432 bstrand(nbstrand,6)=bstrand(nbstrand,2)
433 if(bstrand(in,1).gt.bfrag(3,j)) then
434 call bgrow(bstrand,nbstrand,in,1,bfrag(3,j))
436 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
437 & (-bstrand(in,5)+bfrag(3,j))
439 if(bstrand(in,2).lt.bfrag(4,j)) then
440 call bgrow(bstrand,nbstrand,in,2,bfrag(4,j))
442 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
443 & (bstrand(in,6)-bfrag(4,j))
448 if(betasheet(bfrag(1,j)+i-bfrag(3,j)).eq.nbetasheet) then
449 in=ibetasheet(bfrag(1,j)+i-bfrag(3,j))
450 do k=bfrag(1,j),bfrag(2,j)
451 betasheet(k)=nbetasheet
456 iused_nbfrag=iused_nbfrag+1
457 do k=bfrag(3,1),bfrag(4,1)
458 betasheet(k)=nbetasheet
459 ibetasheet(k)=nbstrand
461 if (bstrand(in,4).lt.0) then
462 bstrand(nbstrand,1)=bfrag(4,j)
463 bstrand(nbstrand,2)=bfrag(3,j)
464 bstrand(nbstrand,3)=nbetasheet
465 bstrand(nbstrand,4)=-nbstrand
466 bstrand(nbstrand,5)=bstrand(nbstrand,1)
467 bstrand(nbstrand,6)=bstrand(nbstrand,2)
468 if(bstrand(in,1).lt.bfrag(2,j)) then
469 call bgrow(bstrand,nbstrand,in,1,bfrag(2,j))
471 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
472 & (bstrand(in,5)-bfrag(2,j))
474 if(bstrand(in,2).gt.bfrag(1,j)) then
475 call bgrow(bstrand,nbstrand,in,2,bfrag(1,j))
477 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
478 & (-bstrand(in,6)+bfrag(1,j))
481 bstrand(nbstrand,1)=bfrag(3,j)
482 bstrand(nbstrand,2)=bfrag(4,j)
483 bstrand(nbstrand,3)=nbetasheet
484 bstrand(nbstrand,4)=nbstrand
485 bstrand(nbstrand,5)=bstrand(nbstrand,1)
486 bstrand(nbstrand,6)=bstrand(nbstrand,2)
487 if(bstrand(in,1).gt.bfrag(1,j)) then
488 call bgrow(bstrand,nbstrand,in,1,bfrag(1,j))
490 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
491 & (-bstrand(in,5)+bfrag(1,j))
493 if(bstrand(in,2).lt.bfrag(2,j)) then
494 call bgrow(bstrand,nbstrand,in,2,bfrag(2,j))
496 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
497 & (bstrand(in,6)-bfrag(2,j))
504 do i=bfrag(4,j),bfrag(3,j)
505 if(betasheet(i).eq.nbetasheet) then
507 do k=bfrag(4,j),bfrag(3,j)
508 betasheet(k)=nbetasheet
513 iused_nbfrag=iused_nbfrag+1
514 do k=bfrag(1,j),bfrag(2,j)
515 betasheet(k)=nbetasheet
516 ibetasheet(k)=nbstrand
518 if (bstrand(in,4).lt.0) then
519 bstrand(nbstrand,1)=bfrag(1,j)
520 bstrand(nbstrand,2)=bfrag(2,j)
521 bstrand(nbstrand,3)=nbetasheet
522 bstrand(nbstrand,4)=nbstrand
523 bstrand(nbstrand,5)=bstrand(nbstrand,1)
524 bstrand(nbstrand,6)=bstrand(nbstrand,2)
525 if(bstrand(in,1).lt.bfrag(3,j)) then
526 call bgrow(bstrand,nbstrand,in,1,bfrag(3,j))
528 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
529 & (bstrand(in,5)-bfrag(3,j))
531 if(bstrand(in,2).gt.bfrag(4,j)) then
532 call bgrow(bstrand,nbstrand,in,2,bfrag(4,j))
534 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
535 & (-bstrand(in,6)+bfrag(4,j))
538 bstrand(nbstrand,1)=bfrag(2,j)
539 bstrand(nbstrand,2)=bfrag(1,j)
540 bstrand(nbstrand,3)=nbetasheet
541 bstrand(nbstrand,4)=-nbstrand
542 bstrand(nbstrand,5)=bstrand(nbstrand,1)
543 bstrand(nbstrand,6)=bstrand(nbstrand,2)
544 if(bstrand(in,1).gt.bfrag(4,j)) then
545 call bgrow(bstrand,nbstrand,in,1,bfrag(4,j))
547 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
548 & (-bstrand(in,5)+bfrag(4,j))
550 if(bstrand(in,2).lt.bfrag(3,j)) then
551 call bgrow(bstrand,nbstrand,in,2,bfrag(3,j))
553 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
554 & (bstrand(in,6)-bfrag(3,j))
559 if(betasheet(bfrag(2,j)-i+bfrag(4,j)).eq.nbetasheet) then
560 in=ibetasheet(bfrag(2,j)-i+bfrag(4,j))
561 do k=bfrag(1,j),bfrag(2,j)
562 betasheet(k)=nbetasheet
567 iused_nbfrag=iused_nbfrag+1
568 do k=bfrag(4,j),bfrag(3,j)
569 betasheet(k)=nbetasheet
570 ibetasheet(k)=nbstrand
572 if (bstrand(in,4).lt.0) then
573 bstrand(nbstrand,1)=bfrag(4,j)
574 bstrand(nbstrand,2)=bfrag(3,j)
575 bstrand(nbstrand,3)=nbetasheet
576 bstrand(nbstrand,4)=nbstrand
577 bstrand(nbstrand,5)=bstrand(nbstrand,1)
578 bstrand(nbstrand,6)=bstrand(nbstrand,2)
579 if(bstrand(in,1).lt.bfrag(2,j)) then
580 call bgrow(bstrand,nbstrand,in,1,bfrag(2,j))
582 bstrand(nbstrand,5)=bstrand(nbstrand,5)-
583 & (bstrand(in,5)-bfrag(2,j))
585 if(bstrand(in,2).gt.bfrag(1,j)) then
586 call bgrow(bstrand,nbstrand,in,2,bfrag(1,j))
588 bstrand(nbstrand,6)=bstrand(nbstrand,6)+
589 & (-bstrand(in,6)+bfrag(1,j))
592 bstrand(nbstrand,1)=bfrag(3,j)
593 bstrand(nbstrand,2)=bfrag(4,j)
594 bstrand(nbstrand,3)=nbetasheet
595 bstrand(nbstrand,4)=-nbstrand
596 bstrand(nbstrand,5)=bstrand(nbstrand,1)
597 bstrand(nbstrand,6)=bstrand(nbstrand,2)
598 if(bstrand(in,1).gt.bfrag(1,j)) then
599 call bgrow(bstrand,nbstrand,in,1,bfrag(1,j))
601 bstrand(nbstrand,5)=bstrand(nbstrand,5)+
602 & (-bstrand(in,5)+bfrag(1,j))
604 if(bstrand(in,2).lt.bfrag(2,j)) then
605 call bgrow(bstrand,nbstrand,in,2,bfrag(2,j))
607 bstrand(nbstrand,6)=bstrand(nbstrand,6)-
608 & (bstrand(in,6)-bfrag(2,j))
622 do while (usedbfrag(j))
627 nbetasheet=nbetasheet+1
628 bstrand(nbstrand,1)=bfrag(1,j)
629 bstrand(nbstrand,2)=bfrag(2,j)
630 bstrand(nbstrand,3)=nbetasheet
631 bstrand(nbstrand,5)=bfrag(1,j)
632 bstrand(nbstrand,6)=bfrag(2,j)
634 bstrand(nbstrand,4)=nbstrand
635 do i=bfrag(1,j),bfrag(2,j)
636 betasheet(i)=nbetasheet
637 ibetasheet(i)=nbstrand
641 bstrand(nbstrand,1)=bfrag(3,j)
642 bstrand(nbstrand,2)=bfrag(4,j)
643 bstrand(nbstrand,3)=nbetasheet
644 bstrand(nbstrand,5)=bfrag(3,j)
645 bstrand(nbstrand,6)=bfrag(4,j)
647 if (bfrag(3,j).le.bfrag(4,j)) then
648 bstrand(nbstrand,4)=nbstrand
649 do i=bfrag(3,j),bfrag(4,j)
650 betasheet(i)=nbetasheet
651 ibetasheet(i)=nbstrand
654 bstrand(nbstrand,4)=-nbstrand
655 do i=bfrag(4,j),bfrag(3,j)
656 betasheet(i)=nbetasheet
657 ibetasheet(i)=nbstrand
661 iused_nbfrag=iused_nbfrag+1
667 write (*,'(i4,a3,10i4)') jk,'A',(bstrand(i,jk),i=1,nbstrand)
674 if (betasheet(i).ne.0) write(*,*) i,betasheet(i),ibetasheet(i)
678 write (*,'(i4,a3,10i4)') j,':',(bstrand(i,j),i=1,nbstrand)
681 c------------------------
685 if(iabs(bstrand(i,5)-bstrand(j,5)).le.5 .or.
686 & iabs(bstrand(i,6)-bstrand(j,6)).le.5 ) then
688 ifb(nifb,1)=bstrand(i,4)
689 ifb(nifb,2)=bstrand(j,4)
696 write (*,'(a3,20i4)') "ifb",i,ifb(i,1),ifb(i,2)
702 write (*,'(a3,20i4)') "ifa",(ifa(i),i=1,nbstrand)
704 nif=iabs(bstrand(1,6)-bstrand(1,5))+1
706 if (iabs(bstrand(j,6)-bstrand(j,5))+1.gt.nif)
707 & nif=iabs(bstrand(j,6)-bstrand(j,5))+1
713 if(j,i)=bstrand(j,6)+(i-1)*sign(1,bstrand(j,5)-bstrand(j,6))
714 if (if(j,i).gt.0) then
715 if(betasheet(if(j,i)).eq.0 .or.
716 & ibetasheet(if(j,i)).ne.iabs(bstrand(j,4))) if(j,i)=0
721 write(*,'(a3,10i4)') 'if ',(if(j,i),j=1,nbstrand)
724 c read (inp,*) (ifa(i),i=1,4)
726 c read (inp,*,err=20,end=20) (if(j,i),j=1,4)
730 c------------------------
735 cccccccccccccccccccccccccccccccccc
737 cccccccccccccccccccccccccccccccccc
741 istrand(is-j+1)=int(ii/is**(is-j))
742 ii=ii-istrand(is-j+1)*is**(is-j)
746 istrand(k)=istrand(k)+1
747 if(istrand(k).gt.isa) istrand(k)=istrand(k)-2*isa-1
751 if(istrand(k).eq.istrand(l).and.k.ne.l.or.
752 & istrand(k).eq.-istrand(l).and.k.ne.l) ltest=.false.
761 & ifb(m,1).eq.istrand(k).and.ifb(m,2).eq.istrand(k+1).or.
762 & ifb(m,2).eq.istrand(k).and.ifb(m,1).eq.istrand(k+1).or.
763 & -ifb(m,1).eq.istrand(k).and.-ifb(m,2).eq.istrand(k+1).or.
764 & -ifb(m,2).eq.istrand(k).and.-ifb(m,1).eq.istrand(k+1))
770 if (mod(isa,2).eq.0) then
772 if (istrand(k).eq.1) ltest=.false.
776 if (istrand(k).eq.1) ltest=.false.
780 IF (ltest.and.lifb0.eq.1) THEN
783 call var_to_geom(nvar,vorg)
785 write (*,'(i5,i10,10i3)') iconf,ig,(istrand(k),k=1,isa)
786 write (iout,'(i5,i10,10i3)') iconf,ig,(istrand(k),k=1,isa)
787 write (linia,'(10i3)') (istrand(k),k=1,isa)
797 if ( sign(1,istrand(i)).eq.sign(1,ifa(iabs(istrand(i)))) ) then
799 itmp(iabs(istrand(i)),j)=if(iabs(ifa(iabs(istrand(i)))),j)
803 itmp(iabs(istrand(i)),j)=if(iabs(ifa(iabs(istrand(i)))),nif-j+1)
809 write(*,*) (itmp(j,i),j=1,4)
813 c ifa(1),ifa(2),ifa(3),ifa(4)
814 c if(1,i),if(2,i),if(3,i),if(4,i)
819 & ifb(m,1).eq.istrand(k).and.ifb(m,2).eq.istrand(k+1).or.
820 & ifb(m,2).eq.istrand(k).and.ifb(m,1).eq.istrand(k+1).or.
821 & -ifb(m,1).eq.istrand(k).and.-ifb(m,2).eq.istrand(k+1).or.
822 & -ifb(m,2).eq.istrand(k).and.-ifb(m,1).eq.istrand(k+1))
830 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+1)),i))=-1
832 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+1)),i))=-2
836 & ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+2)),i))=-3
838 & ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+3)),i))=-4
841 c------------------------
844 c freeze sec.elements
854 do i=bfrag(1,j),bfrag(2,j)
859 if (bfrag(3,j).le.bfrag(4,j)) then
860 do i=bfrag(3,j),bfrag(4,j)
866 do i=bfrag(4,j),bfrag(3,j)
874 do i=hfrag(1,j),hfrag(2,j)
882 c------------------------
883 c generate constrains
891 if ( ibc(i,j).eq.-1 .or. ibc(j,i).eq.-1) then
899 else if ( ibc(i,j).eq.-2 .or. ibc(j,i).eq.-2) then
907 else if ( ibc(i,j).eq.-3 .or. ibc(j,i).eq.-3) then
915 else if ( ibc(i,j).eq.-4 .or. ibc(j,i).eq.-4) then
923 else if ( ibc(i,j).gt.0 ) then
924 d0(ind)=DIST(i,ibc(i,j))
931 else if ( ibc(j,i).gt.0 ) then
932 d0(ind)=DIST(ibc(j,i),j)
946 cd--------------------------
948 write(iout,'(i3,2i4,a3,2i4,f7.2)') (i,ibc(ihpb(i),jhpb(i)),
949 & ibc(jhpb(i),ihpb(i)),' --',
950 & ihpb(i),jhpb(i),dhpb(i),i=1,nhpb)
956 call contact_cp_min(varia,ifun,iconf,linia,debug)
959 call minimize(etot,varia,iretcode,nfun)
960 write(iout,*)'------------------------------------------------'
961 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
965 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
966 & nfun/(time1-time0),' eval/s'
968 write (linia,'(a10,10i3)') 'full_min',(istrand(k),k=1,isa)
969 call var_to_geom(nvar,varia)
971 call write_pdb(900+iconf,linia,etot)
974 call etotal(energy(0))
976 call enerprint(energy(0))
978 cd call briefout(0,etot)
979 cd call secondary2(.true.)
983 cccccccccccccccccccccccccccccccccccc
986 cccccccccccccccccccccccccccccccccccc
989 10 write (iout,'(a)') 'Error reading test structure.'
992 c--------------------------------------------------------
995 implicit real*8 (a-h,o-z)
999 include 'COMMON.CHAIN'
1000 include 'COMMON.IOUNITS'
1001 include 'COMMON.VAR'
1002 include 'COMMON.CONTROL'
1003 include 'COMMON.SBRIDGE'
1004 include 'COMMON.FFIELD'
1005 include 'COMMON.MINIM'
1007 include 'COMMON.DISTFIT'
1008 integer if(3,maxres),nif
1009 integer ibc(maxres,maxres),istrand(20)
1010 integer ibd(maxres),ifb(10,2),nifb,lifb(10),lifb0
1011 double precision time0,time1
1012 double precision energy(0:n_ene),ee
1013 double precision varia(maxvar)
1019 read (inp,*,err=20,end=20) if(1,i),if(2,i),if(3,i)
1022 write (*,'(a4,3i5)') ('if =',if(1,i),if(2,i),if(3,i),
1026 c------------------------
1027 call secondary2(debug)
1028 c------------------------
1036 c freeze sec.elements and store indexes for beta constrains
1046 do i=bfrag(1,j),bfrag(2,j)
1051 if (bfrag(3,j).le.bfrag(4,j)) then
1052 do i=bfrag(3,j),bfrag(4,j)
1056 ibc(bfrag(1,j)+i-bfrag(3,j),i)=-1
1059 do i=bfrag(4,j),bfrag(3,j)
1063 ibc(bfrag(2,j)-i+bfrag(4,j),i)=-1
1068 do i=hfrag(1,j),hfrag(2,j)
1077 c ---------------- test --------------
1079 if (ibc(if(1,i),if(2,i)).eq.-1) then
1080 ibc(if(1,i),if(2,i))=if(3,i)
1081 ibc(if(1,i),if(3,i))=if(2,i)
1082 else if (ibc(if(2,i),if(1,i)).eq.-1) then
1083 ibc(if(2,i),if(1,i))=0
1084 ibc(if(1,i),if(2,i))=if(3,i)
1085 ibc(if(1,i),if(3,i))=if(2,i)
1087 ibc(if(1,i),if(2,i))=if(3,i)
1088 ibc(if(1,i),if(3,i))=if(2,i)
1094 if (ibc(i,j).ne.0) write(*,'(3i5)') i,j,ibc(i,j)
1097 c------------------------
1103 if ( ibc(i,j).eq.-1 ) then
1111 else if ( ibc(i,j).gt.0 ) then
1112 d0(ind)=DIST(i,ibc(i,j))
1119 else if ( ibc(j,i).gt.0 ) then
1120 d0(ind)=DIST(ibc(j,i),j)
1134 cd--------------------------
1135 write(*,'(i3,2i4,a3,2i4,f7.2)') (i,ibc(ihpb(i),jhpb(i)),
1136 & ibc(jhpb(i),ihpb(i)),' --',
1137 & ihpb(i),jhpb(i),dhpb(i),i=1,nhpb)
1144 call contact_cp_min(varia,ieval,in_pdb,linia,debug)
1147 call minimize(etot,varia,iretcode,nfun)
1148 write(iout,*)'------------------------------------------------'
1149 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
1150 & '+ DIST eval',ieval
1153 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
1154 & nfun/(time1-time0),' eval/s'
1157 call var_to_geom(nvar,varia)
1159 call write_pdb(999,'full min',etot)
1162 call etotal(energy(0))
1164 call enerprint(energy(0))
1166 call briefout(0,etot)
1167 call secondary2(.true.)
1170 10 write (iout,'(a)') 'Error reading test structure.'
1178 implicit real*8 (a-h,o-z)
1179 include 'DIMENSIONS'
1181 include 'COMMON.GEO'
1182 include 'COMMON.CHAIN'
1183 include 'COMMON.IOUNITS'
1184 include 'COMMON.VAR'
1185 include 'COMMON.CONTROL'
1186 include 'COMMON.SBRIDGE'
1187 include 'COMMON.FFIELD'
1188 include 'COMMON.MINIM'
1190 include 'COMMON.DISTFIT'
1193 double precision time0,time1
1194 double precision energy(0:n_ene),ee
1195 double precision theta2(maxres),phi2(maxres),alph2(maxres),
1197 & theta1(maxres),phi1(maxres),alph1(maxres),
1199 double precision varia(maxvar),varia2(maxvar)
1203 read (inp,*,err=10,end=10) if(1,1),if(1,2),if(2,1),if(2,2)
1204 write (iout,'(a4,4i5)') 'if =',if(1,1),if(1,2),if(2,1),if(2,2)
1205 read (inp,*,err=10,end=10) (theta2(i),i=3,nres)
1206 read (inp,*,err=10,end=10) (phi2(i),i=4,nres)
1207 read (inp,*,err=10,end=10) (alph2(i),i=2,nres-1)
1208 read (inp,*,err=10,end=10) (omeg2(i),i=2,nres-1)
1210 theta2(i)=deg2rad*theta2(i)
1211 phi2(i)=deg2rad*phi2(i)
1212 alph2(i)=deg2rad*alph2(i)
1213 omeg2(i)=deg2rad*omeg2(i)
1227 c------------------------
1232 do i=if(j,1),if(j,2)
1238 call geom_to_var(nvar,varia)
1239 call write_pdb(1,'first structure',0d0)
1241 call secondary(.true.)
1243 call secondary2(.true.)
1246 if ( (bfrag(3,j).lt.bfrag(4,j) .or.
1247 & bfrag(4,j)-bfrag(2,j).gt.4) .and.
1248 & bfrag(2,j)-bfrag(1,j).gt.3 ) then
1251 if (bfrag(3,j).lt.bfrag(4,j)) then
1252 write(iout,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1253 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
1254 & ,",",bfrag(3,j)-1,"-",bfrag(4,j)-1
1256 write(iout,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1257 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
1258 & ,",",bfrag(4,j)-1,"-",bfrag(3,j)-1
1271 call geom_to_var(nvar,varia2)
1272 call write_pdb(2,'second structure',0d0)
1276 c-------------------------------------------------------
1279 call contact_cp(varia,varia2,iff,ifun,7)
1282 call minimize(etot,varia,iretcode,nfun)
1283 write(iout,*)'------------------------------------------------'
1284 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
1285 & '+ DIST eval',ifun
1288 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
1289 & nfun/(time1-time0),' eval/s'
1292 call var_to_geom(nvar,varia)
1294 call write_pdb(999,'full min',etot)
1297 call etotal(energy(0))
1299 call enerprint(energy(0))
1301 call briefout(0,etot)
1304 10 write (iout,'(a)') 'Error reading test structure.'
1308 c-------------------------------------------------
1309 c-------------------------------------------------
1311 subroutine secondary(lprint)
1312 implicit real*8 (a-h,o-z)
1313 include 'DIMENSIONS'
1314 include 'COMMON.CHAIN'
1315 include 'COMMON.IOUNITS'
1316 include 'COMMON.DISTFIT'
1318 integer ncont,icont(2,maxres*maxres/2),isec(maxres,3)
1319 logical lprint,not_done
1320 real dcont(maxres*maxres/2),d
1325 double precision xpi(3),xpj(3)
1330 cd call write_pdb(99,'sec structure',0d0)
1342 xpi(k)=0.5d0*(c(k,i-1)+c(k,i))
1346 xpj(k)=0.5d0*(c(k,j-1)+c(k,j))
1348 cd d = (c(1,i)-c(1,j))*(c(1,i)-c(1,j)) +
1349 cd & (c(2,i)-c(2,j))*(c(2,i)-c(2,j)) +
1350 cd & (c(3,i)-c(3,j))*(c(3,i)-c(3,j))
1351 cd print *,'CA',i,j,d
1352 d = (xpi(1)-xpj(1))*(xpi(1)-xpj(1)) +
1353 & (xpi(2)-xpj(2))*(xpi(2)-xpj(2)) +
1354 & (xpi(3)-xpj(3))*(xpi(3)-xpj(3))
1355 if ( d.lt.rcomp*rcomp) then
1359 dcont(ncont)=sqrt(d)
1365 write (iout,'(a)') '#PP contact map distances:'
1367 write (iout,'(3i4,f10.5)')
1368 & i,icont(1,i),icont(2,i),dcont(i)
1372 c finding parallel beta
1373 cd write (iout,*) '------- looking for parallel beta -----------'
1379 if(dcont(i).le.rbeta .and. j1-i1.gt.4 .and.
1380 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1381 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1382 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1383 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1384 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1388 cd write (iout,*) i1,j1,dcont(i)
1394 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)
1395 & .and. dcont(j).le.rbeta .and.
1396 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1397 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1398 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1399 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1400 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1405 cd write (iout,*) i1,j1,dcont(j),not_done
1409 if (i1-ii1.gt.1) then
1413 if(lprint)write(iout,*)'parallel beta',nbeta,ii1,i1,jj1,j1
1422 isec(ij,1)=isec(ij,1)+1
1423 isec(ij,1+isec(ij,1))=nbeta
1426 isec(ij,1)=isec(ij,1)+1
1427 isec(ij,1+isec(ij,1))=nbeta
1432 if (nbeta.le.9) then
1433 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1434 & "DefPropRes 'strand",nstrand,
1435 & "' 'num = ",ii1-1,"..",i1-1,"'"
1437 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1438 & "DefPropRes 'strand",nstrand,
1439 & "' 'num = ",ii1-1,"..",i1-1,"'"
1442 if (nbeta.le.9) then
1443 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1444 & "DefPropRes 'strand",nstrand,
1445 & "' 'num = ",jj1-1,"..",j1-1,"'"
1447 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1448 & "DefPropRes 'strand",nstrand,
1449 & "' 'num = ",jj1-1,"..",j1-1,"'"
1451 write(12,'(a8,4i4)')
1452 & "SetNeigh",ii1-1,i1-1,jj1-1,j1-1
1458 c finding antiparallel beta
1459 cd write (iout,*) '--------- looking for antiparallel beta ---------'
1464 if (dcont(i).le.rbeta.and.
1465 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1466 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1467 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1468 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1469 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1473 cd write (iout,*) i1,j1,dcont(i)
1480 if (i1.eq.icont(1,j).and.j1.eq.icont(2,j) .and.
1481 & isec(i1,1).le.1.and.isec(j1,1).le.1.and.
1482 & (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and.
1483 & (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and.
1484 & (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and.
1485 & (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0)
1486 & .and. dcont(j).le.rbeta ) goto 6
1490 cd write (iout,*) i1,j1,dcont(j),not_done
1494 if (i1-ii1.gt.1) then
1495 if(lprint)write (iout,*)'antiparallel beta',
1496 & nbeta,ii1-1,i1,jj1,j1-1
1499 bfrag(1,nbfrag)=max0(ii1-1,1)
1502 bfrag(4,nbfrag)=max0(j1-1,1)
1507 isec(ij,1)=isec(ij,1)+1
1508 isec(ij,1+isec(ij,1))=nbeta
1512 isec(ij,1)=isec(ij,1)+1
1513 isec(ij,1+isec(ij,1))=nbeta
1519 if (nstrand.le.9) then
1520 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1521 & "DefPropRes 'strand",nstrand,
1522 & "' 'num = ",ii1-2,"..",i1-1,"'"
1524 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1525 & "DefPropRes 'strand",nstrand,
1526 & "' 'num = ",ii1-2,"..",i1-1,"'"
1529 if (nstrand.le.9) then
1530 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
1531 & "DefPropRes 'strand",nstrand,
1532 & "' 'num = ",j1-2,"..",jj1-1,"'"
1534 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
1535 & "DefPropRes 'strand",nstrand,
1536 & "' 'num = ",j1-2,"..",jj1-1,"'"
1538 write(12,'(a8,4i4)')
1539 & "SetNeigh",ii1-2,i1-1,jj1-1,j1-2
1545 if (nstrand.gt.0.and.lprint) then
1546 write(12,'(a27,$)') "DefPropRes 'sheet' 'strand1"
1549 write(12,'(a9,i1,$)') " | strand",i
1551 write(12,'(a9,i2,$)') " | strand",i
1554 write(12,'(a1)') "'"
1558 c finding alpha or 310 helix
1564 if (j1.eq.i1+3.and.dcont(i).le.r310
1565 & .or.j1.eq.i1+4.and.dcont(i).le.ralfa ) then
1566 cd if (j1.eq.i1+3) write (iout,*) "found 1-4 ",i1,j1,dcont(i)
1567 cd if (j1.eq.i1+4) write (iout,*) "found 1-5 ",i1,j1,dcont(i)
1570 if (isec(ii1,1).eq.0) then
1579 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)) goto 10
1583 cd write (iout,*) i1,j1,not_done
1586 if (j1-ii1.gt.4) then
1588 cd write (iout,*)'helix',nhelix,ii1,j1
1592 hfrag(2,nhfrag)=max0(j1-1,1)
1598 write (iout,'(a6,i3,2i4)') "Helix",nhelix,ii1-1,j1-2
1599 if (nhelix.le.9) then
1600 write(12,'(a17,i1,a9,i3,a2,i3,a1)')
1601 & "DefPropRes 'helix",nhelix,
1602 & "' 'num = ",ii1-1,"..",j1-2,"'"
1604 write(12,'(a17,i2,a9,i3,a2,i3,a1)')
1605 & "DefPropRes 'helix",nhelix,
1606 & "' 'num = ",ii1-1,"..",j1-2,"'"
1613 if (nhelix.gt.0.and.lprint) then
1614 write(12,'(a26,$)') "DefPropRes 'helix' 'helix1"
1616 if (nhelix.le.9) then
1617 write(12,'(a8,i1,$)') " | helix",i
1619 write(12,'(a8,i2,$)') " | helix",i
1622 write(12,'(a1)') "'"
1626 write(12,'(a37)') "DefPropRes 'coil' '! (helix | sheet)'"
1627 write(12,'(a20)') "XMacStand ribbon.mac"
1633 c----------------------------------------------------------------------------
1635 subroutine write_pdb(npdb,titelloc,ee)
1636 implicit real*8 (a-h,o-z)
1637 include 'DIMENSIONS'
1638 include 'COMMON.IOUNITS'
1639 character*50 titelloc1
1640 character*(*) titelloc
1649 if (npdb.lt.1000) then
1650 call numstr(npdb,zahl)
1651 open(ipdb,file=prefix(:lenpre)//'@@'//zahl//'.pdb')
1653 if (npdb.lt.10000) then
1654 write(liczba5,'(i1,i4)') 0,npdb
1656 write(liczba5,'(i5)') npdb
1658 open(ipdb,file=prefix(:lenpre)//'@@'//liczba5//'.pdb')
1660 call pdbout(ee,titelloc1,ipdb)
1665 c-----------------------------------------------------------
1666 subroutine contact_cp2(var,var2,iff,ieval,in_pdb)
1667 implicit real*8 (a-h,o-z)
1668 include 'DIMENSIONS'
1670 include 'COMMON.SBRIDGE'
1671 include 'COMMON.FFIELD'
1672 include 'COMMON.IOUNITS'
1673 include 'COMMON.DISTFIT'
1674 include 'COMMON.VAR'
1675 include 'COMMON.CHAIN'
1676 include 'COMMON.MINIM'
1680 double precision var(maxvar),var2(maxvar)
1681 double precision time0,time1
1682 integer iff(maxres),ieval
1683 double precision theta1(maxres),phi1(maxres),alph1(maxres),
1687 call var_to_geom(nvar,var)
1694 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
1716 call var_to_geom(nvar,var2)
1719 if ( iff(i).eq.1 ) then
1728 cd call write_pdb(3,'combined structure',0d0)
1729 cd time0=MPI_WTIME()
1732 NY=((NRES-4)*(NRES-5))/2
1733 call distfit(.true.,200)
1735 cd time1=MPI_WTIME()
1736 cd write (iout,'(a,f6.2,a)') ' Time for distfit ',time1-time0,' sec'
1746 call geom_to_var(nvar,var)
1747 cd time0=MPI_WTIME()
1748 call minimize(etot,var,iretcode,nfun)
1749 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
1751 cd time1=MPI_WTIME()
1752 cd write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
1753 cd & nfun/(time1-time0),' SOFT eval/s'
1754 call var_to_geom(nvar,var)
1760 if (iff(1).eq.1) then
1766 if ( iwsk.eq.0.and.iff(i-1).eq.0.and.iff(i).eq.1 ) then
1771 if ( iwsk.eq.1.and.iff(i-1).eq.1.and.iff(i).eq.0 ) then
1777 if (iff(nres).eq.1) then
1783 cd write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1784 cd & "select",ij(1),"-",ij(2),
1785 cd & ",",ij(3),"-",ij(4)
1786 cd call write_pdb(in_pdb,linia,etot)
1792 cd time0=MPI_WTIME()
1793 call minimize(etot,var,iretcode,nfun)
1794 cd write(iout,*)'SUMSL DIST return code is',iretcode,' eval ',nfun
1797 cd time1=MPI_WTIME()
1798 cd write (iout,'(a,f6.2,f8.2,a)')' Time for DIST min.',time1-time0,
1799 cd & nfun/(time1-time0),' eval/s'
1800 cd call var_to_geom(nvar,var)
1802 cd call write_pdb(6,'dist structure',etot)
1812 c-----------------------------------------------------------
1813 subroutine contact_cp(var,var2,iff,ieval,in_pdb)
1814 implicit real*8 (a-h,o-z)
1815 include 'DIMENSIONS'
1816 include 'COMMON.SBRIDGE'
1817 include 'COMMON.FFIELD'
1818 include 'COMMON.IOUNITS'
1819 include 'COMMON.DISTFIT'
1820 include 'COMMON.VAR'
1821 include 'COMMON.CHAIN'
1822 include 'COMMON.MINIM'
1826 double precision energy(0:n_ene)
1827 double precision var(maxvar),var2(maxvar)
1828 double precision time0,time1
1829 integer iff(maxres),ieval
1830 double precision theta1(maxres),phi1(maxres),alph1(maxres),
1836 if (ieval.eq.-1) debug=.true.
1840 c store selected dist. constrains from 1st structure
1843 c Intercept NaNs in the coordinates
1844 c write(iout,*) (var(i),i=1,nvar)
1849 if (x_sum.ne.x_sum) then
1850 write(iout,*)" *** contact_cp : Found NaN in coordinates"
1852 print *," *** contact_cp : Found NaN in coordinates"
1858 call var_to_geom(nvar,var)
1865 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
1888 c freeze sec.elements from 2nd structure
1896 call var_to_geom(nvar,var2)
1897 call secondary2(debug)
1899 do i=bfrag(1,j),bfrag(2,j)
1904 if (bfrag(3,j).le.bfrag(4,j)) then
1905 do i=bfrag(3,j),bfrag(4,j)
1911 do i=bfrag(4,j),bfrag(3,j)
1919 do i=hfrag(1,j),hfrag(2,j)
1928 c copy selected res from 1st to 2nd structure
1932 if ( iff(i).eq.1 ) then
1942 c prepare description in linia variable
1946 if (iff(1).eq.1) then
1952 if ( iwsk.eq.0.and.iff(i-1).eq.0.and.iff(i).eq.1 ) then
1957 if ( iwsk.eq.1.and.iff(i-1).eq.1.and.iff(i).eq.0 ) then
1963 if (iff(nres).eq.1) then
1968 write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
1969 & "SELECT",ij(1)-1,"-",ij(2)-1,
1970 & ",",ij(3)-1,"-",ij(4)-1
1976 call contact_cp_min(var,ieval,in_pdb,linia,debug)
1981 subroutine contact_cp_min(var,ieval,in_pdb,linia,debug)
1983 c input : theta,phi,alph,omeg,in_pdb,linia,debug
1984 c output : var,ieval
1986 implicit real*8 (a-h,o-z)
1987 include 'DIMENSIONS'
1989 include 'COMMON.SBRIDGE'
1990 include 'COMMON.FFIELD'
1991 include 'COMMON.IOUNITS'
1992 include 'COMMON.DISTFIT'
1993 include 'COMMON.VAR'
1994 include 'COMMON.CHAIN'
1995 include 'COMMON.MINIM'
1999 double precision energy(0:n_ene)
2000 double precision var(maxvar)
2001 double precision time0,time1
2002 integer ieval,info(3)
2003 logical debug,fail,check_var,reduce,change
2005 write(iout,'(a20,i6,a20)')
2006 & '------------------',in_pdb,'-------------------'
2010 call write_pdb(1000+in_pdb,'combined structure',0d0)
2015 c run optimization of distances
2017 c uses d0(),w() and mask() for frozen 2D
2019 ctest---------------------------------------------
2021 ctest NY=((NRES-4)*(NRES-5))/2
2022 ctest call distfit(debug,5000)
2054 call geom_to_var(nvar,var)
2055 cde change=reduce(var)
2056 if (check_var(var,info)) then
2057 write(iout,*) 'cp_min error in input'
2058 print *,'cp_min error in input'
2062 cd call etotal(energy(0))
2063 cd call enerprint(energy(0))
2067 cdtest call minimize(etot,var,iretcode,nfun)
2068 cdtest write(iout,*)'SUMSL return code is',iretcode,' eval SDIST',nfun
2071 cd call etotal(energy(0))
2072 cd call enerprint(energy(0))
2091 ctest--------------------------------------------------
2095 write (iout,'(a,f6.2,a)')' Time for distfit ',time1-time0,' sec'
2096 call write_pdb(2000+in_pdb,'distfit structure',0d0)
2105 c run soft pot. optimization
2107 c nhpb,ihpb(),jhpb(),forcon(),dhpb() and hpb_partition
2109 c mask_phi(),mask_theta(),mask_side(),mask_r
2115 cde change=reduce(var)
2116 cde if (check_var(var,info)) write(iout,*) 'error before soft'
2118 call minimize(etot,var,iretcode,nfun)
2120 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
2122 write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
2123 & nfun/(time1-time0),' SOFT eval/s'
2125 call var_to_geom(nvar,var)
2127 call write_pdb(3000+in_pdb,'soft structure',etot)
2130 c run full UNRES optimization with constrains and frozen 2D
2131 c the same variables as soft pot. optimizatio
2137 c check overlaps before calling full UNRES minim
2139 call var_to_geom(nvar,var)
2141 call etotal(energy(0))
2143 write(iout,*) 'N7 ',energy(0)
2144 if (energy(0).ne.energy(0)) then
2145 write(iout,*) 'N7 error - gives NaN',energy(0)
2149 if (energy(1).eq.1.0d20) then
2150 write (iout,'(a,1pe14.5)')'#N7_OVERLAP evdw=1d20',energy(1)
2151 call overlap_sc(fail)
2153 call etotal(energy(0))
2155 write (iout,'(a,1pe14.5)')'#N7_OVERLAP evdw after',energy(1)
2167 cdte time0=MPI_WTIME()
2168 cde change=reduce(var)
2169 cde if (check_var(var,info)) then
2170 cde write(iout,*) 'error before mask dist'
2171 cde call var_to_geom(nvar,var)
2173 cde call write_pdb(10000+in_pdb,'before mask dist',etot)
2175 cdte call minimize(etot,var,iretcode,nfun)
2176 cdte write(iout,*)'SUMSL MASK DIST return code is',iretcode,
2177 cdte & ' eval ',nfun
2178 cdte ieval=ieval+nfun
2180 cdte time1=MPI_WTIME()
2181 cdte write (iout,'(a,f6.2,f8.2,a)')
2182 cdte & ' Time for mask dist min.',time1-time0,
2183 cdte & nfun/(time1-time0),' eval/s'
2184 cdte call flush(iout)
2186 call var_to_geom(nvar,var)
2188 call write_pdb(4000+in_pdb,'mask dist',etot)
2191 c switch off freezing of 2D and
2192 c run full UNRES optimization with constrains
2196 cde change=reduce(var)
2197 cde if (check_var(var,info)) then
2198 cde write(iout,*) 'error before dist'
2199 cde call var_to_geom(nvar,var)
2201 cde call write_pdb(11000+in_pdb,'before dist',etot)
2204 call minimize(etot,var,iretcode,nfun)
2206 cde change=reduce(var)
2207 cde if (check_var(var,info)) then
2208 cde write(iout,*) 'error after dist',ico
2209 cde call var_to_geom(nvar,var)
2211 cde call write_pdb(12000+in_pdb+ico*1000,'after dist',etot)
2213 write(iout,*)'SUMSL DIST return code is',iretcode,' eval ',nfun
2217 write (iout,'(a,f6.2,f8.2,a)')' Time for dist min.',time1-time0,
2218 & nfun/(time1-time0),' eval/s'
2219 cde call etotal(energy(0))
2220 cde write(iout,*) 'N7 after dist',energy(0)
2224 call var_to_geom(nvar,var)
2226 call write_pdb(in_pdb,linia,etot)
2238 c--------------------------------------------------------
2240 implicit real*8 (a-h,o-z)
2241 include 'DIMENSIONS'
2243 include 'COMMON.GEO'
2244 include 'COMMON.CHAIN'
2245 include 'COMMON.IOUNITS'
2246 include 'COMMON.VAR'
2247 include 'COMMON.CONTROL'
2248 include 'COMMON.SBRIDGE'
2249 include 'COMMON.FFIELD'
2250 include 'COMMON.MINIM'
2251 include 'COMMON.INTERACT'
2253 include 'COMMON.DISTFIT'
2255 double precision time0,time1
2256 double precision energy(0:n_ene),ee
2257 double precision var(maxvar)
2260 logical debug,ltest,fail
2269 c------------------------
2271 c freeze sec.elements
2281 do i=bfrag(1,j),bfrag(2,j)
2286 if (bfrag(3,j).le.bfrag(4,j)) then
2287 do i=bfrag(3,j),bfrag(4,j)
2293 do i=bfrag(4,j),bfrag(3,j)
2301 do i=hfrag(1,j),hfrag(2,j)
2313 c store dist. constrains
2317 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
2322 dhpb(nhpb)=DIST(i,j)
2330 call write_pdb(100+in_pdb,'input reg. structure',0d0)
2340 c run soft pot. optimization
2346 call geom_to_var(nvar,var)
2348 call minimize(etot,var,iretcode,nfun)
2350 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
2352 write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
2353 & nfun/(time1-time0),' SOFT eval/s'
2355 call var_to_geom(nvar,var)
2357 call write_pdb(300+in_pdb,'soft structure',etot)
2360 c run full UNRES optimization with constrains and frozen 2D
2361 c the same variables as soft pot. optimizatio
2368 call minimize(etot,var,iretcode,nfun)
2369 write(iout,*)'SUMSL MASK DIST return code is',iretcode,
2374 write (iout,'(a,f6.2,f8.2,a)')
2375 & ' Time for mask dist min.',time1-time0,
2376 & nfun/(time1-time0),' eval/s'
2378 call var_to_geom(nvar,var)
2380 call write_pdb(400+in_pdb,'mask & dist',etot)
2383 c switch off constrains and
2384 c run full UNRES optimization with frozen 2D
2398 call minimize(etot,var,iretcode,nfun)
2399 write(iout,*)'SUMSL MASK return code is',iretcode,' eval ',nfun
2403 write (iout,'(a,f6.2,f8.2,a)')' Time for mask min.',time1-time0,
2404 & nfun/(time1-time0),' eval/s'
2408 call var_to_geom(nvar,var)
2410 call write_pdb(500+in_pdb,'mask 2d frozen',etot)
2417 c run full UNRES optimization with constrains and NO frozen 2D
2427 wstrain=wstrain0/ico
2430 call minimize(etot,var,iretcode,nfun)
2431 write(iout,'(a10,f6.3,a14,i3,a6,i5)')
2432 & ' SUMSL DIST',wstrain,' return code is',iretcode,
2437 write (iout,'(a,f6.2,f8.2,a)')
2438 & ' Time for dist min.',time1-time0,
2439 & nfun/(time1-time0),' eval/s'
2441 call var_to_geom(nvar,var)
2443 call write_pdb(600+in_pdb+ico,'dist cons',etot)
2458 call minimize(etot,var,iretcode,nfun)
2459 write(iout,*)'------------------------------------------------'
2460 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,
2461 & '+ DIST eval',ieval
2464 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,
2465 & nfun/(time1-time0),' eval/s'
2468 call var_to_geom(nvar,var)
2470 call write_pdb(999,'full min',etot)
2477 subroutine beta_slide(i1,i2,i3,i4,i5,ieval,ij)
2478 implicit real*8 (a-h,o-z)
2479 include 'DIMENSIONS'
2481 include 'COMMON.GEO'
2482 include 'COMMON.VAR'
2483 include 'COMMON.INTERACT'
2484 include 'COMMON.IOUNITS'
2485 include 'COMMON.DISTFIT'
2486 include 'COMMON.SBRIDGE'
2487 include 'COMMON.CONTROL'
2488 include 'COMMON.FFIELD'
2489 include 'COMMON.MINIM'
2490 include 'COMMON.CHAIN'
2491 double precision time0,time1
2492 double precision energy(0:n_ene),ee
2493 double precision var(maxvar)
2494 integer jdata(5),isec(maxres)
2502 call secondary2(.false.)
2508 do i=bfrag(1,j),bfrag(2,j)
2511 do i=bfrag(4,j),bfrag(3,j),sign(1,bfrag(3,j)-bfrag(4,j))
2516 do i=hfrag(1,j),hfrag(2,j)
2522 c cut strands at the ends
2524 if (jdata(2)-jdata(1).gt.3) then
2527 if (jdata(3).lt.jdata(4)) then
2537 cv call etotal(energy(0))
2539 cv write(iout,*) nnt,nct,etot
2540 cv call write_pdb(ij*100,'first structure',etot)
2541 cv write(iout,*) 'N16 test',(jdata(i),i=1,5)
2543 c------------------------
2544 c generate constrains
2547 if(ishift.eq.0) ishift=-2
2550 do i=jdata(1),jdata(2)
2552 if(jdata(4).gt.jdata(3))then
2553 do j=jdata(3)+i-jdata(1)-2,jdata(3)+i-jdata(1)+2
2555 cd print *,i,j,j+ishift
2560 dhpb(nhpb)=DIST(i,j+ishift)
2563 do j=jdata(3)-i+jdata(1)+2,jdata(3)-i+jdata(1)-2,-1
2565 cd print *,i,j,j+ishift
2570 dhpb(nhpb)=DIST(i,j+ishift)
2577 if(isec(i).gt.0.or.isec(j).gt.0) then
2583 dhpb(nhpb)=DIST(i,j)
2590 call geom_to_var(nvar,var)
2597 wstrain=wstrain0/ico
2599 cv time0=MPI_WTIME()
2600 call minimize(etot,var,iretcode,nfun)
2601 write(iout,'(a10,f6.3,a14,i3,a6,i5)')
2602 & ' SUMSL DIST',wstrain,' return code is',iretcode,
2605 cv time1=MPI_WTIME()
2606 cv write (iout,'(a,f6.2,f8.2,a)')
2607 cv & ' Time for dist min.',time1-time0,
2608 cv & nfun/(time1-time0),' eval/s'
2609 cv call var_to_geom(nvar,var)
2611 cv call write_pdb(ij*100+ico,'dist cons',etot)
2623 call sc_move(nnt,nct,100,100d0,nft_sc,etot)
2626 cv call etotal(energy(0))
2628 cv call write_pdb(ij*100+10,'sc_move',etot)
2630 cd print *,nft_sc,etot
2635 subroutine beta_zip(i1,i2,ieval,ij)
2636 implicit real*8 (a-h,o-z)
2637 include 'DIMENSIONS'
2639 include 'COMMON.GEO'
2640 include 'COMMON.VAR'
2641 include 'COMMON.INTERACT'
2642 include 'COMMON.IOUNITS'
2643 include 'COMMON.DISTFIT'
2644 include 'COMMON.SBRIDGE'
2645 include 'COMMON.CONTROL'
2646 include 'COMMON.FFIELD'
2647 include 'COMMON.MINIM'
2648 include 'COMMON.CHAIN'
2649 double precision time0,time1
2650 double precision energy(0:n_ene),ee
2651 double precision var(maxvar)
2655 cv call etotal(energy(0))
2657 cv write(test,'(2i5)') i1,i2
2658 cv call write_pdb(ij*100,test,etot)
2659 cv write(iout,*) 'N17 test',i1,i2,etot,ij
2662 c generate constrains
2673 call geom_to_var(nvar,var)
2679 wstrain=wstrain0/ico
2680 cv time0=MPI_WTIME()
2681 call minimize(etot,var,iretcode,nfun)
2682 write(iout,'(a10,f6.3,a14,i3,a6,i5)')
2683 & ' SUMSL DIST',wstrain,' return code is',iretcode,
2686 cv time1=MPI_WTIME()
2687 cv write (iout,'(a,f6.2,f8.2,a)')
2688 cv & ' Time for dist min.',time1-time0,
2689 cv & nfun/(time1-time0),' eval/s'
2690 c do not comment the next line
2691 call var_to_geom(nvar,var)
2693 cv call write_pdb(ij*100+ico,'dist cons',etot)
2701 cv call etotal(energy(0))
2703 cv write(iout,*) 'N17 test end',i1,i2,etot,ij