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
172 write (iout,'(a,i5)') ' Number of residues found: ',ires
174 if (ires.eq.0) return
175 C Calculate the CM of the last side chain.
179 dc(j,ires)=sccor(j,iii)
182 call sccenter(ires,iii,sccor)
188 if (itype(nres).ne.10) then
192 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
193 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
200 c(j,nres)=c(j,nres-1)-3.8d0*e2(j)
204 dcj=c(j,nres-2)-c(j,nres-3)
205 c(j,nres)=c(j,nres-1)+dcj
206 c(j,2*nres)=c(j,nres)
217 c(j,2*nres)=c(j,nres)
219 if (itype(1).eq.ntyp1) then
223 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
224 call refsys(2,3,4,e1,e2,e3,fail)
231 c(j,1)=c(j,2)-3.8d0*e2(j)
241 C Copy the coordinates to reference coordinates
247 C Calculate internal coordinates.
250 & "Cartesian coordinates of the reference structure"
251 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
252 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
254 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
255 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
256 & (c(j,ires+nres),j=1,3)
259 C Calculate internal coordinates.
261 & "Backbone and SC coordinates as read from the PDB"
263 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
264 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
265 & (c(j,nres+ires),j=1,3)
267 call int_from_cart(.true.,.false.)
268 call sc_loc_geom(.false.)
275 dc(j,i)=c(j,i+1)-c(j,i)
276 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
281 dc(j,i+nres)=c(j,i+nres)-c(j,i)
282 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
284 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
288 C Copy the coordinates to reference coordinates
298 bfrag(i,j)=bfrag(i,j)-ishift
304 hfrag(i,j)=hfrag(i,j)-ishift
310 c---------------------------------------------------------------------------
311 subroutine int_from_cart(lside,lprn)
312 implicit real*8 (a-h,o-z)
314 include 'COMMON.LOCAL'
316 include 'COMMON.CHAIN'
317 include 'COMMON.INTERACT'
318 include 'COMMON.IOUNITS'
320 include 'COMMON.NAMES'
324 dimension sccor(3,20)
329 & 'Internal coordinates calculated from crystal structure.'
331 write (iout,'(8a)') ' Res ',' dvb',' Theta',
332 & ' Gamma',' Dsc_id',' Dsc',' Alpha',
335 write (iout,'(4a)') ' Res ',' dvb',' Theta',
341 if (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0) then
342 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
345 vbld(i+1)=dist(i,i+1)
346 vbld_inv(i+1)=1.0d0/vbld(i+1)
347 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
348 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
350 c if (unres_pdb) then
351 c if (itype(1).eq.ntyp1) then
352 c theta(3)=90.0d0*deg2rad
353 c phi(4)=180.0d0*deg2rad
355 c vbld_inv(2)=1.0d0/vbld(2)
357 c if (itype(nres).eq.ntyp1) then
358 c theta(nres)=90.0d0*deg2rad
359 c phi(nres)=180.0d0*deg2rad
361 c vbld_inv(nres)=1.0d0/vbld(2)
367 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
368 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
372 C 10/03/12 Adam: Correction for zero SC-SC bond length
373 if (itype(i).ne.10 .and. itype(i).ne.ntyp1. and. di.eq.0.0d0)
376 if (itype(i).ne.10) then
377 vbld_inv(i+nres)=1.0d0/di
379 vbld_inv(i+nres)=0.0d0
382 alph(i)=alpha(nres+i,i,maxres2)
383 omeg(i)=beta(nres+i,i,maxres2,i+1)
386 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
387 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
388 & rad2deg*alph(i),rad2deg*omeg(i)
393 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
394 & rad2deg*theta(i),rad2deg*phi(i)
399 c-------------------------------------------------------------------------------
400 subroutine sc_loc_geom(lprn)
401 implicit real*8 (a-h,o-z)
403 include 'COMMON.LOCAL'
405 include 'COMMON.CHAIN'
406 include 'COMMON.INTERACT'
407 include 'COMMON.IOUNITS'
409 include 'COMMON.NAMES'
410 include 'COMMON.CONTROL'
411 double precision x_prime(3),y_prime(3),z_prime(3)
415 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
419 if (itype(i).ne.10) then
421 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
425 dc_norm(j,i+nres)=0.0d0
430 costtab(i+1) =dcos(theta(i+1))
431 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
432 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
433 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
434 cosfac2=0.5d0/(1.0d0+costtab(i+1))
435 cosfac=dsqrt(cosfac2)
436 sinfac2=0.5d0/(1.0d0-costtab(i+1))
437 sinfac=dsqrt(sinfac2)
441 C Compute the axes of tghe local cartesian coordinates system; store in
442 c x_prime, y_prime and z_prime
450 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
451 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
453 call vecpr(x_prime,y_prime,z_prime)
455 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
456 C to local coordinate system. Store in xx, yy, zz.
462 xx = xx + x_prime(j)*dc_norm(j,i+nres)
463 yy = yy + y_prime(j)*dc_norm(j,i+nres)
464 zz = zz + z_prime(j)*dc_norm(j,i+nres)
479 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),
485 c---------------------------------------------------------------------------
486 subroutine sccenter(ires,nscat,sccor)
487 implicit real*8 (a-h,o-z)
489 include 'COMMON.CHAIN'
490 dimension sccor(3,20)
494 sccmj=sccmj+sccor(j,i)
496 dc(j,ires)=sccmj/nscat
500 c---------------------------------------------------------------------------
501 subroutine bond_regular
505 include 'COMMON.LOCAL'
506 include 'COMMON.INTERACT'
507 include 'COMMON.CHAIN'
512 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
513 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
514 c print *,vbld(i+1),vbld(i+1+nres)
516 c Adam 2/26/20 Alter virtual bonds for non-blocking end groups of each chain
522 vbld_inv(i1)=vbld_inv(i1)*2
525 vbld(i2+1)=vbld(i2+1)/2
526 vbld_inv(i2+1)=vbld_inv(i2+1)*2
531 c---------------------------------------------------------------------------
532 subroutine readpdb_template(k)
533 C Read the PDB file with gaps for read_constr_homology with read2sigma
534 C and convert the peptide geometry into virtual-chain geometry.
535 implicit real*8 (a-h,o-z)
537 include 'COMMON.LOCAL'
539 include 'COMMON.CHAIN'
540 include 'COMMON.INTERACT'
541 include 'COMMON.IOUNITS'
543 include 'COMMON.NAMES'
544 include 'COMMON.CONTROL'
545 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
546 logical lprn /.false./,fail
547 double precision e1(3),e2(3),e3(3)
548 double precision dcj,efree_temp
552 double precision sccor(3,20)
558 c write (2,*) "UNRES_PDB",unres_pdb
566 read (ipdbin,'(a80)',end=10) card
567 c write (iout,'(a)') card
568 if (card(:3).eq.'END' .or. card(:3).eq.'TER') goto 10
569 C Fish out the ATOM cards.
570 if (index(card(1:4),'ATOM').gt.0) then
571 read (card(12:16),*) atom
572 c write (iout,*) "! ",atom," !",ires
573 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
574 read (card(23:26),*) ires
575 read (card(18:20),'(a3)') res
576 c write (iout,*) "ires",ires,ires-ishift+ishift1,
577 c & " ires_old",ires_old
578 c write (iout,*) "ishift",ishift," ishift1",ishift1
579 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
580 if (ires-ishift+ishift1.ne.ires_old) then
581 C Calculate the CM of the preceding residue.
582 c if (ibeg.eq.0) call sccenter(ires,iii,sccor)
584 c write (iout,*) "Calculating sidechain center iii",iii
587 dc(j,ires)=sccor(j,iii)
590 call sccenter(ires_old,iii,sccor)
595 if (res.eq.'Cl-' .or. res.eq.'Na+') then
598 else if (ibeg.eq.1) then
599 c write (iout,*) "BEG ires",ires
601 if (res.ne.'GLY' .and. res.ne. 'ACE') then
605 ires=ires-ishift+ishift1
607 c write (iout,*) "ishift",ishift," ires",ires,
608 c & " ires_old",ires_old
611 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
612 ires=ires-ishift+ishift1
615 if (res.eq.'ACE' .or. res.eq.'NHE') then
618 itype(ires)=rescode(ires,res,0)
621 ires=ires-ishift+ishift1
623 c write (iout,*) "ires_old",ires_old," ires",ires
624 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
627 c write (2,*) "ires",ires," res ",res," ity",ity
628 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
629 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
630 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
631 c write (iout,*) "backbone ",atom
633 write (iout,'(2i3,2x,a,3f8.3)')
634 & ires,itype(ires),res,(c(j,ires),j=1,3)
638 sccor(j,iii)=c(j,ires)
640 if (ishift.ne.0) then
641 ires_ca=ires+ishift-ishift1
645 c write (*,*) card(23:27),ires,itype(ires)
646 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
647 & atom.ne.'N' .and. atom.ne.'C' .and.
648 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
649 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
650 c write (iout,*) "sidechain ",atom
652 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
658 write (iout,'(a,i5)') ' Number of residues found: ',ires
660 if (ires.eq.0) return
661 C Calculate the CM of the last side chain.
665 dc(j,ires)=sccor(j,iii)
668 call sccenter(ires,iii,sccor)
674 if (itype(nres).ne.10) then
678 dcj=c(j,nres-2)-c(j,nres-3)
679 c(j,nres)=c(j,nres-1)+dcj
680 c(j,2*nres)=c(j,nres)
690 c(j,2*nres)=c(j,nres)
692 if (itype(1).eq.ntyp1) then
696 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
697 call refsys(2,3,4,e1,e2,e3,fail)
704 c(j,1)=c(j,2)-3.8d0*e2(j)
714 C Calculate internal coordinates.
717 & "Cartesian coordinates of the reference structure"
718 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
719 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
721 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
722 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
723 & (c(j,ires+nres),j=1,3)
726 C Calculate internal coordinates.
728 & "Backbone and SC coordinates as read from the PDB"
730 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
731 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
732 & (c(j,nres+ires),j=1,3)
734 call int_from_cart(.true.,.false.)
735 call sc_loc_geom(.false.)
742 dc(j,i)=c(j,i+1)-c(j,i)
743 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
748 dc(j,i+nres)=c(j,i+nres)-c(j,i)
749 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
751 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
755 C Copy the coordinates to reference coordinates