2 !-----------------------------------------------------------------------------
14 use control, only: hpb_partition
16 use minimm, only: sc_move, minimize
19 !-----------------------------------------------------------------------------
22 !-----------------------------------------------------------------------------
25 !-----------------------------------------------------------------------------
27 !-----------------------------------------------------------------------------
28 subroutine contact(lprint,ncont,icont,co)
30 use geometry, only:dist
31 ! implicit real*8 (a-h,o-z)
32 ! include 'DIMENSIONS'
33 ! include 'COMMON.IOUNITS'
34 ! include 'COMMON.CHAIN'
35 ! include 'COMMON.INTERACT'
36 ! include 'COMMON.FFIELD'
37 ! include 'COMMON.NAMES'
38 real(kind=8) :: facont=1.569D0 ! facont = (2/(1-sqrt(1-1/4)))**(1/6)
40 integer,dimension(2,12*nres) :: icont!(2,12*nres) !(2,maxcont) (maxcont=12*maxres)
43 real(kind=8) :: co,rcomp
44 integer :: kkk,i,j,i1,i2,it1,it2,iti,itj
53 ! rcomp=sigmaii(iti,itj)+1.0D0
54 rcomp=facont*sigmaii(iti,itj)
56 ! rcomp=sigma(iti,itj)+1.0D0
57 rcomp=facont*sigma(iti,itj)
60 ! print *,'rcomp=',rcomp,' dist=',dist(nres+i,nres+j)
61 if (dist(nres+i,nres+j).lt.rcomp) then
69 write (iout,'(a)') 'Contact map:'
75 write (iout,'(i3,2x,a,i4,2x,a,i4)') &
76 i,restyp(it1),i1,restyp(it2),i2
81 co = co + dfloat(iabs(icont(1,i)-icont(2,i)))
83 co = co / (nres*ncont)
85 end subroutine contact
86 !-----------------------------------------------------------------------------
87 real(kind=8) function contact_fract(ncont,ncont_ref,icont,icont_ref)
89 ! implicit real*8 (a-h,o-z)
90 ! include 'DIMENSIONS'
91 ! include 'COMMON.IOUNITS'
92 integer :: ncont,ncont_ref
93 integer,dimension(2,12*nres) :: icont,icont_ref !(2,12*nres) (2,maxcont) (maxcont=12*maxres)
97 ! print *,'ncont=',ncont,' ncont_ref=',ncont_ref
98 ! write (iout,'(20i4)') (icont_ref(1,i),i=1,ncont_ref)
99 ! write (iout,'(20i4)') (icont_ref(2,i),i=1,ncont_ref)
100 ! write (iout,'(20i4)') (icont(1,i),i=1,ncont)
101 ! write (iout,'(20i4)') (icont(2,i),i=1,ncont)
104 if (icont(1,i).eq.icont_ref(1,j) .and. &
105 icont(2,i).eq.icont_ref(2,j)) nmatch=nmatch+1
108 ! print *,' nmatch=',nmatch
109 ! contact_fract=dfloat(nmatch)/dfloat(max0(ncont,ncont_ref))
110 contact_fract=dfloat(nmatch)/dfloat(ncont_ref)
112 end function contact_fract
113 !-----------------------------------------------------------------------------
114 real(kind=8) function contact_fract_nn(ncont,ncont_ref,icont,icont_ref)
116 ! implicit real*8 (a-h,o-z)
117 ! include 'DIMENSIONS'
118 ! include 'COMMON.IOUNITS'
119 integer :: ncont,ncont_ref
120 integer,dimension(2,12*nres) :: icont,icont_ref !(2,12*nres) (2,maxcont) (maxcont=12*maxres)
122 integer :: i,j,nmatch
124 ! print *,'ncont=',ncont,' ncont_ref=',ncont_ref
125 ! write (iout,'(20i4)') (icont_ref(1,i),i=1,ncont_ref)
126 ! write (iout,'(20i4)') (icont_ref(2,i),i=1,ncont_ref)
127 ! write (iout,'(20i4)') (icont(1,i),i=1,ncont)
128 ! write (iout,'(20i4)') (icont(2,i),i=1,ncont)
131 if (icont(1,i).eq.icont_ref(1,j) .and. &
132 icont(2,i).eq.icont_ref(2,j)) nmatch=nmatch+1
135 ! print *,' nmatch=',nmatch
136 ! contact_fract=dfloat(nmatch)/dfloat(max0(ncont,ncont_ref))
137 contact_fract_nn=dfloat(ncont-nmatch)/dfloat(ncont)
139 end function contact_fract_nn
140 !-----------------------------------------------------------------------------
141 subroutine hairpin(lprint,nharp,iharp)
143 use geometry, only:dist
144 ! implicit real*8 (a-h,o-z)
145 ! include 'DIMENSIONS'
146 ! include 'COMMON.IOUNITS'
147 ! include 'COMMON.CHAIN'
148 ! include 'COMMON.INTERACT'
149 ! include 'COMMON.FFIELD'
150 ! include 'COMMON.NAMES'
152 integer,dimension(2,12*nres) :: icont !(2,maxcont) (maxcont=12*maxres)
154 integer,dimension(4,nres/3) :: iharp !(4,nres/3)(4,maxres/3)
155 logical :: lprint,not_done
156 real(kind=8) :: rcomp=6.0d0
158 integer :: i,j,kkk,k,i1,i2,it1,it2,j1,ii1,jj1
159 ! allocate(icont(2,12*nres))
163 ! print *,'nnt=',nnt,' nct=',nct
166 c(k,2*nres+1)=0.5d0*(c(k,i)+c(k,i+1))
170 c(k,2*nres+2)=0.5d0*(c(k,j)+c(k,j+1))
172 if (dist(2*nres+1,2*nres+2).lt.rcomp) then
180 write (iout,'(a)') 'PP contact map:'
186 write (iout,'(i3,2x,a,i4,2x,a,i4)') &
187 i,restyp(it1),i1,restyp(it2),i2
195 if (j1.eq.i1+2 .and. i1.gt.nnt .and. j1.lt.nct) then
196 ! write (iout,*) "found turn at ",i1,j1
204 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)) goto 10
208 ! write (iout,*) i1,j1,not_done
218 ! write (iout,*)'nharp',nharp,' iharp',(iharp(k,nharp),k=1,4)
223 ! write (iout,*)'i',i,' iharp',(iharp(k,i),k=1,4)
226 write (iout,*) "Hairpins:"
233 write (iout,'(20(a,i3,1x))') (restyp(itype(k)),k,k=i1,ii1)
234 write (iout,'(20(a,i3,1x))') (restyp(itype(k)),k,k=j1,jj1,-1)
236 ! write (iout,'(a,i3,$)') restyp(itype(k)),k
240 !elwrite(iout,*) "nharp=", nharp,"nres/3",nres/3
242 end subroutine hairpin
243 !-----------------------------------------------------------------------------
245 !-----------------------------------------------------------------------------
246 subroutine elecont(lprint,ncont,icont)
248 ! implicit real*8 (a-h,o-z)
249 ! include 'DIMENSIONS'
250 ! include 'COMMON.IOUNITS'
251 ! include 'COMMON.CHAIN'
252 ! include 'COMMON.INTERACT'
253 ! include 'COMMON.LOCAL'
254 ! include 'COMMON.FFIELD'
255 ! include 'COMMON.NAMES'
257 real(kind=8),dimension(2,2) :: elpp_6,elpp_3,ael6_,ael3_
258 real(kind=8) :: ael6_i,ael3_i
259 real(kind=8),dimension(2,2) :: app_,bpp_,rpp_
261 integer,dimension(2,12*nres) :: icont !(2,12*nres)(2,maxcont) (maxcont=12*maxres)
262 real(kind=8),dimension(12*nres) :: econt !(maxcont)
264 integer :: i,j,k,iteli,itelj,i1,i2,it1,it2,ic1,ic2
265 real(kind=8) :: elcutoff,elecutoff_14,rri,ees,evdw
266 real(kind=8) :: xi,yi,zi,dxi,dyi,dzi,aaa,bbb
267 real(kind=8) :: xmedi,ymedi,zmedi
268 real(kind=8) :: xj,yj,zj,dxj,dyj,dzj,rrmij,rmij,r3ij,r6ij
269 real(kind=8) :: vrmij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,&
270 evdwij,el1,el2,eesij,ene
272 ! Load the constants of peptide bond - peptide bond interactions.
273 ! Type 1 - ordinary peptide bond, type 2 - alkylated peptide bond (e.g.
274 ! proline) - determined by averaging ECEPP energy.
278 ! data epp / 0.3045d0, 0.3649d0, 0.3649d0, 0.5743d0/
279 data rpp_ / 4.5088d0, 4.5395d0, 4.5395d0, 4.4846d0/
280 data elpp_6 /-0.2379d0,-0.2056d0,-0.2056d0,-0.0610d0/
281 data elpp_3 / 0.0503d0, 0.0000d0, 0.0000d0, 0.0692d0/
283 !el allocate(econt(12*nres)) !(maxcont)
286 elecutoff_14 = -0.5d0
287 if (lprint) write (iout,'(a)') &
288 "Constants of electrostatic interaction energy expression."
292 app_(i,j)=epp(i,j)*rri*rri
293 bpp_(i,j)=-2.0*epp(i,j)*rri
294 ael6_(i,j)=elpp_6(i,j)*4.2**6
295 ael3_(i,j)=elpp_3(i,j)*4.2**3
297 write (iout,'(2i2,4e15.4)') i,j,app_(i,j),bpp_(i,j),ael6_(i,j),&
305 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) goto 1
316 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1) goto 4
319 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
320 if (iteli.eq.2 .and. itelj.eq.2) goto 4
321 aaa=app_(iteli,itelj)
322 bbb=bpp_(iteli,itelj)
323 ael6_i=ael6_(iteli,itelj)
324 ael3_i=ael3_(iteli,itelj)
328 xj=c(1,j)+0.5*dxj-xmedi
329 yj=c(2,j)+0.5*dyj-ymedi
330 zj=c(3,j)+0.5*dzj-zmedi
331 rrmij=1.0/(xj*xj+yj*yj+zj*zj)
336 cosa=(dxi*dxj+dyi*dyj+dzi*dzj)*vblinv2
337 cosb=(xj*dxi+yj*dyi+zj*dzi)*vrmij
338 cosg=(xj*dxj+yj*dyj+zj*dzj)*vrmij
339 fac=cosa-3.0*cosb*cosg
345 el1=fac3*(4.0+fac*fac-3.0*(cosb*cosb+cosg*cosg))
348 if (j.gt.i+2 .and. eesij.le.elcutoff .or. &
349 j.eq.i+2 .and. eesij.le.elecutoff_14) then
360 write (iout,*) 'Total average electrostatic energy: ',ees
361 write (iout,*) 'VDW energy between peptide-group centers: ',evdw
363 write (iout,*) 'Electrostatic contacts before pruning: '
365 !elwrite(iout,*) "petla",i
370 write (iout,'(i3,2x,a,i4,2x,a,i4,f10.5)') &
371 i,restyp(it1),i1,restyp(it2),i2,econt(i)
374 !elwrite(iout,*)"po petli"
375 ! For given residues keep only the contacts with the greatest energy.
377 do while (i.lt.ncont)
383 do while (j.lt.ncont)
385 if (ic1.eq.icont(1,j).and.iabs(icont(2,j)-ic2).le.2 .or. &
386 ic2.eq.icont(2,j).and.iabs(icont(1,j)-ic1).le.2) then
387 ! write (iout,*) "i",i," j",j," ic1",ic1," ic2",ic2,
388 ! & " jc1",icont(1,j)," jc2",icont(2,j)," ncont",ncont
389 if (econt(j).lt.ene .and. icont(2,j).ne.icont(1,j)+2) then
390 if (ic1.eq.icont(1,j)) then
392 if (k.ne.i .and. k.ne.j .and. icont(2,k).eq.icont(2,j) &
393 .and. iabs(icont(1,k)-ic1).le.2 .and. &
394 econt(k).lt.econt(j) ) goto 21
396 else if (ic2.eq.icont(2,j) ) then
398 if (k.ne.i .and. k.ne.j .and. icont(1,k).eq.icont(1,j) &
399 .and. iabs(icont(2,k)-ic2).le.2 .and. &
400 econt(k).lt.econt(j) ) goto 21
405 icont(1,k-1)=icont(1,k)
406 icont(2,k-1)=icont(2,k)
411 ! write (iout,*) "ncont",ncont
413 ! write (iout,*) icont(1,k),icont(2,k)
416 else if (econt(j).gt.ene .and. ic2.ne.ic1+2) &
418 if (ic1.eq.icont(1,j)) then
420 if (k.ne.i .and. k.ne.j .and. icont(2,k).eq.ic2 &
421 .and. iabs(icont(1,k)-icont(1,j)).le.2 .and. &
422 econt(k).lt.econt(i) ) goto 21
424 else if (ic2.eq.icont(2,j) ) then
426 if (k.ne.i .and. k.ne.j .and. icont(1,k).eq.ic1 &
427 .and. iabs(icont(2,k)-icont(2,j)).le.2 .and. &
428 econt(k).lt.econt(i) ) goto 21
433 icont(1,k-1)=icont(1,k)
434 icont(2,k-1)=icont(2,k)
438 ! write (iout,*) "ncont",ncont
440 ! write (iout,*) icont(1,k),icont(2,k)
451 write (iout,*) 'Electrostatic contacts after pruning: '
453 !elwrite(iout,*) "petla",i
458 write (iout,'(i3,2x,a,i4,2x,a,i4,f10.5)') &
459 i,restyp(it1),i1,restyp(it2),i2,econt(i)
462 !elwrite(iout,*) "koniec elecont"
464 end subroutine elecont
465 !-----------------------------------------------------------------------------
466 subroutine secondary2(lprint)
468 ! implicit real*8 (a-h,o-z)
469 ! include 'DIMENSIONS'
470 ! include 'COMMON.CHAIN'
471 ! include 'COMMON.IOUNITS'
472 ! include 'COMMON.DISTFIT'
473 ! include 'COMMON.VAR'
474 ! include 'COMMON.GEO'
475 ! include 'COMMON.CONTROL'
476 integer :: ncont,i,j,i1,j1,nbeta,nstrand,ii1,jj1,ij,nhelix,&
478 integer,dimension(2,12*nres) :: icont !(2,maxcont) (maxcont=12*maxres)
479 integer,dimension(nres,4) :: isec !(maxres,4)
480 integer,dimension(nres) :: nsec !(maxres)
481 logical :: lprint,not_done !,freeres
482 real(kind=8) :: p1,p2
485 !el allocate(icont(2,12*nres),isec(nres,4),nsec(nres))
487 !elwrite(iout,*)"przed chainbuild"
488 if(.not.dccart) call chainbuild
489 if(.not.allocated(hfrag)) allocate(hfrag(2,nres/3)) !(2,maxres/3)
490 !elwrite(iout,*)"po chainbuild"
491 !d call write_pdb(99,'sec structure',0d0)
501 call elecont(lprint,ncont,icont)
503 ! finding parallel beta
504 !d write (iout,*) '------- looking for parallel beta -----------'
510 if(j1-i1.gt.5 .and. freeres(i1,j1,nsec,isec)) then
513 !d write (iout,*) i1,j1
519 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j) .and. &
520 freeres(i1,j1,nsec,isec)) goto 5
524 !d write (iout,*) i1,j1,not_done
528 if (i1-ii1.gt.1) then
532 if(lprint)write(iout,'(a,i3,4i4)')'parallel beta',&
536 bfrag(1,nbfrag)=ii1+1
538 bfrag(3,nbfrag)=jj1+1
539 bfrag(4,nbfrag)=min0(j1+1,nres)
543 isec(ij,nsec(ij))=nbeta
547 isec(ij,nsec(ij))=nbeta
553 write(12,'(a18,i1,a9,i3,a2,i3,a1)') &
554 "DefPropRes 'strand",nstrand,&
555 "' 'num = ",ii1-1,"..",i1-1,"'"
557 write(12,'(a18,i2,a9,i3,a2,i3,a1)') &
558 "DefPropRes 'strand",nstrand,&
559 "' 'num = ",ii1-1,"..",i1-1,"'"
563 write(12,'(a18,i1,a9,i3,a2,i3,a1)') &
564 "DefPropRes 'strand",nstrand,&
565 "' 'num = ",jj1-1,"..",j1-1,"'"
567 write(12,'(a18,i2,a9,i3,a2,i3,a1)') &
568 "DefPropRes 'strand",nstrand,&
569 "' 'num = ",jj1-1,"..",j1-1,"'"
571 write(12,'(a8,4i4)') &
572 "SetNeigh",ii1-1,i1-1,jj1-1,j1-1
578 ! finding alpha or 310 helix
579 !elwrite(iout,*) "findings helix"
586 if (j1+2.le.nres) p2=phi(j1+2)*rad2deg
589 if (j1.eq.i1+3 .and. &
590 ((p1.ge.10.and.p1.le.80).or.i1.le.2).and. &
591 ((p2.ge.10.and.p2.le.80).or.j1.le.2.or.j1.ge.nres-3) )then
592 !d if (j1.eq.i1+3) write (iout,*) "found 1-4 ",i1,j1,p1,p2
593 !o if (j1.eq.i1+4) write (iout,*) "found 1-5 ",i1,j1,p1,p2
596 if (nsec(ii1).eq.0) then
605 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)) goto 10
611 if (p1.lt.10.or.p1.gt.80.or.p2.lt.10.or.p2.gt.80) &
614 !el write (iout,*) i1,j1,not_done,p1,p2
617 if (j1-ii1.gt.5) then
620 !elwrite (iout,*)'helix',nhelix,ii1,j1
623 !elwrite(iout,*) nhfrag
625 !elwrite (iout,*)'helix',nhelix,ii1,j1,hfrag(1,nhfrag)
626 !elwrite (iout,*)'helix',nhelix,ii1,j1
628 !elwrite (iout,*)'helix',nhelix,ii1,j1
634 write (iout,'(a,i3,2i4)') "Helix",nhelix,ii1-1,j1-1
635 if (nhelix.le.9) then
636 write(12,'(a17,i1,a9,i3,a2,i3,a1)') &
637 "DefPropRes 'helix",nhelix,&
638 "' 'num = ",ii1-1,"..",j1-2,"'"
640 write(12,'(a17,i2,a9,i3,a2,i3,a1)') &
641 "DefPropRes 'helix",nhelix,&
642 "' 'num = ",ii1-1,"..",j1-2,"'"
648 !elwrite(iout,*) "po find helix"
649 if (nhelix.gt.0.and.lprint) then
650 write(12,'(a26,$)') "DefPropRes 'helix' 'helix1"
652 if (nhelix.le.9) then
653 write(12,'(a8,i1,$)') " | helix",i
655 write(12,'(a8,i2,$)') " | helix",i
662 ! finding antiparallel beta
663 !d write (iout,*) '--------- looking for antiparallel beta ---------'
668 if (freeres(i1,j1,nsec,isec)) then
671 !d write (iout,*) i1,j1
678 if (i1.eq.icont(1,j).and.j1.eq.icont(2,j) .and. &
679 freeres(i1,j1,nsec,isec)) goto 6
683 !d write (iout,*) i1,j1,not_done
687 if (i1-ii1.gt.1) then
691 bfrag(2,nbfrag)=min0(i1+1,nres)
692 bfrag(3,nbfrag)=min0(jj1+1,nres)
699 if (nsec(ij).le.2) then
700 isec(ij,nsec(ij))=nbeta
706 if (nsec(ij).le.2 .and. nsec(ij).gt.0) then
707 isec(ij,nsec(ij))=nbeta
713 write (iout,'(a,i3,4i4)')'antiparallel beta',&
714 nbeta,ii1-1,i1,jj1,j1-1
716 if (nstrand.le.9) then
717 write(12,'(a18,i1,a9,i3,a2,i3,a1)') &
718 "DefPropRes 'strand",nstrand,&
719 "' 'num = ",ii1-2,"..",i1-1,"'"
721 write(12,'(a18,i2,a9,i3,a2,i3,a1)') &
722 "DefPropRes 'strand",nstrand,&
723 "' 'num = ",ii1-2,"..",i1-1,"'"
726 if (nstrand.le.9) then
727 write(12,'(a18,i1,a9,i3,a2,i3,a1)') &
728 "DefPropRes 'strand",nstrand,&
729 "' 'num = ",j1-2,"..",jj1-1,"'"
731 write(12,'(a18,i2,a9,i3,a2,i3,a1)') &
732 "DefPropRes 'strand",nstrand,&
733 "' 'num = ",j1-2,"..",jj1-1,"'"
735 write(12,'(a8,4i4)') &
736 "SetNeigh",ii1-2,i1-1,jj1-1,j1-2
742 if (nstrand.gt.0.and.lprint) then
743 write(12,'(a27,$)') "DefPropRes 'sheet' 'strand1"
746 write(12,'(a9,i1,$)') " | strand",i
748 write(12,'(a9,i2,$)') " | strand",i
757 write(12,'(a37)') "DefPropRes 'coil' '! (helix | sheet)'"
758 write(12,'(a20)') "XMacStand ribbon.mac"
761 write(iout,*) 'UNRES seq:'
763 write(iout,*) 'beta ',(bfrag(i,j),i=1,4)
767 write(iout,*) 'helix ',(hfrag(i,j),i=1,2)
772 end subroutine secondary2
774 !-----------------------------------------------------------------------------
775 logical function freeres(i,j,nsec,isec)
777 ! implicit real*8 (a-h,o-z)
778 ! include 'DIMENSIONS'
779 integer,dimension(nres,4) :: isec !(maxres,4)
780 integer,dimension(nres) :: nsec !(maxres)
787 if (nsec(i).lt.0.or.nsec(j).lt.0) return
789 if (nsec(i).gt.1.or.nsec(j).gt.1) return
792 if (isec(i,k).eq.isec(j,l)) return
798 !-----------------------------------------------------------------------------
800 !-----------------------------------------------------------------------------
801 logical function seq_comp(itypea,itypeb,length)
804 integer :: length,itypea(length),itypeb(length)
807 if (itypea(i).ne.itypeb(i)) then
814 end function seq_comp
816 !-----------------------------------------------------------------------------
818 !-----------------------------------------------------------------------------
819 subroutine rms_nac_nnc(rms,frac,frac_nn,co,lprn)
821 ! implicit real*8 (a-h,o-z)
822 ! include 'DIMENSIONS'
823 ! include 'COMMON.CHAIN'
824 ! include 'COMMON.CONTACTS'
825 ! include 'COMMON.IOUNITS'
826 real(kind=8) :: przes(3),obr(3,3)
827 logical :: non_conv,lprn
828 real(kind=8) :: rms,frac,frac_nn,co
829 ! call fitsq(rms,c(1,nstart_seq),cref(1,nstart_sup),nsup,przes,
833 call contact(.false.,ncont,icont,co)
834 frac=contact_fract(ncont,ncont_ref,icont,icont_ref)
835 frac_nn=contact_fract_nn(ncont,ncont_ref,icont,icont_ref)
836 if (lprn) write (iout,'(a,f8.3/a,f8.3/a,f8.3/a,f8.3)') &
837 'RMS deviation from the reference structure:',rms,&
838 ' % of native contacts:',frac*100,&
839 ' % of nonnative contacts:',frac_nn*100,&
843 end subroutine rms_nac_nnc
844 !-----------------------------------------------------------------------------
845 subroutine rmsd(drms)
847 use regularize_, only:fitsq
848 ! implicit real*8 (a-h,o-z)
849 ! include 'DIMENSIONS'
853 ! include 'COMMON.CHAIN'
854 ! include 'COMMON.IOUNITS'
855 ! include 'COMMON.INTERACT'
856 ! include 'COMMON.CONTROL'
858 real(kind=8) :: przes(3),obrot(3,3)
859 real(kind=8),dimension(3,2*nres+2) :: ccopy,crefcopy !(3,maxres2+2) maxres2=2*maxres
862 real(kind=8) :: drms,rminroz,roznica
863 integer :: i,j,iatom,kkk,iti,k
865 !el allocate(ccopy(3,2*nres+2),crefcopy(3,2*nres+2)) !(3,maxres2+2) maxres2=2*maxres
873 ! print *,"nz_start",nz_start," nz_end",nz_end
874 ! if (symetr.le.1) then
876 ! do i=nz_start,nz_end
880 ! ccopy(k,iatom)=c(k,i+nstart_seq-nstart_sup)
881 ! crefcopy(k,iatom,kkk)=cref(k,i,kkk)
883 ! if (iz_sc.eq.1.and.iti.ne.10) then
886 ! ccopy(k,iatom)=c(k,nres+i+nstart_seq-nstart_sup)
887 ! crefcopy(k,iatom,kkk)=cref(k,nres+i,kkk)
898 ccopy(k,iatom)=c(k,i+nstart_seq-nstart_sup)
899 crefcopy(k,iatom)=cref(k,i,kkk)
901 if (iz_sc.eq.1.and.iti.ne.10) then
904 ccopy(k,iatom)=c(k,nres+i+nstart_seq-nstart_sup)
905 crefcopy(k,iatom)=cref(k,nres+i,kkk)
914 ! write (iout,*) 'Ccopy and CREFcopy'
915 ! print '(i5,3f10.5,5x,3f10.5)',(k,(ccopy(j,k),j=1,3),
916 ! & (crefcopy(j,k),j=1,3),k=1,iatom)
917 ! write (iout,'(i5,3f10.5,5x,3f10.5)') (k,(ccopy(j,k),j=1,3),
918 ! & (crefcopy(j,k),j=1,3),k=1,iatom)
920 ! ----- end diagnostics
922 call fitsq(roznica,ccopy(1,1),crefcopy(1,1),iatom,&
923 przes,obrot,non_conv)
925 print *,'Problems in FITSQ!!! rmsd'
926 write (iout,*) 'Problems in FITSQ!!! rmsd'
927 print *,'Ccopy and CREFcopy'
928 write (iout,*) 'Ccopy and CREFcopy'
929 print '(i5,3f10.5,5x,3f10.5)',(k,(ccopy(j,k),j=1,3),&
930 (crefcopy(j,k),j=1,3),k=1,iatom)
931 write (iout,'(i5,3f10.5,5x,3f10.5)') (k,(ccopy(j,k),j=1,3),&
932 (crefcopy(j,k),j=1,3),k=1,iatom)
934 ! call mpi_abort(mpi_comm_world,ierror,ierrcode)
940 ! write (iout,*) "roznica", roznica,kkk
941 if (roznica.le.rminroz) rminroz=roznica
943 drms=dsqrt(dabs(rminroz))
945 ! write (iout,*) "nperm,symetr", nperm,symetr
946 ! ---- end diagnostics
949 !-----------------------------------------------------------------------------
950 subroutine rmsd_csa(drms)
952 use regularize_, only:fitsq
953 ! implicit real*8 (a-h,o-z)
954 ! include 'DIMENSIONS'
958 ! include 'COMMON.CHAIN'
959 ! include 'COMMON.IOUNITS'
960 ! include 'COMMON.INTERACT'
962 real(kind=8) :: przes(3),obrot(3,3)
963 real(kind=8),dimension(:,:),allocatable :: ccopy,crefcopy !(3,maxres2+2) maxres2=2*maxres
964 integer :: kkk,iatom,ierror,ierrcode
968 real(kind=8) :: drms,roznica
970 allocate(ccopy(3,2*nres+2),crefcopy(3,2*nres+2)) !(3,maxres2+2) maxres2=2*maxres
978 ccopy(k,iatom)=c(k,i)
979 crefcopy(k,iatom)=crefjlee(k,i)
981 if (iz_sc.eq.1.and.iti.ne.10) then
984 ccopy(k,iatom)=c(k,nres+i)
985 crefcopy(k,iatom)=crefjlee(k,nres+i)
990 call fitsq(roznica,ccopy(1,1),crefcopy(1,1),iatom,&
991 przes,obrot,non_conv)
993 print *,'Problems in FITSQ!!! rmsd_csa'
994 write (iout,*) 'Problems in FITSQ!!! rmsd_csa'
995 print *,'Ccopy and CREFcopy'
996 write (iout,*) 'Ccopy and CREFcopy'
997 print '(i5,3f10.5,5x,3f10.5)',(k,(ccopy(j,k),j=1,3),&
998 (crefcopy(j,k),j=1,3),k=1,iatom)
999 write (iout,'(i5,3f10.5,5x,3f10.5)') (k,(ccopy(j,k),j=1,3),&
1000 (crefcopy(j,k),j=1,3),k=1,iatom)
1002 call mpi_abort(mpi_comm_world,ierror,ierrcode)
1007 drms=dsqrt(dabs(roznica))
1009 end subroutine rmsd_csa
1010 !-----------------------------------------------------------------------------
1012 !-----------------------------------------------------------------------------
1015 use geometry, only:pinorm
1016 use random, only:ran_number,iran_num
1017 ! implicit real*8 (a-h,o-z)
1018 ! include 'DIMENSIONS'
1020 ! include 'COMMON.GEO'
1021 ! include 'COMMON.VAR'
1022 ! include 'COMMON.INTERACT'
1023 ! include 'COMMON.IOUNITS'
1024 ! include 'COMMON.DISTFIT'
1025 ! include 'COMMON.SBRIDGE'
1026 ! include 'COMMON.CONTROL'
1027 ! include 'COMMON.FFIELD'
1028 ! include 'COMMON.MINIM'
1029 ! include 'COMMON.CHAIN'
1030 real(kind=8) :: time0,time1
1031 real(kind=8) :: energy(0:n_ene),ee
1032 real(kind=8),dimension(6*nres) :: var,var1 !(maxvar) (maxvar=6*maxres)
1033 integer :: j1,j2,jr,i,iretcode,nfun,nft_sc
1034 logical :: debug,accepted
1035 real(kind=8) :: etot,rms,da,temp,betbol,etot0,d,phiold,&
1038 !el allocate(var(6*nres),var1(6*nres)) !(maxvar) (maxvar=6*maxres)
1040 call geom_to_var(nvar,var1)
1045 write(iout,*) 'etot=',0,etot,rms
1046 call secondary2(.false.)
1048 call write_pdb(0,'first structure',etot)
1057 betbol=1.0D0/(1.9858D-3*temp)
1059 d=ran_number(-pi,pi)
1060 ! phi(jr)=pinorm(phi(jr)+d)
1065 write(iout,*) 'etot=',1,etot0,rms
1066 call write_pdb(1,'perturb structure',etot0)
1070 d=ran_number(-da,da)
1072 phi(jr)=pinorm(phi(jr)+d)
1077 if (etot.lt.etot0) then
1081 xxr=ran_number(0.0D0,1.0D0)
1082 xxh=betbol*(etot-etot0)
1083 if (xxh.lt.50.0D0) then
1085 if (xxh.gt.xxr) accepted=.true.
1089 ! print *,etot0,etot,accepted
1093 write(iout,*) 'etot=',i,etot,rms
1094 call write_pdb(i,'MC structure',etot)
1096 ! call geom_to_var(nvar,var1)
1097 call sc_move(2,nres-1,1,10d0,nft_sc,etot)
1098 call geom_to_var(nvar,var)
1099 call minimize(etot,var,iretcode,nfun)
1100 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun
1101 call var_to_geom(nvar,var)
1104 write(iout,*) 'etot mcm=',i,etot,rms
1105 call write_pdb(i+1,'MCM structure',etot)
1106 call var_to_geom(nvar,var1)
1114 ! call sc_move(2,nres-1,1,10d0,nft_sc,etot)
1115 ! call geom_to_var(nvar,var)
1118 ! call write_pdb(998 ,'sc min',etot)
1120 ! call minimize(etot,var,iretcode,nfun)
1121 ! write(iout,*)'------------------------------------------------'
1122 ! write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun
1124 ! call var_to_geom(nvar,var)
1126 ! call write_pdb(999,'full min',etot)
1130 !-----------------------------------------------------------------------------
1134 ! implicit real*8 (a-h,o-z)
1135 ! include 'DIMENSIONS'
1137 ! include 'COMMON.GEO'
1138 ! include 'COMMON.VAR'
1139 ! include 'COMMON.INTERACT'
1140 ! include 'COMMON.IOUNITS'
1141 ! include 'COMMON.DISTFIT'
1142 ! include 'COMMON.SBRIDGE'
1143 ! include 'COMMON.CONTROL'
1144 ! include 'COMMON.FFIELD'
1145 ! include 'COMMON.MINIM'
1146 ! include 'COMMON.CHAIN'
1147 real(kind=8) :: time0,time1
1148 real(kind=8) :: energy(0:n_ene),ee
1149 real(kind=8),dimension(:),allocatable :: var,var1 !(maxvar) (maxvar=6*maxres)
1153 integer :: i,ij,ieval,iretcode,nfun
1154 real(kind=8) :: etot
1156 allocate(var(6*nres),var1(6*nres)) !(maxvar) (maxvar=6*maxres)
1158 call geom_to_var(nvar,var1)
1162 write(iout,*) nnt,nct,etot
1163 call write_pdb(1,'first structure',etot)
1164 call secondary2(.true.)
1173 call var_to_geom(nvar,var1)
1174 write(iout,*) 'N16 test',(jdata(i),i=1,5)
1175 call beta_slide(jdata(1),jdata(2),jdata(3),jdata(4),jdata(5), &
1177 call geom_to_var(nvar,var)
1183 call minimize(etot,var,iretcode,nfun)
1184 write(iout,*)'------------------------------------------------'
1185 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,&
1191 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,&
1192 nfun/(time1-time0),' eval/s'
1194 call var_to_geom(nvar,var)
1196 call write_pdb(ij*100+99,'full min',etot)
1203 end subroutine test_n16
1205 !-----------------------------------------------------------------------------
1206 subroutine test_local
1208 ! implicit real*8 (a-h,o-z)
1209 ! include 'DIMENSIONS'
1210 ! include 'COMMON.GEO'
1211 ! include 'COMMON.VAR'
1212 ! include 'COMMON.INTERACT'
1213 ! include 'COMMON.IOUNITS'
1214 real(kind=8) :: time0,time1
1215 real(kind=8) :: energy(0:n_ene),ee
1216 real(kind=8),dimension(6*nres) :: varia !(maxvar) (maxvar=6*maxres)
1218 real(kind=8) :: etot
1220 ! allocate(varia(6*nres)) !(maxvar) (maxvar=6*maxres)
1222 ! call geom_to_var(nvar,varia)
1223 call write_pdb(1,'first structure',0d0)
1227 write(iout,*) nnt,nct,etot
1229 write(iout,*) 'calling sc_move'
1230 call sc_move(nnt,nct,5,10d0,nft_sc,etot)
1231 write(iout,*) nft_sc,etot
1232 call write_pdb(2,'second structure',etot)
1234 write(iout,*) 'calling local_move'
1235 call local_move_init(.false.)
1236 call local_move(24,29,20d0,50d0)
1238 call write_pdb(3,'third structure',etot)
1240 write(iout,*) 'calling sc_move'
1241 call sc_move(24,29,5,10d0,nft_sc,etot)
1242 write(iout,*) nft_sc,etot
1243 call write_pdb(2,'last structure',etot)
1246 end subroutine test_local
1247 !-----------------------------------------------------------------------------
1250 ! implicit real*8 (a-h,o-z)
1251 ! include 'DIMENSIONS'
1252 ! include 'COMMON.GEO'
1253 ! include 'COMMON.VAR'
1254 ! include 'COMMON.INTERACT'
1255 ! include 'COMMON.IOUNITS'
1256 real(kind=8) :: time0,time1,etot
1257 real(kind=8) :: energy(0:n_ene),ee
1258 real(kind=8),dimension(6*nres) :: varia !(maxvar) (maxvar=6*maxres)
1262 ! call geom_to_var(nvar,varia)
1263 call write_pdb(1,'first structure',0d0)
1267 write(iout,*) nnt,nct,etot
1269 write(iout,*) 'calling sc_move'
1271 call sc_move(nnt,nct,5,10d0,nft_sc,etot)
1272 write(iout,*) nft_sc,etot
1273 call write_pdb(2,'second structure',etot)
1275 write(iout,*) 'calling sc_move 2nd time'
1277 call sc_move(nnt,nct,5,1d0,nft_sc,etot)
1278 write(iout,*) nft_sc,etot
1279 call write_pdb(3,'last structure',etot)
1281 end subroutine test_sc
1282 !-----------------------------------------------------------------------------
1283 subroutine bgrow(bstrand,nbstrand,in,ind,new)
1285 ! implicit real*8 (a-h,o-z)
1286 ! include 'DIMENSIONS'
1287 ! include 'COMMON.CHAIN'
1288 integer,dimension(nres/3,6) :: bstrand !(maxres/3,6)
1291 integer :: nbstrand,in,ind,new,ishift,i
1293 ishift=iabs(bstrand(in,ind+4)-new)
1295 print *,'bgrow',bstrand(in,ind+4),new,ishift
1300 bstrand(nbstrand,5)=bstrand(nbstrand,1)
1302 IF (bstrand(nbstrand,3).eq.bstrand(i,3)) THEN
1303 if (bstrand(i,5).lt.bstrand(i,6)) then
1304 bstrand(i,5)=bstrand(i,5)-ishift
1306 bstrand(i,5)=bstrand(i,5)+ishift
1311 bstrand(nbstrand,6)=bstrand(nbstrand,2)
1313 IF (bstrand(nbstrand,3).eq.bstrand(i,3)) THEN
1314 if (bstrand(i,6).lt.bstrand(i,5)) then
1315 bstrand(i,6)=bstrand(i,6)-ishift
1317 bstrand(i,6)=bstrand(i,6)+ishift
1324 end subroutine bgrow
1325 !-----------------------------------------------------------------------------
1328 use geometry, only:dist
1329 ! implicit real*8 (a-h,o-z)
1330 ! include 'DIMENSIONS'
1332 ! include 'COMMON.GEO'
1333 ! include 'COMMON.CHAIN'
1334 ! include 'COMMON.IOUNITS'
1335 ! include 'COMMON.VAR'
1336 ! include 'COMMON.CONTROL'
1337 ! include 'COMMON.SBRIDGE'
1338 ! include 'COMMON.FFIELD'
1339 ! include 'COMMON.MINIM'
1341 ! include 'COMMON.DISTFIT'
1342 integer :: if(20,nres),nif,ifa(20)
1343 integer :: ibc(0:nres,0:nres),istrand(20)
1344 integer :: ibd(nres),ifb(10,2),nifb,lifb(10),lifb0
1345 integer :: itmp(20,nres)
1346 real(kind=8) :: time0,time1
1347 real(kind=8) :: energy(0:n_ene),ee
1348 real(kind=8),dimension(6*nres) :: varia,vorg !(maxvar) (maxvar=6*maxres)
1350 logical :: debug,ltest,usedbfrag(nres/3)
1351 character(len=50) :: linia
1353 integer :: betasheet(nres),ibetasheet(nres),nbetasheet
1354 integer :: bstrand(nres/3,6),nbstrand
1355 real(kind=8) :: etot
1356 integer :: i,j,jk,k,isa,m,l,ig,iconf,is,ii,iused_nbfrag,&
1357 in,ind,ifun,nfun,iretcode
1358 !------------------------
1361 !------------------------
1368 call geom_to_var(nvar,vorg)
1369 call secondary2(debug)
1371 if (nbfrag.le.1) return
1374 usedbfrag(i)=.false.
1378 nbetasheet=nbetasheet+1
1380 bstrand(1,1)=bfrag(1,1)
1381 bstrand(1,2)=bfrag(2,1)
1382 bstrand(1,3)=nbetasheet
1384 bstrand(1,5)=bfrag(1,1)
1385 bstrand(1,6)=bfrag(2,1)
1386 do i=bfrag(1,1),bfrag(2,1)
1387 betasheet(i)=nbetasheet
1391 bstrand(2,1)=bfrag(3,1)
1392 bstrand(2,2)=bfrag(4,1)
1393 bstrand(2,3)=nbetasheet
1394 bstrand(2,5)=bfrag(3,1)
1395 bstrand(2,6)=bfrag(4,1)
1397 if (bfrag(3,1).le.bfrag(4,1)) then
1399 do i=bfrag(3,1),bfrag(4,1)
1400 betasheet(i)=nbetasheet
1405 do i=bfrag(4,1),bfrag(3,1)
1406 betasheet(i)=nbetasheet
1413 do while (iused_nbfrag.ne.nbfrag)
1417 IF (.not.usedbfrag(j)) THEN
1419 write (*,*) j,(bfrag(i,j),i=1,4)
1421 write (*,'(i4,a3,10i4)') jk,'B',(bstrand(i,jk),i=1,nbstrand)
1423 write (*,*) '------------------'
1426 if (bfrag(3,j).le.bfrag(4,j)) then
1427 do i=bfrag(3,j),bfrag(4,j)
1428 if(betasheet(i).eq.nbetasheet) then
1430 do k=bfrag(3,j),bfrag(4,j)
1431 betasheet(k)=nbetasheet
1436 iused_nbfrag=iused_nbfrag+1
1437 do k=bfrag(1,j),bfrag(2,j)
1438 betasheet(k)=nbetasheet
1439 ibetasheet(k)=nbstrand
1441 if (bstrand(in,4).lt.0) then
1442 bstrand(nbstrand,1)=bfrag(2,j)
1443 bstrand(nbstrand,2)=bfrag(1,j)
1444 bstrand(nbstrand,3)=nbetasheet
1445 bstrand(nbstrand,4)=-nbstrand
1446 bstrand(nbstrand,5)=bstrand(nbstrand,1)
1447 bstrand(nbstrand,6)=bstrand(nbstrand,2)
1448 if(bstrand(in,1).lt.bfrag(4,j)) then
1449 call bgrow(bstrand,nbstrand,in,1,bfrag(4,j))
1451 bstrand(nbstrand,5)=bstrand(nbstrand,5)+&
1452 (bstrand(in,5)-bfrag(4,j))
1454 if(bstrand(in,2).gt.bfrag(3,j)) then
1455 call bgrow(bstrand,nbstrand,in,2,bfrag(3,j))
1457 bstrand(nbstrand,6)=bstrand(nbstrand,6)-&
1458 (-bstrand(in,6)+bfrag(3,j))
1461 bstrand(nbstrand,1)=bfrag(1,j)
1462 bstrand(nbstrand,2)=bfrag(2,j)
1463 bstrand(nbstrand,3)=nbetasheet
1464 bstrand(nbstrand,4)=nbstrand
1465 bstrand(nbstrand,5)=bstrand(nbstrand,1)
1466 bstrand(nbstrand,6)=bstrand(nbstrand,2)
1467 if(bstrand(in,1).gt.bfrag(3,j)) then
1468 call bgrow(bstrand,nbstrand,in,1,bfrag(3,j))
1470 bstrand(nbstrand,5)=bstrand(nbstrand,5)-&
1471 (-bstrand(in,5)+bfrag(3,j))
1473 if(bstrand(in,2).lt.bfrag(4,j)) then
1474 call bgrow(bstrand,nbstrand,in,2,bfrag(4,j))
1476 bstrand(nbstrand,6)=bstrand(nbstrand,6)+&
1477 (bstrand(in,6)-bfrag(4,j))
1482 if(betasheet(bfrag(1,j)+i-bfrag(3,j)).eq.nbetasheet) then
1483 in=ibetasheet(bfrag(1,j)+i-bfrag(3,j))
1484 do k=bfrag(1,j),bfrag(2,j)
1485 betasheet(k)=nbetasheet
1490 iused_nbfrag=iused_nbfrag+1
1491 do k=bfrag(3,1),bfrag(4,1)
1492 betasheet(k)=nbetasheet
1493 ibetasheet(k)=nbstrand
1495 if (bstrand(in,4).lt.0) then
1496 bstrand(nbstrand,1)=bfrag(4,j)
1497 bstrand(nbstrand,2)=bfrag(3,j)
1498 bstrand(nbstrand,3)=nbetasheet
1499 bstrand(nbstrand,4)=-nbstrand
1500 bstrand(nbstrand,5)=bstrand(nbstrand,1)
1501 bstrand(nbstrand,6)=bstrand(nbstrand,2)
1502 if(bstrand(in,1).lt.bfrag(2,j)) then
1503 call bgrow(bstrand,nbstrand,in,1,bfrag(2,j))
1505 bstrand(nbstrand,5)=bstrand(nbstrand,5)+&
1506 (bstrand(in,5)-bfrag(2,j))
1508 if(bstrand(in,2).gt.bfrag(1,j)) then
1509 call bgrow(bstrand,nbstrand,in,2,bfrag(1,j))
1511 bstrand(nbstrand,6)=bstrand(nbstrand,6)-&
1512 (-bstrand(in,6)+bfrag(1,j))
1515 bstrand(nbstrand,1)=bfrag(3,j)
1516 bstrand(nbstrand,2)=bfrag(4,j)
1517 bstrand(nbstrand,3)=nbetasheet
1518 bstrand(nbstrand,4)=nbstrand
1519 bstrand(nbstrand,5)=bstrand(nbstrand,1)
1520 bstrand(nbstrand,6)=bstrand(nbstrand,2)
1521 if(bstrand(in,1).gt.bfrag(1,j)) then
1522 call bgrow(bstrand,nbstrand,in,1,bfrag(1,j))
1524 bstrand(nbstrand,5)=bstrand(nbstrand,5)-&
1525 (-bstrand(in,5)+bfrag(1,j))
1527 if(bstrand(in,2).lt.bfrag(2,j)) then
1528 call bgrow(bstrand,nbstrand,in,2,bfrag(2,j))
1530 bstrand(nbstrand,6)=bstrand(nbstrand,6)+&
1531 (bstrand(in,6)-bfrag(2,j))
1538 do i=bfrag(4,j),bfrag(3,j)
1539 if(betasheet(i).eq.nbetasheet) then
1541 do k=bfrag(4,j),bfrag(3,j)
1542 betasheet(k)=nbetasheet
1547 iused_nbfrag=iused_nbfrag+1
1548 do k=bfrag(1,j),bfrag(2,j)
1549 betasheet(k)=nbetasheet
1550 ibetasheet(k)=nbstrand
1552 if (bstrand(in,4).lt.0) then
1553 bstrand(nbstrand,1)=bfrag(1,j)
1554 bstrand(nbstrand,2)=bfrag(2,j)
1555 bstrand(nbstrand,3)=nbetasheet
1556 bstrand(nbstrand,4)=nbstrand
1557 bstrand(nbstrand,5)=bstrand(nbstrand,1)
1558 bstrand(nbstrand,6)=bstrand(nbstrand,2)
1559 if(bstrand(in,1).lt.bfrag(3,j)) then
1560 call bgrow(bstrand,nbstrand,in,1,bfrag(3,j))
1562 bstrand(nbstrand,5)=bstrand(nbstrand,5)-&
1563 (bstrand(in,5)-bfrag(3,j))
1565 if(bstrand(in,2).gt.bfrag(4,j)) then
1566 call bgrow(bstrand,nbstrand,in,2,bfrag(4,j))
1568 bstrand(nbstrand,6)=bstrand(nbstrand,6)+&
1569 (-bstrand(in,6)+bfrag(4,j))
1572 bstrand(nbstrand,1)=bfrag(2,j)
1573 bstrand(nbstrand,2)=bfrag(1,j)
1574 bstrand(nbstrand,3)=nbetasheet
1575 bstrand(nbstrand,4)=-nbstrand
1576 bstrand(nbstrand,5)=bstrand(nbstrand,1)
1577 bstrand(nbstrand,6)=bstrand(nbstrand,2)
1578 if(bstrand(in,1).gt.bfrag(4,j)) then
1579 call bgrow(bstrand,nbstrand,in,1,bfrag(4,j))
1581 bstrand(nbstrand,5)=bstrand(nbstrand,5)+&
1582 (-bstrand(in,5)+bfrag(4,j))
1584 if(bstrand(in,2).lt.bfrag(3,j)) then
1585 call bgrow(bstrand,nbstrand,in,2,bfrag(3,j))
1587 bstrand(nbstrand,6)=bstrand(nbstrand,6)-&
1588 (bstrand(in,6)-bfrag(3,j))
1593 if(betasheet(bfrag(2,j)-i+bfrag(4,j)).eq.nbetasheet) then
1594 in=ibetasheet(bfrag(2,j)-i+bfrag(4,j))
1595 do k=bfrag(1,j),bfrag(2,j)
1596 betasheet(k)=nbetasheet
1601 iused_nbfrag=iused_nbfrag+1
1602 do k=bfrag(4,j),bfrag(3,j)
1603 betasheet(k)=nbetasheet
1604 ibetasheet(k)=nbstrand
1606 if (bstrand(in,4).lt.0) then
1607 bstrand(nbstrand,1)=bfrag(4,j)
1608 bstrand(nbstrand,2)=bfrag(3,j)
1609 bstrand(nbstrand,3)=nbetasheet
1610 bstrand(nbstrand,4)=nbstrand
1611 bstrand(nbstrand,5)=bstrand(nbstrand,1)
1612 bstrand(nbstrand,6)=bstrand(nbstrand,2)
1613 if(bstrand(in,1).lt.bfrag(2,j)) then
1614 call bgrow(bstrand,nbstrand,in,1,bfrag(2,j))
1616 bstrand(nbstrand,5)=bstrand(nbstrand,5)-&
1617 (bstrand(in,5)-bfrag(2,j))
1619 if(bstrand(in,2).gt.bfrag(1,j)) then
1620 call bgrow(bstrand,nbstrand,in,2,bfrag(1,j))
1622 bstrand(nbstrand,6)=bstrand(nbstrand,6)+&
1623 (-bstrand(in,6)+bfrag(1,j))
1626 bstrand(nbstrand,1)=bfrag(3,j)
1627 bstrand(nbstrand,2)=bfrag(4,j)
1628 bstrand(nbstrand,3)=nbetasheet
1629 bstrand(nbstrand,4)=-nbstrand
1630 bstrand(nbstrand,5)=bstrand(nbstrand,1)
1631 bstrand(nbstrand,6)=bstrand(nbstrand,2)
1632 if(bstrand(in,1).gt.bfrag(1,j)) then
1633 call bgrow(bstrand,nbstrand,in,1,bfrag(1,j))
1635 bstrand(nbstrand,5)=bstrand(nbstrand,5)+&
1636 (-bstrand(in,5)+bfrag(1,j))
1638 if(bstrand(in,2).lt.bfrag(2,j)) then
1639 call bgrow(bstrand,nbstrand,in,2,bfrag(2,j))
1641 bstrand(nbstrand,6)=bstrand(nbstrand,6)-&
1642 (bstrand(in,6)-bfrag(2,j))
1656 do while (usedbfrag(j))
1661 nbetasheet=nbetasheet+1
1662 bstrand(nbstrand,1)=bfrag(1,j)
1663 bstrand(nbstrand,2)=bfrag(2,j)
1664 bstrand(nbstrand,3)=nbetasheet
1665 bstrand(nbstrand,5)=bfrag(1,j)
1666 bstrand(nbstrand,6)=bfrag(2,j)
1668 bstrand(nbstrand,4)=nbstrand
1669 do i=bfrag(1,j),bfrag(2,j)
1670 betasheet(i)=nbetasheet
1671 ibetasheet(i)=nbstrand
1675 bstrand(nbstrand,1)=bfrag(3,j)
1676 bstrand(nbstrand,2)=bfrag(4,j)
1677 bstrand(nbstrand,3)=nbetasheet
1678 bstrand(nbstrand,5)=bfrag(3,j)
1679 bstrand(nbstrand,6)=bfrag(4,j)
1681 if (bfrag(3,j).le.bfrag(4,j)) then
1682 bstrand(nbstrand,4)=nbstrand
1683 do i=bfrag(3,j),bfrag(4,j)
1684 betasheet(i)=nbetasheet
1685 ibetasheet(i)=nbstrand
1688 bstrand(nbstrand,4)=-nbstrand
1689 do i=bfrag(4,j),bfrag(3,j)
1690 betasheet(i)=nbetasheet
1691 ibetasheet(i)=nbstrand
1695 iused_nbfrag=iused_nbfrag+1
1701 write (*,'(i4,a3,10i4)') jk,'A',(bstrand(i,jk),i=1,nbstrand)
1708 if (betasheet(i).ne.0) write(*,*) i,betasheet(i),ibetasheet(i)
1712 write (*,'(i4,a3,10i4)') j,':',(bstrand(i,j),i=1,nbstrand)
1715 !------------------------
1719 if(iabs(bstrand(i,5)-bstrand(j,5)).le.5 .or. &
1720 iabs(bstrand(i,6)-bstrand(j,6)).le.5 ) then
1722 ifb(nifb,1)=bstrand(i,4)
1723 ifb(nifb,2)=bstrand(j,4)
1730 write (*,'(a3,20i4)') "ifb",i,ifb(i,1),ifb(i,2)
1736 write (*,'(a3,20i4)') "ifa",(ifa(i),i=1,nbstrand)
1738 nif=iabs(bstrand(1,6)-bstrand(1,5))+1
1740 if (iabs(bstrand(j,6)-bstrand(j,5))+1.gt.nif) &
1741 nif=iabs(bstrand(j,6)-bstrand(j,5))+1
1747 if(j,i)=bstrand(j,6)+(i-1)*sign(1,bstrand(j,5)-bstrand(j,6))
1748 if (if(j,i).gt.0) then
1749 if(betasheet(if(j,i)).eq.0 .or. &
1750 ibetasheet(if(j,i)).ne.iabs(bstrand(j,4))) if(j,i)=0
1755 write(*,'(a3,10i4)') 'if ',(if(j,i),j=1,nbstrand)
1758 ! read (inp,*) (ifa(i),i=1,4)
1760 ! read (inp,*,err=20,end=20) (if(j,i),j=1,4)
1764 !------------------------
1769 !ccccccccccccccccccccccccccccccccc
1771 !ccccccccccccccccccccccccccccccccc
1775 istrand(is-j+1)=int(ii/is**(is-j))
1776 ii=ii-istrand(is-j+1)*is**(is-j)
1780 istrand(k)=istrand(k)+1
1781 if(istrand(k).gt.isa) istrand(k)=istrand(k)-2*isa-1
1785 if(istrand(k).eq.istrand(l).and.k.ne.l.or. &
1786 istrand(k).eq.-istrand(l).and.k.ne.l) ltest=.false.
1795 ifb(m,1).eq.istrand(k).and.ifb(m,2).eq.istrand(k+1).or. &
1796 ifb(m,2).eq.istrand(k).and.ifb(m,1).eq.istrand(k+1).or. &
1797 -ifb(m,1).eq.istrand(k).and.-ifb(m,2).eq.istrand(k+1).or. &
1798 -ifb(m,2).eq.istrand(k).and.-ifb(m,1).eq.istrand(k+1)) &
1804 if (mod(isa,2).eq.0) then
1806 if (istrand(k).eq.1) ltest=.false.
1809 do k=(isa+1)/2+1,isa
1810 if (istrand(k).eq.1) ltest=.false.
1814 IF (ltest.and.lifb0.eq.1) THEN
1817 call var_to_geom(nvar,vorg)
1819 write (*,'(i5,i10,10i3)') iconf,ig,(istrand(k),k=1,isa)
1820 write (iout,'(i5,i10,10i3)') iconf,ig,(istrand(k),k=1,isa)
1821 write (linia,'(10i3)') (istrand(k),k=1,isa)
1831 if ( sign(1,istrand(i)).eq.sign(1,ifa(iabs(istrand(i)))) ) then
1833 itmp(iabs(istrand(i)),j)=if(iabs(ifa(iabs(istrand(i)))),j)
1837 itmp(iabs(istrand(i)),j)=if(iabs(ifa(iabs(istrand(i)))),nif-j+1)
1843 write(*,*) (itmp(j,i),j=1,4)
1847 ! ifa(1),ifa(2),ifa(3),ifa(4)
1848 ! if(1,i),if(2,i),if(3,i),if(4,i)
1853 ifb(m,1).eq.istrand(k).and.ifb(m,2).eq.istrand(k+1).or. &
1854 ifb(m,2).eq.istrand(k).and.ifb(m,1).eq.istrand(k+1).or. &
1855 -ifb(m,1).eq.istrand(k).and.-ifb(m,2).eq.istrand(k+1).or. &
1856 -ifb(m,2).eq.istrand(k).and.-ifb(m,1).eq.istrand(k+1)) &
1864 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+1)),i))=-1
1866 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+1)),i))=-2
1870 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+2)),i))=-3
1872 ibc(itmp(iabs(istrand(k)),i),itmp(iabs(istrand(k+3)),i))=-4
1875 !------------------------
1878 ! freeze sec.elements
1888 do i=bfrag(1,j),bfrag(2,j)
1893 if (bfrag(3,j).le.bfrag(4,j)) then
1894 do i=bfrag(3,j),bfrag(4,j)
1900 do i=bfrag(4,j),bfrag(3,j)
1908 do i=hfrag(1,j),hfrag(2,j)
1916 !------------------------
1917 ! generate constrains
1925 if ( ibc(i,j).eq.-1 .or. ibc(j,i).eq.-1) then
1933 else if ( ibc(i,j).eq.-2 .or. ibc(j,i).eq.-2) then
1941 else if ( ibc(i,j).eq.-3 .or. ibc(j,i).eq.-3) then
1949 else if ( ibc(i,j).eq.-4 .or. ibc(j,i).eq.-4) then
1957 else if ( ibc(i,j).gt.0 ) then
1958 d0(ind)=DIST(i,ibc(i,j))
1965 else if ( ibc(j,i).gt.0 ) then
1966 d0(ind)=DIST(ibc(j,i),j)
1980 !d--------------------------
1982 write(iout,'(i3,2i4,a3,2i4,f7.2)') (i,ibc(ihpb(i),jhpb(i)),&
1983 ibc(jhpb(i),ihpb(i)),' --',&
1984 ihpb(i),jhpb(i),dhpb(i),i=1,nhpb)
1991 call contact_cp_min(varia,ifun,iconf,linia,debug)
1996 call minimize(etot,varia,iretcode,nfun)
1997 write(iout,*)'------------------------------------------------'
1998 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,&
2004 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,&
2005 nfun/(time1-time0),' eval/s'
2007 write (linia,'(a10,10i3)') 'full_min',(istrand(k),k=1,isa)
2008 call var_to_geom(nvar,varia)
2010 call write_pdb(900+iconf,linia,etot)
2015 call enerprint(energy)
2017 !d call briefout(0,etot)
2018 !d call secondary2(.true.)
2022 !ccccccccccccccccccccccccccccccccccc
2025 !ccccccccccccccccccccccccccccccccccc
2028 10 write (iout,'(a)') 'Error reading test structure.'
2030 end subroutine test11
2031 !-----------------------------------------------------------------------------
2034 use geometry, only:dist
2035 ! implicit real*8 (a-h,o-z)
2036 ! include 'DIMENSIONS'
2038 ! include 'COMMON.GEO'
2039 ! include 'COMMON.CHAIN'
2040 ! include 'COMMON.IOUNITS'
2041 ! include 'COMMON.VAR'
2042 ! include 'COMMON.CONTROL'
2043 ! include 'COMMON.SBRIDGE'
2044 ! include 'COMMON.FFIELD'
2045 ! include 'COMMON.MINIM'
2047 ! include 'COMMON.DISTFIT'
2048 integer :: if(3,nres),nif
2049 integer :: ibc(nres,nres),istrand(20)
2050 integer :: ibd(nres),ifb(10,2),nifb,lifb(10),lifb0
2051 real(kind=8) :: time0,time1
2052 real(kind=8) :: energy(0:n_ene),ee
2053 real(kind=8),dimension(6*nres) :: varia !(maxvar) (maxvar=6*maxres)
2055 logical :: debug,ltest
2056 character(len=50) :: linia
2057 integer :: ieval,i,j,ind,in_pdb,nfun,iretcode
2058 real(kind=8) :: etot
2061 read (inp,*,err=20,end=20) if(1,i),if(2,i),if(3,i)
2064 write (*,'(a4,3i5)') ('if =',if(1,i),if(2,i),if(3,i),&
2068 !------------------------
2069 call secondary2(debug)
2070 !------------------------
2078 ! freeze sec.elements and store indexes for beta constrains
2088 do i=bfrag(1,j),bfrag(2,j)
2093 if (bfrag(3,j).le.bfrag(4,j)) then
2094 do i=bfrag(3,j),bfrag(4,j)
2098 ibc(bfrag(1,j)+i-bfrag(3,j),i)=-1
2101 do i=bfrag(4,j),bfrag(3,j)
2105 ibc(bfrag(2,j)-i+bfrag(4,j),i)=-1
2110 do i=hfrag(1,j),hfrag(2,j)
2119 ! ---------------- test --------------
2121 if (ibc(if(1,i),if(2,i)).eq.-1) then
2122 ibc(if(1,i),if(2,i))=if(3,i)
2123 ibc(if(1,i),if(3,i))=if(2,i)
2124 else if (ibc(if(2,i),if(1,i)).eq.-1) then
2125 ibc(if(2,i),if(1,i))=0
2126 ibc(if(1,i),if(2,i))=if(3,i)
2127 ibc(if(1,i),if(3,i))=if(2,i)
2129 ibc(if(1,i),if(2,i))=if(3,i)
2130 ibc(if(1,i),if(3,i))=if(2,i)
2136 if (ibc(i,j).ne.0) write(*,'(3i5)') i,j,ibc(i,j)
2139 !------------------------
2145 if ( ibc(i,j).eq.-1 ) then
2153 else if ( ibc(i,j).gt.0 ) then
2154 d0(ind)=DIST(i,ibc(i,j))
2161 else if ( ibc(j,i).gt.0 ) then
2162 d0(ind)=DIST(ibc(j,i),j)
2176 !d--------------------------
2177 write(*,'(i3,2i4,a3,2i4,f7.2)') (i,ibc(ihpb(i),jhpb(i)),&
2178 ibc(jhpb(i),ihpb(i)),' --',&
2179 ihpb(i),jhpb(i),dhpb(i),i=1,nhpb)
2187 call contact_cp_min(varia,ieval,in_pdb,linia,debug)
2192 call minimize(etot,varia,iretcode,nfun)
2193 write(iout,*)'------------------------------------------------'
2194 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,&
2200 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,&
2201 nfun/(time1-time0),' eval/s'
2204 call var_to_geom(nvar,varia)
2206 call write_pdb(999,'full min',etot)
2211 call enerprint(energy)
2213 call briefout(0,etot)
2214 call secondary2(.true.)
2217 10 write (iout,'(a)') 'Error reading test structure.'
2219 end subroutine test3
2220 !-----------------------------------------------------------------------------
2223 ! implicit real*8 (a-h,o-z)
2224 ! include 'DIMENSIONS'
2226 ! include 'COMMON.GEO'
2227 ! include 'COMMON.CHAIN'
2228 ! include 'COMMON.IOUNITS'
2229 ! include 'COMMON.VAR'
2230 ! include 'COMMON.CONTROL'
2231 ! include 'COMMON.SBRIDGE'
2232 ! include 'COMMON.FFIELD'
2233 ! include 'COMMON.MINIM'
2235 ! include 'COMMON.DISTFIT'
2236 integer :: if(2,2),ind
2237 integer :: iff(nres)
2238 real(kind=8) :: time0,time1
2239 real(kind=8) :: energy(0:n_ene),ee
2240 real(kind=8),dimension(nres) :: theta2,phi2,alph2,omeg2,&
2241 theta1,phi1,alph1,omeg1 !(maxres)
2242 real(kind=8),dimension(6*nres) :: varia,varia2 !(maxvar) (maxvar=6*maxres)
2244 integer :: i,j,nn,ifun,iretcode,nfun
2245 real(kind=8) :: etot
2248 read (inp,*,err=10,end=10) if(1,1),if(1,2),if(2,1),if(2,2)
2249 write (iout,'(a4,4i5)') 'if =',if(1,1),if(1,2),if(2,1),if(2,2)
2250 read (inp,*,err=10,end=10) (theta2(i),i=3,nres)
2251 read (inp,*,err=10,end=10) (phi2(i),i=4,nres)
2252 read (inp,*,err=10,end=10) (alph2(i),i=2,nres-1)
2253 read (inp,*,err=10,end=10) (omeg2(i),i=2,nres-1)
2255 theta2(i)=deg2rad*theta2(i)
2256 phi2(i)=deg2rad*phi2(i)
2257 alph2(i)=deg2rad*alph2(i)
2258 omeg2(i)=deg2rad*omeg2(i)
2272 !------------------------
2277 do i=if(j,1),if(j,2)
2283 call geom_to_var(nvar,varia)
2284 call write_pdb(1,'first structure',0d0)
2286 call secondary(.true.)
2288 call secondary2(.true.)
2291 if ( (bfrag(3,j).lt.bfrag(4,j) .or. &
2292 bfrag(4,j)-bfrag(2,j).gt.4) .and. &
2293 bfrag(2,j)-bfrag(1,j).gt.3 ) then
2296 if (bfrag(3,j).lt.bfrag(4,j)) then
2297 write(iout,'(a6,i3,a1,i3,a1,i3,a1,i3)') &
2298 "select",bfrag(1,j)-1,"-",bfrag(2,j)-1,&
2299 ",",bfrag(3,j)-1,"-",bfrag(4,j)-1
2301 write(iout,'(a6,i3,a1,i3,a1,i3,a1,i3)') &
2302 "select",bfrag(1,j)-1,"-",bfrag(2,j)-1,&
2303 ",",bfrag(4,j)-1,"-",bfrag(3,j)-1
2316 call geom_to_var(nvar,varia2)
2317 call write_pdb(2,'second structure',0d0)
2321 !-------------------------------------------------------
2324 call contact_cp(varia,varia2,iff,ifun,7)
2329 call minimize(etot,varia,iretcode,nfun)
2330 write(iout,*)'------------------------------------------------'
2331 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,&
2337 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,&
2338 nfun/(time1-time0),' eval/s'
2341 call var_to_geom(nvar,varia)
2343 call write_pdb(999,'full min',etot)
2348 call enerprint(energy)
2350 call briefout(0,etot)
2353 10 write (iout,'(a)') 'Error reading test structure.'
2355 end subroutine test__
2356 !-----------------------------------------------------------------------------
2357 subroutine secondary(lprint)
2359 ! implicit real*8 (a-h,o-z)
2360 ! include 'DIMENSIONS'
2361 ! include 'COMMON.CHAIN'
2362 ! include 'COMMON.IOUNITS'
2363 ! include 'COMMON.DISTFIT'
2365 integer :: ncont,icont(2,nres*nres/2),isec(nres,3)
2366 logical :: lprint,not_done
2367 real(kind=4) :: dcont(nres*nres/2),d
2368 real(kind=4) :: rcomp = 7.0
2369 real(kind=4) :: rbeta = 5.2
2370 real(kind=4) :: ralfa = 5.2
2371 real(kind=4) :: r310 = 6.6
2372 real(kind=8),dimension(3) :: xpi,xpj
2373 integer :: i,k,j,i1,j1,nbeta,nstrand,ii1,jj1,ij,iii1,jjj1,&
2376 !d call write_pdb(99,'sec structure',0d0)
2388 xpi(k)=0.5d0*(c(k,i-1)+c(k,i))
2392 xpj(k)=0.5d0*(c(k,j-1)+c(k,j))
2394 !d d = (c(1,i)-c(1,j))*(c(1,i)-c(1,j)) +
2395 !d & (c(2,i)-c(2,j))*(c(2,i)-c(2,j)) +
2396 !d & (c(3,i)-c(3,j))*(c(3,i)-c(3,j))
2397 !d print *,'CA',i,j,d
2398 d = (xpi(1)-xpj(1))*(xpi(1)-xpj(1)) + &
2399 (xpi(2)-xpj(2))*(xpi(2)-xpj(2)) + &
2400 (xpi(3)-xpj(3))*(xpi(3)-xpj(3))
2401 if ( d.lt.rcomp*rcomp) then
2405 dcont(ncont)=sqrt(d)
2411 write (iout,'(a)') '#PP contact map distances:'
2413 write (iout,'(3i4,f10.5)') &
2414 i,icont(1,i),icont(2,i),dcont(i)
2418 ! finding parallel beta
2419 !d write (iout,*) '------- looking for parallel beta -----------'
2425 if(dcont(i).le.rbeta .and. j1-i1.gt.4 .and. &
2426 isec(i1,1).le.1.and.isec(j1,1).le.1.and. &
2427 (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and. &
2428 (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and. &
2429 (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and. &
2430 (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0) &
2434 !d write (iout,*) i1,j1,dcont(i)
2440 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j) &
2441 .and. dcont(j).le.rbeta .and. &
2442 isec(i1,1).le.1.and.isec(j1,1).le.1.and. &
2443 (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and. &
2444 (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and. &
2445 (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and. &
2446 (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0) &
2451 !d write (iout,*) i1,j1,dcont(j),not_done
2455 if (i1-ii1.gt.1) then
2459 if(lprint)write(iout,*)'parallel beta',nbeta,ii1,i1,jj1,j1
2468 isec(ij,1)=isec(ij,1)+1
2469 isec(ij,1+isec(ij,1))=nbeta
2472 isec(ij,1)=isec(ij,1)+1
2473 isec(ij,1+isec(ij,1))=nbeta
2478 if (nbeta.le.9) then
2479 write(12,'(a18,i1,a9,i3,a2,i3,a1)') &
2480 "DefPropRes 'strand",nstrand,&
2481 "' 'num = ",ii1-1,"..",i1-1,"'"
2483 write(12,'(a18,i2,a9,i3,a2,i3,a1)') &
2484 "DefPropRes 'strand",nstrand,&
2485 "' 'num = ",ii1-1,"..",i1-1,"'"
2488 if (nbeta.le.9) then
2489 write(12,'(a18,i1,a9,i3,a2,i3,a1)') &
2490 "DefPropRes 'strand",nstrand,&
2491 "' 'num = ",jj1-1,"..",j1-1,"'"
2493 write(12,'(a18,i2,a9,i3,a2,i3,a1)') &
2494 "DefPropRes 'strand",nstrand,&
2495 "' 'num = ",jj1-1,"..",j1-1,"'"
2497 write(12,'(a8,4i4)') &
2498 "SetNeigh",ii1-1,i1-1,jj1-1,j1-1
2504 ! finding antiparallel beta
2505 !d write (iout,*) '--------- looking for antiparallel beta ---------'
2510 if (dcont(i).le.rbeta.and. &
2511 isec(i1,1).le.1.and.isec(j1,1).le.1.and. &
2512 (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and. &
2513 (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and. &
2514 (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and. &
2515 (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0) &
2519 !d write (iout,*) i1,j1,dcont(i)
2526 if (i1.eq.icont(1,j).and.j1.eq.icont(2,j) .and. &
2527 isec(i1,1).le.1.and.isec(j1,1).le.1.and. &
2528 (isec(i1,2).ne.isec(j1,2).or.isec(i1,2)*isec(j1,2).eq.0).and. &
2529 (isec(i1,3).ne.isec(j1,3).or.isec(i1,3)*isec(j1,3).eq.0).and. &
2530 (isec(i1,2).ne.isec(j1,3).or.isec(i1,2)*isec(j1,3).eq.0).and. &
2531 (isec(i1,3).ne.isec(j1,2).or.isec(i1,3)*isec(j1,2).eq.0) &
2532 .and. dcont(j).le.rbeta ) goto 6
2536 !d write (iout,*) i1,j1,dcont(j),not_done
2540 if (i1-ii1.gt.1) then
2541 if(lprint)write (iout,*)'antiparallel beta',&
2542 nbeta,ii1-1,i1,jj1,j1-1
2545 bfrag(1,nbfrag)=max0(ii1-1,1)
2548 bfrag(4,nbfrag)=max0(j1-1,1)
2553 isec(ij,1)=isec(ij,1)+1
2554 isec(ij,1+isec(ij,1))=nbeta
2558 isec(ij,1)=isec(ij,1)+1
2559 isec(ij,1+isec(ij,1))=nbeta
2565 if (nstrand.le.9) then
2566 write(12,'(a18,i1,a9,i3,a2,i3,a1)') &
2567 "DefPropRes 'strand",nstrand,&
2568 "' 'num = ",ii1-2,"..",i1-1,"'"
2570 write(12,'(a18,i2,a9,i3,a2,i3,a1)') &
2571 "DefPropRes 'strand",nstrand,&
2572 "' 'num = ",ii1-2,"..",i1-1,"'"
2575 if (nstrand.le.9) then
2576 write(12,'(a18,i1,a9,i3,a2,i3,a1)') &
2577 "DefPropRes 'strand",nstrand,&
2578 "' 'num = ",j1-2,"..",jj1-1,"'"
2580 write(12,'(a18,i2,a9,i3,a2,i3,a1)') &
2581 "DefPropRes 'strand",nstrand,&
2582 "' 'num = ",j1-2,"..",jj1-1,"'"
2584 write(12,'(a8,4i4)') &
2585 "SetNeigh",ii1-2,i1-1,jj1-1,j1-2
2591 if (nstrand.gt.0.and.lprint) then
2592 write(12,'(a27,$)') "DefPropRes 'sheet' 'strand1"
2595 write(12,'(a9,i1,$)') " | strand",i
2597 write(12,'(a9,i2,$)') " | strand",i
2600 write(12,'(a1)') "'"
2604 ! finding alpha or 310 helix
2610 if (j1.eq.i1+3.and.dcont(i).le.r310 &
2611 .or.j1.eq.i1+4.and.dcont(i).le.ralfa ) then
2612 !d if (j1.eq.i1+3) write (iout,*) "found 1-4 ",i1,j1,dcont(i)
2613 !d if (j1.eq.i1+4) write (iout,*) "found 1-5 ",i1,j1,dcont(i)
2616 if (isec(ii1,1).eq.0) then
2625 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)) goto 10
2629 !d write (iout,*) i1,j1,not_done
2632 if (j1-ii1.gt.4) then
2634 !d write (iout,*)'helix',nhelix,ii1,j1
2638 hfrag(2,nhfrag)=max0(j1-1,1)
2644 write (iout,'(a6,i3,2i4)') "Helix",nhelix,ii1-1,j1-2
2645 if (nhelix.le.9) then
2646 write(12,'(a17,i1,a9,i3,a2,i3,a1)') &
2647 "DefPropRes 'helix",nhelix,&
2648 "' 'num = ",ii1-1,"..",j1-2,"'"
2650 write(12,'(a17,i2,a9,i3,a2,i3,a1)') &
2651 "DefPropRes 'helix",nhelix,&
2652 "' 'num = ",ii1-1,"..",j1-2,"'"
2659 if (nhelix.gt.0.and.lprint) then
2660 write(12,'(a26,$)') "DefPropRes 'helix' 'helix1"
2662 if (nhelix.le.9) then
2663 write(12,'(a8,i1,$)') " | helix",i
2665 write(12,'(a8,i2,$)') " | helix",i
2668 write(12,'(a1)') "'"
2672 write(12,'(a37)') "DefPropRes 'coil' '! (helix | sheet)'"
2673 write(12,'(a20)') "XMacStand ribbon.mac"
2677 end subroutine secondary
2678 !-----------------------------------------------------------------------------
2679 subroutine contact_cp2(var,var2,iff,ieval,in_pdb)
2681 use geometry, only:dist
2682 ! implicit real*8 (a-h,o-z)
2683 ! include 'DIMENSIONS'
2685 ! include 'COMMON.SBRIDGE'
2686 ! include 'COMMON.FFIELD'
2687 ! include 'COMMON.IOUNITS'
2688 ! include 'COMMON.DISTFIT'
2689 ! include 'COMMON.VAR'
2690 ! include 'COMMON.CHAIN'
2691 ! include 'COMMON.MINIM'
2693 character(len=50) :: linia
2695 real(kind=8),dimension(6*nres) :: var,var2 !(maxvar) (maxvar=6*maxres)
2696 real(kind=8) :: time0,time1
2697 integer :: iff(nres),ieval
2698 real(kind=8),dimension(nres) :: theta1,phi1,alph1,omeg1 !(maxres)
2701 integer :: in_pdb,i,j,ind,ipot0,maxmin0,maxfun0,nfun,iwsk,iretcode
2702 real(kind=8) :: wstrain0,etot
2704 maxres22=nres*(nres+1)/2
2706 if(.not.allocated(DRDG)) allocate(DRDG(maxres22,maxres22)) !(MAXRES22,MAXRES)
2707 call var_to_geom(nvar,var)
2714 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
2736 call var_to_geom(nvar,var2)
2739 if ( iff(i).eq.1 ) then
2748 !d call write_pdb(3,'combined structure',0d0)
2749 !d time0=MPI_WTIME()
2752 NY=((NRES-4)*(NRES-5))/2
2753 call distfit(.true.,200)
2755 !d time1=MPI_WTIME()
2756 !d write (iout,'(a,f6.2,a)') ' Time for distfit ',time1-time0,' sec'
2766 call geom_to_var(nvar,var)
2767 !d time0=MPI_WTIME()
2768 call minimize(etot,var,iretcode,nfun)
2769 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
2771 !d time1=MPI_WTIME()
2772 !d write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,
2773 !d & nfun/(time1-time0),' SOFT eval/s'
2774 call var_to_geom(nvar,var)
2780 if (iff(1).eq.1) then
2786 if ( iwsk.eq.0.and.iff(i-1).eq.0.and.iff(i).eq.1 ) then
2791 if ( iwsk.eq.1.and.iff(i-1).eq.1.and.iff(i).eq.0 ) then
2797 if (iff(nres).eq.1) then
2803 !d write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
2804 !d & "select",ij(1),"-",ij(2),
2805 !d & ",",ij(3),"-",ij(4)
2806 !d call write_pdb(in_pdb,linia,etot)
2812 !d time0=MPI_WTIME()
2813 call minimize(etot,var,iretcode,nfun)
2814 !d write(iout,*)'SUMSL DIST return code is',iretcode,' eval ',nfun
2817 !d time1=MPI_WTIME()
2818 !d write (iout,'(a,f6.2,f8.2,a)')' Time for DIST min.',time1-time0,
2819 !d & nfun/(time1-time0),' eval/s'
2820 !d call var_to_geom(nvar,var)
2822 !d call write_pdb(6,'dist structure',etot)
2831 end subroutine contact_cp2
2832 !-----------------------------------------------------------------------------
2833 subroutine contact_cp(var,var2,iff,ieval,in_pdb)
2835 use geometry, only:dist
2836 ! implicit real*8 (a-h,o-z)
2837 ! include 'DIMENSIONS'
2838 ! include 'COMMON.SBRIDGE'
2839 ! include 'COMMON.FFIELD'
2840 ! include 'COMMON.IOUNITS'
2841 ! include 'COMMON.DISTFIT'
2842 ! include 'COMMON.VAR'
2843 ! include 'COMMON.CHAIN'
2844 ! include 'COMMON.MINIM'
2846 character(len=50) :: linia
2848 real(kind=8) :: energy(0:n_ene)
2849 real(kind=8),dimension(6*nres) :: var,var2 !(maxvar) (maxvar=6*maxres)
2850 real(kind=8) :: time0,time1
2851 integer :: iff(nres),ieval
2852 real(kind=8),dimension(nres) :: theta1,phi1,alph1,omeg1 !(maxres)
2856 integer :: in_pdb,i,j,ind,iwsk
2860 if (ieval.eq.-1) debug=.true.
2864 ! store selected dist. constrains from 1st structure
2867 ! Intercept NaNs in the coordinates
2868 ! write(iout,*) (var(i),i=1,nvar)
2873 if (x_sum.ne.x_sum) then
2874 write(iout,*)" *** contact_cp : Found NaN in coordinates"
2876 print *," *** contact_cp : Found NaN in coordinates"
2882 call var_to_geom(nvar,var)
2889 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
2912 ! freeze sec.elements from 2nd structure
2920 call var_to_geom(nvar,var2)
2921 call secondary2(debug)
2923 do i=bfrag(1,j),bfrag(2,j)
2928 if (bfrag(3,j).le.bfrag(4,j)) then
2929 do i=bfrag(3,j),bfrag(4,j)
2935 do i=bfrag(4,j),bfrag(3,j)
2943 do i=hfrag(1,j),hfrag(2,j)
2952 ! copy selected res from 1st to 2nd structure
2956 if ( iff(i).eq.1 ) then
2966 ! prepare description in linia variable
2970 if (iff(1).eq.1) then
2976 if ( iwsk.eq.0.and.iff(i-1).eq.0.and.iff(i).eq.1 ) then
2981 if ( iwsk.eq.1.and.iff(i-1).eq.1.and.iff(i).eq.0 ) then
2987 if (iff(nres).eq.1) then
2992 write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)') &
2993 "SELECT",ij(1)-1,"-",ij(2)-1,&
2994 ",",ij(3)-1,"-",ij(4)-1
3000 call contact_cp_min(var,ieval,in_pdb,linia,debug)
3003 end subroutine contact_cp
3004 !-----------------------------------------------------------------------------
3005 subroutine contact_cp_min(var,ieval,in_pdb,linia,debug)
3007 ! implicit real*8 (a-h,o-z)
3008 ! include 'DIMENSIONS'
3010 ! include 'COMMON.SBRIDGE'
3011 ! include 'COMMON.FFIELD'
3012 ! include 'COMMON.IOUNITS'
3013 ! include 'COMMON.DISTFIT'
3014 ! include 'COMMON.VAR'
3015 ! include 'COMMON.CHAIN'
3016 ! include 'COMMON.MINIM'
3018 character(len=50) :: linia
3020 real(kind=8) :: energy(0:n_ene)
3021 real(kind=8),dimension(6*nres) :: var !(maxvar) (maxvar=6*maxres)
3022 real(kind=8) :: time0,time1
3023 integer :: ieval,info(3)
3024 logical :: debug,fail,reduce,change !check_var,
3027 integer :: in_pdb,i,ipot0,ipot01,maxmin0,maxfun0,maxmin01,maxfun01,&
3029 real(kind=8) :: wsc01,wscp01,welec01,wvdwpp01,wscloc01,wtor01,&
3030 wtor_d01,wstrain0,etot
3032 write(iout,'(a20,i6,a20)') &
3033 '------------------',in_pdb,'-------------------'
3037 call write_pdb(1000+in_pdb,'combined structure',0d0)
3044 ! run optimization of distances
3046 ! uses d0(),w() and mask() for frozen 2D
3048 !test---------------------------------------------
3050 !test NY=((NRES-4)*(NRES-5))/2
3051 !test call distfit(debug,5000)
3083 call geom_to_var(nvar,var)
3084 !de change=reduce(var)
3085 if (check_var(var,info)) then
3086 write(iout,*) 'cp_min error in input'
3087 print *,'cp_min error in input'
3091 !d call etotal(energy(0))
3092 !d call enerprint(energy(0))
3096 !dtest call minimize(etot,var,iretcode,nfun)
3097 !dtest write(iout,*)'SUMSL return code is',iretcode,' eval SDIST',nfun
3100 !d call etotal(energy(0))
3101 !d call enerprint(energy(0))
3120 !test--------------------------------------------------
3126 write (iout,'(a,f6.2,a)')' Time for distfit ',time1-time0,' sec'
3127 call write_pdb(2000+in_pdb,'distfit structure',0d0)
3135 ! run soft pot. optimization
3137 ! nhpb,ihpb(),jhpb(),forcon(),dhpb() and hpb_partition
3139 ! mask_phi(),mask_theta(),mask_side(),mask_r
3145 !de change=reduce(var)
3146 !de if (check_var(var,info)) write(iout,*) 'error before soft'
3150 call minimize(etot,var,iretcode,nfun)
3152 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
3156 write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,&
3157 nfun/(time1-time0),' SOFT eval/s'
3160 call var_to_geom(nvar,var)
3162 call write_pdb(3000+in_pdb,'soft structure',etot)
3166 ! run full UNRES optimization with constrains and frozen 2D
3167 ! the same variables as soft pot. optimizatio
3173 ! check overlaps before calling full UNRES minim
3175 call var_to_geom(nvar,var)
3179 write(iout,*) 'N7 ',energy(0)
3180 if (energy(0).ne.energy(0)) then
3181 write(iout,*) 'N7 error - gives NaN',energy(0)
3185 if (energy(1).eq.1.0d20) then
3186 write (iout,'(a,1pe14.5)')'#N7_OVERLAP evdw=1d20',energy(1)
3187 call overlap_sc(fail)
3191 write (iout,'(a,1pe14.5)')'#N7_OVERLAP evdw after',energy(1)
3203 !dte time0=MPI_WTIME()
3204 !de change=reduce(var)
3205 !de if (check_var(var,info)) then
3206 !de write(iout,*) 'error before mask dist'
3207 !de call var_to_geom(nvar,var)
3209 !de call write_pdb(10000+in_pdb,'before mask dist',etot)
3211 !dte call minimize(etot,var,iretcode,nfun)
3212 !dte write(iout,*)'SUMSL MASK DIST return code is',iretcode,
3213 !dte & ' eval ',nfun
3214 !dte ieval=ieval+nfun
3216 !dte time1=MPI_WTIME()
3217 !dte write (iout,'(a,f6.2,f8.2,a)')
3218 !dte & ' Time for mask dist min.',time1-time0,
3219 !dte & nfun/(time1-time0),' eval/s'
3220 !dte call flush(iout)
3223 call var_to_geom(nvar,var)
3225 call write_pdb(4000+in_pdb,'mask dist',etot)
3228 ! switch off freezing of 2D and
3229 ! run full UNRES optimization with constrains
3235 !de change=reduce(var)
3236 !de if (check_var(var,info)) then
3237 !de write(iout,*) 'error before dist'
3238 !de call var_to_geom(nvar,var)
3240 !de call write_pdb(11000+in_pdb,'before dist',etot)
3243 call minimize(etot,var,iretcode,nfun)
3245 !de change=reduce(var)
3246 !de if (check_var(var,info)) then
3247 !de write(iout,*) 'error after dist',ico
3248 !de call var_to_geom(nvar,var)
3250 !de call write_pdb(12000+in_pdb+ico*1000,'after dist',etot)
3252 write(iout,*)'SUMSL DIST return code is',iretcode,' eval ',nfun
3258 write (iout,'(a,f6.2,f8.2,a)')' Time for dist min.',time1-time0,&
3259 nfun/(time1-time0),' eval/s'
3261 !de call etotal(energy(0))
3262 !de write(iout,*) 'N7 after dist',energy(0)
3266 call var_to_geom(nvar,var)
3268 call write_pdb(in_pdb,linia,etot)
3280 end subroutine contact_cp_min
3281 !-----------------------------------------------------------------------------
3284 use geometry, only:dist
3285 ! implicit real*8 (a-h,o-z)
3286 ! include 'DIMENSIONS'
3288 ! include 'COMMON.GEO'
3289 ! include 'COMMON.CHAIN'
3290 ! include 'COMMON.IOUNITS'
3291 ! include 'COMMON.VAR'
3292 ! include 'COMMON.CONTROL'
3293 ! include 'COMMON.SBRIDGE'
3294 ! include 'COMMON.FFIELD'
3295 ! include 'COMMON.MINIM'
3296 ! include 'COMMON.INTERACT'
3298 ! include 'COMMON.DISTFIT'
3299 integer :: iff(nres)
3300 real(kind=8) :: time0,time1
3301 real(kind=8) :: energy(0:n_ene),ee
3302 real(kind=8),dimension(6*nres) :: var !(maxvar) (maxvar=6*maxres)
3304 logical :: debug,ltest,fail
3305 character(len=50) :: linia
3306 integer :: ieval,i,j,in_pdb,ipot0,maxmin0,maxfun0,ico,nhpb_c,&
3308 real(kind=8) :: wstrain0,wang0,etot
3314 !------------------------
3316 ! freeze sec.elements
3326 do i=bfrag(1,j),bfrag(2,j)
3331 if (bfrag(3,j).le.bfrag(4,j)) then
3332 do i=bfrag(3,j),bfrag(4,j)
3338 do i=bfrag(4,j),bfrag(3,j)
3346 do i=hfrag(1,j),hfrag(2,j)
3358 ! store dist. constrains
3362 if ( iff(i).eq.1.and.iff(j).eq.1 ) then
3367 dhpb(nhpb)=DIST(i,j)
3375 call write_pdb(100+in_pdb,'input reg. structure',0d0)
3385 ! run soft pot. optimization
3391 call geom_to_var(nvar,var)
3395 call minimize(etot,var,iretcode,nfun)
3397 write(iout,*)'SUMSL return code is',iretcode,' eval SOFT',nfun
3401 write (iout,'(a,f6.2,f8.2,a)')' Time for soft min.',time1-time0,&
3402 nfun/(time1-time0),' SOFT eval/s'
3404 call var_to_geom(nvar,var)
3406 call write_pdb(300+in_pdb,'soft structure',etot)
3409 ! run full UNRES optimization with constrains and frozen 2D
3410 ! the same variables as soft pot. optimizatio
3419 call minimize(etot,var,iretcode,nfun)
3420 write(iout,*)'SUMSL MASK DIST return code is',iretcode,&
3427 write (iout,'(a,f6.2,f8.2,a)') &
3428 ' Time for mask dist min.',time1-time0,&
3429 nfun/(time1-time0),' eval/s'
3431 call var_to_geom(nvar,var)
3433 call write_pdb(400+in_pdb,'mask & dist',etot)
3436 ! switch off constrains and
3437 ! run full UNRES optimization with frozen 2D
3452 call minimize(etot,var,iretcode,nfun)
3453 write(iout,*)'SUMSL MASK return code is',iretcode,' eval ',nfun
3459 write (iout,'(a,f6.2,f8.2,a)')' Time for mask min.',time1-time0,&
3460 nfun/(time1-time0),' eval/s'
3464 call var_to_geom(nvar,var)
3466 call write_pdb(500+in_pdb,'mask 2d frozen',etot)
3473 ! run full UNRES optimization with constrains and NO frozen 2D
3483 wstrain=wstrain0/ico
3488 call minimize(etot,var,iretcode,nfun)
3489 write(iout,'(a10,f6.3,a14,i3,a6,i5)') &
3490 ' SUMSL DIST',wstrain,' return code is',iretcode,&
3497 write (iout,'(a,f6.2,f8.2,a)') &
3498 ' Time for dist min.',time1-time0,&
3499 nfun/(time1-time0),' eval/s'
3501 call var_to_geom(nvar,var)
3503 call write_pdb(600+in_pdb+ico,'dist cons',etot)
3520 call minimize(etot,var,iretcode,nfun)
3521 write(iout,*)'------------------------------------------------'
3522 write(iout,*)'SUMSL return code is',iretcode,' eval ',nfun,&
3528 write (iout,'(a,f6.2,f8.2,a)')' Time for full min.',time1-time0,&
3529 nfun/(time1-time0),' eval/s'
3532 call var_to_geom(nvar,var)
3534 call write_pdb(999,'full min',etot)
3538 end subroutine softreg
3539 !-----------------------------------------------------------------------------
3540 subroutine beta_slide(i1,i2,i3,i4,i5,ieval,ij)
3542 use geometry, only:dist
3543 ! implicit real*8 (a-h,o-z)
3544 ! include 'DIMENSIONS'
3546 ! include 'COMMON.GEO'
3547 ! include 'COMMON.VAR'
3548 ! include 'COMMON.INTERACT'
3549 ! include 'COMMON.IOUNITS'
3550 ! include 'COMMON.DISTFIT'
3551 ! include 'COMMON.SBRIDGE'
3552 ! include 'COMMON.CONTROL'
3553 ! include 'COMMON.FFIELD'
3554 ! include 'COMMON.MINIM'
3555 ! include 'COMMON.CHAIN'
3556 real(kind=8) :: time0,time1
3557 real(kind=8) :: energy(0:n_ene),ee
3558 real(kind=8),dimension(6*nres) :: var !(maxvar) (maxvar=6*maxres)
3559 integer :: jdata(5),isec(nres)
3562 integer :: i1,i2,i3,i4,i5,ieval,ij
3563 integer :: i,j,nft_sc,ishift,iretcode,nfun,maxfun0,ico
3564 real(kind=8) :: etot,wscloc0,wstrain0
3572 call secondary2(.false.)
3578 do i=bfrag(1,j),bfrag(2,j)
3581 do i=bfrag(4,j),bfrag(3,j),sign(1,bfrag(3,j)-bfrag(4,j))
3586 do i=hfrag(1,j),hfrag(2,j)
3592 ! cut strands at the ends
3594 if (jdata(2)-jdata(1).gt.3) then
3597 if (jdata(3).lt.jdata(4)) then
3607 !v call etotal(energy(0))
3609 !v write(iout,*) nnt,nct,etot
3610 !v call write_pdb(ij*100,'first structure',etot)
3611 !v write(iout,*) 'N16 test',(jdata(i),i=1,5)
3613 !------------------------
3614 ! generate constrains
3617 if(ishift.eq.0) ishift=-2
3620 do i=jdata(1),jdata(2)
3622 if(jdata(4).gt.jdata(3))then
3623 do j=jdata(3)+i-jdata(1)-2,jdata(3)+i-jdata(1)+2
3625 !d print *,i,j,j+ishift
3630 dhpb(nhpb)=DIST(i,j+ishift)
3633 do j=jdata(3)-i+jdata(1)+2,jdata(3)-i+jdata(1)-2,-1
3635 !d print *,i,j,j+ishift
3640 dhpb(nhpb)=DIST(i,j+ishift)
3647 if(isec(i).gt.0.or.isec(j).gt.0) then
3653 dhpb(nhpb)=DIST(i,j)
3660 call geom_to_var(nvar,var)
3667 wstrain=wstrain0/ico
3669 !v time0=MPI_WTIME()
3670 call minimize(etot,var,iretcode,nfun)
3671 write(iout,'(a10,f6.3,a14,i3,a6,i5)') &
3672 ' SUMSL DIST',wstrain,' return code is',iretcode,&
3675 !v time1=MPI_WTIME()
3676 !v write (iout,'(a,f6.2,f8.2,a)')
3677 !v & ' Time for dist min.',time1-time0,
3678 !v & nfun/(time1-time0),' eval/s'
3679 !v call var_to_geom(nvar,var)
3681 !v call write_pdb(ij*100+ico,'dist cons',etot)
3693 call sc_move(nnt,nct,100,100d0,nft_sc,etot)
3696 !v call etotal(energy(0))
3698 !v call write_pdb(ij*100+10,'sc_move',etot)
3700 !d print *,nft_sc,etot
3703 end subroutine beta_slide
3704 !-----------------------------------------------------------------------------
3705 subroutine beta_zip(i1,i2,ieval,ij)
3707 ! implicit real*8 (a-h,o-z)
3708 ! include 'DIMENSIONS'
3710 ! include 'COMMON.GEO'
3711 ! include 'COMMON.VAR'
3712 ! include 'COMMON.INTERACT'
3713 ! include 'COMMON.IOUNITS'
3714 ! include 'COMMON.DISTFIT'
3715 ! include 'COMMON.SBRIDGE'
3716 ! include 'COMMON.CONTROL'
3717 ! include 'COMMON.FFIELD'
3718 ! include 'COMMON.MINIM'
3719 ! include 'COMMON.CHAIN'
3720 real(kind=8) :: time0,time1
3721 real(kind=8) :: energy(0:n_ene),ee
3722 real(kind=8),dimension(6*nres) :: var !(maxvar) (maxvar=6*maxres)
3723 character(len=10) :: test
3725 integer :: i1,i2,ieval,ij,ico,iretcode,nfun,maxfun0
3726 real(kind=8) :: etot,wstrain0
3728 !v call etotal(energy(0))
3730 !v write(test,'(2i5)') i1,i2
3731 !v call write_pdb(ij*100,test,etot)
3732 !v write(iout,*) 'N17 test',i1,i2,etot,ij
3735 ! generate constrains
3746 call geom_to_var(nvar,var)
3752 wstrain=wstrain0/ico
3753 !v time0=MPI_WTIME()
3754 call minimize(etot,var,iretcode,nfun)
3755 write(iout,'(a10,f6.3,a14,i3,a6,i5)') &
3756 ' SUMSL DIST',wstrain,' return code is',iretcode,&
3759 !v time1=MPI_WTIME()
3760 !v write (iout,'(a,f6.2,f8.2,a)')
3761 !v & ' Time for dist min.',time1-time0,
3762 !v & nfun/(time1-time0),' eval/s'
3763 ! do not comment the next line
3764 call var_to_geom(nvar,var)
3766 !v call write_pdb(ij*100+ico,'dist cons',etot)
3774 !v call etotal(energy(0))
3776 !v write(iout,*) 'N17 test end',i1,i2,etot,ij
3779 end subroutine beta_zip
3780 !-----------------------------------------------------------------------------
3782 !-----------------------------------------------------------------------------
3783 subroutine thread_seq
3785 use geometry, only:dist
3786 use random, only:iran_num
3787 use control, only:tcpu
3788 use regularize_, only:regularize
3789 use mcm_data, only: nsave_part,nacc_tot
3790 ! Thread the sequence through a database of known structures
3791 ! implicit real*8 (a-h,o-z)
3792 ! include 'DIMENSIONS'
3794 use MPI_data !include 'COMMON.INFO'
3798 ! include 'COMMON.CONTROL'
3799 ! include 'COMMON.CHAIN'
3800 ! include 'COMMON.DBASE'
3801 ! include 'COMMON.INTERACT'
3802 ! include 'COMMON.VAR'
3803 ! include 'COMMON.THREAD'
3804 ! include 'COMMON.FFIELD'
3805 ! include 'COMMON.SBRIDGE'
3806 ! include 'COMMON.HEADER'
3807 ! include 'COMMON.IOUNITS'
3808 ! include 'COMMON.TIME1'
3809 ! include 'COMMON.CONTACTS'
3810 ! include 'COMMON.MCM'
3811 ! include 'COMMON.NAMES'
3813 integer :: ThreadId,ThreadType,Kwita
3815 real(kind=8),dimension(6*nres) :: varia !(maxvar) (maxvar=6*maxres)
3816 real(kind=8) :: przes(3),obr(3,3)
3817 real(kind=8) :: time_for_thread
3818 logical :: found_pattern,non_conv
3819 character(len=32) :: head_pdb
3820 real(kind=8) :: energia(0:n_ene)
3821 integer :: i,j,ithread,itrial,ii,jj,nres_t,ist,ipattern,iretcode,&
3823 real(kind=8) :: dcj,rms,frac,frac_nn,co,etot,curr_tim,curr_tim1
3825 n_ene_comp=nprint_ene
3830 if (me.eq.king) then
3849 ave_time_for_thread=0.0D0
3850 max_time_for_thread=0.0D0
3851 !d print *,'nthread=',nthread,' nseq=',nseq,' nres0=',nres0
3852 nthread=nexcl+nthread
3853 do ithread=1,nthread
3854 found_pattern=.false.
3856 do while (.not.found_pattern)
3858 if (itrial.gt.1000) then
3859 write (iout,'(/a/)') 'Too many attempts to find pattern.'
3862 call recv_stop_sig(Kwita)
3863 call send_stop_sig(-3)
3867 ! Find long enough chain in the database
3869 nres_t=nres_base(1,ii)
3870 ! Select the starting position to thread.
3871 print *,'nseq',nseq,' ii=',ii,' nres_t=',&
3872 nres_t,' nres0=',nres0
3873 if (nres_t.ge.nres0) then
3874 ist=iran_num(0,nres_t-nres0)
3876 if (Kwita.eq.0) call recv_stop_sig(Kwita)
3877 if (Kwita.lt.0) then
3878 write (iout,*) 'Stop signal received. Terminating.'
3879 write (*,*) 'Stop signal received. Terminating.'
3881 write (*,*) 'ithread=',ithread,' nthread=',nthread
3884 call pattern_receive
3887 if (iexam(1,i).eq.ii .and. iexam(2,i).eq.ist) goto 10
3889 found_pattern=.true.
3891 ! If this point is reached, the pattern has not yet been examined.
3893 ! print *,'found_pattern:',found_pattern
3899 if (Kwita.eq.0) call recv_stop_sig(Kwita)
3900 if (Kwita.lt.0) then
3901 write (iout,*) 'Stop signal received. Terminating.'
3903 write (*,*) 'ithread=',ithread,' nthread=',nthread
3909 ipatt(2,ithread)=ist
3911 write (iout,'(/80(1h*)/a,i4,a,i5,2a,i3,a,i3,a,i3/)') &
3912 'Processor:',me,' Attempt:',ithread,&
3913 ' pattern: ',str_nam(ii),nres_base(2,ii),':',nres_base(3,ii),&
3914 ' start at res.',ist+1
3915 write (*,'(a,i4,a,i5,2a,i3,a,i3,a,i3)') 'Processor:',me,&
3916 ' Attempt:',ithread,&
3917 ' pattern: ',str_nam(ii),nres_base(2,ii),':',nres_base(3,ii),&
3918 ' start at res.',ist+1
3920 write (iout,'(/80(1h*)/a,i5,2a,i3,a,i3,a,i3/)') &
3921 'Attempt:',ithread,&
3922 ' pattern: ',str_nam(ii),nres_base(2,ii),':',nres_base(3,ii),&
3923 ' start at res.',ist+1
3924 write (*,'(a,i5,2a,i3,a,i3,a,i3)') &
3925 'Attempt:',ithread,&
3926 ' pattern: ',str_nam(ii),nres_base(2,ii),':',nres_base(3,ii),&
3927 ' start at res.',ist+1
3930 ! Copy coordinates from the database.
3934 c(j,i)=cart_base(j,i+ist,ii)
3937 !d write (iout,'(a,i4,3f10.5)') restyp(itype(i)),i,(c(j,i),j=1,3)
3939 !d call fitsq(rms,c(1,nnt),cref(1,nnt),nct-nnt+1,przes,obr,
3941 !d write (iout,'(a,f10.5)')
3942 !d & 'Initial RMS deviation from reference structure:',rms
3943 if (itype(nres).eq.ntyp1) then
3945 dcj=c(j,nres-2)-c(j,nres-3)
3946 c(j,nres)=c(j,nres-1)+dcj
3947 c(j,2*nres)=c(j,nres)
3950 if (itype(1).eq.ntyp1) then
3957 call int_from_cart(.false.,.false.)
3958 !d print *,'Exit INT_FROM_CART.'
3959 !d print *,'nhpb=',nhpb
3964 ! write (iout,'(2i5,2f10.5)') ihpb(i),jhpb(i),dhpb(i),forcon(i)
3966 ! stop 'End generate'
3967 ! Generate SC conformations.
3971 !d print *,'Processor:',me,': exit GEN_SIDE.'
3973 !d print *,'Exit GEN_SIDE.'
3975 ! Calculate initial energy.
3977 call etotal(energia)
3980 ener0(i,ithread)=energia(i)
3982 ener0(n_ene_comp+1,ithread)=energia(0)
3984 call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
3985 ener0(n_ene_comp+3,ithread)=contact_fract(ncont,ncont_ref,&
3987 ener0(n_ene_comp+2,ithread)=rms
3988 ener0(n_ene_comp+4,ithread)=frac
3989 ener0(n_ene_comp+5,ithread)=frac_nn
3991 ener0(n_ene_comp+3,ithread)=0.0d0
3994 print*,'Processor:',me,' ithread=',ithread,' Start REGULARIZE.'
3996 print*,'ithread=',ithread,' Start REGULARIZE.'
3999 call regularize(nct-nnt+1,etot,rms,&
4000 cart_base(1,ist+nnt,ipattern),iretcode)
4002 time_for_thread=curr_tim1-curr_tim
4003 ave_time_for_thread= &
4004 ((ithread-1)*ave_time_for_thread+time_for_thread)/ithread
4005 if (time_for_thread.gt.max_time_for_thread) &
4006 max_time_for_thread=time_for_thread
4008 print *,'Processor',me,': Exit REGULARIZE.'
4009 if (WhatsUp.eq.2) then
4011 'Sufficient number of confs. collected. Terminating.'
4014 else if (WhatsUp.eq.-1) then
4016 write (iout,*) 'Time up in REGULARIZE. Call SEND_STOP_SIG.'
4017 if (Kwita.eq.0) call recv_stop_sig(Kwita)
4018 call send_stop_sig(-2)
4020 else if (WhatsUp.eq.-2) then
4022 write (iout,*) 'Timeup signal received. Terminating.'
4024 else if (WhatsUp.eq.-3) then
4026 write (iout,*) 'Error stop signal received. Terminating.'
4030 print *,'Exit REGULARIZE.'
4031 if (iretcode.eq.11) then
4032 write (iout,'(/a/)') &
4033 '******* Allocated time exceeded in SUMSL. The program will stop.'
4038 head_pdb=titel(:24)//':'//str_nam(ipattern)
4039 if (outpdb) call pdbout(etot,head_pdb,ipdb)
4040 if (outmol2) call mol2out(etot,head_pdb)
4042 call briefout(ithread,etot)
4044 link_end=min0(link_end,nss)
4045 write (iout,*) 'link_end=',link_end,' link_end0=',link_end0,&
4047 call etotal(energia)
4048 ! call enerprint(energia(0))
4051 !d call fitsq(rms,c(1,nnt),cref(1,nnt),nct-nnt+1,przes,obr,non_conv)
4052 !d write (iout,'(a,f10.5)')
4053 !d & 'RMS deviation from reference structure:',dsqrt(rms)
4055 ener(i,ithread)=energia(i)
4057 ener(n_ene_comp+1,ithread)=energia(0)
4058 ener(n_ene_comp+3,ithread)=rms
4060 call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
4061 ener(n_ene_comp+2,ithread)=rms
4062 ener(n_ene_comp+4,ithread)=frac
4063 ener(n_ene_comp+5,ithread)=frac_nn
4065 call write_stat_thread(ithread,ipattern,ist)
4066 ! write (istat,'(i4,2x,a8,i4,11(1pe14.5),2(0pf8.3),f8.5)')
4067 ! & ithread,str_nam(ipattern),ist+1,(ener(k,ithread),k=1,11),
4068 ! & (ener(k,ithread),k=12,14)
4070 if (me.eq.king) then
4072 call pattern_receive
4073 call receive_MCM_info
4074 if (nacc_tot.ge.nthread) then
4076 'Sufficient number of conformations collected nacc_tot=',&
4077 nacc_tot,'. Stopping other processors and terminating.'
4079 'Sufficient number of conformations collected nacc_tot=',&
4080 nacc_tot,'. Stopping other processors and terminating.'
4081 call recv_stop_sig(Kwita)
4082 if (Kwita.eq.0) call send_stop_sig(-1)
4087 call send_MCM_info(2)
4090 if (timlim-curr_tim1-safety .lt. max_time_for_thread) then
4091 write (iout,'(/2a)') &
4092 '********** There would be not enough time for another thread. ',&
4093 'The program will stop.'
4095 '********** There would be not enough time for another thread. ',&
4096 'The program will stop.'
4097 write (iout,'(a,1pe14.4/)') &
4098 'Elapsed time for last threading step: ',time_for_thread
4101 call recv_stop_sig(Kwita)
4102 call send_stop_sig(-2)
4107 write (iout,'(a,1pe14.4)') &
4108 'Elapsed time for this threading step: ',time_for_thread
4111 if (Kwita.eq.0) call recv_stop_sig(Kwita)
4112 if (Kwita.lt.0) then
4113 write (iout,*) 'Stop signal received. Terminating.'
4114 write (*,*) 'Stop signal received. Terminating.'
4116 write (*,*) 'nthread=',nthread,' ithread=',ithread
4122 call send_stop_sig(-1)
4126 ! Any messages left for me?
4127 call pattern_receive
4128 if (Kwita.eq.0) call recv_stop_sig(Kwita)
4130 call write_thread_summary
4132 if (king.eq.king) then
4134 do while (Kwita.ne.0 .or. nacc_tot.ne.0)
4137 call recv_stop_sig(Kwita)
4138 call receive_MCM_info
4141 call receive_thread_results(iproc)
4143 call write_thread_summary
4145 call send_thread_results
4149 end subroutine thread_seq
4150 !-----------------------------------------------------------------------------
4153 ! Sample (hopefully) optimal SC orientations given backcone conformation.
4154 use random, only:iran_num
4155 ! implicit real*8 (a-h,o-z)
4156 ! include 'DIMENSIONS'
4157 ! include 'COMMON.CHAIN'
4158 ! include 'COMMON.DBASE'
4159 ! include 'COMMON.INTERACT'
4160 ! include 'COMMON.VAR'
4161 ! include 'COMMON.THREAD'
4162 ! include 'COMMON.FFIELD'
4163 ! include 'COMMON.SBRIDGE'
4164 ! include 'COMMON.HEADER'
4165 ! include 'COMMON.GEO'
4166 ! include 'COMMON.IOUNITS'
4167 real(kind=8),dimension(6*nres) :: varia !(maxvar) (maxvar=6*maxres)
4168 !el integer :: icall
4169 !el common /srutu/ icall
4170 real(kind=8) :: energia(0:n_ene)
4171 logical :: glycine,fail
4172 integer :: i,maxsample,link_end0,ind_sc,isample
4173 real(kind=8) :: alph0,omeg0,e1,e0
4177 link_end=min0(link_end,nss)
4179 if (itype(i).ne.10) then
4180 !d print *,'i=',i,' itype=',itype(i),' theta=',theta(i+1)
4181 call gen_side(itype(i),theta(i+1),alph(i),omeg(i),fail)
4185 call etotal(energia)
4187 do isample=1,maxsample
4188 ! Choose a non-glycine side chain.
4191 ind_sc=iran_num(nnt,nct)
4192 glycine=(itype(ind_sc).eq.10)
4196 call gen_side(itype(ind_sc),theta(ind_sc+1),alph(ind_sc),&
4199 call etotal(energia)
4200 !d write (iout,'(a,i5,a,i4,2(a,f8.3),2(a,1pe14.5))')
4201 !d & 'Step:',isample,' SC',ind_sc,' alpha',alph(ind_sc)*rad2deg,
4202 !d & ' omega',omeg(ind_sc)*rad2deg,' old energy',e0,' new energy',e1
4213 end subroutine sc_conf
4214 !-----------------------------------------------------------------------------
4216 !-----------------------------------------------------------------------------
4217 logical function check_var(var,info)
4221 ! implicit real*8 (a-h,o-z)
4222 ! include 'DIMENSIONS'
4223 ! include 'COMMON.VAR'
4224 ! include 'COMMON.IOUNITS'
4225 ! include 'COMMON.GEO'
4226 ! include 'COMMON.SETUP'
4227 real(kind=8),dimension(6*nres) :: var !(maxvar) (maxvar=6*maxres)
4228 integer,dimension(3) :: info
4232 do i=nphi+ntheta+1,nphi+ntheta+nside
4233 ! Check the side chain "valence" angles alpha
4234 if (var(i).lt.1.0d-7) then
4235 write (iout,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
4236 write (iout,*) 'Processor',me,'received bad variables!!!!'
4237 write (iout,*) 'Variables'
4238 write (iout,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
4239 write (iout,*) 'Continuing calculations at this point',&
4240 ' could destroy the results obtained so far... ABORTING!!!!!!'
4241 write (iout,'(a19,i5,f10.4,a4,2i4,a3,i3)') &
4242 'valence angle alpha',i-nphi-ntheta,var(i),&
4243 'n it',info(1),info(2),'mv ',info(3)
4244 write (*,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
4245 write (*,*) 'Processor',me,'received bad variables!!!!'
4246 write (*,*) 'Variables'
4247 write (*,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
4248 write (*,*) 'Continuing calculations at this point',&
4249 ' could destroy the results obtained so far... ABORTING!!!!!!'
4250 write (*,'(a19,i5,f10.4,a4,2i4,a3,i3)') &
4251 'valence angle alpha',i-nphi-ntheta,var(i),&
4252 'n it',info(1),info(2),'mv ',info(3)
4257 ! Check the backbone "valence" angles theta
4258 do i=nphi+1,nphi+ntheta
4259 if (var(i).lt.1.0d-7) then
4260 write (iout,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
4261 write (iout,*) 'Processor',me,'received bad variables!!!!'
4262 write (iout,*) 'Variables'
4263 write (iout,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
4264 write (iout,*) 'Continuing calculations at this point',&
4265 ' could destroy the results obtained so far... ABORTING!!!!!!'
4266 write (iout,'(a19,i5,f10.4,a4,2i4,a3,i3)') &
4267 'valence angle theta',i-nphi,var(i),&
4268 'n it',info(1),info(2),'mv ',info(3)
4269 write (*,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
4270 write (*,*) 'Processor',me,'received bad variables!!!!'
4271 write (*,*) 'Variables'
4272 write (*,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
4273 write (*,*) 'Continuing calculations at this point',&
4274 ' could destroy the results obtained so far... ABORTING!!!!!!'
4275 write (*,'(a19,i5,f10.4,a4,2i4,a3,i3)') &
4276 'valence angle theta',i-nphi,var(i),&
4277 'n it',info(1),info(2),'mv ',info(3)
4283 end function check_var
4284 !-----------------------------------------------------------------------------
4286 !-----------------------------------------------------------------------------
4287 subroutine distfit(debug,maxit)
4289 use geometry_data, only: phi
4292 ! implicit real*8 (a-h,o-z)
4293 ! include 'DIMENSIONS'
4294 ! include 'COMMON.CHAIN'
4295 ! include 'COMMON.VAR'
4296 ! include 'COMMON.IOUNITS'
4297 ! include 'COMMON.DISTFIT'
4298 integer :: i,maxit,MAXMAR,IT,IMAR
4299 real(kind=8),DIMENSION(nres) :: X,DIAGH,phiold !(maxres)
4300 logical :: debug,sing
4301 real(kind=8) :: TOL,RL,F0,AIN,F1
4303 !input------------------------------------
4305 ! NY=((NRES-4)*(NRES-5))/2
4306 !input------------------------------------
4312 CALL TRANSFER(NRES,phi,phiold)
4316 !d WRITE (IOUT,*) 'DISTFIT: F0=',F0
4332 CALL TRANSFER(NX,XX,X)
4333 CALL BANACH(NX,NRES,H,X,sing)
4338 IF (AIN.LT.0.1*TOL .AND. RL.LT.1.0E-4) THEN
4340 WRITE (IOUT,*) 'DISTFIT: CONVERGENCE HAS BEEN ACHIEVED'
4341 WRITE (IOUT,*) 'IT=',it,'F=',F0
4346 phi(I)=phiold(I)+mask(i)*X(I-3)
4351 !d WRITE (IOUT,*) 'IMAR=',IMAR,' RL=',RL,' F1=',F1
4353 CALL TRANSFER(NRES,phi,phiold)
4356 ELSE IF (DABS(F1-F0).LT.1.0E-5) THEN
4358 WRITE (IOUT,*) 'DISTFIT: CANNOT IMPROVE DISTANCE FIT'
4359 WRITE (IOUT,*) 'IT=',it,'F=',F1
4365 WRITE (IOUT,*) 'DISTFIT: MARQUARDT PROCEDURE HAS FAILED'
4366 WRITE (IOUT,*) 'IT=',it,'F=',F0
4367 CALL TRANSFER(NRES,phiold,phi)
4370 !d write (iout,*) "it",it," imar",imar," f0",f0
4372 WRITE (IOUT,*) 'DISTFIT: FINAL F=',F0,'after MAXIT=',maxit
4374 end subroutine distfit
4375 !-----------------------------------------------------------------------------
4376 real(kind=8) function RDIF()
4379 use geometry, only: dist
4380 ! implicit real*8 (a-h,o-z)
4381 ! include 'DIMENSIONS'
4382 ! include 'COMMON.CHAIN'
4383 ! include 'COMMON.DISTFIT'
4385 real(kind=8) :: suma,DIJ
4394 if (w(ind).ne.0.0) then
4396 suma=suma+w(ind)*(DIJ-d0(ind))*(DIJ-d0(ind))
4398 ! print '(2i3,i4,4f12.2)',i,j,ind,dij,d0(ind),w(ind),suma
4406 !-----------------------------------------------------------------------------
4411 use geometry, only:dist
4412 ! implicit real*8 (a-h,o-z)
4413 ! include 'DIMENSIONS'
4414 ! include 'COMMON.CHAIN'
4415 ! include 'COMMON.DISTFIT'
4416 ! include 'COMMON.GEO'
4417 integer :: i,j,k,l,I1,I2,IND
4418 real(kind=8),DIMENSION(3) :: E12,R13,R24,PRODU
4431 R13(K)=C(K,J)-C(K,I1)
4435 R24(L)=C(L,K)-C(L,I2)
4437 IND=((J-1)*(2*NRES-J-6))/2+K-3
4438 PRODU(1)=R13(2)*R24(3)-R13(3)*R24(2)
4439 PRODU(2)=R13(3)*R24(1)-R13(1)*R24(3)
4440 PRODU(3)=R13(1)*R24(2)-R13(2)*R24(1)
4441 DRDG(IND,I)=SCALAR(E12,PRODU)/DIST(J,K)
4446 end subroutine RDERIV
4447 !-----------------------------------------------------------------------------
4451 ! implicit real*8 (a-h,o-z)
4452 ! include 'DIMENSIONS'
4453 ! include 'COMMON.CHAIN'
4454 ! include 'COMMON.DISTFIT'
4456 real(kind=8) :: XI,HII,BKI,BKIWK,HIJ
4464 XI=XI+BKIWK*(D0(K)-DDD(K))
4472 HIJ=HIJ+DRDG(K,I)*DRDG(K,J)*w(K)
4479 end subroutine HEVAL
4480 !-----------------------------------------------------------------------------
4481 subroutine VEC(I,J,U)
4483 use geometry_data, only: C
4484 ! Find the unit vector from atom (I) to atom (J). Store in U.
4486 ! implicit real*8 (a-h,o-z)
4487 ! include 'DIMENSIONS'
4488 ! include 'COMMON.CHAIN'
4490 real(kind=8),DIMENSION(3) :: U
4491 real(kind=8) :: ANORM,UK
4505 !-----------------------------------------------------------------------------
4506 subroutine TRANSFER(N,X1,X2)
4508 ! implicit real*8 (a-h,o-z)
4509 ! include 'DIMENSIONS'
4511 real(kind=8),DIMENSION(N) :: X1,X2
4515 end subroutine TRANSFER
4516 !-----------------------------------------------------------------------------
4517 !-----------------------------------------------------------------------------
4518 subroutine alloc_compare_arrays
4520 maxres22=nres*(nres+1)/2
4522 ! common /struct/ in io_common: read_threadbase
4523 ! allocate(cart_base !(3,maxres_base,maxseq)
4524 ! allocate(nres_base !(3,maxseq)
4525 ! allocate(str_nam !(maxseq)
4527 ! COMMON /c_frag/ in io_conf: readpdb
4528 if(.not.allocated(bfrag)) allocate(bfrag(4,nres/3)) !(4,maxres/3)
4529 if(.not.allocated(hfrag)) allocate(hfrag(2,nres/3)) !(2,maxres/3)
4531 allocate(w(maxres22),d0(maxres22)) !(maxres22)
4533 !el allocate(DRDG(maxres22,maxres22)) !(MAXRES22,MAXRES)
4534 allocate(DDD(maxres22)) !(maxres22)
4535 allocate(H(nres,nres)) !(MAXRES,MAXRES)
4536 allocate(XX(nres)) !(MAXRES)
4538 allocate(mask(nres)) !(maxres)
4541 allocate(iexam(2,maxthread),ipatt(2,maxthread)) !(2,maxthread)
4543 allocate(ener0(n_ene+2,maxthread),ener(n_ene+2,maxthread)) !(n_ene+2,maxthread)
4546 end subroutine alloc_compare_arrays
4547 !-----------------------------------------------------------------------------
4549 !-----------------------------------------------------------------------------