2 C Read the PDB file and convert the peptide geometry into virtual-chain
4 implicit real*8 (a-h,o-z)
10 include 'COMMON.INTERACT'
11 include 'COMMON.IOUNITS'
13 include 'COMMON.NAMES'
14 include 'COMMON.CONTROL'
15 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
16 logical lprn /.false./,fail,sccalc
17 double precision e1(3),e2(3),e3(3)
18 double precision dcj,efree_temp
22 double precision sccor(3,50)
24 integer iterter(maxres)
29 c write (2,*) "UNRES_PDB",unres_pdb
38 read (ipdbin,'(a80)',end=10) card
39 ! write (iout,'(a)') card
40 if (card(:5).eq.'HELIX') then
43 read(card(22:25),*) hfrag(1,nhfrag)
44 read(card(34:37),*) hfrag(2,nhfrag)
46 if (card(:5).eq.'SHEET') then
49 read(card(24:26),*) bfrag(1,nbfrag)
50 read(card(35:37),*) bfrag(2,nbfrag)
51 !rc----------------------------------------
52 !rc to be corrected !!!
53 bfrag(3,nbfrag)=bfrag(1,nbfrag)
54 bfrag(4,nbfrag)=bfrag(2,nbfrag)
55 !rc----------------------------------------
57 if (card(:3).eq.'END') then
59 else if (card(:3).eq.'TER') then
62 itype(ires_old-1)=ntyp1
68 ! write (iout,*) "Chain ended",ires,ishift,ires_old
71 dc(j,ires)=sccor(j,iii)
74 call sccenter(ires,iii,sccor)
80 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
81 ! Fish out the ATOM cards.
82 if (index(card(1:4),'ATOM').gt.0) then
84 read (card(12:16),*) atom
85 c write (2,'(a)') card
86 ! write (iout,*) "! ",atom," !",ires
87 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
88 read (card(23:26),*) ires
89 read (card(18:20),'(a3)') res
90 ! write (iout,*) "ires",ires,ires-ishift+ishift1,
91 ! & " ires_old",ires_old
92 ! write (iout,*) "ishift",ishift," ishift1",ishift1
93 ! write (iout,*) "IRES",ires-ishift+ishift1,ires_old
94 if (ires-ishift+ishift1.ne.ires_old) then
95 ! Calculate the CM of the preceding residue.
96 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
98 ! write (iout,*) "Calculating sidechain center iii",iii
101 dc(j,ires+nres)=sccor(j,iii)
104 call sccenter(ires_old,iii,sccor)
110 if (res.eq.'Cl-' .or. res.eq.'Na+') then
113 else if (ibeg.eq.1) then
114 c write (iout,*) "BEG ires",ires
116 if (res.ne.'GLY' .and. res.ne. 'ACE') then
120 ires=ires-ishift+ishift1
122 ! write (iout,*) "ishift",ishift," ires",ires,&
123 ! " ires_old",ires_old
125 else if (ibeg.eq.2) then
127 ishift=-ires_old+ires-1 !!!!!
128 ishift1=ishift1-1 !!!!!
129 ! write (iout,*) "New chain started",ires,ishift,ishift1,"!"
130 ires=ires-ishift+ishift1
134 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
135 ires=ires-ishift+ishift1
138 if (res.eq.'ACE' .or. res.eq.'NHE') then
141 itype(ires)=rescode(ires,res,0)
144 ires=ires-ishift+ishift1
146 ! write (iout,*) "ires_old",ires_old," ires",ires
147 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
150 ! write (2,*) "ires",ires," res ",res!," ity"!,ity
151 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
152 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
153 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
154 ! write (iout,*) "backbone ",atom
156 write (iout,'(2i3,2x,a,3f8.3)')
157 & ires,itype(ires),res,(c(j,ires),j=1,3)
161 sccor(j,iii)=c(j,ires)
163 c write (2,*) card(23:27),ires,itype(ires),iii
164 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
165 & atom.ne.'N' .and. atom.ne.'C' .and.
166 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
167 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
168 ! write (iout,*) "sidechain ",atom
170 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
171 c write (2,*) "iii",iii
175 10 write (iout,'(a,i5)') ' Nres: ',ires
176 C Calculate dummy residue coordinates inside the "chain" of a multichain
180 c write (iout,*) i,itype(i)
182 if (itype(i).eq.ntyp1) then
183 if (itype(i+1).eq.ntyp1) then
184 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
185 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
186 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
187 C if (unres_pdb) then
188 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
189 C call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
196 C c(j,i)=c(j,i-1)-1.9d0*e2(j)
200 dcj=(c(j,i-2)-c(j,i-3))/2.0
205 else !itype(i+1).eq.ntyp1
206 C if (unres_pdb) then
207 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
208 C call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
215 C c(j,i)=c(j,i+1)-1.9d0*e2(j)
219 dcj=(c(j,i+3)-c(j,i+2))/2.0
224 endif !itype(i+1).eq.ntyp1
225 endif !itype.eq.ntyp1
227 C Calculate the CM of the last side chain.
228 if (.not.sccalc) call sccenter(ires,iii,sccor)
231 if (itype(nres).ne.10) then
235 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
236 c(j,nres)=c(j,nres-1)+dcj
237 c(j,2*nres)=c(j,nres)
247 c(j,2*nres)=c(j,nres)
249 if (itype(1).eq.ntyp1) then
253 dcj=(c(j,4)-c(j,3))/2.0
258 C Calculate internal coordinates.
261 & "Cartesian coordinates of the reference structure"
262 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
263 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
265 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
266 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
267 & (c(j,ires+nres),j=1,3)
270 C Calculate internal coordinates.
272 & "Backbone and SC coordinates as read from the PDB"
274 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
275 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
276 & (c(j,nres+ires),j=1,3)
278 call int_from_cart(.true.,.false.)
279 call sc_loc_geom(.false.)
286 dc(j,i)=c(j,i+1)-c(j,i)
287 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
292 dc(j,i+nres)=c(j,i+nres)-c(j,i)
293 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
295 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
299 C Copy the coordinates to reference coordinates
309 bfrag(i,j)=bfrag(i,j)-ishift
315 hfrag(i,j)=hfrag(i,j)-ishift
321 c---------------------------------------------------------------------------
322 subroutine int_from_cart(lside,lprn)
323 implicit real*8 (a-h,o-z)
325 include 'COMMON.LOCAL'
327 include 'COMMON.CHAIN'
328 include 'COMMON.INTERACT'
329 include 'COMMON.IOUNITS'
331 include 'COMMON.NAMES'
335 dimension sccor(3,50)
340 & 'Internal coordinates calculated from crystal structure.'
342 write (iout,'(8a)') ' Res ',' dvb',' Theta',
343 & ' Gamma',' Dsc_id',' Dsc',' Alpha',
346 write (iout,'(4a)') ' Res ',' dvb',' Theta',
352 if (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0) then
353 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
356 vbld(i+1)=dist(i,i+1)
357 vbld_inv(i+1)=1.0d0/vbld(i+1)
358 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
359 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
361 c if (unres_pdb) then
362 c if (itype(1).eq.ntyp1) then
363 c theta(3)=90.0d0*deg2rad
364 c phi(4)=180.0d0*deg2rad
366 c vbld_inv(2)=1.0d0/vbld(2)
368 c if (itype(nres).eq.ntyp1) then
369 c theta(nres)=90.0d0*deg2rad
370 c phi(nres)=180.0d0*deg2rad
372 c vbld_inv(nres)=1.0d0/vbld(2)
378 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
379 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
383 C 10/03/12 Adam: Correction for zero SC-SC bond length
384 if (itype(i).ne.10 .and. itype(i).ne.ntyp1. and. di.eq.0.0d0)
387 if (itype(i).ne.10) then
388 vbld_inv(i+nres)=1.0d0/di
390 vbld_inv(i+nres)=0.0d0
393 alph(i)=alpha(nres+i,i,maxres2)
394 omeg(i)=beta(nres+i,i,maxres2,i+1)
397 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
398 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
399 & rad2deg*alph(i),rad2deg*omeg(i)
404 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
405 & rad2deg*theta(i),rad2deg*phi(i)
410 c-------------------------------------------------------------------------------
411 subroutine sc_loc_geom(lprn)
412 implicit real*8 (a-h,o-z)
414 include 'COMMON.LOCAL'
416 include 'COMMON.CHAIN'
417 include 'COMMON.INTERACT'
418 include 'COMMON.IOUNITS'
420 include 'COMMON.NAMES'
421 include 'COMMON.CONTROL'
422 double precision x_prime(3),y_prime(3),z_prime(3)
426 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
430 if (itype(i).ne.10) then
432 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
436 dc_norm(j,i+nres)=0.0d0
441 costtab(i+1) =dcos(theta(i+1))
442 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
443 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
444 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
445 cosfac2=0.5d0/(1.0d0+costtab(i+1))
446 cosfac=dsqrt(cosfac2)
447 sinfac2=0.5d0/(1.0d0-costtab(i+1))
448 sinfac=dsqrt(sinfac2)
452 C Compute the axes of tghe local cartesian coordinates system; store in
453 c x_prime, y_prime and z_prime
461 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
462 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
464 call vecpr(x_prime,y_prime,z_prime)
466 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
467 C to local coordinate system. Store in xx, yy, zz.
473 xx = xx + x_prime(j)*dc_norm(j,i+nres)
474 yy = yy + y_prime(j)*dc_norm(j,i+nres)
475 zz = zz + z_prime(j)*dc_norm(j,i+nres)
490 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),
496 c---------------------------------------------------------------------------
497 subroutine sccenter(ires,nscat,sccor)
498 implicit real*8 (a-h,o-z)
500 include 'COMMON.CHAIN'
501 dimension sccor(3,50)
505 sccmj=sccmj+sccor(j,i)
507 dc(j,ires)=sccmj/nscat
511 c---------------------------------------------------------------------------
512 subroutine bond_regular
516 include 'COMMON.LOCAL'
517 include 'COMMON.INTERACT'
518 include 'COMMON.CHAIN'
523 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
524 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
525 c print *,vbld(i+1),vbld(i+1+nres)
527 c Adam 2/26/20 Alter virtual bonds for non-blocking end groups of each chain
533 vbld_inv(i1)=vbld_inv(i1)*2
536 vbld(i2+1)=vbld(i2+1)/2
537 vbld_inv(i2+1)=vbld_inv(i2+1)*2
542 c---------------------------------------------------------------------------
543 subroutine readpdb_template(k)
544 C Read the PDB file with gaps for read_constr_homology with read2sigma
545 C and convert the peptide geometry into virtual-chain geometry.
546 implicit real*8 (a-h,o-z)
548 include 'COMMON.LOCAL'
550 include 'COMMON.CHAIN'
551 include 'COMMON.INTERACT'
552 include 'COMMON.IOUNITS'
554 include 'COMMON.NAMES'
555 include 'COMMON.CONTROL'
556 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
557 logical lprn /.false./,fail
558 double precision e1(3),e2(3),e3(3)
559 double precision dcj,efree_temp
563 double precision sccor(3,50)
564 integer rescode,iterter(maxres)
571 c write (2,*) "UNRES_PDB",unres_pdb
579 read (ipdbin,'(a80)',end=10) card
580 if (card(:3).eq.'END') then
582 else if (card(:3).eq.'TER') then
585 itype(ires_old-1)=ntyp1
586 iterter(ires_old-1)=1
587 itype(ires_old)=ntyp1
590 c write (iout,*) "Chain ended",ires,ishift,ires_old
593 dc(j,ires)=sccor(j,iii)
596 call sccenter(ires,iii,sccor)
599 C Fish out the ATOM cards.
600 if (index(card(1:4),'ATOM').gt.0) then
601 read (card(12:16),*) atom
602 c write (iout,*) "! ",atom," !",ires
603 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
604 read (card(23:26),*) ires
605 read (card(18:20),'(a3)') res
606 c write (iout,*) "ires",ires,ires-ishift+ishift1,
607 c & " ires_old",ires_old
608 c write (iout,*) "ishift",ishift," ishift1",ishift1
609 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
610 if (ires-ishift+ishift1.ne.ires_old) then
611 C Calculate the CM of the preceding residue.
615 dc(j,ires)=sccor(j,iii)
618 call sccenter(ires_old,iii,sccor)
623 if (res.eq.'Cl-' .or. res.eq.'Na+') then
626 else if (ibeg.eq.1) then
627 c write (iout,*) "BEG ires",ires
629 if (res.ne.'GLY' .and. res.ne. 'ACE') then
633 ires=ires-ishift+ishift1
635 c write (iout,*) "ishift",ishift," ires",ires,
636 c & " ires_old",ires_old
637 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
639 else if (ibeg.eq.2) then
641 ishift=-ires_old+ires-1
643 c write (iout,*) "New chain started",ires,ishift
646 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
647 ires=ires-ishift+ishift1
650 if (res.eq.'ACE' .or. res.eq.'NHE') then
653 itype(ires)=rescode(ires,res,0)
656 ires=ires-ishift+ishift1
658 c write (iout,*) "ires_old",ires_old," ires",ires
659 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
662 c write (2,*) "ires",ires," res ",res," ity",ity
663 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
664 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
665 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
666 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
668 write (iout,'(2i3,2x,a,3f8.3)')
669 & ires,itype(ires),res,(c(j,ires),j=1,3)
673 sccor(j,iii)=c(j,ires)
675 if (ishift.ne.0) then
676 ires_ca=ires+ishift-ishift1
680 c write (*,*) card(23:27),ires,itype(ires)
681 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
682 & atom.ne.'N' .and. atom.ne.'C' .and.
683 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
684 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
685 c write (iout,*) "sidechain ",atom
687 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
691 10 write (iout,'(a,i5)') ' Nres: ',ires
692 C Calculate dummy residue coordinates inside the "chain" of a multichain
696 c write (iout,*) i,itype(i),itype(i+1)
697 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
698 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
699 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
700 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
701 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
703 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
704 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
711 c(j,i)=c(j,i-1)-1.9d0*e2(j)
715 dcj=(c(j,i-2)-c(j,i-3))/2.0
716 if (dcj.eq.0) dcj=1.23591524223
721 else !itype(i+1).eq.ntyp1
723 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
724 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
731 c(j,i)=c(j,i+1)-1.9d0*e2(j)
735 dcj=(c(j,i+3)-c(j,i+2))/2.0
736 if (dcj.eq.0) dcj=1.23591524223
741 endif !itype(i+1).eq.ntyp1
742 endif !itype.eq.ntyp1
744 C Calculate the CM of the last side chain.
747 dc(j,ires)=sccor(j,iii)
750 call sccenter(ires,iii,sccor)
754 if (itype(nres).ne.10) then
758 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
759 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
766 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
770 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
771 if (dcj.eq.0) dcj=1.23591524223
772 c(j,nres)=c(j,nres-1)+dcj
773 c(j,2*nres)=c(j,nres)
784 c(j,2*nres)=c(j,nres)
786 if (itype(1).eq.ntyp1) then
790 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
791 call refsys(2,3,4,e1,e2,e3,fail)
798 c(j,1)=c(j,2)-1.9d0*e2(j)
802 dcj=(c(j,4)-c(j,3))/2.0
808 C Calculate internal coordinates.
811 & "Cartesian coordinates of the reference structure"
812 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
813 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
815 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
816 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
817 & (c(j,ires+nres),j=1,3)
820 C Calculate internal coordinates.
822 & "Backbone and SC coordinates as read from the PDB"
824 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
825 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
826 & (c(j,nres+ires),j=1,3)
828 call int_from_cart(.true.,.false.)
829 call sc_loc_geom(.false.)
836 dc(j,i)=c(j,i+1)-c(j,i)
837 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
842 dc(j,i+nres)=c(j,i+nres)-c(j,i)
843 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
845 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
851 cref(j,i+nres)=c(j,i+nres)