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,20)
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
66 ! write (iout,*) "Chain ended",ires,ishift,ires_old
69 dc(j,ires)=sccor(j,iii)
72 call sccenter(ires,iii,sccor)
77 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
78 ! Fish out the ATOM cards.
79 if (index(card(1:4),'ATOM').gt.0) then
80 read (card(12:16),*) atom
81 c write (2,'(a)') card
82 ! write (iout,*) "! ",atom," !",ires
83 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
84 read (card(23:26),*) ires
85 read (card(18:20),'(a3)') res
86 ! write (iout,*) "ires",ires,ires-ishift+ishift1,
87 ! & " ires_old",ires_old
88 ! write (iout,*) "ishift",ishift," ishift1",ishift1
89 ! write (iout,*) "IRES",ires-ishift+ishift1,ires_old
90 if (ires-ishift+ishift1.ne.ires_old) then
91 ! Calculate the CM of the preceding residue.
92 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
94 ! write (iout,*) "Calculating sidechain center iii",iii
97 dc(j,ires+nres)=sccor(j,iii)
100 call sccenter(ires_old,iii,sccor)
105 if (res.eq.'Cl-' .or. res.eq.'Na+') then
108 else if (ibeg.eq.1) then
109 c write (iout,*) "BEG ires",ires
111 if (res.ne.'GLY' .and. res.ne. 'ACE') then
115 ires=ires-ishift+ishift1
117 ! write (iout,*) "ishift",ishift," ires",ires,&
118 ! " ires_old",ires_old
120 else if (ibeg.eq.2) then
122 ishift=-ires_old+ires-1 !!!!!
123 ishift1=ishift1-1 !!!!!
124 ! write (iout,*) "New chain started",ires,ishift,ishift1,"!"
125 ires=ires-ishift+ishift1
129 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
130 ires=ires-ishift+ishift1
133 if (res.eq.'ACE' .or. res.eq.'NHE') then
136 itype(ires)=rescode(ires,res,0)
139 ires=ires-ishift+ishift1
141 ! write (iout,*) "ires_old",ires_old," ires",ires
142 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
145 ! write (2,*) "ires",ires," res ",res!," ity"!,ity
146 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
147 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
148 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
149 ! write (iout,*) "backbone ",atom
151 write (iout,'(2i3,2x,a,3f8.3)')
152 & ires,itype(ires),res,(c(j,ires),j=1,3)
156 sccor(j,iii)=c(j,ires)
158 c write (2,*) card(23:27),ires,itype(ires),iii
159 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
160 & atom.ne.'N' .and. atom.ne.'C' .and.
161 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
162 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
163 ! write (iout,*) "sidechain ",atom
165 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
166 c write (2,*) "iii",iii
170 10 write (iout,'(a,i5)') ' Nres: ',ires
171 C Calculate dummy residue coordinates inside the "chain" of a multichain
175 c write (iout,*) i,itype(i)
177 if (itype(i).eq.ntyp1) then
178 if (itype(i+1).eq.ntyp1) then
179 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
180 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
181 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
182 C if (unres_pdb) then
183 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
184 C call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
191 C c(j,i)=c(j,i-1)-1.9d0*e2(j)
195 dcj=(c(j,i-2)-c(j,i-3))/2.0
200 else !itype(i+1).eq.ntyp1
201 C if (unres_pdb) then
202 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
203 C call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
210 C c(j,i)=c(j,i+1)-1.9d0*e2(j)
214 dcj=(c(j,i+3)-c(j,i+2))/2.0
219 endif !itype(i+1).eq.ntyp1
220 endif !itype.eq.ntyp1
222 C Calculate the CM of the last side chain.
223 call sccenter(ires,iii,sccor)
226 if (itype(nres).ne.10) then
230 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
231 c(j,nres)=c(j,nres-1)+dcj
232 c(j,2*nres)=c(j,nres)
242 c(j,2*nres)=c(j,nres)
244 if (itype(1).eq.ntyp1) then
248 dcj=(c(j,4)-c(j,3))/2.0
253 C Calculate internal coordinates.
256 & "Cartesian coordinates of the reference structure"
257 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
258 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
260 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
261 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
262 & (c(j,ires+nres),j=1,3)
265 C Calculate internal coordinates.
267 & "Backbone and SC coordinates as read from the PDB"
269 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
270 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
271 & (c(j,nres+ires),j=1,3)
273 call int_from_cart(.true.,.false.)
274 call sc_loc_geom(.false.)
281 dc(j,i)=c(j,i+1)-c(j,i)
282 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
287 dc(j,i+nres)=c(j,i+nres)-c(j,i)
288 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
290 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
294 C Copy the coordinates to reference coordinates
304 bfrag(i,j)=bfrag(i,j)-ishift
310 hfrag(i,j)=hfrag(i,j)-ishift
316 c---------------------------------------------------------------------------
317 subroutine int_from_cart(lside,lprn)
318 implicit real*8 (a-h,o-z)
320 include 'COMMON.LOCAL'
322 include 'COMMON.CHAIN'
323 include 'COMMON.INTERACT'
324 include 'COMMON.IOUNITS'
326 include 'COMMON.NAMES'
330 dimension sccor(3,20)
335 & 'Internal coordinates calculated from crystal structure.'
337 write (iout,'(8a)') ' Res ',' dvb',' Theta',
338 & ' Gamma',' Dsc_id',' Dsc',' Alpha',
341 write (iout,'(4a)') ' Res ',' dvb',' Theta',
347 if (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0) then
348 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
351 vbld(i+1)=dist(i,i+1)
352 vbld_inv(i+1)=1.0d0/vbld(i+1)
353 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
354 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
356 c if (unres_pdb) then
357 c if (itype(1).eq.ntyp1) then
358 c theta(3)=90.0d0*deg2rad
359 c phi(4)=180.0d0*deg2rad
361 c vbld_inv(2)=1.0d0/vbld(2)
363 c if (itype(nres).eq.ntyp1) then
364 c theta(nres)=90.0d0*deg2rad
365 c phi(nres)=180.0d0*deg2rad
367 c vbld_inv(nres)=1.0d0/vbld(2)
373 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
374 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
378 C 10/03/12 Adam: Correction for zero SC-SC bond length
379 if (itype(i).ne.10 .and. itype(i).ne.ntyp1. and. di.eq.0.0d0)
382 if (itype(i).ne.10) then
383 vbld_inv(i+nres)=1.0d0/di
385 vbld_inv(i+nres)=0.0d0
388 alph(i)=alpha(nres+i,i,maxres2)
389 omeg(i)=beta(nres+i,i,maxres2,i+1)
392 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
393 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
394 & rad2deg*alph(i),rad2deg*omeg(i)
399 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
400 & rad2deg*theta(i),rad2deg*phi(i)
405 c-------------------------------------------------------------------------------
406 subroutine sc_loc_geom(lprn)
407 implicit real*8 (a-h,o-z)
409 include 'COMMON.LOCAL'
411 include 'COMMON.CHAIN'
412 include 'COMMON.INTERACT'
413 include 'COMMON.IOUNITS'
415 include 'COMMON.NAMES'
416 include 'COMMON.CONTROL'
417 double precision x_prime(3),y_prime(3),z_prime(3)
421 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
425 if (itype(i).ne.10) then
427 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
431 dc_norm(j,i+nres)=0.0d0
436 costtab(i+1) =dcos(theta(i+1))
437 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
438 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
439 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
440 cosfac2=0.5d0/(1.0d0+costtab(i+1))
441 cosfac=dsqrt(cosfac2)
442 sinfac2=0.5d0/(1.0d0-costtab(i+1))
443 sinfac=dsqrt(sinfac2)
447 C Compute the axes of tghe local cartesian coordinates system; store in
448 c x_prime, y_prime and z_prime
456 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
457 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
459 call vecpr(x_prime,y_prime,z_prime)
461 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
462 C to local coordinate system. Store in xx, yy, zz.
468 xx = xx + x_prime(j)*dc_norm(j,i+nres)
469 yy = yy + y_prime(j)*dc_norm(j,i+nres)
470 zz = zz + z_prime(j)*dc_norm(j,i+nres)
485 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),
491 c---------------------------------------------------------------------------
492 subroutine sccenter(ires,nscat,sccor)
493 implicit real*8 (a-h,o-z)
495 include 'COMMON.CHAIN'
496 dimension sccor(3,20)
500 sccmj=sccmj+sccor(j,i)
502 dc(j,ires)=sccmj/nscat
506 c---------------------------------------------------------------------------
507 subroutine bond_regular
511 include 'COMMON.LOCAL'
512 include 'COMMON.INTERACT'
513 include 'COMMON.CHAIN'
518 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
519 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
520 c print *,vbld(i+1),vbld(i+1+nres)
522 c Adam 2/26/20 Alter virtual bonds for non-blocking end groups of each chain
528 vbld_inv(i1)=vbld_inv(i1)*2
531 vbld(i2+1)=vbld(i2+1)/2
532 vbld_inv(i2+1)=vbld_inv(i2+1)*2
537 c---------------------------------------------------------------------------
538 subroutine readpdb_template(k)
539 C Read the PDB file with gaps for read_constr_homology with read2sigma
540 C and convert the peptide geometry into virtual-chain geometry.
541 implicit real*8 (a-h,o-z)
543 include 'COMMON.LOCAL'
545 include 'COMMON.CHAIN'
546 include 'COMMON.INTERACT'
547 include 'COMMON.IOUNITS'
549 include 'COMMON.NAMES'
550 include 'COMMON.CONTROL'
551 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
552 logical lprn /.false./,fail
553 double precision e1(3),e2(3),e3(3)
554 double precision dcj,efree_temp
558 double precision sccor(3,20)
559 integer rescode,iterter(maxres)
566 c write (2,*) "UNRES_PDB",unres_pdb
574 read (ipdbin,'(a80)',end=10) card
575 if (card(:3).eq.'END') then
577 else if (card(:3).eq.'TER') then
580 itype(ires_old-1)=ntyp1
581 iterter(ires_old-1)=1
582 itype(ires_old)=ntyp1
585 c write (iout,*) "Chain ended",ires,ishift,ires_old
588 dc(j,ires)=sccor(j,iii)
591 call sccenter(ires,iii,sccor)
594 C Fish out the ATOM cards.
595 if (index(card(1:4),'ATOM').gt.0) then
596 read (card(12:16),*) atom
597 c write (iout,*) "! ",atom," !",ires
598 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
599 read (card(23:26),*) ires
600 read (card(18:20),'(a3)') res
601 c write (iout,*) "ires",ires,ires-ishift+ishift1,
602 c & " ires_old",ires_old
603 c write (iout,*) "ishift",ishift," ishift1",ishift1
604 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
605 if (ires-ishift+ishift1.ne.ires_old) then
606 C Calculate the CM of the preceding residue.
610 dc(j,ires)=sccor(j,iii)
613 call sccenter(ires_old,iii,sccor)
618 if (res.eq.'Cl-' .or. res.eq.'Na+') then
621 else if (ibeg.eq.1) then
622 c write (iout,*) "BEG ires",ires
624 if (res.ne.'GLY' .and. res.ne. 'ACE') then
628 ires=ires-ishift+ishift1
630 c write (iout,*) "ishift",ishift," ires",ires,
631 c & " ires_old",ires_old
632 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
634 else if (ibeg.eq.2) then
636 ishift=-ires_old+ires-1
638 c write (iout,*) "New chain started",ires,ishift
641 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
642 ires=ires-ishift+ishift1
645 if (res.eq.'ACE' .or. res.eq.'NHE') then
648 itype(ires)=rescode(ires,res,0)
651 ires=ires-ishift+ishift1
653 c write (iout,*) "ires_old",ires_old," ires",ires
654 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
657 c write (2,*) "ires",ires," res ",res," ity",ity
658 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
659 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
660 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
661 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
663 write (iout,'(2i3,2x,a,3f8.3)')
664 & ires,itype(ires),res,(c(j,ires),j=1,3)
668 sccor(j,iii)=c(j,ires)
670 if (ishift.ne.0) then
671 ires_ca=ires+ishift-ishift1
675 c write (*,*) card(23:27),ires,itype(ires)
676 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
677 & atom.ne.'N' .and. atom.ne.'C' .and.
678 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
679 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
680 c write (iout,*) "sidechain ",atom
682 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
686 10 write (iout,'(a,i5)') ' Nres: ',ires
687 C Calculate dummy residue coordinates inside the "chain" of a multichain
691 c write (iout,*) i,itype(i),itype(i+1)
692 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
693 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
694 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
695 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
696 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
698 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
699 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
706 c(j,i)=c(j,i-1)-1.9d0*e2(j)
710 dcj=(c(j,i-2)-c(j,i-3))/2.0
711 if (dcj.eq.0) dcj=1.23591524223
716 else !itype(i+1).eq.ntyp1
718 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
719 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
726 c(j,i)=c(j,i+1)-1.9d0*e2(j)
730 dcj=(c(j,i+3)-c(j,i+2))/2.0
731 if (dcj.eq.0) dcj=1.23591524223
736 endif !itype(i+1).eq.ntyp1
737 endif !itype.eq.ntyp1
739 C Calculate the CM of the last side chain.
742 dc(j,ires)=sccor(j,iii)
745 call sccenter(ires,iii,sccor)
749 if (itype(nres).ne.10) then
753 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
754 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
761 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
765 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
766 if (dcj.eq.0) dcj=1.23591524223
767 c(j,nres)=c(j,nres-1)+dcj
768 c(j,2*nres)=c(j,nres)
779 c(j,2*nres)=c(j,nres)
781 if (itype(1).eq.ntyp1) then
785 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
786 call refsys(2,3,4,e1,e2,e3,fail)
793 c(j,1)=c(j,2)-1.9d0*e2(j)
797 dcj=(c(j,4)-c(j,3))/2.0
803 C Calculate internal coordinates.
806 & "Cartesian coordinates of the reference structure"
807 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
808 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
810 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
811 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
812 & (c(j,ires+nres),j=1,3)
815 C Calculate internal coordinates.
817 & "Backbone and SC coordinates as read from the PDB"
819 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
820 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
821 & (c(j,nres+ires),j=1,3)
823 call int_from_cart(.true.,.false.)
824 call sc_loc_geom(.false.)
831 dc(j,i)=c(j,i+1)-c(j,i)
832 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
837 dc(j,i+nres)=c(j,i+nres)-c(j,i)
838 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
840 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
846 cref(j,i+nres)=c(j,i+nres)