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)
28 c write (2,*) "UNRES_PDB",unres_pdb
36 read (ipdbin,'(a80)',end=10) card
37 c write (iout,'(a)') card
38 if (card(:5).eq.'HELIX') then
41 read(card(22:25),*) hfrag(1,nhfrag)
42 read(card(34:37),*) hfrag(2,nhfrag)
44 if (card(:5).eq.'SHEET') then
47 read(card(24:26),*) bfrag(1,nbfrag)
48 read(card(35:37),*) bfrag(2,nbfrag)
49 crc----------------------------------------
50 crc to be corrected !!!
51 bfrag(3,nbfrag)=bfrag(1,nbfrag)
52 bfrag(4,nbfrag)=bfrag(2,nbfrag)
53 crc----------------------------------------
55 if (card(:3).eq.'END' .or. card(:3).eq.'TER') goto 10
57 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
58 C Fish out the ATOM cards.
59 if (index(card(1:4),'ATOM').gt.0) then
60 read (card(12:16),*) atom
61 c write (iout,*) "! ",atom," !",ires
62 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
63 read (card(23:26),*) ires
64 read (card(18:20),'(a3)') res
65 c write (iout,*) "ires",ires,ires-ishift+ishift1,
66 c & " ires_old",ires_old
67 c write (iout,*) "ishift",ishift," ishift1",ishift1
68 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
69 if (ires-ishift+ishift1.ne.ires_old) then
70 C Calculate the CM of the preceding residue.
71 c if (ibeg.eq.0) call sccenter(ires,iii,sccor)
73 c write (iout,*) "Calculating sidechain center iii",iii
76 dc(j,ires)=sccor(j,iii)
79 call sccenter(ires_old,iii,sccor)
84 if (res.eq.'Cl-' .or. res.eq.'Na+') then
87 else if (ibeg.eq.1) then
88 c write (iout,*) "BEG ires",ires
90 if (res.ne.'GLY' .and. res.ne. 'ACE') then
94 ires=ires-ishift+ishift1
96 c write (iout,*) "ishift",ishift," ires",ires,
97 c & " ires_old",ires_old
100 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
101 ires=ires-ishift+ishift1
104 if (res.eq.'ACE' .or. res.eq.'NHE') then
107 itype(ires)=rescode(ires,res,0)
110 ires=ires-ishift+ishift1
112 c write (iout,*) "ires_old",ires_old," ires",ires
113 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
116 c write (2,*) "ires",ires," res ",res," ity",ity
117 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
118 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
119 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
120 c write (iout,*) "backbone ",atom
122 write (iout,'(2i3,2x,a,3f8.3)')
123 & ires,itype(ires),res,(c(j,ires),j=1,3)
127 sccor(j,iii)=c(j,ires)
129 if (ishift.ne.0) then
130 ires_ca=ires+ishift-ishift1
134 c write (*,*) card(23:27),ires,itype(ires)
135 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
136 & atom.ne.'N' .and. atom.ne.'C' .and.
137 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
138 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
139 c write (iout,*) "sidechain ",atom
141 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
147 write (iout,'(a,i5)') ' Number of residues found: ',ires
149 if (ires.eq.0) return
150 C Calculate the CM of the last side chain.
154 dc(j,ires)=sccor(j,iii)
157 call sccenter(ires,iii,sccor)
163 if (itype(nres).ne.10) then
167 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
168 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
175 c(j,nres)=c(j,nres-1)-3.8d0*e2(j)
179 dcj=c(j,nres-2)-c(j,nres-3)
180 c(j,nres)=c(j,nres-1)+dcj
181 c(j,2*nres)=c(j,nres)
192 c(j,2*nres)=c(j,nres)
194 if (itype(1).eq.ntyp1) then
198 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
199 call refsys(2,3,4,e1,e2,e3,fail)
206 c(j,1)=c(j,2)-3.8d0*e2(j)
216 C Copy the coordinates to reference coordinates
222 C Calculate internal coordinates.
225 & "Cartesian coordinates of the reference structure"
226 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
227 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
229 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
230 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
231 & (c(j,ires+nres),j=1,3)
234 C Calculate internal coordinates.
236 & "Backbone and SC coordinates as read from the PDB"
238 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
239 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
240 & (c(j,nres+ires),j=1,3)
242 call int_from_cart(.true.,.false.)
243 call sc_loc_geom(.false.)
250 dc(j,i)=c(j,i+1)-c(j,i)
251 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
256 dc(j,i+nres)=c(j,i+nres)-c(j,i)
257 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
259 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
263 C Copy the coordinates to reference coordinates
273 bfrag(i,j)=bfrag(i,j)-ishift
279 hfrag(i,j)=hfrag(i,j)-ishift
285 c---------------------------------------------------------------------------
286 subroutine int_from_cart(lside,lprn)
287 implicit real*8 (a-h,o-z)
289 include 'COMMON.LOCAL'
291 include 'COMMON.CHAIN'
292 include 'COMMON.INTERACT'
293 include 'COMMON.IOUNITS'
295 include 'COMMON.NAMES'
299 dimension sccor(3,20)
304 & 'Internal coordinates calculated from crystal structure.'
306 write (iout,'(8a)') ' Res ',' dvb',' Theta',
307 & ' Gamma',' Dsc_id',' Dsc',' Alpha',
310 write (iout,'(4a)') ' Res ',' dvb',' Theta',
316 if (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0) then
317 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
320 vbld(i+1)=dist(i,i+1)
321 vbld_inv(i+1)=1.0d0/vbld(i+1)
322 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
323 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
325 c if (unres_pdb) then
326 c if (itype(1).eq.ntyp1) then
327 c theta(3)=90.0d0*deg2rad
328 c phi(4)=180.0d0*deg2rad
330 c vbld_inv(2)=1.0d0/vbld(2)
332 c if (itype(nres).eq.ntyp1) then
333 c theta(nres)=90.0d0*deg2rad
334 c phi(nres)=180.0d0*deg2rad
336 c vbld_inv(nres)=1.0d0/vbld(2)
342 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
343 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
347 C 10/03/12 Adam: Correction for zero SC-SC bond length
348 if (itype(i).ne.10 .and. itype(i).ne.ntyp1. and. di.eq.0.0d0)
351 if (itype(i).ne.10) then
352 vbld_inv(i+nres)=1.0d0/di
354 vbld_inv(i+nres)=0.0d0
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,vbld(i),
362 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
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 sc_loc_geom(lprn)
376 implicit real*8 (a-h,o-z)
378 include 'COMMON.LOCAL'
380 include 'COMMON.CHAIN'
381 include 'COMMON.INTERACT'
382 include 'COMMON.IOUNITS'
384 include 'COMMON.NAMES'
385 include 'COMMON.CONTROL'
386 double precision x_prime(3),y_prime(3),z_prime(3)
390 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
394 if (itype(i).ne.10) then
396 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
400 dc_norm(j,i+nres)=0.0d0
405 costtab(i+1) =dcos(theta(i+1))
406 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
407 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
408 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
409 cosfac2=0.5d0/(1.0d0+costtab(i+1))
410 cosfac=dsqrt(cosfac2)
411 sinfac2=0.5d0/(1.0d0-costtab(i+1))
412 sinfac=dsqrt(sinfac2)
416 C Compute the axes of tghe local cartesian coordinates system; store in
417 c x_prime, y_prime and z_prime
425 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
426 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
428 call vecpr(x_prime,y_prime,z_prime)
430 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
431 C to local coordinate system. Store in xx, yy, zz.
437 xx = xx + x_prime(j)*dc_norm(j,i+nres)
438 yy = yy + y_prime(j)*dc_norm(j,i+nres)
439 zz = zz + z_prime(j)*dc_norm(j,i+nres)
454 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),
460 c---------------------------------------------------------------------------
461 subroutine sccenter(ires,nscat,sccor)
462 implicit real*8 (a-h,o-z)
464 include 'COMMON.CHAIN'
465 dimension sccor(3,20)
469 sccmj=sccmj+sccor(j,i)
471 dc(j,ires)=sccmj/nscat
475 c---------------------------------------------------------------------------
476 subroutine bond_regular
477 implicit real*8 (a-h,o-z)
480 include 'COMMON.LOCAL'
481 include 'COMMON.CALC'
482 include 'COMMON.INTERACT'
483 include 'COMMON.CHAIN'
486 vbld_inv(i+1)=1.0d0/vbld(i+1)
487 vbld(i+1+nres)=dsc(itype(i+1))
488 vbld_inv(i+1+nres)=dsc_inv(itype(i+1))
489 c print *,vbld(i+1),vbld(i+1+nres)
493 subroutine readpdb_template(k)
494 C Read the PDB file with gaps for read_constr_homology with read2sigma
495 C and convert the peptide geometry into virtual-chain geometry.
496 implicit real*8 (a-h,o-z)
498 include 'COMMON.LOCAL'
500 include 'COMMON.CHAIN'
501 include 'COMMON.INTERACT'
502 include 'COMMON.IOUNITS'
504 include 'COMMON.NAMES'
505 include 'COMMON.CONTROL'
506 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
507 logical lprn /.false./,fail
508 double precision e1(3),e2(3),e3(3)
509 double precision dcj,efree_temp
513 double precision sccor(3,20)
519 c write (2,*) "UNRES_PDB",unres_pdb
527 read (ipdbin,'(a80)',end=10) card
528 c write (iout,'(a)') card
529 if (card(:3).eq.'END' .or. card(:3).eq.'TER') goto 10
530 C Fish out the ATOM cards.
531 if (index(card(1:4),'ATOM').gt.0) then
532 read (card(12:16),*) atom
533 c write (iout,*) "! ",atom," !",ires
534 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
535 read (card(23:26),*) ires
536 read (card(18:20),'(a3)') res
537 c write (iout,*) "ires",ires,ires-ishift+ishift1,
538 c & " ires_old",ires_old
539 c write (iout,*) "ishift",ishift," ishift1",ishift1
540 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
541 if (ires-ishift+ishift1.ne.ires_old) then
542 C Calculate the CM of the preceding residue.
543 c if (ibeg.eq.0) call sccenter(ires,iii,sccor)
545 c write (iout,*) "Calculating sidechain center iii",iii
548 dc(j,ires)=sccor(j,iii)
551 call sccenter(ires_old,iii,sccor)
556 if (res.eq.'Cl-' .or. res.eq.'Na+') then
559 else if (ibeg.eq.1) then
560 c write (iout,*) "BEG ires",ires
562 if (res.ne.'GLY' .and. res.ne. 'ACE') then
566 ires=ires-ishift+ishift1
568 c write (iout,*) "ishift",ishift," ires",ires,
569 c & " ires_old",ires_old
572 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
573 ires=ires-ishift+ishift1
576 if (res.eq.'ACE' .or. res.eq.'NHE') then
579 itype(ires)=rescode(ires,res,0)
582 ires=ires-ishift+ishift1
584 c write (iout,*) "ires_old",ires_old," ires",ires
585 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
588 c write (2,*) "ires",ires," res ",res," ity",ity
589 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
590 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
591 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
592 c write (iout,*) "backbone ",atom
594 write (iout,'(2i3,2x,a,3f8.3)')
595 & ires,itype(ires),res,(c(j,ires),j=1,3)
599 sccor(j,iii)=c(j,ires)
601 if (ishift.ne.0) then
602 ires_ca=ires+ishift-ishift1
606 c write (*,*) card(23:27),ires,itype(ires)
607 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
608 & atom.ne.'N' .and. atom.ne.'C' .and.
609 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
610 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
611 c write (iout,*) "sidechain ",atom
613 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
619 write (iout,'(a,i5)') ' Number of residues found: ',ires
621 if (ires.eq.0) return
622 C Calculate the CM of the last side chain.
626 dc(j,ires)=sccor(j,iii)
629 call sccenter(ires,iii,sccor)
635 if (itype(nres).ne.10) then
639 dcj=c(j,nres-2)-c(j,nres-3)
640 c(j,nres)=c(j,nres-1)+dcj
641 c(j,2*nres)=c(j,nres)
651 c(j,2*nres)=c(j,nres)
653 if (itype(1).eq.ntyp1) then
657 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
658 call refsys(2,3,4,e1,e2,e3,fail)
665 c(j,1)=c(j,2)-3.8d0*e2(j)
675 C Calculate internal coordinates.
678 & "Cartesian coordinates of the reference structure"
679 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
680 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
682 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
683 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
684 & (c(j,ires+nres),j=1,3)
687 C Calculate internal coordinates.
689 & "Backbone and SC coordinates as read from the PDB"
691 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
692 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
693 & (c(j,nres+ires),j=1,3)
695 call int_from_cart(.true.,.false.)
696 call sc_loc_geom(.false.)
703 dc(j,i)=c(j,i+1)-c(j,i)
704 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
709 dc(j,i+nres)=c(j,i+nres)-c(j,i)
710 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
712 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
716 C Copy the coordinates to reference coordinates