2 C Read the PDB file and convert the peptide geometry into virtual-chain
4 implicit real*8 (a-h,o-z)
6 include 'DIMENSIONS.ZSCOPT'
7 include 'DIMENSIONS.FREE'
11 include 'COMMON.CHAIN'
12 include 'COMMON.INTERACT'
13 include 'COMMON.IOUNITS'
15 include 'COMMON.NAMES'
16 include 'COMMON.CONTROL'
17 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
18 logical lprn /.false./,fail
19 double precision e1(3),e2(3),e3(3)
20 double precision dcj,efree_temp
24 double precision sccor(3,20)
30 c write (2,*) "UNRES_PDB",unres_pdb
38 read (ipdbin,'(a80)',end=10) card
39 c 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 crc----------------------------------------
52 crc to be corrected !!!
53 bfrag(3,nbfrag)=bfrag(1,nbfrag)
54 bfrag(4,nbfrag)=bfrag(2,nbfrag)
55 crc----------------------------------------
57 if (card(:3).eq.'END' .or. card(:3).eq.'TER') goto 10
59 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
60 C Fish out the ATOM cards.
61 if (index(card(1:4),'ATOM').gt.0) then
62 read (card(12:16),*) atom
63 c write (iout,*) "! ",atom," !",ires
64 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
65 read (card(23:26),*) ires
66 read (card(18:20),'(a3)') res
67 c write (iout,*) "ires",ires,ires-ishift+ishift1,
68 c & " ires_old",ires_old
69 c write (iout,*) "ishift",ishift," ishift1",ishift1
70 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
71 if (ires-ishift+ishift1.ne.ires_old) then
72 C Calculate the CM of the preceding residue.
73 c if (ibeg.eq.0) call sccenter(ires,iii,sccor)
75 c write (iout,*) "Calculating sidechain center iii",iii
78 dc(j,ires)=sccor(j,iii)
81 call sccenter(ires_old,iii,sccor)
86 if (res.eq.'Cl-' .or. res.eq.'Na+') then
89 else if (ibeg.eq.1) then
90 c write (iout,*) "BEG ires",ires
92 if (res.ne.'GLY' .and. res.ne. 'ACE') then
96 ires=ires-ishift+ishift1
98 c write (iout,*) "ishift",ishift," ires",ires,
99 c & " ires_old",ires_old
102 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
103 ires=ires-ishift+ishift1
106 if (res.eq.'ACE' .or. res.eq.'NHE') then
109 itype(ires)=rescode(ires,res,0)
112 ires=ires-ishift+ishift1
114 c write (iout,*) "ires_old",ires_old," ires",ires
115 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
118 c write (2,*) "ires",ires," res ",res," ity",ity
119 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
120 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
121 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
122 c write (iout,*) "backbone ",atom
124 write (iout,'(2i3,2x,a,3f8.3)')
125 & ires,itype(ires),res,(c(j,ires),j=1,3)
129 sccor(j,iii)=c(j,ires)
131 if (ishift.ne.0) then
132 ires_ca=ires+ishift-ishift1
136 c write (*,*) card(23:27),ires,itype(ires)
137 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
138 & atom.ne.'N' .and. atom.ne.'C' .and.
139 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
140 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
141 c write (iout,*) "sidechain ",atom
143 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
149 write (iout,'(a,i5)') ' Number of residues found: ',ires
151 if (ires.eq.0) return
152 C Calculate the CM of the last side chain.
156 dc(j,ires)=sccor(j,iii)
159 call sccenter(ires,iii,sccor)
165 if (itype(nres).ne.10) then
169 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
170 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
177 c(j,nres)=c(j,nres-1)-3.8d0*e2(j)
181 dcj=c(j,nres-2)-c(j,nres-3)
182 c(j,nres)=c(j,nres-1)+dcj
183 c(j,2*nres)=c(j,nres)
194 c(j,2*nres)=c(j,nres)
196 if (itype(1).eq.ntyp1) then
200 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
201 call refsys(2,3,4,e1,e2,e3,fail)
208 c(j,1)=c(j,2)-3.8d0*e2(j)
218 C Copy the coordinates to reference coordinates
224 C Calculate internal coordinates.
227 & "Cartesian coordinates of the reference structure"
228 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
229 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
231 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
232 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
233 & (c(j,ires+nres),j=1,3)
236 C Calculate internal coordinates.
238 & "Backbone and SC coordinates as read from the PDB"
240 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
241 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
242 & (c(j,nres+ires),j=1,3)
244 call int_from_cart(.true.,.false.)
245 call sc_loc_geom(.false.)
252 dc(j,i)=c(j,i+1)-c(j,i)
253 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
258 dc(j,i+nres)=c(j,i+nres)-c(j,i)
259 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
261 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
265 C Copy the coordinates to reference coordinates
275 bfrag(i,j)=bfrag(i,j)-ishift
281 hfrag(i,j)=hfrag(i,j)-ishift
287 c---------------------------------------------------------------------------
288 subroutine int_from_cart(lside,lprn)
289 implicit real*8 (a-h,o-z)
291 include 'DIMENSIONS.ZSCOPT'
292 include 'COMMON.LOCAL'
294 include 'COMMON.CHAIN'
295 include 'COMMON.INTERACT'
296 include 'COMMON.IOUNITS'
298 include 'COMMON.NAMES'
299 include 'COMMON.CONTROL'
303 dimension sccor(3,20)
308 & 'Internal coordinates calculated from crystal structure.'
310 write (iout,'(8a)') ' Res ',' dvb',' Theta',
311 & ' Gamma',' Dsc_id',' Dsc',' Alpha',
314 write (iout,'(4a)') ' Res ',' dvb',' Theta',
320 if (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0) then
321 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
324 vbld(i+1)=dist(i,i+1)
325 vbld_inv(i+1)=1.0d0/vbld(i+1)
326 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
327 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
329 c if (unres_pdb) then
330 c if (itype(1).eq.ntyp1) then
331 c theta(3)=90.0d0*deg2rad
332 c phi(4)=180.0d0*deg2rad
334 c vbld_inv(2)=1.0d0/vbld(2)
336 c if (itype(nres).eq.ntyp1) then
337 c theta(nres)=90.0d0*deg2rad
338 c phi(nres)=180.0d0*deg2rad
340 c vbld_inv(nres)=1.0d0/vbld(2)
346 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
347 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
351 C 10/03/12 Adam: Correction for zero SC-SC bond length
352 if (itype(i).ne.10 .and. itype(i).ne.ntyp1. and. di.eq.0.0d0)
355 if (itype(i).ne.10) then
356 vbld_inv(i+nres)=1.0d0/di
358 vbld_inv(i+nres)=0.0d0
361 alph(i)=alpha(nres+i,i,maxres2)
362 omeg(i)=beta(nres+i,i,maxres2,i+1)
365 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
366 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
367 & rad2deg*alph(i),rad2deg*omeg(i)
372 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
373 & rad2deg*theta(i),rad2deg*phi(i)
378 c-------------------------------------------------------------------------------
379 subroutine sc_loc_geom(lprn)
380 implicit real*8 (a-h,o-z)
382 include 'DIMENSIONS.ZSCOPT'
383 include 'COMMON.LOCAL'
385 include 'COMMON.CHAIN'
386 include 'COMMON.INTERACT'
387 include 'COMMON.IOUNITS'
389 include 'COMMON.NAMES'
390 include 'COMMON.CONTROL'
391 double precision x_prime(3),y_prime(3),z_prime(3)
395 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
399 if (itype(i).ne.10) then
401 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
405 dc_norm(j,i+nres)=0.0d0
410 costtab(i+1) =dcos(theta(i+1))
411 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
412 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
413 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
414 cosfac2=0.5d0/(1.0d0+costtab(i+1))
415 cosfac=dsqrt(cosfac2)
416 sinfac2=0.5d0/(1.0d0-costtab(i+1))
417 sinfac=dsqrt(sinfac2)
421 C Compute the axes of tghe local cartesian coordinates system; store in
422 c x_prime, y_prime and z_prime
430 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
431 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
433 call vecpr(x_prime,y_prime,z_prime)
435 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
436 C to local coordinate system. Store in xx, yy, zz.
442 xx = xx + x_prime(j)*dc_norm(j,i+nres)
443 yy = yy + y_prime(j)*dc_norm(j,i+nres)
444 zz = zz + z_prime(j)*dc_norm(j,i+nres)
459 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),
465 c---------------------------------------------------------------------------
466 subroutine sccenter(ires,nscat,sccor)
467 implicit real*8 (a-h,o-z)
469 include 'COMMON.CHAIN'
470 dimension sccor(3,20)
474 sccmj=sccmj+sccor(j,i)
476 dc(j,ires)=sccmj/nscat
480 c---------------------------------------------------------------------------
481 subroutine bond_regular
482 implicit real*8 (a-h,o-z)
485 include 'COMMON.LOCAL'
486 include 'COMMON.CALC'
487 include 'COMMON.INTERACT'
488 include 'COMMON.CHAIN'
491 vbld_inv(i+1)=1.0d0/vbld(i+1)
492 vbld(i+1+nres)=dsc(itype(i+1))
493 vbld_inv(i+1+nres)=dsc_inv(itype(i+1))
494 c print *,vbld(i+1),vbld(i+1+nres)
498 subroutine readpdb_template(k)
499 C Read the PDB file with gaps for read_constr_homology with read2sigma
500 C and convert the peptide geometry into virtual-chain geometry.
501 implicit real*8 (a-h,o-z)
503 include 'DIMENSIONS.ZSCOPT'
504 include 'DIMENSIONS.FREE'
505 include 'COMMON.LOCAL'
507 include 'COMMON.CHAIN'
508 include 'COMMON.INTERACT'
509 include 'COMMON.IOUNITS'
511 include 'COMMON.NAMES'
512 include 'COMMON.CONTROL'
513 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
514 logical lprn /.false./,fail
515 double precision e1(3),e2(3),e3(3)
516 double precision dcj,efree_temp
520 double precision sccor(3,20)
526 c write (2,*) "UNRES_PDB",unres_pdb
534 read (ipdbin,'(a80)',end=10) card
535 c write (iout,'(a)') card
536 if (card(:3).eq.'END' .or. card(:3).eq.'TER') goto 10
537 C Fish out the ATOM cards.
538 if (index(card(1:4),'ATOM').gt.0) then
539 read (card(12:16),*) atom
540 c write (iout,*) "! ",atom," !",ires
541 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
542 read (card(23:26),*) ires
543 read (card(18:20),'(a3)') res
544 c write (iout,*) "ires",ires,ires-ishift+ishift1,
545 c & " ires_old",ires_old
546 c write (iout,*) "ishift",ishift," ishift1",ishift1
547 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
548 if (ires-ishift+ishift1.ne.ires_old) then
549 C Calculate the CM of the preceding residue.
550 c if (ibeg.eq.0) call sccenter(ires,iii,sccor)
552 c write (iout,*) "Calculating sidechain center iii",iii
555 dc(j,ires)=sccor(j,iii)
558 call sccenter(ires_old,iii,sccor)
563 if (res.eq.'Cl-' .or. res.eq.'Na+') then
566 else if (ibeg.eq.1) then
567 c write (iout,*) "BEG ires",ires
569 if (res.ne.'GLY' .and. res.ne. 'ACE') then
573 ires=ires-ishift+ishift1
575 c write (iout,*) "ishift",ishift," ires",ires,
576 c & " ires_old",ires_old
579 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
580 ires=ires-ishift+ishift1
583 if (res.eq.'ACE' .or. res.eq.'NHE') then
586 itype(ires)=rescode(ires,res,0)
589 ires=ires-ishift+ishift1
591 c write (iout,*) "ires_old",ires_old," ires",ires
592 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
595 c write (2,*) "ires",ires," res ",res," ity",ity
596 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
597 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
598 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
599 c write (iout,*) "backbone ",atom
601 write (iout,'(2i3,2x,a,3f8.3)')
602 & ires,itype(ires),res,(c(j,ires),j=1,3)
606 sccor(j,iii)=c(j,ires)
608 if (ishift.ne.0) then
609 ires_ca=ires+ishift-ishift1
613 c write (*,*) card(23:27),ires,itype(ires)
614 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
615 & atom.ne.'N' .and. atom.ne.'C' .and.
616 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
617 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
618 c write (iout,*) "sidechain ",atom
620 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
626 write (iout,'(a,i5)') ' Number of residues found: ',ires
628 if (ires.eq.0) return
629 C Calculate the CM of the last side chain.
633 dc(j,ires)=sccor(j,iii)
636 call sccenter(ires,iii,sccor)
642 if (itype(nres).ne.10) then
646 dcj=c(j,nres-2)-c(j,nres-3)
647 c(j,nres)=c(j,nres-1)+dcj
648 c(j,2*nres)=c(j,nres)
658 c(j,2*nres)=c(j,nres)
660 if (itype(1).eq.ntyp1) then
664 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
665 call refsys(2,3,4,e1,e2,e3,fail)
672 c(j,1)=c(j,2)-3.8d0*e2(j)
682 C Calculate internal coordinates.
685 & "Cartesian coordinates of the reference structure"
686 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
687 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
689 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
690 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
691 & (c(j,ires+nres),j=1,3)
694 C Calculate internal coordinates.
696 & "Backbone and SC coordinates as read from the PDB"
698 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
699 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
700 & (c(j,nres+ires),j=1,3)
702 call int_from_cart(.true.,.false.)
703 call sc_loc_geom(.false.)
710 dc(j,i)=c(j,i+1)-c(j,i)
711 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
716 dc(j,i+nres)=c(j,i+nres)-c(j,i)
717 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
719 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
723 C Copy the coordinates to reference coordinates