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
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
37 read (ipdbin,'(a80)',end=10) card
38 ! write (iout,'(a)') card
39 if (card(:5).eq.'HELIX') then
42 read(card(22:25),*) hfrag(1,nhfrag)
43 read(card(34:37),*) hfrag(2,nhfrag)
45 if (card(:5).eq.'SHEET') then
48 read(card(24:26),*) bfrag(1,nbfrag)
49 read(card(35:37),*) bfrag(2,nbfrag)
50 !rc----------------------------------------
51 !rc to be corrected !!!
52 bfrag(3,nbfrag)=bfrag(1,nbfrag)
53 bfrag(4,nbfrag)=bfrag(2,nbfrag)
54 !rc----------------------------------------
56 if (card(:3).eq.'END') then
58 else if (card(:3).eq.'TER') then
61 itype(ires_old-1)=ntyp1
67 ! write (iout,*) "Chain ended",ires,ishift,ires_old
70 dc(j,ires)=sccor(j,iii)
73 call sccenter(ires,iii,sccor)
78 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
79 ! Fish out the ATOM cards.
80 if (index(card(1:4),'ATOM').gt.0) then
81 read (card(12:16),*) atom
82 c write (2,'(a)') card
83 ! write (iout,*) "! ",atom," !",ires
84 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
85 read (card(23:26),*) ires
86 read (card(18:20),'(a3)') res
87 ! write (iout,*) "ires",ires,ires-ishift+ishift1,
88 ! & " ires_old",ires_old
89 ! write (iout,*) "ishift",ishift," ishift1",ishift1
90 ! write (iout,*) "IRES",ires-ishift+ishift1,ires_old
91 if (ires-ishift+ishift1.ne.ires_old) then
92 ! Calculate the CM of the preceding residue.
93 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
95 ! write (iout,*) "Calculating sidechain center iii",iii
98 dc(j,ires+nres)=sccor(j,iii)
101 call sccenter(ires_old,iii,sccor)
106 if (res.eq.'Cl-' .or. res.eq.'Na+') then
109 else if (ibeg.eq.1) then
110 c write (iout,*) "BEG ires",ires
112 if (res.ne.'GLY' .and. res.ne. 'ACE') then
116 ires=ires-ishift+ishift1
118 ! write (iout,*) "ishift",ishift," ires",ires,&
119 ! " ires_old",ires_old
121 else if (ibeg.eq.2) then
123 ishift=-ires_old+ires-1 !!!!!
124 ishift1=ishift1-1 !!!!!
125 ! write (iout,*) "New chain started",ires,ishift,ishift1,"!"
126 ires=ires-ishift+ishift1
130 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
131 ires=ires-ishift+ishift1
134 if (res.eq.'ACE' .or. res.eq.'NHE') then
137 itype(ires)=rescode(ires,res,0)
140 ires=ires-ishift+ishift1
142 ! write (iout,*) "ires_old",ires_old," ires",ires
143 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
146 ! write (2,*) "ires",ires," res ",res!," ity"!,ity
147 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
148 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
149 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
150 ! write (iout,*) "backbone ",atom
152 write (iout,'(2i3,2x,a,3f8.3)')
153 & ires,itype(ires),res,(c(j,ires),j=1,3)
157 sccor(j,iii)=c(j,ires)
159 c write (2,*) card(23:27),ires,itype(ires),iii
160 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
161 & atom.ne.'N' .and. atom.ne.'C' .and.
162 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
163 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
164 ! write (iout,*) "sidechain ",atom
166 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
167 c write (2,*) "iii",iii
171 10 write (iout,'(a,i5)') ' Nres: ',ires
172 C Calculate dummy residue coordinates inside the "chain" of a multichain
176 c write (iout,*) i,itype(i)
178 if (itype(i).eq.ntyp1) then
179 if (itype(i+1).eq.ntyp1) then
180 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
181 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
182 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
183 C if (unres_pdb) then
184 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
185 C call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
192 C c(j,i)=c(j,i-1)-1.9d0*e2(j)
196 dcj=(c(j,i-2)-c(j,i-3))/2.0
201 else !itype(i+1).eq.ntyp1
202 C if (unres_pdb) then
203 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
204 C call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
211 C c(j,i)=c(j,i+1)-1.9d0*e2(j)
215 dcj=(c(j,i+3)-c(j,i+2))/2.0
220 endif !itype(i+1).eq.ntyp1
221 endif !itype.eq.ntyp1
223 C Calculate the CM of the last side chain.
224 call sccenter(ires,iii,sccor)
227 if (itype(nres).ne.10) then
231 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
232 c(j,nres)=c(j,nres-1)+dcj
233 c(j,2*nres)=c(j,nres)
243 c(j,2*nres)=c(j,nres)
245 if (itype(1).eq.ntyp1) then
249 dcj=(c(j,4)-c(j,3))/2.0
254 C Calculate internal coordinates.
257 & "Cartesian coordinates of the reference structure"
258 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
259 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
261 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
262 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
263 & (c(j,ires+nres),j=1,3)
266 C Calculate internal coordinates.
268 & "Backbone and SC coordinates as read from the PDB"
270 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
271 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
272 & (c(j,nres+ires),j=1,3)
274 call int_from_cart(.true.,.false.)
275 call sc_loc_geom(.false.)
282 dc(j,i)=c(j,i+1)-c(j,i)
283 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
288 dc(j,i+nres)=c(j,i+nres)-c(j,i)
289 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
291 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
295 C Copy the coordinates to reference coordinates
305 bfrag(i,j)=bfrag(i,j)-ishift
311 hfrag(i,j)=hfrag(i,j)-ishift
317 c---------------------------------------------------------------------------
318 subroutine int_from_cart(lside,lprn)
319 implicit real*8 (a-h,o-z)
321 include 'COMMON.LOCAL'
323 include 'COMMON.CHAIN'
324 include 'COMMON.INTERACT'
325 include 'COMMON.IOUNITS'
327 include 'COMMON.NAMES'
331 dimension sccor(3,50)
336 & 'Internal coordinates calculated from crystal structure.'
338 write (iout,'(8a)') ' Res ',' dvb',' Theta',
339 & ' Gamma',' Dsc_id',' Dsc',' Alpha',
342 write (iout,'(4a)') ' Res ',' dvb',' Theta',
348 if (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0) then
349 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
352 vbld(i+1)=dist(i,i+1)
353 vbld_inv(i+1)=1.0d0/vbld(i+1)
354 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
355 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
357 c if (unres_pdb) then
358 c if (itype(1).eq.ntyp1) then
359 c theta(3)=90.0d0*deg2rad
360 c phi(4)=180.0d0*deg2rad
362 c vbld_inv(2)=1.0d0/vbld(2)
364 c if (itype(nres).eq.ntyp1) then
365 c theta(nres)=90.0d0*deg2rad
366 c phi(nres)=180.0d0*deg2rad
368 c vbld_inv(nres)=1.0d0/vbld(2)
374 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
375 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
379 C 10/03/12 Adam: Correction for zero SC-SC bond length
380 if (itype(i).ne.10 .and. itype(i).ne.ntyp1. and. di.eq.0.0d0)
383 if (itype(i).ne.10) then
384 vbld_inv(i+nres)=1.0d0/di
386 vbld_inv(i+nres)=0.0d0
389 alph(i)=alpha(nres+i,i,maxres2)
390 omeg(i)=beta(nres+i,i,maxres2,i+1)
393 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
394 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
395 & rad2deg*alph(i),rad2deg*omeg(i)
400 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
401 & rad2deg*theta(i),rad2deg*phi(i)
406 c-------------------------------------------------------------------------------
407 subroutine sc_loc_geom(lprn)
408 implicit real*8 (a-h,o-z)
410 include 'COMMON.LOCAL'
412 include 'COMMON.CHAIN'
413 include 'COMMON.INTERACT'
414 include 'COMMON.IOUNITS'
416 include 'COMMON.NAMES'
417 include 'COMMON.CONTROL'
418 double precision x_prime(3),y_prime(3),z_prime(3)
422 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
426 if (itype(i).ne.10) then
428 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
432 dc_norm(j,i+nres)=0.0d0
437 costtab(i+1) =dcos(theta(i+1))
438 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
439 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
440 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
441 cosfac2=0.5d0/(1.0d0+costtab(i+1))
442 cosfac=dsqrt(cosfac2)
443 sinfac2=0.5d0/(1.0d0-costtab(i+1))
444 sinfac=dsqrt(sinfac2)
448 C Compute the axes of tghe local cartesian coordinates system; store in
449 c x_prime, y_prime and z_prime
457 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
458 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
460 call vecpr(x_prime,y_prime,z_prime)
462 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
463 C to local coordinate system. Store in xx, yy, zz.
469 xx = xx + x_prime(j)*dc_norm(j,i+nres)
470 yy = yy + y_prime(j)*dc_norm(j,i+nres)
471 zz = zz + z_prime(j)*dc_norm(j,i+nres)
486 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),
492 c---------------------------------------------------------------------------
493 subroutine sccenter(ires,nscat,sccor)
494 implicit real*8 (a-h,o-z)
496 include 'COMMON.CHAIN'
497 dimension sccor(3,50)
501 sccmj=sccmj+sccor(j,i)
503 dc(j,ires)=sccmj/nscat
507 c---------------------------------------------------------------------------
508 subroutine bond_regular
512 include 'COMMON.LOCAL'
513 include 'COMMON.INTERACT'
514 include 'COMMON.CHAIN'
519 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
520 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
521 c print *,vbld(i+1),vbld(i+1+nres)
523 c Adam 2/26/20 Alter virtual bonds for non-blocking end groups of each chain
529 vbld_inv(i1)=vbld_inv(i1)*2
532 vbld(i2+1)=vbld(i2+1)/2
533 vbld_inv(i2+1)=vbld_inv(i2+1)*2
538 c---------------------------------------------------------------------------
539 subroutine readpdb_template(k)
540 C Read the PDB file with gaps for read_constr_homology with read2sigma
541 C and convert the peptide geometry into virtual-chain geometry.
542 implicit real*8 (a-h,o-z)
544 include 'COMMON.LOCAL'
546 include 'COMMON.CHAIN'
547 include 'COMMON.INTERACT'
548 include 'COMMON.IOUNITS'
550 include 'COMMON.NAMES'
551 include 'COMMON.CONTROL'
552 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
553 logical lprn /.false./,fail
554 double precision e1(3),e2(3),e3(3)
555 double precision dcj,efree_temp
559 double precision sccor(3,50)
560 integer rescode,iterter(maxres)
567 c write (2,*) "UNRES_PDB",unres_pdb
575 read (ipdbin,'(a80)',end=10) card
576 if (card(:3).eq.'END') then
578 else if (card(:3).eq.'TER') then
581 itype(ires_old-1)=ntyp1
582 iterter(ires_old-1)=1
583 itype(ires_old)=ntyp1
586 c write (iout,*) "Chain ended",ires,ishift,ires_old
589 dc(j,ires)=sccor(j,iii)
592 call sccenter(ires,iii,sccor)
595 C Fish out the ATOM cards.
596 if (index(card(1:4),'ATOM').gt.0) then
597 read (card(12:16),*) atom
598 c write (iout,*) "! ",atom," !",ires
599 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
600 read (card(23:26),*) ires
601 read (card(18:20),'(a3)') res
602 c write (iout,*) "ires",ires,ires-ishift+ishift1,
603 c & " ires_old",ires_old
604 c write (iout,*) "ishift",ishift," ishift1",ishift1
605 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
606 if (ires-ishift+ishift1.ne.ires_old) then
607 C Calculate the CM of the preceding residue.
611 dc(j,ires)=sccor(j,iii)
614 call sccenter(ires_old,iii,sccor)
619 if (res.eq.'Cl-' .or. res.eq.'Na+') then
622 else if (ibeg.eq.1) then
623 c write (iout,*) "BEG ires",ires
625 if (res.ne.'GLY' .and. res.ne. 'ACE') then
629 ires=ires-ishift+ishift1
631 c write (iout,*) "ishift",ishift," ires",ires,
632 c & " ires_old",ires_old
633 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
635 else if (ibeg.eq.2) then
637 ishift=-ires_old+ires-1
639 c write (iout,*) "New chain started",ires,ishift
642 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
643 ires=ires-ishift+ishift1
646 if (res.eq.'ACE' .or. res.eq.'NHE') then
649 itype(ires)=rescode(ires,res,0)
652 ires=ires-ishift+ishift1
654 c write (iout,*) "ires_old",ires_old," ires",ires
655 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
658 c write (2,*) "ires",ires," res ",res," ity",ity
659 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
660 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
661 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
662 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
664 write (iout,'(2i3,2x,a,3f8.3)')
665 & ires,itype(ires),res,(c(j,ires),j=1,3)
669 sccor(j,iii)=c(j,ires)
671 if (ishift.ne.0) then
672 ires_ca=ires+ishift-ishift1
676 c write (*,*) card(23:27),ires,itype(ires)
677 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
678 & atom.ne.'N' .and. atom.ne.'C' .and.
679 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
680 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
681 c write (iout,*) "sidechain ",atom
683 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
687 10 write (iout,'(a,i5)') ' Nres: ',ires
688 C Calculate dummy residue coordinates inside the "chain" of a multichain
692 c write (iout,*) i,itype(i),itype(i+1)
693 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
694 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
695 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
696 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
697 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
699 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
700 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
707 c(j,i)=c(j,i-1)-1.9d0*e2(j)
711 dcj=(c(j,i-2)-c(j,i-3))/2.0
712 if (dcj.eq.0) dcj=1.23591524223
717 else !itype(i+1).eq.ntyp1
719 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
720 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
727 c(j,i)=c(j,i+1)-1.9d0*e2(j)
731 dcj=(c(j,i+3)-c(j,i+2))/2.0
732 if (dcj.eq.0) dcj=1.23591524223
737 endif !itype(i+1).eq.ntyp1
738 endif !itype.eq.ntyp1
740 C Calculate the CM of the last side chain.
743 dc(j,ires)=sccor(j,iii)
746 call sccenter(ires,iii,sccor)
750 if (itype(nres).ne.10) then
754 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
755 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
762 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
766 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
767 if (dcj.eq.0) dcj=1.23591524223
768 c(j,nres)=c(j,nres-1)+dcj
769 c(j,2*nres)=c(j,nres)
780 c(j,2*nres)=c(j,nres)
782 if (itype(1).eq.ntyp1) then
786 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
787 call refsys(2,3,4,e1,e2,e3,fail)
794 c(j,1)=c(j,2)-1.9d0*e2(j)
798 dcj=(c(j,4)-c(j,3))/2.0
804 C Calculate internal coordinates.
807 & "Cartesian coordinates of the reference structure"
808 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
809 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
811 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
812 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
813 & (c(j,ires+nres),j=1,3)
816 C Calculate internal coordinates.
818 & "Backbone and SC coordinates as read from the PDB"
820 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
821 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
822 & (c(j,nres+ires),j=1,3)
824 call int_from_cart(.true.,.false.)
825 call sc_loc_geom(.false.)
832 dc(j,i)=c(j,i+1)-c(j,i)
833 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
838 dc(j,i+nres)=c(j,i+nres)-c(j,i)
839 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
841 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
847 cref(j,i+nres)=c(j,i+nres)