2 C Read the PDB file and convert the peptide geometry into virtual-chain
6 include 'DIMENSIONS.ZSCOPT'
7 include 'COMMON.CONTROL'
10 include 'COMMON.CHAIN'
11 include 'COMMON.INTERACT'
12 include 'COMMON.IOUNITS'
14 include 'COMMON.NAMES'
15 include 'COMMON.SBRIDGE'
17 character*3 seq,atom,res
19 double precision sccor(3,50)
20 integer i,j,iii,ibeg,ishift,ishift1,ity,ires,ires_old
22 integer rescode,kkk,lll,icha,cou,kupa,iprzes
24 integer iterter(maxres)
25 double precision efree_temp
29 read (ipdbin,'(a80)',end=10) card
30 ! write (iout,'(a)') card
31 if (card(:5).eq.'HELIX') then
34 read(card(22:25),*) hfrag(1,nhfrag)
35 read(card(34:37),*) hfrag(2,nhfrag)
37 if (card(:5).eq.'SHEET') then
40 read(card(24:26),*) bfrag(1,nbfrag)
41 read(card(35:37),*) bfrag(2,nbfrag)
42 !rc----------------------------------------
43 !rc to be corrected !!!
44 bfrag(3,nbfrag)=bfrag(1,nbfrag)
45 bfrag(4,nbfrag)=bfrag(2,nbfrag)
46 !rc----------------------------------------
48 if (card(:3).eq.'END') then
50 else if (card(:3).eq.'TER') then
53 itype(ires_old-1)=ntyp1
58 ! write (iout,*) "Chain ended",ires,ishift,ires_old
61 dc(j,ires)=sccor(j,iii)
64 call sccenter(ires,iii,sccor)
69 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
70 ! Fish out the ATOM cards.
71 if (index(card(1:4),'ATOM').gt.0) then
72 read (card(12:16),*) atom
73 c write (2,'(a)') card
74 ! write (iout,*) "! ",atom," !",ires
75 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
76 read (card(23:26),*) ires
77 read (card(18:20),'(a3)') res
78 ! write (iout,*) "ires",ires,ires-ishift+ishift1,
79 ! & " ires_old",ires_old
80 ! write (iout,*) "ishift",ishift," ishift1",ishift1
81 ! write (iout,*) "IRES",ires-ishift+ishift1,ires_old
82 if (ires-ishift+ishift1.ne.ires_old) then
83 ! Calculate the CM of the preceding residue.
84 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
86 ! write (iout,*) "Calculating sidechain center iii",iii
89 dc(j,ires+nres)=sccor(j,iii)
92 call sccenter(ires_old,iii,sccor)
97 if (res.eq.'Cl-' .or. res.eq.'Na+') then
100 else if (ibeg.eq.1) then
101 c write (iout,*) "BEG ires",ires
103 if (res.ne.'GLY' .and. res.ne. 'ACE') then
107 ires=ires-ishift+ishift1
109 ! write (iout,*) "ishift",ishift," ires",ires,&
110 ! " ires_old",ires_old
112 else if (ibeg.eq.2) then
114 ishift=-ires_old+ires-1 !!!!!
115 ishift1=ishift1-1 !!!!!
116 ! write (iout,*) "New chain started",ires,ishift,ishift1,"!"
117 ires=ires-ishift+ishift1
121 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
122 ires=ires-ishift+ishift1
125 if (res.eq.'ACE' .or. res.eq.'NHE') then
128 itype(ires)=rescode(ires,res,0)
131 ires=ires-ishift+ishift1
133 ! write (iout,*) "ires_old",ires_old," ires",ires
134 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
137 ! write (2,*) "ires",ires," res ",res!," ity"!,ity
138 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
139 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
140 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
141 ! write (iout,*) "backbone ",atom
143 write (iout,'(2i3,2x,a,3f8.3)')
144 & ires,itype(ires),res,(c(j,ires),j=1,3)
148 sccor(j,iii)=c(j,ires)
150 c write (2,*) card(23:27),ires,itype(ires),iii
151 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
152 & atom.ne.'N' .and. atom.ne.'C' .and.
153 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
154 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
155 ! write (iout,*) "sidechain ",atom
157 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
158 c write (2,*) "iii",iii
162 10 write (iout,'(a,i5)') ' Nres: ',ires
163 C Calculate dummy residue coordinates inside the "chain" of a multichain
167 c write (iout,*) i,itype(i)
169 if (itype(i).eq.ntyp1) then
170 if (itype(i+1).eq.ntyp1) then
171 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
172 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
173 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
174 C if (unres_pdb) then
175 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
176 C call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
183 C c(j,i)=c(j,i-1)-1.9d0*e2(j)
187 dcj=(c(j,i-2)-c(j,i-3))/2.0
192 else !itype(i+1).eq.ntyp1
193 C if (unres_pdb) then
194 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
195 C call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
202 C c(j,i)=c(j,i+1)-1.9d0*e2(j)
206 dcj=(c(j,i+3)-c(j,i+2))/2.0
211 endif !itype(i+1).eq.ntyp1
212 endif !itype.eq.ntyp1
214 C Calculate the CM of the last side chain.
215 call sccenter(ires,iii,sccor)
218 if (itype(nres).ne.10) then
222 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
223 c(j,nres)=c(j,nres-1)+dcj
224 c(j,2*nres)=c(j,nres)
234 c(j,2*nres)=c(j,nres)
236 if (itype(1).eq.ntyp1) then
240 dcj=(c(j,4)-c(j,3))/2.0
245 C Calculate internal coordinates.
248 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
249 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
250 & (c(j,nres+ires),j=1,3)
252 call int_from_cart(.true.,.false.)
256 dc(j,i)=c(j,i+1)-c(j,i)
257 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
262 dc(j,i+nres)=c(j,i+nres)-c(j,i)
263 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
265 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
269 C Copy the coordinates to reference coordinates
273 cref(j,i+nres)=c(j,i+nres)
276 100 format ('Residue alpha-carbon coordinates ',
277 & ' centroid coordinates'/
278 1 ' ', 6X,'X',7X,'Y',7X,'Z',
279 & 12X,'X',7X,'Y',7X,'Z')
280 110 format (a,'(',i3,')',6f12.5)
285 c---------------------------------------------------------------------------
286 subroutine int_from_cart(lside,lprn)
289 include 'DIMENSIONS.ZSCOPT'
290 include 'COMMON.LOCAL'
292 include 'COMMON.CHAIN'
293 include 'COMMON.INTERACT'
294 include 'COMMON.IOUNITS'
296 include 'COMMON.NAMES'
297 character*3 seq,atom,res
299 double precision sccor(3,50)
301 double precision dist,alpha,beta,di
306 & 'Internal coordinates calculated from crystal structure.'
308 write (iout,'(8a)') ' Res ',' dvb',' Theta',
309 & ' Phi',' Dsc_id',' Dsc',' Alpha',
312 write (iout,'(4a)') ' Res ',' dvb',' Theta',
318 c write (iout,*) i,i-1,(c(j,i),j=1,3),(c(j,i-1),j=1,3),dist(i,i-1)
319 if (itype(i-1).ne.ntyp1 .and. itype(i).ne.ntyp1 .and.
320 & (dist(i,i-1).lt.1.0D0 .or. dist(i,i-1).gt.6.0D0)) then
321 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
325 vbld_inv(i)=1.0d0/vbld(i)
326 theta(i+1)=alpha(i-1,i,i+1)
327 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
329 c if (itype(1).eq.ntyp1) then
331 c c(j,1)=c(j,2)+(c(j,3)-c(j,4))
334 c if (itype(nres).eq.ntyp1) then
336 c c(j,nres)=c(j,nres-1)+(c(j,nres-2)-c(j,nres-3))
342 c(j,maxres2)=0.5D0*(c(j,i-1)+c(j,i+1))
347 if (itype(i).ne.10) then
348 vbld_inv(i+nres)=1.0d0/di
350 vbld_inv(i+nres)=0.0d0
353 alph(i)=alpha(nres+i,i,maxres2)
354 omeg(i)=beta(nres+i,i,maxres2,i+1)
357 alph(i)=alpha(nres+i,i,maxres2)
358 omeg(i)=beta(nres+i,i,maxres2,i+1)
361 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
362 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),di,
363 & rad2deg*alph(i),rad2deg*omeg(i)
368 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
369 & rad2deg*theta(i),rad2deg*phi(i)
374 c---------------------------------------------------------------------------
375 subroutine sccenter(ires,nscat,sccor)
378 include 'COMMON.CHAIN'
379 integer ires,nscat,i,j
380 double precision sccor(3,50),sccmj
384 sccmj=sccmj+sccor(j,i)
386 dc(j,ires)=sccmj/nscat
390 c---------------------------------------------------------------------------
391 subroutine sc_loc_geom(lprn)
392 implicit real*8 (a-h,o-z)
394 include 'DIMENSIONS.ZSCOPT'
395 include 'COMMON.LOCAL'
397 include 'COMMON.CHAIN'
398 include 'COMMON.INTERACT'
399 include 'COMMON.IOUNITS'
401 include 'COMMON.NAMES'
402 include 'COMMON.CONTROL'
403 include 'COMMON.SETUP'
404 double precision x_prime(3),y_prime(3),z_prime(3)
408 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
412 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
414 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
418 dc_norm(j,i+nres)=0.0d0
423 costtab(i+1) =dcos(theta(i+1))
424 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
425 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
426 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
427 cosfac2=0.5d0/(1.0d0+costtab(i+1))
428 cosfac=dsqrt(cosfac2)
429 sinfac2=0.5d0/(1.0d0-costtab(i+1))
430 sinfac=dsqrt(sinfac2)
432 if (it.ne.10 .and. itype(i).ne.ntyp1) then
434 C Compute the axes of tghe local cartesian coordinates system; store in
435 c x_prime, y_prime and z_prime
443 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
444 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
446 c write (iout,*) "x_prime",(x_prime(j),j=1,3)
447 c write (iout,*) "y_prime",(y_prime(j),j=1,3)
448 call vecpr(x_prime,y_prime,z_prime)
449 c write (iout,*) "z_prime",(z_prime(j),j=1,3)
451 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
452 C to local coordinate system. Store in xx, yy, zz.
458 xx = xx + x_prime(j)*dc_norm(j,i+nres)
459 yy = yy + y_prime(j)*dc_norm(j,i+nres)
460 zz = zz + z_prime(j)*dc_norm(j,i+nres)
473 write (iout,*) "xxref,yyref,zzref"
476 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),yyref(i),
482 c---------------------------------------------------------------------------
483 subroutine bond_regular
487 include 'COMMON.LOCAL'
488 include 'COMMON.INTERACT'
489 include 'COMMON.CHAIN'
494 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
495 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
496 c print *,vbld(i+1),vbld(i+1+nres)
498 c Adam 2/26/20 Alter virtual bonds for non-blocking end groups of each chain
504 vbld_inv(i1)=vbld_inv(i1)*2
507 vbld(i2+1)=vbld(i2+1)/2
508 vbld_inv(i2+1)=vbld_inv(i2+1)*2
513 c---------------------------------------------------------------------------
514 subroutine readpdb_template(k)
515 C Read the PDB file for read_constr_homology with read2sigma
516 C and convert the peptide geometry into virtual-chain geometry.
517 implicit real*8 (a-h,o-z)
519 include 'DIMENSIONS.ZSCOPT'
520 include 'COMMON.LOCAL'
522 include 'COMMON.CHAIN'
523 include 'COMMON.INTERACT'
524 include 'COMMON.IOUNITS'
526 include 'COMMON.NAMES'
527 include 'COMMON.CONTROL'
528 include 'COMMON.SETUP'
529 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
530 logical lprn /.false./,fail
531 double precision e1(3),e2(3),e3(3)
532 double precision dcj,efree_temp
536 double precision sccor(3,20)
537 integer rescode,iterter(maxres)
544 c write (2,*) "UNRES_PDB",unres_pdb
552 read (ipdbin,'(a80)',end=10) card
553 if (card(:3).eq.'END') then
555 else if (card(:3).eq.'TER') then
558 itype(ires_old-1)=ntyp1
559 iterter(ires_old-1)=1
560 itype(ires_old)=ntyp1
563 c write (iout,*) "Chain ended",ires,ishift,ires_old
566 dc(j,ires)=sccor(j,iii)
569 call sccenter(ires,iii,sccor)
572 C Fish out the ATOM cards.
573 if (index(card(1:4),'ATOM').gt.0) then
574 read (card(12:16),*) atom
575 c write (iout,*) "! ",atom," !",ires
576 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
577 read (card(23:26),*) ires
578 read (card(18:20),'(a3)') res
579 c write (iout,*) "ires",ires,ires-ishift+ishift1,
580 c & " ires_old",ires_old
581 c write (iout,*) "ishift",ishift," ishift1",ishift1
582 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
583 if (ires-ishift+ishift1.ne.ires_old) then
584 C Calculate the CM of the preceding residue.
588 dc(j,ires)=sccor(j,iii)
591 call sccenter(ires_old,iii,sccor)
596 if (res.eq.'Cl-' .or. res.eq.'Na+') then
599 else if (ibeg.eq.1) then
600 c write (iout,*) "BEG ires",ires
602 if (res.ne.'GLY' .and. res.ne. 'ACE') then
606 ires=ires-ishift+ishift1
608 c write (iout,*) "ishift",ishift," ires",ires,
609 c & " ires_old",ires_old
610 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
612 else if (ibeg.eq.2) then
614 ishift=-ires_old+ires-1
616 c write (iout,*) "New chain started",ires,ishift
619 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
620 ires=ires-ishift+ishift1
623 if (res.eq.'ACE' .or. res.eq.'NHE') then
626 itype(ires)=rescode(ires,res,0)
629 ires=ires-ishift+ishift1
631 c write (iout,*) "ires_old",ires_old," ires",ires
632 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
635 c write (2,*) "ires",ires," res ",res," ity",ity
636 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
637 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
638 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
639 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
641 write (iout,'(2i3,2x,a,3f8.3)')
642 & ires,itype(ires),res,(c(j,ires),j=1,3)
646 sccor(j,iii)=c(j,ires)
648 if (ishift.ne.0) then
649 ires_ca=ires+ishift-ishift1
653 c write (*,*) card(23:27),ires,itype(ires)
654 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
655 & atom.ne.'N' .and. atom.ne.'C' .and.
656 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
657 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
658 c write (iout,*) "sidechain ",atom
660 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
664 10 write (iout,'(a,i5)') ' Nres: ',ires
665 C Calculate dummy residue coordinates inside the "chain" of a multichain
669 c write (iout,*) i,itype(i),itype(i+1)
670 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
671 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
672 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
673 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
674 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
676 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
677 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
684 c(j,i)=c(j,i-1)-1.9d0*e2(j)
688 dcj=(c(j,i-2)-c(j,i-3))/2.0
689 if (dcj.eq.0) dcj=1.23591524223
694 else !itype(i+1).eq.ntyp1
696 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
697 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
704 c(j,i)=c(j,i+1)-1.9d0*e2(j)
708 dcj=(c(j,i+3)-c(j,i+2))/2.0
709 if (dcj.eq.0) dcj=1.23591524223
714 endif !itype(i+1).eq.ntyp1
715 endif !itype.eq.ntyp1
717 C Calculate the CM of the last side chain.
720 dc(j,ires)=sccor(j,iii)
723 call sccenter(ires,iii,sccor)
727 if (itype(nres).ne.10) then
731 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
732 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
739 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
743 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
744 if (dcj.eq.0) dcj=1.23591524223
745 c(j,nres)=c(j,nres-1)+dcj
746 c(j,2*nres)=c(j,nres)
757 c(j,2*nres)=c(j,nres)
759 if (itype(1).eq.ntyp1) then
763 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
764 call refsys(2,3,4,e1,e2,e3,fail)
771 c(j,1)=c(j,2)-1.9d0*e2(j)
775 dcj=(c(j,4)-c(j,3))/2.0
781 C Copy the coordinates to reference coordinates
787 C Calculate internal coordinates.
788 if (out_template_coord) then
790 & "Cartesian coordinates of the reference structure"
791 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
792 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
794 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
795 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
796 & (c(j,ires+nres),j=1,3)
799 C Calculate internal coordinates.
800 c call int_from_cart1(.false.)
801 call int_from_cart(.true.,.true.)
802 call sc_loc_geom(.true.)
809 dc(j,i)=c(j,i+1)-c(j,i)
810 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
815 dc(j,i+nres)=c(j,i+nres)-c(j,i)
816 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
818 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
824 cref(j,i+nres)=c(j,i+nres)