2 !-----------------------------------------------------------------------
8 !-----------------------------------------------------------------------------
11 !-----------------------------------------------------------------------------
13 !-----------------------------------------------------------------------------
15 !-----------------------------------------------------------------------------
16 subroutine write_csa_pdb(var,ene,nft,ik,iw_pdb)
19 use geometry_data, only:nres,nvar
20 use geometry, only:var_to_geom,chainbuild
21 use compare, only:secondary2
22 ! implicit real*8 (a-h,o-z)
23 ! include 'DIMENSIONS'
24 ! include 'COMMON.CSA'
25 ! include 'COMMON.BANK'
26 ! include 'COMMON.VAR'
27 ! include 'COMMON.IOUNITS'
28 ! include 'COMMON.MINIM'
29 ! include 'COMMON.SETUP'
30 ! include 'COMMON.GEO'
31 ! include 'COMMON.CHAIN'
32 ! include 'COMMON.LOCAL'
33 ! include 'COMMON.INTERACT'
34 ! include 'COMMON.NAMES'
35 ! include 'COMMON.SBRIDGE'
36 integer :: lenpre,lenpot !,ilen
38 real(kind=8),dimension(nvar) :: var !(maxvar) (maxvar=6*maxres)
39 character(len=50) :: titelloc
40 character(len=3) :: zahl
41 real(kind=8),dimension(mxch*(mxch+1)/2+1) :: ene
43 integer :: nft,ik,iw_pdb
46 if(ene(1).lt.eglob_csa) then
49 call numstr(nglob_csa,zahl)
51 call var_to_geom(nvar,var)
53 call secondary2(.false.)
56 open(icsa_pdb,file=prefix(:lenpre)//'@'//zahl//'.pdb')
59 write(titelloc,'(a2,i3,a3,i9,a3,i6)') &
60 'GM',nglob_csa,' e ',nft,' m ',nmin_csa
62 write(titelloc,'(a2,i3,a3,i9,a3,i6,a5,f5.2,a5,f5.1)') &
63 'GM',nglob_csa,' e ',nft,' m ',nmin_csa,' rms ',&
64 rmsn(ik),' %NC ',pncn(ik)*100
66 call pdbout(eglob_csa,titelloc,icsa_pdb)
71 end subroutine write_csa_pdb
72 !-----------------------------------------------------------------------------
74 !-----------------------------------------------------------------------------
75 subroutine from_pdb(n,idum)
76 ! This subroutine stores the UNRES int variables generated from
77 ! subroutine readpdb into the 1st conformation of in dihang_in.
78 ! Subsequent n-1 conformations of dihang_in have identical values
79 ! of theta and phi as the 1st conformation but random values for
81 ! The array cref (also generated from subroutine readpdb) is stored
82 ! to crefjlee to be used for rmsd calculation in CSA, if necessary.
86 use random, only: ran1
87 ! implicit real*8 (a-h,o-z)
88 ! include 'DIMENSIONS'
89 ! include 'COMMON.IOUNITS'
90 ! include 'COMMON.CHAIN'
91 ! include 'COMMON.VAR'
92 ! include 'COMMON.BANK'
93 ! include 'COMMON.GEO'
95 integer :: n,idum,m,i,j,k,kk,kkk
100 dihang_in(1,j,1,m)=theta(j+1)
101 dihang_in(2,j,1,m)=phi(j+2)
102 dihang_in(3,j,1,m)=alph(j)
103 dihang_in(4,j,1,m)=omeg(j)
105 dihang_in(2,nres-1,1,k)=0.0d0
109 dihang_in(1,k,1,m)=dihang_in(1,k,1,1)
110 dihang_in(2,k,1,m)=dihang_in(2,k,1,1)
111 if(dabs(dihang_in(3,k,1,1)).gt.1.d-6) then
112 dihang_in(3,k,1,m)=90.d0*ran1(idum)+90.d0
113 dihang_in(3,k,1,m)=dihang_in(3,k,1,m)*deg2rad
115 if(dabs(dihang_in(4,k,1,1)).gt.1.d-6) then
116 dihang_in(4,k,1,m)=360.d0*ran1(idum)-180.d0
117 dihang_in(4,k,1,m)=dihang_in(4,k,1,m)*deg2rad
122 ! Store cref to crefjlee (they are in COMMON.CHAIN).
126 crefjlee(kk,k)=cref(kk,k,kkk)
130 open(icsa_native_int,file=csa_native_int,status="old")
132 write(icsa_native_int,*) m,e
133 write(icsa_native_int,200) &
134 (dihang_in(1,k,1,m)*rad2deg,k=2,nres-1)
135 write(icsa_native_int,200) &
136 (dihang_in(2,k,1,m)*rad2deg,k=2,nres-2)
137 write(icsa_native_int,200) &
138 (dihang_in(3,k,1,m)*rad2deg,k=2,nres-1)
139 write(icsa_native_int,200) &
140 (dihang_in(4,k,1,m)*rad2deg,k=2,nres-1)
144 write(icsa_native_int,200) (crefjlee(i,k),i=1,3)
146 close(icsa_native_int)
151 end subroutine from_pdb
152 !-----------------------------------------------------------------------------
153 subroutine from_int(n,mm,idum)
158 use geometry, only:chainbuild,gen_side
159 use energy, only:etotal
161 ! implicit real*8 (a-h,o-z)
162 ! include 'DIMENSIONS'
163 ! include 'COMMON.IOUNITS'
164 ! include 'COMMON.CHAIN'
165 ! include 'COMMON.VAR'
166 ! include 'COMMON.INTERACT'
167 ! include 'COMMON.BANK'
168 ! include 'COMMON.GEO'
169 ! include 'COMMON.CONTACTS'
173 real(kind=8),dimension(0:n_ene) :: energia
175 integer :: n,mm,idum,i,ii,j,m,k,kk,maxcount_fail,icount_fail,maxsi
178 open(icsa_native_int,file=csa_native_int,status="old")
179 read (icsa_native_int,*)
180 call read_angles(icsa_native_int,*10)
182 10 write (iout,'(2a)') "CHUJ NASTAPIL - error in ",&
183 csa_native_int(:ilen(csa_native_int))
187 dihang_in(1,j,1,1)=theta(j+1)
188 dihang_in(2,j,1,1)=phi(j+2)
189 dihang_in(3,j,1,1)=alph(j)
190 dihang_in(4,j,1,1)=omeg(j)
192 dihang_in(2,nres-1,1,1)=0.0d0
194 ! read(icsa_native_int,*) ind,e
195 ! read(icsa_native_int,200) (dihang_in(1,k,1,1),k=2,nres-1)
196 ! read(icsa_native_int,200) (dihang_in(2,k,1,1),k=2,nres-2)
197 ! read(icsa_native_int,200) (dihang_in(3,k,1,1),k=2,nres-1)
198 ! read(icsa_native_int,200) (dihang_in(4,k,1,1),k=2,nres-1)
199 ! dihang_in(2,nres-1,1,1)=0.d0
206 ! dihang_in(1,k,1,m)=dihang_in(1,k,1,1)
207 ! dihang_in(2,k,1,m)=dihang_in(2,k,1,1)
208 ! if(abs(dihang_in(3,k,1,1)).gt.1.d-3) then
209 ! dihang_in(3,k,1,m)=90.d0*ran1(idum)+90.d0
211 ! if(abs(dihang_in(4,k,1,1)).gt.1.d-3) then
212 ! dihang_in(4,k,1,m)=360.d0*ran1(idum)-180.d0
220 DO WHILE (FAIL .AND. ICOUNT_FAIL .LE. MAXCOUNT_FAIL)
223 if (itype(i,1).ne.10) then
224 !d print *,'i=',i,' itype=',itype(i,1),' theta=',theta(i+1)
227 do while (fail .and. ii .le. maxsi)
228 call gen_side(itype(i,1),theta(i+1),alph(i),omeg(i),fail,molnum(i))
235 fail = (energia(0).ge.1.0d20)
236 icount_fail=icount_fail+1
240 if (icount_fail.gt.maxcount_fail) then
242 'Failed to generate non-overlaping near-native conf.',&
247 dihang_in(1,j,1,m)=theta(j+1)
248 dihang_in(2,j,1,m)=phi(j+2)
249 dihang_in(3,j,1,m)=alph(j)
250 dihang_in(4,j,1,m)=omeg(j)
252 dihang_in(2,nres-1,1,m)=0.0d0
256 ! write(icsa_native_int,*) m,e
257 ! write(icsa_native_int,200) (dihang_in(1,k,1,m),k=2,nres-1)
258 ! write(icsa_native_int,200) (dihang_in(2,k,1,m),k=2,nres-2)
259 ! write(icsa_native_int,200) (dihang_in(3,k,1,m),k=2,nres-1)
260 ! write(icsa_native_int,200) (dihang_in(4,k,1,m),k=2,nres-1)
262 ! close(icsa_native_int)
267 ! dihang_in(i,j,1,m)=dihang_in(i,j,1,m)*deg2rad
272 call dihang_to_c(dihang_in(1,1,1,1))
274 ! Store c to cref (they are in COMMON.CHAIN).
277 crefjlee(kk,k)=c(kk,k)
281 call contact(.true.,ncont_ref,icont_ref,co)
284 ! write(icsa_native_int,200) (crefjlee(i,k),i=1,3)
286 close(icsa_native_int)
291 end subroutine from_int
292 !-----------------------------------------------------------------------------
293 subroutine dihang_to_c(aarray)
297 use geometry, only:chainbuild
298 ! implicit real*8 (a-h,o-z)
299 ! include 'DIMENSIONS'
300 ! include 'COMMON.CSA'
301 ! include 'COMMON.BANK'
302 ! include 'COMMON.CHAIN'
303 ! include 'COMMON.GEO'
304 ! include 'COMMON.VAR'
306 real(kind=8),dimension(mxang,nres,mxch) :: aarray !(mxang,maxres,mxch)
309 ! phi(i)=dihang_in(1,i-2,1,1)
312 theta(i+1)=aarray(1,i,1)
313 phi(i+2)=aarray(2,i,1)
314 alph(i)=aarray(3,i,1)
315 omeg(i)=aarray(4,i,1)
321 end subroutine dihang_to_c
322 !-----------------------------------------------------------------------------
324 !-----------------------------------------------------------------------------
326 subroutine cartout(time)
328 subroutine cartoutx(time)
330 use geometry_data, only: c,nres
332 use MD_data, only: potE,t_bath
333 ! implicit real*8 (a-h,o-z)
334 ! include 'DIMENSIONS'
335 ! include 'COMMON.CHAIN'
336 ! include 'COMMON.INTERACT'
337 ! include 'COMMON.NAMES'
338 ! include 'COMMON.IOUNITS'
339 ! include 'COMMON.HEADER'
340 ! include 'COMMON.SBRIDGE'
341 ! include 'COMMON.DISTFIT'
342 ! include 'COMMON.MD'
347 #if defined(AIX) || defined(PGI)
348 open(icart,file=cartname,position="append")
350 open(icart,file=cartname,access="append")
352 write (icart,'(e15.8,2e15.5,f12.5,$)') time,potE,uconst,t_bath
354 write (icart,'(i4,$)') &
355 nss,(idssb(j)+nres,jdssb(j)+nres,j=1,nss)
357 write (icart,'(i4,$)') &
358 nss,(ihpb(j),jhpb(j),j=1,nss)
360 write (icart,'(i4,20f7.4)') nfrag+npair+3*nfrag_back,&
361 (qfrag(i),i=1,nfrag),(qpair(i),i=1,npair),&
362 (utheta(i),ugamma(i),uscdiff(i),i=1,nfrag_back)
363 write (icart,'(8f10.5)') &
364 ((c(k,j),k=1,3),j=1,nres),&
365 ((c(k,j+nres),k=1,3),j=nnt,nct)
370 end subroutine cartout
372 end subroutine cartoutx
374 !-----------------------------------------------------------------------------
376 subroutine cartout(time)
377 ! implicit real*8 (a-h,o-z)
378 ! include 'DIMENSIONS'
379 use geometry_data, only: c,nres
381 use MD_data, only: potE,t_bath
385 ! include 'COMMON.SETUP'
387 integer,parameter :: me=0
389 ! include 'COMMON.CHAIN'
390 ! include 'COMMON.INTERACT'
391 ! include 'COMMON.NAMES'
392 ! include 'COMMON.IOUNITS'
393 ! include 'COMMON.HEADER'
394 ! include 'COMMON.SBRIDGE'
395 ! include 'COMMON.DISTFIT'
396 ! include 'COMMON.MD'
400 real(kind=4),dimension(3,2*nres+2) :: xcoord !(3,maxres2+2) (maxres2=2*maxres
405 call xdrfopen_(ixdrf,cartname, "a", iret)
406 call xdrffloat_(ixdrf, real(time), iret)
407 call xdrffloat_(ixdrf, real(potE), iret)
408 call xdrffloat_(ixdrf, real(uconst), iret)
409 call xdrffloat_(ixdrf, real(uconst_back), iret)
410 call xdrffloat_(ixdrf, real(t_bath), iret)
411 call xdrfint_(ixdrf, nss, iret)
414 call xdrfint_(ixdrf, idssb(j)+nres, iret)
415 call xdrfint_(ixdrf, jdssb(j)+nres, iret)
417 call xdrfint_(ixdrf, ihpb(j), iret)
418 call xdrfint_(ixdrf, jhpb(j), iret)
421 call xdrfint_(ixdrf, nfrag+npair+3*nfrag_back, iret)
423 call xdrffloat_(ixdrf, real(qfrag(i)), iret)
426 call xdrffloat_(ixdrf, real(qpair(i)), iret)
429 call xdrffloat_(ixdrf, real(utheta(i)), iret)
430 call xdrffloat_(ixdrf, real(ugamma(i)), iret)
431 call xdrffloat_(ixdrf, real(uscdiff(i)), iret)
434 call xdrfopen(ixdrf,cartname, "a", iret)
435 call xdrffloat(ixdrf, real(time), iret)
436 call xdrffloat(ixdrf, real(potE), iret)
437 call xdrffloat(ixdrf, real(uconst), iret)
438 call xdrffloat(ixdrf, real(uconst_back), iret)
439 call xdrffloat(ixdrf, real(t_bath), iret)
440 call xdrfint(ixdrf, nss, iret)
443 call xdrfint(ixdrf, idssb(j)+nres, iret)
444 call xdrfint(ixdrf, jdssb(j)+nres, iret)
446 call xdrfint(ixdrf, ihpb(j), iret)
447 call xdrfint(ixdrf, jhpb(j), iret)
450 call xdrfint(ixdrf, nfrag+npair+3*nfrag_back, iret)
452 call xdrffloat(ixdrf, real(qfrag(i)), iret)
455 call xdrffloat(ixdrf, real(qpair(i)), iret)
458 call xdrffloat(ixdrf, real(utheta(i)), iret)
459 call xdrffloat(ixdrf, real(ugamma(i)), iret)
460 call xdrffloat(ixdrf, real(uscdiff(i)), iret)
471 xcoord(j,nres+i-nnt+1)=c(j,i+nres)
477 call xdrf3dfcoord_(ixdrf, xcoord, itmp, prec, iret)
478 call xdrfclose_(ixdrf, iret)
480 call xdrf3dfcoord(ixdrf, xcoord, itmp, prec, iret)
481 call xdrfclose(ixdrf, iret)
484 end subroutine cartout
486 !-----------------------------------------------------------------------------
487 subroutine statout(itime)
493 use compare, only:rms_nac_nnc
494 ! implicit real*8 (a-h,o-z)
495 ! include 'DIMENSIONS'
496 ! include 'COMMON.CONTROL'
497 ! include 'COMMON.CHAIN'
498 ! include 'COMMON.INTERACT'
499 ! include 'COMMON.NAMES'
500 ! include 'COMMON.IOUNITS'
501 ! include 'COMMON.HEADER'
502 ! include 'COMMON.SBRIDGE'
503 ! include 'COMMON.DISTFIT'
504 ! include 'COMMON.MD'
505 ! include 'COMMON.REMD'
506 ! include 'COMMON.SETUP'
508 real(kind=8),dimension(0:n_ene) :: energia
509 ! double precision gyrate
511 !el common /gucio/ cm
512 character(len=256) :: line1,line2
513 character(len=4) :: format1,format2
514 character(len=30) :: format
516 integer :: i,ii1,ii2,j
517 real(kind=8) :: rms,frac,frac_nn,co,distance
521 open(istat,file=statname,position="append")
525 open(istat,file=statname,position="append")
527 open(istat,file=statname,access="append")
530 if (AFMlog.gt.0) then
532 call rms_nac_nnc(rms,frac,frac_nn,co,.false.)
533 write (line1,'(i10,f15.2,3f12.3,f7.2,2f6.3,4f12.3,i5,$)')&
534 itime,totT,EK,potE,totE,&
535 rms,frac,frac_nn,kinetic_T,t_bath,gyrate(),&
539 !C print *,'A CHUJ',potEcomp(23)
540 write (line1,'(i10,f15.2,7f12.3,i5,$)') &
541 itime,totT,EK,potE,totE,&
542 kinetic_T,t_bath,gyrate(),&
546 else if (selfguide.gt.0) then
549 distance=distance+(c(j,afmend)-c(j,afmbeg))**2
551 distance=dsqrt(distance)
553 call rms_nac_nnc(rms,frac,frac_nn,co,.false.)
554 write (line1,'(i10,f15.2,3f12.3,f7.2,2f6.3,f12.3,f10.1,2f8.2, &
556 itime,totT,EK,potE,totE,&
557 rms,frac,frac_nn,kinetic_T,t_bath,gyrate(),&
558 distance,potEcomp(23),me
562 !C print *,'A CHUJ',potEcomp(23)
563 write (line1,'(i10,f15.2,8f12.3,i5,$)')&
564 itime,totT,EK,potE,totE, &
565 kinetic_T,t_bath,gyrate(),&
566 distance,potEcomp(23),me
571 call rms_nac_nnc(rms,frac,frac_nn,co,.false.)
572 write (line1,'(i10,f15.2,3f12.3,f7.2,4f6.3,3f12.3,i5,$)') &
573 itime,totT,EK,potE,totE,&
574 rms,frac,frac_nn,co,amax,kinetic_T,t_bath,gyrate(),me
577 write (line1,'(i10,f15.2,7f12.3,i5,$)') &
578 itime,totT,EK,potE,totE,&
579 amax,kinetic_T,t_bath,gyrate(),me
583 if(usampl.and.totT.gt.eq_time) then
584 write(line2,'(i5,2f9.4,300f7.4)') iset,uconst,uconst_back,&
585 (qfrag(ii1),ii1=1,nfrag),(qpair(ii2),ii2=1,npair),&
586 (utheta(i),ugamma(i),uscdiff(i),i=1,nfrag_back)
587 write(format2,'(a1,i3.3)') "a",23+7*nfrag+7*npair &
593 if (print_compon) then
595 write(format,'(a1,a4,a1,a4,a10)') "(",format1,",",format2,&
597 write (istat,format) "#","",&
598 (ename(print_order(i)),i=1,nprint_ene)
600 write(format,'(a1,a4,a1,a4,a10)') "(",format1,",",format2,&
602 write (istat,format) line1,line2,&
603 (potEcomp(print_order(i)),i=1,nprint_ene)
605 write(format,'(a1,a4,a1,a4,a1)') "(",format1,",",format2,")"
606 write (istat,format) line1,line2
614 end subroutine statout
615 !-----------------------------------------------------------------------------
617 !-----------------------------------------------------------------------------
623 use muca_md, only:read_muca
624 ! implicit real*8 (a-h,o-z)
625 ! include 'DIMENSIONS'
629 ! include 'COMMON.SETUP'
630 ! include 'COMMON.CONTROL'
631 ! include 'COMMON.SBRIDGE'
632 ! include 'COMMON.IOUNITS'
633 logical :: file_exist
635 ! Read force-field parameters except weights
637 ! Read job setup parameters
639 ! Read force-field parameters except weights
642 ! Read control parameters for energy minimzation if required
643 if (minim) call read_minim
644 ! Read MCM control parameters if required
645 if (modecalc.eq.3 .or. modecalc.eq.6) call mcmread
646 ! Read MD control parameters if reqjuired
647 if (modecalc.eq.12) call read_MDpar
648 ! Read MREMD control parameters if required
649 if (modecalc.eq.14) then
653 ! Read MUCA control parameters if required
654 if (lmuca) call read_muca
655 ! Read CSA control parameters if required (from fort.40 if exists
656 ! otherwise from general input file)
657 if (modecalc.eq.8) then
658 inquire (file="fort.40",exist=file_exist)
659 if (.not.file_exist) call csaread
661 !fmc if (modecalc.eq.10) call mcmfread
662 ! Read molecule information, molecule geometry, energy-term weights, and
663 ! restraints if requested
665 ! Print restraint information
667 if (.not. out1file .or. me.eq.king) then
670 write (iout,'(a,i5,a)') "The following",nhpb-nss,&
671 " distance constraints have been imposed"
673 write (iout,'(3i6,f10.5)') i-nss,ihpb(i),jhpb(i),forcon(i)
678 ! print *,"Processor",myrank," leaves READRTNS"
679 ! write(iout,*) "end readrtns"
681 end subroutine readrtns
682 !-----------------------------------------------------------------------------
685 ! Read molecular data.
687 ! use control, only: ilen
693 use MD_data, only: t_bath
695 use compare, only:seq_comp,contact
697 ! implicit real*8 (a-h,o-z)
698 ! include 'DIMENSIONS'
701 integer :: error_msg,ierror,ierr,ierrcode
703 ! include 'COMMON.IOUNITS'
704 ! include 'COMMON.GEO'
705 ! include 'COMMON.VAR'
706 ! include 'COMMON.INTERACT'
707 ! include 'COMMON.LOCAL'
708 ! include 'COMMON.NAMES'
709 ! include 'COMMON.CHAIN'
710 ! include 'COMMON.FFIELD'
711 ! include 'COMMON.SBRIDGE'
712 ! include 'COMMON.HEADER'
713 ! include 'COMMON.CONTROL'
714 ! include 'COMMON.DBASE'
715 ! include 'COMMON.THREAD'
716 ! include 'COMMON.CONTACTS'
717 ! include 'COMMON.TORCNSTR'
718 ! include 'COMMON.TIME1'
719 ! include 'COMMON.BOUNDS'
720 ! include 'COMMON.MD'
721 ! include 'COMMON.SETUP'
722 character(len=4),dimension(:,:),allocatable :: sequence !(maxres,maxmolecules)
724 ! double precision x(maxvar)
725 character(len=256) :: pdbfile
726 character(len=800) :: weightcard
727 character(len=80) :: weightcard_t!,ucase
728 ! integer,dimension(:),allocatable :: itype_pdb !(maxres)
729 ! common /pizda/ itype_pdb
730 logical :: fail !seq_comp,
731 real(kind=8) :: energia(0:n_ene)
735 integer :: i,j,l,k,kkk,ii,i1,i2,it1,it2
737 real(kind=8),dimension(3,maxres2+2) :: c_alloc
738 real(kind=8),dimension(3,0:maxres2) :: dc_alloc
739 real(kind=8),dimension(:,:), allocatable :: secprob
740 integer,dimension(maxres) :: itype_alloc
742 integer :: iti,nsi,maxsi,itrial,itmp
743 real(kind=8) :: wlong,scalscp,co,ssscale,phihel,phibet,sigmahel,&
744 sigmabet,sumv,nres_temp
745 allocate(weights(n_ene))
746 !-----------------------------
747 allocate(c(3,2*maxres+2)) !(3,maxres2+2) maxres2=2*maxres
748 allocate(dc(3,0:2*maxres)) !(3,0:maxres2)
749 allocate(itype(maxres,5)) !(maxres)
750 allocate(istype(maxres))
757 !-----------------------------
761 ! Read weights of the subsequent energy terms.
762 call card_concat(weightcard,.true.)
763 call reada(weightcard,'WLONG',wlong,1.0D0)
764 call reada(weightcard,'WSC',wsc,wlong)
765 call reada(weightcard,'WSCP',wscp,wlong)
766 call reada(weightcard,'WELEC',welec,1.0D0)
767 call reada(weightcard,'WVDWPP',wvdwpp,welec)
768 call reada(weightcard,'WEL_LOC',wel_loc,1.0D0)
769 call reada(weightcard,'WCORR4',wcorr4,0.0D0)
770 call reada(weightcard,'WCORR5',wcorr5,0.0D0)
771 call reada(weightcard,'WCORR6',wcorr6,0.0D0)
772 call reada(weightcard,'WTURN3',wturn3,1.0D0)
773 call reada(weightcard,'WTURN4',wturn4,1.0D0)
774 call reada(weightcard,'WTURN6',wturn6,1.0D0)
775 call reada(weightcard,'WSCCOR',wsccor,1.0D0)
776 call reada(weightcard,'WSTRAIN',wstrain,1.0D0)
777 call reada(weightcard,'WVDWPP_NUCL',wvdwpp_nucl,0.0D0)
778 call reada(weightcard,'WELPP',welpp,0.0d0)
779 call reada(weightcard,'WVDWPSB',wvdwpsb,0.0d0)
780 call reada(weightcard,'WELPSB',welpsb,0.0D0)
781 call reada(weightcard,'WVDWSB',wvdwsb,0.0d0)
782 call reada(weightcard,'WELSB',welsb,0.0D0)
783 call reada(weightcard,'WBOND_NUCL',wbond_nucl,0.0D0)
784 call reada(weightcard,'WANG_NUCL',wang_nucl,0.0D0)
785 call reada(weightcard,'WSBLOC',wsbloc,0.0D0)
786 call reada(weightcard,'WTOR_NUCL',wtor_nucl,0.0D0)
787 ! print *,"KUR..",wtor_nucl
788 call reada(weightcard,'WTORD_NUCL',wtor_d_nucl,0.0D0)
789 call reada(weightcard,'WCORR_NUCL',wcorr_nucl,0.0D0)
790 call reada(weightcard,'WCORR3_NUC',wcorr3_nucl,0.0D0)
791 call reada(weightcard,'WBOND',wbond,1.0D0)
792 call reada(weightcard,'WTOR',wtor,1.0D0)
793 call reada(weightcard,'WTORD',wtor_d,1.0D0)
794 call reada(weightcard,'WSHIELD',wshield,0.05D0)
795 call reada(weightcard,'LIPSCALE',lipscale,1.0D0)
796 call reada(weightcard,'WLT',wliptran,1.0D0)
797 call reada(weightcard,'WTUBE',wtube,1.0d0)
798 call reada(weightcard,'WANG',wang,1.0D0)
799 call reada(weightcard,'WSCLOC',wscloc,1.0D0)
800 call reada(weightcard,'SCAL14',scal14,0.4D0)
801 call reada(weightcard,'SCALSCP',scalscp,1.0d0)
802 call reada(weightcard,'CUTOFF',cutoff_corr,7.0d0)
803 call reada(weightcard,'DELT_CORR',delt_corr,0.5d0)
804 call reada(weightcard,'TEMP0',temp0,300.0d0)
805 call reada(weightcard,'WSCBASE',wscbase,0.0D0)
806 if (index(weightcard,'SOFT').gt.0) ipot=6
807 call reada(weightcard,'WBOND_NUCL',wbond_nucl,0.0D0)
808 call reada(weightcard,'WCATCAT',wcatcat,0.0d0)
809 call reada(weightcard,'WCATPROT',wcatprot,0.0d0)
810 call reada(weightcard,'WCATNUCL',wcatnucl,0.0d0)
811 call reada(weightcard,'WPEPBASE',wpepbase,1.0d0)
812 call reada(weightcard,'WSCPHO',wscpho,0.0d0)
813 call reada(weightcard,'WPEPPHO',wpeppho,0.0d0)
815 ! 12/1/95 Added weight for the multi-body term WCORR
816 call reada(weightcard,'WCORRH',wcorr,1.0D0)
817 if (wcorr4.gt.0.0d0) wcorr=wcorr4
837 weights(26)=wvdwpp_nucl
843 weights(32)=wbond_nucl
844 weights(33)=wang_nucl
846 weights(35)=wtor_nucl
847 weights(36)=wtor_d_nucl
848 weights(37)=wcorr_nucl
849 weights(38)=wcorr3_nucl
858 if(me.eq.king.or..not.out1file) &
859 write (iout,10) wsc,wscp,welec,wvdwpp,wbond,wang,wscloc,wtor,&
860 wtor_d,wstrain,wel_loc,wcorr,wcorr5,wcorr6,wsccor,wturn3,&
862 10 format (/'Energy-term weights (unscaled):'// &
863 'WSCC= ',f10.6,' (SC-SC)'/ &
864 'WSCP= ',f10.6,' (SC-p)'/ &
865 'WELEC= ',f10.6,' (p-p electr)'/ &
866 'WVDWPP= ',f10.6,' (p-p VDW)'/ &
867 'WBOND= ',f10.6,' (stretching)'/ &
868 'WANG= ',f10.6,' (bending)'/ &
869 'WSCLOC= ',f10.6,' (SC local)'/ &
870 'WTOR= ',f10.6,' (torsional)'/ &
871 'WTORD= ',f10.6,' (double torsional)'/ &
872 'WSTRAIN=',f10.6,' (SS bridges & dist. cnstr.)'/ &
873 'WEL_LOC=',f10.6,' (multi-body 3-rd order)'/ &
874 'WCORR4= ',f10.6,' (multi-body 4th order)'/ &
875 'WCORR5= ',f10.6,' (multi-body 5th order)'/ &
876 'WCORR6= ',f10.6,' (multi-body 6th order)'/ &
877 'WSCCOR= ',f10.6,' (back-scloc correlation)'/ &
878 'WTURN3= ',f10.6,' (turns, 3rd order)'/ &
879 'WTURN4= ',f10.6,' (turns, 4th order)'/ &
880 'WTURN6= ',f10.6,' (turns, 6th order)')
881 if(me.eq.king.or..not.out1file)then
882 if (wcorr4.gt.0.0d0) then
883 write (iout,'(/2a/)') 'Local-electrostatic type correlation ',&
884 'between contact pairs of peptide groups'
885 write (iout,'(2(a,f5.3/))') &
886 'Cutoff on 4-6th order correlation terms: ',cutoff_corr,&
887 'Range of quenching the correlation terms:',2*delt_corr
888 else if (wcorr.gt.0.0d0) then
889 write (iout,'(/2a/)') 'Hydrogen-bonding correlation ',&
890 'between contact pairs of peptide groups'
892 write (iout,'(a,f8.3)') &
893 'Scaling factor of 1,4 SC-p interactions:',scal14
894 write (iout,'(a,f8.3)') &
895 'General scaling factor of SC-p interactions:',scalscp
897 r0_corr=cutoff_corr-delt_corr
899 aad(i,1)=scalscp*aad(i,1)
900 aad(i,2)=scalscp*aad(i,2)
901 bad(i,1)=scalscp*bad(i,1)
902 bad(i,2)=scalscp*bad(i,2)
904 call rescale_weights(t_bath)
905 if(me.eq.king.or..not.out1file) &
906 write (iout,22) wsc,wscp,welec,wvdwpp,wbond,wang,wscloc,wtor,&
907 wtor_d,wstrain,wel_loc,wcorr,wcorr5,wcorr6,wsccor,wturn3,&
909 22 format (/'Energy-term weights (scaled):'// &
910 'WSCC= ',f10.6,' (SC-SC)'/ &
911 'WSCP= ',f10.6,' (SC-p)'/ &
912 'WELEC= ',f10.6,' (p-p electr)'/ &
913 'WVDWPP= ',f10.6,' (p-p VDW)'/ &
914 'WBOND= ',f10.6,' (stretching)'/ &
915 'WANG= ',f10.6,' (bending)'/ &
916 'WSCLOC= ',f10.6,' (SC local)'/ &
917 'WTOR= ',f10.6,' (torsional)'/ &
918 'WTORD= ',f10.6,' (double torsional)'/ &
919 'WSTRAIN=',f10.6,' (SS bridges & dist. cnstr.)'/ &
920 'WEL_LOC=',f10.6,' (multi-body 3-rd order)'/ &
921 'WCORR4= ',f10.6,' (multi-body 4th order)'/ &
922 'WCORR5= ',f10.6,' (multi-body 5th order)'/ &
923 'WCORR6= ',f10.6,' (multi-body 6th order)'/ &
924 'WSCCOR= ',f10.6,' (back-scloc correlatkion)'/ &
925 'WTURN3= ',f10.6,' (turns, 3rd order)'/ &
926 'WTURN4= ',f10.6,' (turns, 4th order)'/ &
927 'WTURN6= ',f10.6,' (turns, 6th order)')
928 if(me.eq.king.or..not.out1file) &
929 write (iout,*) "Reference temperature for weights calculation:",&
931 call reada(weightcard,"D0CM",d0cm,3.78d0)
932 call reada(weightcard,"AKCM",akcm,15.1d0)
933 call reada(weightcard,"AKTH",akth,11.0d0)
934 call reada(weightcard,"AKCT",akct,12.0d0)
935 call reada(weightcard,"V1SS",v1ss,-1.08d0)
936 call reada(weightcard,"V2SS",v2ss,7.61d0)
937 call reada(weightcard,"V3SS",v3ss,13.7d0)
938 call reada(weightcard,"EBR",ebr,-5.50D0)
939 call reada(weightcard,"ATRISS",atriss,0.301D0)
940 call reada(weightcard,"BTRISS",btriss,0.021D0)
941 call reada(weightcard,"CTRISS",ctriss,1.001D0)
942 call reada(weightcard,"DTRISS",dtriss,1.001D0)
943 call reada(weightcard,"SSSCALE",ssscale,1.0D0)
944 dyn_ss=(index(weightcard,'DYN_SS').gt.0)
946 call reada(weightcard,"HT",Ht,0.0D0)
948 ss_depth=(ebr/wsc-0.25*eps(1,1))*ssscale
949 Ht=(Ht/wsc-0.25*eps(1,1))*ssscale
950 akcm=akcm/wsc*ssscale
951 akth=akth/wsc*ssscale
952 akct=akct/wsc*ssscale
953 v1ss=v1ss/wsc*ssscale
954 v2ss=v2ss/wsc*ssscale
955 v3ss=v3ss/wsc*ssscale
957 ss_depth=ebr/wstrain-0.25*eps(1,1)*wsc/wstrain
960 if(me.eq.king.or..not.out1file) then
961 write (iout,*) "Parameters of the SS-bond potential:"
962 write (iout,*) "D0CM",d0cm," AKCM",akcm," AKTH",akth,&
964 write (iout,*) "V1SS",v1ss," V2SS",v2ss," V3SS",v3ss
965 write (iout,*) "EBR",ebr," SS_DEPTH",ss_depth
966 write (iout,*)" HT",Ht
967 print *,'indpdb=',indpdb,' pdbref=',pdbref
969 if (indpdb.gt.0 .or. pdbref) then
970 read(inp,'(a)') pdbfile
971 if(me.eq.king.or..not.out1file) &
972 write (iout,'(2a)') 'PDB data will be read from file ',&
973 pdbfile(:ilen(pdbfile))
974 open(ipdbin,file=pdbfile,status='old',err=33)
976 33 write (iout,'(a)') 'Error opening PDB file.'
979 ! print *,'Begin reading pdb data'
981 if (.not.allocated(crefjlee)) allocate (crefjlee(3,2*nres+2))
989 write (iout,'(i5,3f8.3,5x,3f8.3)') i,(crefjlee(j,i),j=1,3),
990 & (crefjlee(j,i+nres),j=1,3)
994 ! call int_from_cart1(.true.)
996 ! print *,'Finished reading pdb data'
997 if(me.eq.king.or..not.out1file) &
998 write (iout,'(a,i3,a,i3)')'nsup=',nsup,&
999 ' nstart_sup=',nstart_sup !,"ergwergewrgae"
1000 !el if(.not.allocated(itype_pdb))
1001 allocate(itype_pdb(nres))
1003 itype_pdb(i)=itype(i,1)
1007 nct=nstart_sup+nsup-1
1008 !el if(.not.allocated(icont_ref))
1009 allocate(icont_ref(2,(nres/2)*nres)) ! maxcont=12*maxres
1010 call contact(.false.,ncont_ref,icont_ref,co)
1013 if(me.eq.king.or..not.out1file) &
1014 write(iout,*)'Adding sidechains'
1018 if (iti.ne.10 .and. itype(i,1).ne.ntyp1) then
1021 do while (fail.and.nsi.le.maxsi)
1022 call gen_side(iti,theta(i+1),alph(i),omeg(i),fail,molnum(i))
1025 if(fail) write(iout,*)'Adding sidechain failed for res ',&
1026 i,' after ',nsi,' trials'
1031 print *,"CZY TU DOCHODZE"
1032 if (indpdb.eq.0) then
1034 allocate(sequence(maxres,5))
1038 ! Read sequence if not taken from the pdb file.
1040 read (inp,*) nres_molec(molec)
1041 print *,'nres=',nres
1042 if (iscode.gt.0) then
1043 read (inp,'(80a1)') (sequence(i,molec)(1:1),i=1,nres_molec(molec))
1045 read (inp,'(20(1x,a3))') (sequence(i,molec),i=1,nres_molec(molec))
1047 ! read(inp,*) weightcard_t
1048 ! print *,"po seq" weightcard_t
1049 ! Convert sequence to numeric code
1051 do i=1,nres_molec(molec)
1053 itype(i,1)=rescode(i,sequence(i,molec),iscode,molec)
1058 ! read(inp,*) weightcard_t
1059 ! print *,"po seq", weightcard_t
1062 ! Read sequence if not taken from the pdb file.
1064 read (inp,*) nres_molec(molec)
1065 print *,'nres=',nres_molec(molec)
1066 ! allocate(sequence(maxres,5))
1067 ! if (iscode.gt.0) then
1068 read (inp,'(20a4)') (sequence(i,molec),i=1,nres_molec(molec))
1070 print *,(sequence(i,molec),i=1,nres_molec(molec))
1071 ! Convert sequence to numeric code
1073 do i=1,nres_molec(molec)
1075 istype(itmp)=sugarcode(sequence(i,molec)(1:1),i)
1076 sequence(i,molec)=sequence(i,molec)(1:2)
1077 itype(itmp,molec)=rescode(i,sequence(i,molec),iscode,molec)
1078 write(iout,*) "NUCLE=", itype(itmp,molec)
1083 ! Read sequence if not taken from the pdb file.
1085 read (inp,*) nres_molec(molec)
1086 ! print *,'nres=',nres
1087 read (inp,'(20(1x,a3))') (sequence(i,molec),i=1,nres_molec(molec))
1088 ! Convert sequence to numeric code
1089 print *,nres_molec(molec)
1090 do i=1,nres_molec(molec)
1093 itype(itmp,molec)=rescode(i,sequence(i,molec),iscode,molec)
1098 nres=nres+nres_molec(i)
1099 print *,"nres_molec",nres,nres_molec(i)
1102 ! Assign initial virtual bond lengths
1103 if(.not.allocated(molnum)) then
1104 allocate(molnum(nres+1))
1107 do j=1,nres_molec(i)
1112 ! print *,nres_molec(i)
1115 if(.not.allocated(vbld)) then
1116 print *, "I DO ENTER"
1117 allocate(vbld(2*nres))
1119 if(.not.allocated(vbld_inv)) allocate(vbld_inv(2*nres))
1121 if (molnum(i).eq.1) then
1131 if (molnum(i).eq.1) then
1132 ! print *, "molnum",molnum(i),itype(i,molnum(i)),nres,i
1133 vbld(i+nres)=dsc(iabs(itype(i,molnum(i))))
1134 vbld_inv(i+nres)=dsc_inv(iabs(itype(i,molnum(i))))
1136 vbld(i+nres)=vbldsc0_nucl(1,iabs(itype(i,molnum(i))))
1137 vbld_inv(i+nres)=1.0/vbldsc0_nucl(1,iabs(itype(i,molnum(i))))
1139 ! write (iout,*) "i",i," itype",itype(i,1),
1140 ! & " dsc",dsc(itype(i,1))," vbld",vbld(i),vbld(i+nres)
1144 ! print '(20i4)',(itype(i,1),i=1,nres)
1145 !----------------------------
1146 !el reallocate tables
1149 ! c_alloc(j,i)=c(j,i)
1150 ! dc_alloc(j,i)=dc(j,i)
1154 !elwrite(iout,*) "itype",i,itype(i,1)
1155 ! itype_alloc(i)=itype(i,1)
1161 ! allocate(c(3,2*nres+4))
1162 ! allocate(dc(3,0:2*nres+2))
1163 ! allocate(itype(nres+2))
1164 allocate(itel(nres+2))
1169 ! c(j,i)=c_alloc(j,i)
1170 ! dc(j,i)=dc_alloc(j,i)
1174 ! itype(i,1)=itype_alloc(i)
1177 !--------------------------
1180 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) then
1182 if (itype(i,1).eq.ntyp1) then
1186 else if (iabs(itype(i+1,1)).ne.20) then
1188 else if (iabs(itype(i,1)).ne.20) then
1195 if(me.eq.king.or..not.out1file)then
1196 write (iout,*) "ITEL"
1199 write (iout,*) i,itype(i,1),itel(i)
1201 print *,'Call Read_Bridge.'
1204 !--------------------------------
1205 ! print *,"tu dochodze"
1206 ! znamy nres oraz nss można zaalokowac potrzebne tablice
1207 call alloc_geo_arrays
1208 call alloc_ener_arrays
1209 !--------------------------------
1210 ! 8/13/98 Set limits to generating the dihedral angles
1215 read (inp,*) ndih_constr
1216 if (ndih_constr.gt.0) then
1218 allocate(idih_constr(ndih_constr),idih_nconstr(ndih_constr)) !(maxdih_constr)
1219 allocate(phi0(ndih_constr),drange(ndih_constr)) !(maxdih_constr)
1220 allocate(ftors(ndih_constr)) !(maxdih_constr)
1222 ! read (inp,*) ftors
1223 read (inp,*) (idih_constr(i),phi0(i),drange(i),ftors(i), &
1225 if(me.eq.king.or..not.out1file)then
1227 'There are',ndih_constr,' constraints on phi angles.'
1229 write (iout,'(i5,3f8.3)') idih_constr(i),phi0(i),drange(i), &
1234 phi0(i)=deg2rad*phi0(i)
1235 drange(i)=deg2rad*drange(i)
1237 ! if(me.eq.king.or..not.out1file) &
1238 ! write (iout,*) 'FTORS',ftors
1241 phibound(1,ii) = phi0(i)-drange(i)
1242 phibound(2,ii) = phi0(i)+drange(i)
1244 else if (ndih_constr.lt.0) then
1246 allocate(idih_constr(nres))
1247 allocate(secprob(3,nres))
1248 allocate(vpsipred(3,nres))
1249 allocate(sdihed(2,nres))
1250 call card_concat(weightcard,.true.)
1251 call reada(weightcard,"PHIHEL",phihel,50.0D0)
1252 call reada(weightcard,"PHIBET",phibet,180.0D0)
1253 call reada(weightcard,"SIGMAHEL",sigmahel,30.0d0)
1254 call reada(weightcard,"SIGMABET",sigmabet,40.0d0)
1255 call reada(weightcard,"WDIHC",wdihc,0.591D0)
1256 write (iout,*) "Weight of dihedral angle restraints",wdihc
1257 read(inp,'(9x,3f7.3)') &
1258 (secprob(1,i),secprob(2,i),secprob(3,i),i=nnt,nct)
1259 write (iout,*) "The secprob array"
1261 write (iout,'(i5,3f8.3)') i,(secprob(j,i),j=1,3)
1265 if (itype(i-3,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1 &
1266 .and. itype(i-1,1).ne.ntyp1 .and. itype(i,1).ne.ntyp1) then
1267 ndih_constr=ndih_constr+1
1268 idih_constr(ndih_constr)=i
1271 vpsipred(j,ndih_constr)=secprob(j,i-1)*secprob(j,i-2)
1272 sumv=sumv+vpsipred(j,ndih_constr)
1275 vpsipred(j,ndih_constr)=vpsipred(j,ndih_constr)/sumv
1277 phibound(1,ndih_constr)=phihel*deg2rad
1278 phibound(2,ndih_constr)=phibet*deg2rad
1279 sdihed(1,ndih_constr)=sigmahel*deg2rad
1280 sdihed(2,ndih_constr)=sigmabet*deg2rad
1285 if (with_theta_constr) then
1286 !C with_theta_constr is keyword allowing for occurance of theta constrains
1287 read (inp,*) ntheta_constr
1288 !C ntheta_constr is the number of theta constrains
1289 if (ntheta_constr.gt.0) then
1290 !C read (inp,*) ftors
1291 allocate(itheta_constr(ntheta_constr))
1292 allocate(theta_constr0(ntheta_constr))
1293 allocate(theta_drange(ntheta_constr),for_thet_constr(ntheta_constr))
1294 read (inp,*) (itheta_constr(i),theta_constr0(i), &
1295 theta_drange(i),for_thet_constr(i), &
1297 !C the above code reads from 1 to ntheta_constr
1298 !C itheta_constr(i) residue i for which is theta_constr
1299 !C theta_constr0 the global minimum value
1300 !C theta_drange is range for which there is no energy penalty
1301 !C for_thet_constr is the force constant for quartic energy penalty
1303 if(me.eq.king.or..not.out1file)then
1305 'There are',ntheta_constr,' constraints on phi angles.'
1306 do i=1,ntheta_constr
1307 write (iout,'(i5,3f8.3)') itheta_constr(i),theta_constr0(i), &
1312 do i=1,ntheta_constr
1313 theta_constr0(i)=deg2rad*theta_constr0(i)
1314 theta_drange(i)=deg2rad*theta_drange(i)
1316 !C if(me.eq.king.or..not.out1file)
1317 !C & write (iout,*) 'FTORS',ftors
1318 !C do i=1,ntheta_constr
1319 !C ii = itheta_constr(i)
1320 !C thetabound(1,ii) = phi0(i)-drange(i)
1321 !C thetabound(2,ii) = phi0(i)+drange(i)
1323 endif ! ntheta_constr.gt.0
1324 endif! with_theta_constr
1328 if (me.eq.king) then
1330 write (iout,'(a)') 'Boundaries in phi angle sampling:'
1332 write (iout,'(a3,i5,2f10.1)') &
1333 restyp(itype(i,1),1),i,phibound(1,i)*rad2deg,phibound(2,i)*rad2deg
1339 print *,'NNT=',NNT,' NCT=',NCT
1340 if (itype(1,molnum(1)).eq.ntyp1_molec(molnum(1))) nnt=2
1341 if (itype(nres,molnum(nres)).eq.ntyp1_molec(molnum(nres))) nct=nct-1
1343 if(me.eq.king.or..not.out1file) &
1344 write (iout,'(a,i3)') 'nsup=',nsup
1346 if (nsup.le.(nct-nnt+1)) then
1347 do i=0,nct-nnt+1-nsup
1348 if (seq_comp(itype(nnt+i,1),itype_pdb(nstart_sup),nsup)) then
1353 write (iout,'(a)') &
1354 'Error - sequences to be superposed do not match.'
1357 do i=0,nsup-(nct-nnt+1)
1358 if (seq_comp(itype(nnt,1),itype_pdb(nstart_sup+i),nct-nnt+1)) &
1360 nstart_sup=nstart_sup+i
1365 write (iout,'(a)') &
1366 'Error - sequences to be superposed do not match.'
1369 if (nsup.eq.0) nsup=nct-nnt
1370 if (nstart_sup.eq.0) nstart_sup=nnt
1371 if (nstart_seq.eq.0) nstart_seq=nnt
1372 if(me.eq.king.or..not.out1file) &
1373 write (iout,*) 'nsup=',nsup,' nstart_sup=',nstart_sup,&
1374 ' nstart_seq=',nstart_seq !,"242343453254"
1376 !--- Zscore rms -------
1377 if (nz_start.eq.0) nz_start=nnt
1378 if (nz_end.eq.0 .and. nsup.gt.0) then
1380 else if (nz_end.eq.0) then
1383 if(me.eq.king.or..not.out1file)then
1384 write (iout,*) 'NZ_START=',nz_start,' NZ_END=',nz_end
1385 write (iout,*) 'IZ_SC=',iz_sc
1387 !----------------------
1390 if (.not.pdbref) then
1391 call read_angles(inp,*38)
1393 38 write (iout,'(a)') 'Error reading reference structure.'
1395 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
1396 stop 'Error reading reference structure'
1400 !zscore call geom_to_var(nvar,coord_exp_zs(1,1))
1407 cref(j,i,kkk)=c(j,i)
1410 call contact(.true.,ncont_ref,icont_ref,co)
1412 ! write (iout,*) "constr_dist",constr_dist,nstart_sup,nsup
1414 !EL if (constr_dist.gt.0) call read_dist_constr
1415 !EL write (iout,*) "After read_dist_constr nhpb",nhpb
1416 !EL if ((AFMlog.gt.0).or.(selfguide.gt.0)) call read_afminp
1417 !EL call hpb_partition
1418 if(me.eq.king.or..not.out1file) &
1419 write (iout,*) 'Contact order:',co
1421 if(me.eq.king.or..not.out1file) &
1422 write (2,*) 'Shifting contacts:',nstart_seq,nstart_sup
1425 icont_ref(j,i)=icont_ref(j,i)+nstart_seq-nstart_sup
1427 if(me.eq.king.or..not.out1file) &
1428 write (2,*) i,' ',restyp(itype(icont_ref(1,i),1),1),' ',&
1429 icont_ref(1,i),' ',&
1430 restyp(itype(icont_ref(2,i),1),1),' ',icont_ref(2,i)
1433 if (constr_homology.gt.0) then
1434 ! write (iout,*) "Calling read_constr_homology"
1436 call read_constr_homology
1437 if (indpdb.gt.0 .or. pdbref) then
1440 c(j,i)=crefjlee(j,i)
1441 cref(j,i,1)=crefjlee(j,i)
1447 write (iout,*) "sc_loc_geom: Array C"
1449 write (iout,'(i5,3f8.3,5x,3f8.3)') i,(c(j,i),j=1,3),&
1452 write (iout,*) "Array Cref"
1454 write (iout,'(i5,3f8.3,5x,3f8.3)') i,(cref(j,i,1),j=1,3),&
1455 (cref(j,i+nres,1),j=1,3)
1458 call int_from_cart1(.false.)
1459 call sc_loc_geom(.false.)
1461 thetaref(i)=theta(i)
1466 dc(j,i)=c(j,i+1)-c(j,i)
1467 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
1472 dc(j,i+nres)=c(j,i+nres)-c(j,i)
1473 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
1478 if (start_from_model) then
1481 read(inp,'(a)',end=332,err=332) pdbfile
1482 if (me.eq.king .or. .not. out1file)&
1483 write (iout,'(a,5x,a)') 'Opening PDB file',&
1484 pdbfile(:ilen(pdbfile))
1485 open(ipdbin,file=pdbfile,status='old',err=336)
1487 336 write (iout,'(a,5x,a)') 'Error opening PDB file',&
1488 pdbfile(:ilen(pdbfile))
1495 call readpdb_template(nmodel_start+1)
1497 if (nres.ge.nres_temp) then
1498 nmodel_start=nmodel_start+1
1499 pdbfiles_chomo(nmodel_start)=pdbfile
1502 chomo(j,i,nmodel_start)=c(j,i)
1506 if (me.eq.king .or. .not. out1file) &
1507 write (iout,'(a,2i7,1x,a)') &
1508 "Different number of residues",nres_temp,nres, &
1514 if (nmodel_start.eq.0) then
1515 if (me.eq.king .or. .not. out1file) &
1516 write (iout,'(a)') &
1517 "No valid starting model found START_FROM_MODELS is OFF"
1518 start_from_model=.false.
1520 write (iout,*) "nmodel_start",nmodel_start
1525 if (constr_dist.gt.0) call read_dist_constr
1526 write (iout,*) "After read_dist_constr nhpb",nhpb
1527 if ((AFMlog.gt.0).or.(selfguide.gt.0)) call read_afminp
1530 if (indpdb.eq.0 .and. modecalc.ne.2 .and. modecalc.ne.4 &
1531 .and. modecalc.ne.8 .and. modecalc.ne.9 .and. &
1532 modecalc.ne.10) then
1533 ! If input structure hasn't been supplied from the PDB file read or generate
1535 if (iranconf.eq.0 .and. .not. extconf) then
1536 if(me.eq.king.or..not.out1file .and.fg_rank.eq.0) &
1537 write (iout,'(a)') 'Initial geometry will be read in.'
1539 read(inp,'(8f10.5)',end=36,err=36) &
1540 ((c(l,k),l=1,3),k=1,nres),&
1541 ((c(l,k+nres),l=1,3),k=nnt,nct)
1542 write (iout,*) "Exit READ_CART"
1543 write (iout,'(8f10.5)') &
1544 ((c(l,k),l=1,3),k=1,nres)
1545 write (iout,'(8f10.5)') &
1546 ((c(l,k+nres),l=1,3),k=nnt,nct)
1547 call int_from_cart1(.true.)
1548 write (iout,*) "Finish INT_TO_CART"
1551 dc(j,i)=c(j,i+1)-c(j,i)
1552 dc_norm(j,i)=dc_norm(j,i)*vbld_inv(i+1)
1556 if (itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) then
1558 dc(j,i+nres)=c(j,i+nres)-c(j,i)
1559 dc_norm(j,i+nres)=dc_norm(j,i+nres)*vbld_inv(i+nres)
1565 write(iout,*) "read angles from input"
1566 call read_angles(inp,*36)
1571 36 write (iout,'(a)') 'Error reading angle file.'
1573 call mpi_finalize( MPI_COMM_WORLD,IERR )
1575 stop 'Error reading angle file.'
1577 else if (extconf) then
1578 if(me.eq.king.or..not.out1file .and. fg_rank.eq.0) &
1579 write (iout,'(a)') 'Extended chain initial geometry.'
1581 theta(i)=90d0*deg2rad
1584 phi(i)=180d0*deg2rad
1587 alph(i)=110d0*deg2rad
1590 omeg(i)=-120d0*deg2rad
1591 if (itype(i,1).le.0) omeg(i)=-omeg(i)
1595 if(me.eq.king.or..not.out1file) &
1596 write (iout,'(a)') 'Random-generated initial geometry.'
1600 if (me.eq.king .or. fg_rank.eq.0 .and. &
1601 ( modecalc.eq.12 .or. modecalc.eq.14) ) then
1605 call gen_rand_conf(itmp,*30)
1607 30 write (iout,*) 'Failed to generate random conformation',&
1609 write (*,*) 'Processor:',me,&
1610 ' Failed to generate random conformation',&
1620 write (iout,'(a,i3,a)') 'Processor:',me,&
1621 ' error in generating random conformation.'
1622 write (*,'(a,i3,a)') 'Processor:',me,&
1623 ' error in generating random conformation.'
1626 call MPI_Abort(mpi_comm_world,error_msg,ierrcode)
1632 call gen_rand_conf(itmp,*335)
1634 335 write (iout,*) 'Failed to generate random conformation',&
1636 write (*,*) 'Failed to generate random conformation',&
1639 write (iout,'(a,i3,a)') 'Processor:',me,&
1640 ' error in generating random conformation.'
1641 write (*,'(a,i3,a)') 'Processor:',me,&
1642 ' error in generating random conformation.'
1647 elseif (modecalc.eq.4) then
1648 read (inp,'(a)') intinname
1649 open (intin,file=intinname,status='old',err=333)
1650 if (me.eq.king .or. .not.out1file.and.fg_rank.eq.0) &
1651 write (iout,'(a)') 'intinname',intinname
1652 write (*,'(a)') 'Processor',myrank,' intinname',intinname
1654 333 write (iout,'(2a)') 'Error opening angle file ',intinname
1656 call MPI_Finalize(MPI_COMM_WORLD,IERR)
1658 stop 'Error opening angle file.'
1662 ! Generate distance constraints, if the PDB structure is to be regularized.
1663 if (nthread.gt.0) then
1664 call read_threadbase
1667 if (me.eq.king .or. .not. out1file) &
1669 if (ns.gt.0 .and. (me.eq.king .or. .not.out1file) ) then
1670 write (iout,'(/a,i3,a)') &
1671 'The chain contains',ns,' disulfide-bridging cysteines.'
1672 write (iout,'(20i4)') (iss(i),i=1,ns)
1674 write(iout,*)"Running with dynamic disulfide-bond formation"
1676 write (iout,'(/a/)') 'Pre-formed links are:'
1682 if (me.eq.king.or..not.out1file) &
1683 write (iout,'(2a,i3,3a,i3,a,3f10.3)') &
1684 restyp(it1,1),'(',i1,') -- ',restyp(it2,1),'(',i2,')',dhpb(i),&
1690 if (ns.gt.0.and.dyn_ss) then
1694 forcon(i-nss)=forcon(i)
1701 dyn_ss_mask(iss(i))=.true.
1704 if (i2ndstr.gt.0) call secstrp2dihc
1705 if (indpdb.gt.0) then
1706 write(iout,*) "WCHODZE TU!!"
1707 call int_from_cart1(.true.)
1709 ! call geom_to_var(nvar,x)
1710 ! call etotal(energia(0))
1711 ! call enerprint(energia(0))
1712 ! call briefout(0,etot)
1714 !d write (iout,'(2(a,i3))') 'NNT',NNT,' NCT',NCT
1715 !d write (iout,'(a)') 'Variable list:'
1716 !d write (iout,'(i4,f10.5)') (i,rad2deg*x(i),i=1,nvar)
1718 if (me.eq.king .or. (fg_rank.eq.0 .and. .not.out1file)) &
1719 write (iout,'(//80(1h*)/20x,a,i4,a/80(1h*)//)') &
1720 'Processor',myrank,': end reading molecular data.'
1723 end subroutine molread
1724 !-----------------------------------------------------------------------------
1725 subroutine read_constr_homology
1726 use control, only:init_int_table,homology_partition
1727 use MD_data, only:iset
1729 ! include 'DIMENSIONS'
1733 ! include 'COMMON.SETUP'
1734 ! include 'COMMON.CONTROL'
1735 ! include 'COMMON.HOMOLOGY'
1736 ! include 'COMMON.CHAIN'
1737 ! include 'COMMON.IOUNITS'
1738 ! include 'COMMON.MD'
1739 ! include 'COMMON.QRESTR'
1740 ! include 'COMMON.GEO'
1741 ! include 'COMMON.INTERACT'
1742 ! include 'COMMON.NAMES'
1743 ! include 'COMMON.VAR'
1746 ! double precision odl_temp,sigma_odl_temp,waga_theta,waga_d,
1748 ! common /przechowalnia/ odl_temp(maxres,maxres,max_template),
1749 ! & sigma_odl_temp(maxres,maxres,max_template)
1751 character*24 model_ki_dist, model_ki_angle
1752 character*500 controlcard
1753 integer :: ki,i,ii,j,k,l
1754 integer, dimension (:), allocatable :: ii_in_use
1755 integer :: i_tmp,idomain_tmp,&
1756 irec,ik,iistart,nres_temp
1759 logical :: liiflag,lfirst
1762 ! FP - Nov. 2014 Temporary specifications for new vars
1764 real(kind=8) :: rescore_tmp,x12,y12,z12,rescore2_tmp,&
1765 rescore3_tmp, dist_cut
1766 real(kind=8), dimension (:,:),allocatable :: rescore
1767 real(kind=8), dimension (:,:),allocatable :: rescore2
1768 real(kind=8), dimension (:,:),allocatable :: rescore3
1769 real(kind=8) :: distal
1770 character*24 tpl_k_rescore
1771 character*256 pdbfile
1773 ! -----------------------------------------------------------------
1774 ! Reading multiple PDB ref structures and calculation of retraints
1775 ! not using pre-computed ones stored in files model_ki_{dist,angle}
1777 ! -----------------------------------------------------------------
1780 ! Alternative: reading from input
1781 call card_concat(controlcard,.true.)
1782 call reada(controlcard,"HOMOL_DIST",waga_dist,1.0d0)
1783 call reada(controlcard,"HOMOL_ANGLE",waga_angle,1.0d0)
1784 call reada(controlcard,"HOMOL_THETA",waga_theta,1.0d0) ! new
1785 call reada(controlcard,"HOMOL_SCD",waga_d,1.0d0) ! new
1786 call reada(controlcard,'DIST_CUT',dist_cut,5.0d0) ! for diff ways of calc sigma
1787 call reada(controlcard,'DIST2_CUT',dist2_cut,9999.0d0)
1788 call readi(controlcard,"HOMOL_NSET",homol_nset,1)
1789 read2sigma=(index(controlcard,'READ2SIGMA').gt.0)
1790 start_from_model=(index(controlcard,'START_FROM_MODELS').gt.0)
1791 if(.not.read2sigma.and.start_from_model) then
1792 if(me.eq.king .or. .not. out1file .and. fg_rank.eq.0)&
1793 write(iout,*) 'START_FROM_MODELS works only with READ2SIGMA'
1794 start_from_model=.false.
1795 iranconf=(indpdb.le.0)
1797 if(start_from_model .and. (me.eq.king .or. .not. out1file))&
1798 write(iout,*) 'START_FROM_MODELS is ON'
1799 ! if(start_from_model .and. rest) then
1800 ! if(me.eq.king .or. .not. out1file .and. fg_rank.eq.0) then
1801 ! write(iout,*) 'START_FROM_MODELS is OFF'
1802 ! write(iout,*) 'remove restart keyword from input'
1805 if (start_from_model) nmodel_start=constr_homology
1806 if(.not.allocated(waga_homology)) allocate (waga_homology(homol_nset))
1807 if (homol_nset.gt.1)then
1808 call card_concat(controlcard,.true.)
1809 read(controlcard,*) (waga_homology(i),i=1,homol_nset)
1810 if(me.eq.king .or. .not. out1file .and. fg_rank.eq.0) then
1811 ! write(iout,*) "iset homology_weight "
1813 write(iout,*) i,waga_homology(i)
1816 iset=mod(kolor,homol_nset)+1
1819 waga_homology(1)=1.0
1822 !d write (iout,*) "nnt",nnt," nct",nct
1825 if (read_homol_frag) then
1826 call read_klapaucjusz
1832 ! write(iout,*) 'nnt=',nnt,'nct=',nct
1835 ! do k=1,constr_homology
1849 if(.not.allocated(pdbfiles_chomo)) allocate(pdbfiles_chomo(constr_homology))
1850 if(.not.allocated(chomo)) allocate(chomo(3,2*nres+2,constr_homology))
1852 do k=1,constr_homology
1854 read(inp,'(a)') pdbfile
1855 pdbfiles_chomo(k)=pdbfile
1856 if(me.eq.king .or. .not. out1file) &
1857 write (iout,'(a,5x,a)') 'HOMOL: Opening PDB file',&
1858 pdbfile(:ilen(pdbfile))
1859 open(ipdbin,file=pdbfile,status='old',err=33)
1861 33 write (iout,'(a,5x,a)') 'Error opening PDB file',&
1862 pdbfile(:ilen(pdbfile))
1865 ! print *,'Begin reading pdb data'
1867 ! Files containing res sim or local scores (former containing sigmas)
1870 write(kic2,'(bz,i2.2)') k
1872 tpl_k_rescore="template"//kic2//".sco"
1873 write(iout,*) "tpl_k_rescore=",tpl_k_rescore
1876 write(iout,*) "read2sigma",read2sigma
1878 if (read2sigma) then
1879 call readpdb_template(k)
1883 write(iout,*) "after readpdb"
1884 if(.not.allocated(nres_chomo)) allocate(nres_chomo(constr_homology))
1887 if(.not.allocated(rescore)) allocate(rescore(constr_homology,nres))
1888 if(.not.allocated(rescore2)) allocate(rescore2(constr_homology,nres))
1889 if(.not.allocated(rescore3)) allocate(rescore3(constr_homology,nres))
1890 if(.not.allocated(ii_in_use)) allocate(ii_in_use(nres*(nres-1)))
1891 if(.not.allocated(idomain)) allocate(idomain(constr_homology,nres))
1892 if(.not.allocated(l_homo)) allocate(l_homo(constr_homology,1000*nres))
1893 if(.not.allocated(ires_homo)) allocate(ires_homo(nres*200))
1894 if(.not.allocated(jres_homo)) allocate(jres_homo(nres*200))
1895 if(.not.allocated(odl)) allocate(odl(constr_homology,nres*200))
1896 if(.not.allocated(sigma_odl)) allocate(sigma_odl(constr_homology,nres*200))
1897 if(.not.allocated(dih)) allocate(dih(constr_homology,nres))
1898 if(.not.allocated(sigma_dih)) allocate(sigma_dih(constr_homology,nres))
1899 if(.not.allocated(thetatpl)) allocate(thetatpl(constr_homology,nres))
1900 if(.not.allocated(sigma_theta)) allocate(sigma_theta(constr_homology,nres))
1901 ! if(.not.allocated(thetatpl)) allocate(thetatpl(constr_homology,nres))
1902 if(.not.allocated(sigma_d)) allocate(sigma_d(constr_homology,nres))
1903 if(.not.allocated(xxtpl)) allocate(xxtpl(constr_homology,nres))
1904 if(.not.allocated(yytpl)) allocate(yytpl(constr_homology,nres))
1905 if(.not.allocated(zztpl)) allocate(zztpl(constr_homology,nres))
1906 ! if(.not.allocated(distance)) allocate(distance(constr_homology))
1907 ! if(.not.allocated(distancek)) allocate(distancek(constr_homology))
1911 ! Distance restraints
1914 ! Copy the coordinates from reference coordinates (?)
1915 do i=1,2*nres_chomo(k)
1918 ! write (iout,*) "c(",j,i,") =",c(j,i)
1922 ! From read_dist_constr (commented out 25/11/2014 <-> res sim)
1924 ! write(iout,*) "tpl_k_rescore - ",tpl_k_rescore
1925 open (ientin,file=tpl_k_rescore,status='old')
1926 if (nnt.gt.1) rescore(k,1)=0.0d0
1927 do irec=nnt,nct ! loop for reading res sim
1928 if (read2sigma) then
1929 read (ientin,*,end=1401) i_tmp,rescore2_tmp,rescore_tmp,&
1930 rescore3_tmp,idomain_tmp
1932 idomain(k,i_tmp)=idomain_tmp
1933 rescore(k,i_tmp)=rescore_tmp
1934 rescore2(k,i_tmp)=rescore2_tmp
1935 rescore3(k,i_tmp)=rescore3_tmp
1936 if (.not. out1file .or. me.eq.king)&
1937 write(iout,'(a7,i5,3f10.5,i5)') "rescore",&
1938 i_tmp,rescore2_tmp,rescore_tmp,&
1939 rescore3_tmp,idomain_tmp
1942 read (ientin,*,end=1401) rescore_tmp
1944 ! rescore(k,irec)=rescore_tmp+1.0d0 ! to avoid 0 values
1945 rescore(k,irec)=0.5d0*(rescore_tmp+0.5d0) ! alt transf to reduce scores
1946 ! write(iout,*) "rescore(",k,irec,") =",rescore(k,irec)
1951 if (waga_dist.ne.0.0d0) then
1959 distal=dsqrt(x12*x12+y12*y12+z12*z12)
1960 ! write (iout,*) k,i,j,distal,dist2_cut
1962 if (idomain(k,i).eq.idomain(k,j).and.idomain(k,i).ne.0 &
1963 .and. distal.le.dist2_cut ) then
1969 ! write (iout,*) "k",k
1970 ! write (iout,*) "i",i," j",j," constr_homology",
1975 if (read2sigma) then
1978 sigma_odl(k,ii)=sigma_odl(k,ii)+rescore2(k,ik)
1980 sigma_odl(k,ii)=sigma_odl(k,ii)/(j-i+1)
1981 if (odl(k,ii).gt.dist_cut) sigma_odl(k,ii) = &
1982 sigma_odl(k,ii)*dexp(0.5d0*(odl(k,ii)/dist_cut)**2-0.5d0)
1984 if (odl(k,ii).le.dist_cut) then
1985 sigma_odl(k,ii)=rescore(k,i)+rescore(k,j)
1988 sigma_odl(k,ii)=(rescore(k,i)+rescore(k,j))* &
1989 dexp(0.5d0*(odl(k,ii)/dist_cut)**2)
1991 sigma_odl(k,ii)=(rescore(k,i)+rescore(k,j))* &
1992 dexp(0.5d0*(odl(k,ii)/dist_cut)**2-0.5d0)
1996 sigma_odl(k,ii)=1.0d0/(sigma_odl(k,ii)*sigma_odl(k,ii))
1999 ! l_homo(k,ii)=.false.
2005 ! write (iout,*) "Distance restraints set"
2008 ! Theta, dihedral and SC retraints
2010 if (waga_angle.gt.0.0d0) then
2011 ! open (ientin,file=tpl_k_sigma_dih,status='old')
2012 ! do irec=1,maxres-3 ! loop for reading sigma_dih
2013 ! read (ientin,*,end=1402) i,j,ki,l,sigma_dih(k,i+nnt-1) ! j,ki,l what for?
2014 ! if (i+nnt-1.gt.lim_dih) lim_dih=i+nnt-1 ! right?
2015 ! sigma_dih(k,i+nnt-1)=sigma_dih(k,i+nnt-1)* ! not inverse because of use of res. similarity
2016 ! & sigma_dih(k,i+nnt-1)
2021 if (idomain(k,i).eq.0) then
2025 dih(k,i)=phiref(i) ! right?
2026 ! read (ientin,*) sigma_dih(k,i) ! original variant
2027 ! write (iout,*) "dih(",k,i,") =",dih(k,i)
2028 ! write(iout,*) "rescore(",k,i,") =",rescore(k,i),
2029 ! & "rescore(",k,i-1,") =",rescore(k,i-1),
2030 ! & "rescore(",k,i-2,") =",rescore(k,i-2),
2031 ! & "rescore(",k,i-3,") =",rescore(k,i-3)
2033 sigma_dih(k,i)=(rescore(k,i)+rescore(k,i-1)+ &
2034 rescore(k,i-2)+rescore(k,i-3))/4.0
2035 ! if (read2sigma) sigma_dih(k,i)=sigma_dih(k,i)/4.0
2036 ! write (iout,*) "Raw sigmas for dihedral angle restraints"
2037 ! write (iout,'(i5,10(2f8.2,4x))') i,sigma_dih(k,i)
2038 ! sigma_dih(k,i)=hmscore(k)*rescore(k,i)*rescore(k,i-1)*
2039 ! rescore(k,i-2)*rescore(k,i-3) ! right expression ?
2040 ! Instead of res sim other local measure of b/b str reliability possible
2041 if (sigma_dih(k,i).ne.0) &
2042 sigma_dih(k,i)=1.0d0/(sigma_dih(k,i)*sigma_dih(k,i))
2043 ! sigma_dih(k,i)=sigma_dih(k,i)*sigma_dih(k,i)
2047 ! write (iout,*) "Dihedral angle restraints set"
2050 if (waga_theta.gt.0.0d0) then
2051 ! open (ientin,file=tpl_k_sigma_theta,status='old')
2052 ! do irec=1,maxres-2 ! loop for reading sigma_theta, right bounds?
2053 ! read (ientin,*,end=1403) i,j,ki,sigma_theta(k,i+nnt-1) ! j,ki what for?
2054 ! sigma_theta(k,i+nnt-1)=sigma_theta(k,i+nnt-1)* ! not inverse because of use of res. similarity
2055 ! & sigma_theta(k,i+nnt-1)
2060 do i = nnt+2,nct ! right? without parallel.
2061 ! do i = i=1,nres ! alternative for bounds acc to readpdb?
2062 ! do i=ithet_start,ithet_end ! with FG parallel.
2063 if (idomain(k,i).eq.0) then
2064 sigma_theta(k,i)=0.0
2067 thetatpl(k,i)=thetaref(i)
2068 ! write (iout,*) "thetatpl(",k,i,") =",thetatpl(k,i)
2069 ! write(iout,*) "rescore(",k,i,") =",rescore(k,i),
2070 ! & "rescore(",k,i-1,") =",rescore(k,i-1),
2071 ! & "rescore(",k,i-2,") =",rescore(k,i-2)
2072 ! read (ientin,*) sigma_theta(k,i) ! 1st variant
2073 sigma_theta(k,i)=(rescore(k,i)+rescore(k,i-1)+ &
2075 ! if (read2sigma) sigma_theta(k,i)=sigma_theta(k,i)/3.0
2076 if (sigma_theta(k,i).ne.0) &
2077 sigma_theta(k,i)=1.0d0/(sigma_theta(k,i)*sigma_theta(k,i))
2079 ! sigma_theta(k,i)=hmscore(k)*rescore(k,i)*rescore(k,i-1)*
2080 ! rescore(k,i-2) ! right expression ?
2081 ! sigma_theta(k,i)=sigma_theta(k,i)*sigma_theta(k,i)
2084 ! write (iout,*) "Angle restraints set"
2087 if (waga_d.gt.0.0d0) then
2088 ! open (ientin,file=tpl_k_sigma_d,status='old')
2089 ! do irec=1,maxres-1 ! loop for reading sigma_theta, right bounds?
2090 ! read (ientin,*,end=1404) i,j,sigma_d(k,i+nnt-1) ! j,ki what for?
2091 ! sigma_d(k,i+nnt-1)=sigma_d(k,i+nnt-1)* ! not inverse because of use of res. similarity
2092 ! & sigma_d(k,i+nnt-1)
2096 do i = nnt,nct ! right? without parallel.
2097 ! do i=2,nres-1 ! alternative for bounds acc to readpdb?
2098 ! do i=loc_start,loc_end ! with FG parallel.
2099 if (itype(i,1).eq.10) cycle
2100 if (idomain(k,i).eq.0 ) then
2107 ! write (iout,*) "xxtpl(",k,i,") =",xxtpl(k,i)
2108 ! write (iout,*) "yytpl(",k,i,") =",yytpl(k,i)
2109 ! write (iout,*) "zztpl(",k,i,") =",zztpl(k,i)
2110 ! write(iout,*) "rescore(",k,i,") =",rescore(k,i)
2111 sigma_d(k,i)=rescore3(k,i) ! right expression ?
2112 if (sigma_d(k,i).ne.0) &
2113 sigma_d(k,i)=1.0d0/(sigma_d(k,i)*sigma_d(k,i))
2115 ! sigma_d(k,i)=hmscore(k)*rescore(k,i) ! right expression ?
2116 ! sigma_d(k,i)=sigma_d(k,i)*sigma_d(k,i)
2117 ! read (ientin,*) sigma_d(k,i) ! 1st variant
2121 ! write (iout,*) "SC restraints set"
2124 ! remove distance restraints not used in any model from the list
2125 ! shift data in all arrays
2127 ! write (iout,*) "waga_dist",waga_dist," nnt",nnt," nct",nct
2128 if (waga_dist.ne.0.0d0) then
2135 ! if (idomain(k,i).eq.idomain(k,j).and.idomain(k,i).ne.0
2136 ! & .and. distal.le.dist2_cut ) then
2137 ! write (iout,*) "i",i," j",j," ii",ii
2139 if (ii_in_use(ii).eq.0.and.liiflag.or. &
2140 ii_in_use(ii).eq.1.and.liiflag.and.ii.eq.lim_odl) then
2147 if(i10.eq.lim_odl) i10=i10+1
2149 ires_homo(iistart+ki)=ires_homo(ki+i01)
2150 jres_homo(iistart+ki)=jres_homo(ki+i01)
2151 ii_in_use(iistart+ki)=ii_in_use(ki+i01)
2152 do k=1,constr_homology
2153 odl(k,iistart+ki)=odl(k,ki+i01)
2154 sigma_odl(k,iistart+ki)=sigma_odl(k,ki+i01)
2155 l_homo(k,iistart+ki)=l_homo(k,ki+i01)
2158 iistart=iistart+i10-i01
2161 if (ii_in_use(ii).ne.0.and..not.liiflag) then
2169 ! write (iout,*) "Removing distances completed"
2171 endif ! .not. klapaucjusz
2173 if (constr_homology.gt.0) call homology_partition
2174 write (iout,*) "After homology_partition"
2176 if (constr_homology.gt.0) call init_int_table
2177 write (iout,*) "After init_int_table"
2179 ! endif ! .not. klapaucjusz
2181 ! if (constr_homology.gt.0) call homology_partition
2182 ! write (iout,*) "After homology_partition"
2184 ! if (constr_homology.gt.0) call init_int_table
2185 ! write (iout,*) "After init_int_table"
2187 ! write (iout,*) "ithet_start =",ithet_start,"ithet_end =",ithet_end
2188 ! write (iout,*) "loc_start =",loc_start,"loc_end =",loc_end
2192 if (.not.out_template_restr) return
2193 !d write(iout,*) "waga_theta",waga_theta,"waga_d",waga_d
2194 if(me.eq.king .or. .not. out1file .and. fg_rank.eq.0) then
2195 write (iout,*) "Distance restraints from templates"
2197 write(iout,'(3i7,100(2f8.2,1x,l1,4x))') &
2198 ii,ires_homo(ii),jres_homo(ii),&
2199 (odl(ki,ii),1.0d0/dsqrt(sigma_odl(ki,ii)),l_homo(ki,ii),&
2200 ki=1,constr_homology)
2202 write (iout,*) "Dihedral angle restraints from templates"
2204 write (iout,'(i7,a4,100(2f8.2,4x))') i,restyp(itype(i,1),1),&
2205 (rad2deg*dih(ki,i),&
2206 rad2deg/dsqrt(sigma_dih(ki,i)),ki=1,constr_homology)
2208 write (iout,*) "Virtual-bond angle restraints from templates"
2210 write (iout,'(i7,a4,100(2f8.2,4x))') i,restyp(itype(i,1),1),&
2211 (rad2deg*thetatpl(ki,i),&
2212 rad2deg/dsqrt(sigma_theta(ki,i)),ki=1,constr_homology)
2214 write (iout,*) "SC restraints from templates"
2216 write(iout,'(i7,100(4f8.2,4x))') i,&
2217 (xxtpl(ki,i),yytpl(ki,i),zztpl(ki,i), &
2218 1.0d0/dsqrt(sigma_d(ki,i)),ki=1,constr_homology)
2222 end subroutine read_constr_homology
2223 !-----------------------------------------------------------------------------
2224 subroutine read_klapaucjusz
2227 ! include 'DIMENSIONS'
2231 ! include 'COMMON.SETUP'
2232 ! include 'COMMON.CONTROL'
2233 ! include 'COMMON.HOMOLOGY'
2234 ! include 'COMMON.CHAIN'
2235 ! include 'COMMON.IOUNITS'
2236 ! include 'COMMON.MD'
2237 ! include 'COMMON.GEO'
2238 ! include 'COMMON.INTERACT'
2239 ! include 'COMMON.NAMES'
2240 character(len=256) fragfile
2241 integer, dimension(:), allocatable :: ninclust,nresclust,itype_temp,&
2243 integer, dimension(:,:), allocatable :: iresclust,inclust
2246 character(len=2) :: kic2
2247 character(len=24) :: model_ki_dist, model_ki_angle
2248 character(len=500) :: controlcard
2249 integer :: ki, i, j, jj,k, l, i_tmp,&
2251 ik,ll,lll,ii_old,ii,iii,ichain,kk,iistart,iishift,lim_xx,igr,&
2252 i01,i10,nnt_chain,nct_chain
2253 real(kind=8) :: distal
2254 logical :: lprn = .true.
2255 integer :: nres_temp
2258 logical :: liiflag,lfirst
2260 real(kind=8) rescore_tmp,x12,y12,z12,rescore2_tmp,dist_cut
2261 real(kind=8), dimension (:,:), allocatable :: rescore
2262 real(kind=8), dimension (:,:), allocatable :: rescore2
2263 character(len=24) :: tpl_k_rescore
2264 character(len=256) :: pdbfile
2267 ! For new homol impl
2269 ! include 'COMMON.VAR'
2271 ! write (iout,*) "READ_KLAPAUCJUSZ"
2272 ! print *,"READ_KLAPAUCJUSZ"
2274 call getenv("FRAGFILE",fragfile)
2275 write (iout,*) "Opening", fragfile
2277 open(ientin,file=fragfile,status="old",err=10)
2278 ! write (iout,*) " opened"
2287 itype_temp(:)=itype(:,1)
2291 ! write (iout,*) "Entering loop"
2294 DO IGR = 1,NCHAIN_GROUP
2296 ! write (iout,*) "igr",igr
2298 read(ientin,*) constr_homology,nclust
2299 if (start_from_model) then
2300 nmodel_start=constr_homology
2307 ichain=iequiv(1,igr)
2308 nnt_chain=chain_border(1,ichain)-chain_border1(1,ichain)+1
2309 nct_chain=chain_border(2,ichain)-chain_border1(1,ichain)+1
2310 ! write (iout,*) "nnt_chain",nnt_chain," nct_chain",nct_chain
2313 if(.not.allocated(pdbfiles_chomo)) allocate(pdbfiles_chomo(constr_homology))
2314 if(.not.allocated(nres_chomo)) allocate(nres_chomo(constr_homology))
2315 do k=1,constr_homology
2316 read(ientin,'(a)') pdbfile
2317 write (iout,'(a,5x,a)') 'KLAPAUCJUSZ: Opening PDB file', &
2318 pdbfile(:ilen(pdbfile))
2319 pdbfiles_chomo(k)=pdbfile
2320 open(ipdbin,file=pdbfile,status='old',err=33)
2322 33 write (iout,'(a,5x,a)') 'Error opening PDB file',&
2323 pdbfile(:ilen(pdbfile))
2328 call readpdb_template(k)
2338 read(ientin,*) ninclust(i),nresclust(i)
2339 read(ientin,*) (inclust(k,i),k=1,ninclust(i))
2340 read(ientin,*) (iresclust(k,i),k=1,nresclust(i))
2343 ! Loop over clusters
2346 do ll = 1,ninclust(l)
2349 ! write (iout,*) "l",l," ll",ll," k",k
2355 idomain(k,iresclust(i,l)+1) = 1
2357 idomain(k,iresclust(i,l)) = 1
2361 ! Distance restraints
2364 ! Copy the coordinates from reference coordinates (?)
2370 ! write (iout,*) "c(",j,i,") =",c(j,i)
2373 call int_from_cart(.true.,.false.)
2374 call sc_loc_geom(.false.)
2376 thetaref(i)=theta(i)
2380 if (waga_dist.ne.0.0d0) then
2383 do i = nnt_chain,nct_chain-2
2390 distal=dsqrt(x12*x12+y12*y12+z12*z12)
2391 ! write (iout,*) k,i,j,distal,dist2_cut
2393 if (idomain(k,i).eq.idomain(k,j).and.idomain(k,i).ne.0 &
2394 .and. distal.le.dist2_cut ) then
2400 ! write (iout,*) "k",k
2401 ! write (iout,*) "i",i," j",j," constr_homology",
2403 ires_homo(ii)=i+chain_border1(1,igr)-1
2404 jres_homo(ii)=j+chain_border1(1,igr)-1
2406 if (read2sigma) then
2409 sigma_odl(k,ii)=sigma_odl(k,ii)+rescore2(k,ik)
2411 sigma_odl(k,ii)=sigma_odl(k,ii)/(j-i+1)
2412 if (odl(k,ii).gt.dist_cut) sigma_odl(k,ii) = &
2413 sigma_odl(k,ii)*dexp(0.5d0*(odl(k,ii)/dist_cut)**2-0.5d0)
2415 if (odl(k,ii).le.dist_cut) then
2416 sigma_odl(k,ii)=rescore(k,i)+rescore(k,j)
2419 sigma_odl(k,ii)=(rescore(k,i)+rescore(k,j))* &
2420 dexp(0.5d0*(odl(k,ii)/dist_cut)**2)
2422 sigma_odl(k,ii)=(rescore(k,i)+rescore(k,j))* &
2423 dexp(0.5d0*(odl(k,ii)/dist_cut)**2-0.5d0)
2427 sigma_odl(k,ii)=1.0d0/(sigma_odl(k,ii)*sigma_odl(k,ii))
2430 ! l_homo(k,ii)=.false.
2437 ! Theta, dihedral and SC retraints
2439 if (waga_angle.gt.0.0d0) then
2440 do i = nnt_chain+3,nct_chain
2441 iii=i+chain_border1(1,igr)-1
2442 if (idomain(k,i).eq.0) then
2443 ! sigma_dih(k,i)=0.0
2446 dih(k,iii)=phiref(i)
2448 (rescore(k,i)+rescore(k,i-1)+ &
2449 rescore(k,i-2)+rescore(k,i-3))/4.0
2450 ! write (iout,*) "k",k," l",l," i",i," rescore",rescore(k,i),
2451 ! & " sigma_dihed",sigma_dih(k,i)
2452 if (sigma_dih(k,iii).ne.0) &
2453 sigma_dih(k,iii)=1.0d0/(sigma_dih(k,iii)*sigma_dih(k,iii))
2458 if (waga_theta.gt.0.0d0) then
2459 do i = nnt_chain+2,nct_chain
2460 iii=i+chain_border1(1,igr)-1
2461 if (idomain(k,i).eq.0) then
2462 ! sigma_theta(k,i)=0.0
2465 thetatpl(k,iii)=thetaref(i)
2466 sigma_theta(k,iii)=(rescore(k,i)+rescore(k,i-1)+ &
2468 if (sigma_theta(k,iii).ne.0) &
2469 sigma_theta(k,iii)=1.0d0/ &
2470 (sigma_theta(k,iii)*sigma_theta(k,iii))
2474 if (waga_d.gt.0.0d0) then
2475 do i = nnt_chain,nct_chain
2476 iii=i+chain_border1(1,igr)-1
2477 if (itype(i,1).eq.10) cycle
2478 if (idomain(k,i).eq.0 ) then
2482 xxtpl(k,iii)=xxref(i)
2483 yytpl(k,iii)=yyref(i)
2484 zztpl(k,iii)=zzref(i)
2485 sigma_d(k,iii)=rescore(k,i)
2486 if (sigma_d(k,iii).ne.0) &
2487 sigma_d(k,iii)=1.0d0/(sigma_d(k,iii)*sigma_d(k,iii))
2488 ! if (i-nnt+1.gt.lim_xx) lim_xx=i-nnt+1
2494 ! remove distance restraints not used in any model from the list
2495 ! shift data in all arrays
2497 ! write (iout,*) "ii_old",ii_old
2498 if (waga_dist.ne.0.0d0) then
2500 write (iout,*) "Distance restraints from templates"
2502 write(iout,'(4i5,100(2f8.2,1x,l1,4x))') &
2503 iii,ii_in_use(iii),ires_homo(iii),jres_homo(iii), &
2504 (odl(ki,iii),1.0d0/dsqrt(sigma_odl(ki,iii)),l_homo(ki,iii), &
2505 ki=1,constr_homology)
2511 do i=nnt_chain,nct_chain-2
2514 ! if (idomain(k,i).eq.idomain(k,j).and.idomain(k,i).ne.0
2515 ! & .and. distal.le.dist2_cut ) then
2516 ! write (iout,*) "i",i," j",j," ii",ii," i_in_use",ii_in_use(ii)
2518 if (ii_in_use(ii).eq.0.and.liiflag.or. &
2519 ii_in_use(ii).eq.1.and.liiflag.and.ii.eq.lim_odl) then
2526 if(i10.eq.lim_odl) i10=i10+1
2528 ires_homo(iistart+ki)=ires_homo(ki+i01)
2529 jres_homo(iistart+ki)=jres_homo(ki+i01)
2530 ii_in_use(iistart+ki)=ii_in_use(ki+i01)
2531 do k=1,constr_homology
2532 odl(k,iistart+ki)=odl(k,ki+i01)
2533 sigma_odl(k,iistart+ki)=sigma_odl(k,ki+i01)
2534 l_homo(k,iistart+ki)=l_homo(k,ki+i01)
2537 iistart=iistart+i10-i01
2540 if (ii_in_use(ii).ne.0.and..not.liiflag) then
2553 ichain=iequiv(i,igr)
2555 do j=nnt_chain,nct_chain
2556 jj=j+chain_border1(1,ichain)-chain_border1(1,iequiv(1,igr))
2557 do k=1,constr_homology
2559 sigma_dih(k,jj)=sigma_dih(k,j)
2560 thetatpl(k,jj)=thetatpl(k,j)
2561 sigma_theta(k,jj)=sigma_theta(k,j)
2562 xxtpl(k,jj)=xxtpl(k,j)
2563 yytpl(k,jj)=yytpl(k,j)
2564 zztpl(k,jj)=zztpl(k,j)
2565 sigma_d(k,jj)=sigma_d(k,j)
2569 jj=chain_border1(1,ichain)-chain_border1(1,iequiv(i-1,igr))
2570 ! write (iout,*) "igr",igr," i",i," ichain",ichain," jj",jj
2571 do j=ii_old+1,lim_odl
2572 ires_homo(j+lll)=ires_homo(j)+jj
2573 jres_homo(j+lll)=jres_homo(j)+jj
2574 do k=1,constr_homology
2575 odl(k,j+lll)=odl(k,j)
2576 sigma_odl(k,j+lll)=sigma_odl(k,j)
2577 l_homo(k,j+lll)=l_homo(k,j)
2588 if (waga_angle.gt.0.0d0) lim_dih=nct-nnt-2
2590 itype(:,1)=itype_temp(:)
2593 10 stop "Error in fragment file"
2594 end subroutine read_klapaucjusz
2595 !-----------------------------------------------------------------------------