1 subroutine readpdb(lprint)
2 C Read the PDB file and convert the peptide geometry into virtual-chain
6 include 'COMMON.CONTROL'
10 include 'COMMON.INTERACT'
11 include 'COMMON.IOUNITS'
13 include 'COMMON.NAMES'
14 include 'COMMON.SBRIDGE'
15 character*3 seq,atom,res
17 double precision sccor(3,50)
18 integer i,j,iii,ibeg,ishift,ishift1,ity,ires,ires_old
20 integer rescode,kkk,lll,icha,cou,kupa,iprzes
25 read (ipdbin,'(a80)',end=10) card
26 if (card(:3).eq.'END') then
28 else if (card(:3).eq.'TER') then
32 itype(ires_old-1)=ntyp1
35 c write (iout,*) "Chain ended",ires,ishift,ires_old
36 call sccenter(ires,iii,sccor)
38 C Fish out the ATOM cards.
39 if (index(card(1:4),'ATOM').gt.0) then
40 read (card(14:16),'(a3)') atom
41 if (atom.eq.'CA' .or. atom.eq.'CH3') then
42 C Calculate the CM of the preceding residue.
44 call sccenter(ires,iii,sccor)
47 c write (iout,'(a80)') card
48 read (card(23:26),*) ires
49 read (card(18:20),'(a3)') res
52 if (res.ne.'GLY' .and. res.ne. 'ACE') then
56 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
58 else if (ibeg.eq.2) then
60 ishift=-ires_old+ires-1
61 c write (iout,*) "New chain started",ires,ishift
65 c write (2,*) "ires",ires," ishift",ishift
66 if (res.eq.'ACE') then
69 itype(ires)=rescode(ires,res,0)
71 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
72 read(card(61:66),*) bfac(ires)
73 c write (iout,'(2i3,2x,a,3f8.3,5x,f8.3)')
74 c & ires,itype(ires),res,(c(j,ires),j=1,3),bfac(ires)
77 sccor(j,iii)=c(j,ires)
79 else if (atom.ne.'O '.and.atom(1:1).ne.'H' .and.
80 & atom(1:1).ne.'Q' .and. atom(1:2).ne.'1H' .and.
81 & atom(1:2).ne.'2H' .and. atom(1:2).ne.'3H' .and.
82 & atom.ne.'N ' .and. atom.ne.'C ' .and.
83 & atom.ne.'OXT' ) then
85 c write (iout,*) res,ires,iii,atom
86 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
87 c write (iout,'(3f8.3)') (sccor(j,iii),j=1,3)
91 10 write (iout,'(a,i5)') ' Nres: ',ires
92 C Calculate dummy residue coordinates inside the "chain" of a multichain
96 c write (iout,*) i,itype(i)
98 if (itype(i).eq.ntyp1) then
99 if (itype(i+1).eq.ntyp1) then
100 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
101 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
102 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
103 C if (unres_pdb) then
104 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
105 C call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
112 C c(j,i)=c(j,i-1)-1.9d0*e2(j)
116 dcj=(c(j,i-2)-c(j,i-3))/2.0
121 else !itype(i+1).eq.ntyp1
122 C if (unres_pdb) then
123 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
124 C call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
131 C c(j,i)=c(j,i+1)-1.9d0*e2(j)
135 dcj=(c(j,i+3)-c(j,i+2))/2.0
140 endif !itype(i+1).eq.ntyp1
141 endif !itype.eq.ntyp1
143 C Calculate the CM of the last side chain.
144 call sccenter(ires,iii,sccor)
147 if (itype(nres).ne.10) then
151 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
152 c(j,nres)=c(j,nres-1)+dcj
153 c(j,2*nres)=c(j,nres)
163 c(j,2*nres)=c(j,nres)
165 if (itype(1).eq.ntyp1) then
169 dcj=(c(j,4)-c(j,3))/2.0
174 C Calculate internal coordinates.
178 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
179 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
180 & (c(j,nres+ires),j=1,3)
183 call int_from_cart(.true.,.false.)
187 dc(j,i)=c(j,i+1)-c(j,i)
188 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
193 dc(j,i+nres)=c(j,i+nres)-c(j,i)
194 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
196 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
200 C Copy the coordinates to reference coordinates
204 cref(j,i+nres)=c(j,i+nres)
207 100 format ('Residue alpha-carbon coordinates ',
208 & ' centroid coordinates'/
209 1 ' ', 6X,'X',7X,'Y',7X,'Z',
210 & 12X,'X',7X,'Y',7X,'Z')
211 110 format (a,'(',i3,')',6f12.5)
216 c---------------------------------------------------------------------------
217 subroutine int_from_cart(lside,lprn)
220 include 'COMMON.LOCAL'
222 include 'COMMON.CHAIN'
223 include 'COMMON.INTERACT'
224 include 'COMMON.IOUNITS'
226 include 'COMMON.NAMES'
227 character*3 seq,atom,res
229 double precision sccor(3,50)
231 double precision dist,alpha,beta,di
236 & 'Internal coordinates calculated from crystal structure.'
238 write (iout,'(8a)') ' Res ',' dvb',' Theta',
239 & ' Phi',' Dsc_id',' Dsc',' Alpha',
242 write (iout,'(4a)') ' Res ',' dvb',' Theta',
248 c write (iout,*) i,i-1,(c(j,i),j=1,3),(c(j,i-1),j=1,3),dist(i,i-1)
249 if (itype(i-1).ne.ntyp1 .and. itype(i).ne.ntyp1 .and.
250 & (dist(i,i-1).lt.1.0D0 .or. dist(i,i-1).gt.6.0D0)) then
251 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
255 vbld_inv(i)=1.0d0/vbld(i)
256 theta(i+1)=alpha(i-1,i,i+1)
257 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
259 c if (itype(1).eq.ntyp1) then
261 c c(j,1)=c(j,2)+(c(j,3)-c(j,4))
264 c if (itype(nres).eq.ntyp1) then
266 c c(j,nres)=c(j,nres-1)+(c(j,nres-2)-c(j,nres-3))
272 c(j,maxres2)=0.5D0*(c(j,i-1)+c(j,i+1))
277 if (itype(i).ne.10) then
278 vbld_inv(i+nres)=1.0d0/di
280 vbld_inv(i+nres)=0.0d0
283 alph(i)=alpha(nres+i,i,maxres2)
284 omeg(i)=beta(nres+i,i,maxres2,i+1)
287 alph(i)=alpha(nres+i,i,maxres2)
288 omeg(i)=beta(nres+i,i,maxres2,i+1)
291 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
292 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),di,
293 & rad2deg*alph(i),rad2deg*omeg(i)
298 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
299 & rad2deg*theta(i),rad2deg*phi(i)
304 c---------------------------------------------------------------------------
305 subroutine sccenter(ires,nscat,sccor)
308 include 'COMMON.CHAIN'
309 integer ires,nscat,i,j
310 double precision sccor(3,50),sccmj
314 sccmj=sccmj+sccor(j,i)
316 dc(j,ires)=sccmj/nscat
320 c---------------------------------------------------------------------------
321 subroutine sc_loc_geom(lprn)
322 implicit real*8 (a-h,o-z)
324 include 'COMMON.LOCAL'
326 include 'COMMON.CHAIN'
327 include 'COMMON.INTERACT'
328 include 'COMMON.IOUNITS'
330 include 'COMMON.NAMES'
331 include 'COMMON.CONTROL'
332 include 'COMMON.SETUP'
333 double precision x_prime(3),y_prime(3),z_prime(3)
337 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
341 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
343 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
347 dc_norm(j,i+nres)=0.0d0
352 costtab(i+1) =dcos(theta(i+1))
353 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
354 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
355 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
356 cosfac2=0.5d0/(1.0d0+costtab(i+1))
357 cosfac=dsqrt(cosfac2)
358 sinfac2=0.5d0/(1.0d0-costtab(i+1))
359 sinfac=dsqrt(sinfac2)
361 if (it.ne.10 .and. itype(i).ne.ntyp1) then
363 C Compute the axes of tghe local cartesian coordinates system; store in
364 c x_prime, y_prime and z_prime
372 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
373 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
375 c write (iout,*) "x_prime",(x_prime(j),j=1,3)
376 c write (iout,*) "y_prime",(y_prime(j),j=1,3)
377 call vecpr(x_prime,y_prime,z_prime)
378 c write (iout,*) "z_prime",(z_prime(j),j=1,3)
380 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
381 C to local coordinate system. Store in xx, yy, zz.
387 xx = xx + x_prime(j)*dc_norm(j,i+nres)
388 yy = yy + y_prime(j)*dc_norm(j,i+nres)
389 zz = zz + z_prime(j)*dc_norm(j,i+nres)
402 write (iout,*) "xxref,yyref,zzref"
405 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),yyref(i),
411 c---------------------------------------------------------------------------
412 subroutine bond_regular
413 implicit real*8 (a-h,o-z)
416 include 'COMMON.LOCAL'
417 include 'COMMON.CALC'
418 include 'COMMON.INTERACT'
419 include 'COMMON.CHAIN'
422 vbld_inv(i+1)=1.0d0/vbld(i+1)
423 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
424 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
425 c print *,vbld(i+1),vbld(i+1+nres)
429 c---------------------------------------------------------------------------
430 subroutine readpdb_template(k)
431 C Read the PDB file for read_constr_homology with read2sigma
432 C and convert the peptide geometry into virtual-chain geometry.
433 implicit real*8 (a-h,o-z)
435 include 'COMMON.LOCAL'
437 include 'COMMON.CHAIN'
438 include 'COMMON.INTERACT'
439 include 'COMMON.IOUNITS'
441 include 'COMMON.NAMES'
442 include 'COMMON.CONTROL'
443 include 'COMMON.SETUP'
444 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
445 logical lprn /.false./,fail
446 double precision e1(3),e2(3),e3(3)
447 double precision dcj,efree_temp
451 double precision sccor(3,20)
452 integer rescode,iterter(maxres)
459 c write (2,*) "UNRES_PDB",unres_pdb
467 read (ipdbin,'(a80)',end=10) card
468 if (card(:3).eq.'END') then
470 else if (card(:3).eq.'TER') then
473 itype(ires_old-1)=ntyp1
474 iterter(ires_old-1)=1
475 itype(ires_old)=ntyp1
478 c write (iout,*) "Chain ended",ires,ishift,ires_old
481 dc(j,ires)=sccor(j,iii)
484 call sccenter(ires,iii,sccor)
487 C Fish out the ATOM cards.
488 if (index(card(1:4),'ATOM').gt.0) then
489 read (card(12:16),*) atom
490 c write (iout,*) "! ",atom," !",ires
491 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
492 read (card(23:26),*) ires
493 read (card(18:20),'(a3)') res
494 c write (iout,*) "ires",ires,ires-ishift+ishift1,
495 c & " ires_old",ires_old
496 c write (iout,*) "ishift",ishift," ishift1",ishift1
497 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
498 if (ires-ishift+ishift1.ne.ires_old) then
499 C Calculate the CM of the preceding residue.
503 dc(j,ires)=sccor(j,iii)
506 call sccenter(ires_old,iii,sccor)
511 if (res.eq.'Cl-' .or. res.eq.'Na+') then
514 else if (ibeg.eq.1) then
515 c write (iout,*) "BEG ires",ires
517 if (res.ne.'GLY' .and. res.ne. 'ACE') then
521 ires=ires-ishift+ishift1
523 c write (iout,*) "ishift",ishift," ires",ires,
524 c & " ires_old",ires_old
525 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
527 else if (ibeg.eq.2) then
529 ishift=-ires_old+ires-1
531 c write (iout,*) "New chain started",ires,ishift
534 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
535 ires=ires-ishift+ishift1
538 if (res.eq.'ACE' .or. res.eq.'NHE') then
541 itype(ires)=rescode(ires,res,0)
544 ires=ires-ishift+ishift1
546 c write (iout,*) "ires_old",ires_old," ires",ires
547 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
550 c write (2,*) "ires",ires," res ",res," ity",ity
551 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
552 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
553 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
554 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
556 write (iout,'(2i3,2x,a,3f8.3)')
557 & ires,itype(ires),res,(c(j,ires),j=1,3)
561 sccor(j,iii)=c(j,ires)
563 if (ishift.ne.0) then
564 ires_ca=ires+ishift-ishift1
568 c write (*,*) card(23:27),ires,itype(ires)
569 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
570 & atom.ne.'N' .and. atom.ne.'C' .and.
571 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
572 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
573 c write (iout,*) "sidechain ",atom
575 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
579 10 write (iout,'(a,i5)') ' Nres: ',ires
580 C Calculate dummy residue coordinates inside the "chain" of a multichain
584 c write (iout,*) i,itype(i),itype(i+1)
585 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
586 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
587 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
588 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
589 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
591 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
592 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
599 c(j,i)=c(j,i-1)-1.9d0*e2(j)
603 dcj=(c(j,i-2)-c(j,i-3))/2.0
604 if (dcj.eq.0) dcj=1.23591524223
609 else !itype(i+1).eq.ntyp1
611 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
612 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
619 c(j,i)=c(j,i+1)-1.9d0*e2(j)
623 dcj=(c(j,i+3)-c(j,i+2))/2.0
624 if (dcj.eq.0) dcj=1.23591524223
629 endif !itype(i+1).eq.ntyp1
630 endif !itype.eq.ntyp1
632 C Calculate the CM of the last side chain.
635 dc(j,ires)=sccor(j,iii)
638 call sccenter(ires,iii,sccor)
642 if (itype(nres).ne.10) then
646 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
647 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
654 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
658 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
659 if (dcj.eq.0) dcj=1.23591524223
660 c(j,nres)=c(j,nres-1)+dcj
661 c(j,2*nres)=c(j,nres)
672 c(j,2*nres)=c(j,nres)
674 if (itype(1).eq.ntyp1) then
678 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
679 call refsys(2,3,4,e1,e2,e3,fail)
686 c(j,1)=c(j,2)-1.9d0*e2(j)
690 dcj=(c(j,4)-c(j,3))/2.0
696 C Copy the coordinates to reference coordinates
702 C Calculate internal coordinates.
703 if (out_template_coord) then
705 & "Cartesian coordinates of the reference structure"
706 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
707 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
709 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
710 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
711 & (c(j,ires+nres),j=1,3)
714 C Calculate internal coordinates.
715 c call int_from_cart1(.false.)
716 call int_from_cart(.true.,.true.)
717 call sc_loc_geom(.true.)
724 dc(j,i)=c(j,i+1)-c(j,i)
725 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
730 dc(j,i+nres)=c(j,i+nres)-c(j,i)
731 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
733 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
739 cref(j,i+nres)=c(j,i+nres)