2 C Read the PDB file and convert the peptide geometry into virtual-chain
4 implicit real*8 (a-h,o-z)
9 include 'COMMON.INTERACT'
10 include 'COMMON.IOUNITS'
12 include 'COMMON.NAMES'
13 include 'COMMON.CONTROL'
14 include 'COMMON.DISTFIT'
15 include 'COMMON.SETUP'
16 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
18 logical lprn /.true./,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
39 read (ipdbin,'(a80)',end=10) card
40 c write (iout,'(a)') card
41 if (card(:5).eq.'HELIX') then
44 read(card(22:25),*) hfrag(1,nhfrag)
45 read(card(34:37),*) hfrag(2,nhfrag)
47 if (card(:5).eq.'SHEET') then
50 read(card(24:26),*) bfrag(1,nbfrag)
51 read(card(35:37),*) bfrag(2,nbfrag)
52 crc----------------------------------------
53 crc to be corrected !!!
54 bfrag(3,nbfrag)=bfrag(1,nbfrag)
55 bfrag(4,nbfrag)=bfrag(2,nbfrag)
56 crc----------------------------------------
58 if (card(:3).eq.'END') then
60 else if (card(:3).eq.'TER') then
66 c 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 C Fish out the ATOM cards.
79 if (index(card(1:4),'ATOM').gt.0) then
80 read (card(12:16),*) atom
81 c write (iout,*) "! ",atom," !",ires
82 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
83 read (card(23:26),*) ires
84 read (card(18:20),'(a3)') res
85 c write (iout,*) "ires",ires,ires-ishift+ishift1,
86 c & " ires_old",ires_old
87 c write (iout,*) "ishift",ishift," ishift1",ishift1
88 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
89 if (ires-ishift+ishift1.ne.ires_old) then
90 C Calculate the CM of the preceding residue.
91 c if (ibeg.eq.0) call sccenter(ires,iii,sccor)
93 c write (iout,*) "Calculating sidechain center iii",iii
96 dc(j,ires+nres)=sccor(j,iii)
99 call sccenter(ires_old,iii,sccor)
104 if (res.eq.'Cl-' .or. res.eq.'Na+') then
107 else if (ibeg.eq.1) then
108 c write (iout,*) "BEG ires",ires
110 if (res.ne.'GLY' .and. res.ne. 'ACE') then
114 ires=ires-ishift+ishift1
116 c write (iout,*) "ishift",ishift," ires",ires,
117 c & " ires_old",ires_old
119 else if (ibeg.eq.2) then
121 c ishift=-ires_old+ires-1
123 c write (iout,*) "New chain started",ires,ishift,ishift1,"!"
124 ires=ires-ishift+ishift1
128 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
129 ires=ires-ishift+ishift1
132 if (res.eq.'ACE' .or. res.eq.'NHE') then
135 itype(ires)=rescode(ires,res,0)
138 ires=ires-ishift+ishift1
140 c write (iout,*) "ires_old",ires_old," ires",ires
141 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
144 c write (2,*) "ires",ires," res ",res," ity",ity
145 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
146 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
147 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
148 c write (iout,*) "backbone ",atom
150 write (iout,'(2i3,2x,a,3f8.3)')
151 & ires,itype(ires),res,(c(j,ires),j=1,3)
155 sccor(j,iii)=c(j,ires)
157 c write (*,*) card(23:27),ires,itype(ires)
158 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
159 & atom.ne.'N' .and. atom.ne.'C' .and.
160 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
161 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
162 c write (iout,*) "sidechain ",atom
164 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
168 10 write (iout,'(a,i5)') ' Number of residues found: ',ires
169 if (ires.eq.0) return
170 C Calculate dummy residue coordinates inside the "chain" of a multichain
174 c write (iout,*) i,itype(i)
175 if (itype(i).eq.ntyp1) then
176 c write (iout,*) "dummy",i,itype(i)
178 c(j,i)=((c(j,i-1)+c(j,i+1))/2+2*c(j,i-1)-c(j,i-2))/2
179 c c(j,i)=(c(j,i-1)+c(j,i+1))/2
184 C Calculate the CM of the last side chain.
188 dc(j,ires)=sccor(j,iii)
191 call sccenter(ires,iii,sccor)
197 if (itype(nres).ne.10) then
201 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
202 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
209 c(j,nres)=c(j,nres-1)-3.8d0*e2(j)
213 dcj=c(j,nres-2)-c(j,nres-3)
214 c(j,nres)=c(j,nres-1)+dcj
215 c(j,2*nres)=c(j,nres)
226 c(j,2*nres)=c(j,nres)
228 if (itype(1).eq.ntyp1) then
232 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
233 call refsys(2,3,4,e1,e2,e3,fail)
240 c(j,1)=c(j,2)-3.8d0*e2(j)
250 C Copy the coordinates to reference coordinates
256 C Calculate internal coordinates.
259 & "Cartesian coordinates of the reference structure"
260 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
261 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
263 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
264 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
265 & (c(j,ires+nres),j=1,3)
268 C Calculate internal coordinates.
269 if(me.eq.king.or..not.out1file)then
271 & "Backbone and SC coordinates as read from the PDB"
273 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
274 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
275 & (c(j,nres+ires),j=1,3)
278 call int_from_cart(.true.,.false.)
279 call sc_loc_geom(.true.)
280 c wczesbiej bylo false
287 dc(j,i)=c(j,i+1)-c(j,i)
288 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
293 dc(j,i+nres)=c(j,i+nres)-c(j,i)
294 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
296 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
300 C Copy the coordinates to reference coordinates
301 C Splits to single chain if occurs
305 c cref(j,i,cou)=c(j,i)
314 cc write (iout,*) "spraw lancuchy",(c(j,i),j=1,3)
316 if ((itype(i-1).eq.ntyp1).and.(i.gt.2)) then
319 c write (iout,*) "spraw lancuchy",(c(j,i),j=1,3)
325 cref(j,i+nres,cou)=c(j,i+nres)
327 chain_rep(j,lll,kkk)=c(j,i)
328 chain_rep(j,lll+nres,kkk)=c(j,i+nres)
332 write (iout,*) chain_length
333 if (chain_length.eq.0) chain_length=nres
335 chain_rep(j,chain_length,symetr)=chain_rep(j,chain_length,1)
336 chain_rep(j,chain_length+nres,symetr)
337 &=chain_rep(j,chain_length+nres,1)
340 c write (iout,*) "spraw lancuchy",chain_length,symetr
342 c do kkk=1,chain_length
343 c write (iout,*) itype(kkk),(chain_rep(j,kkk,i), j=1,3)
347 C makes copy of chains
348 write (iout,*) "symetr", symetr
350 if (symetr.gt.1) then
357 write(iout,*) (tabperm(i,kkk),kkk=1,4)
363 c write (iout,*) i,icha
364 do lll=1,chain_length
366 if (cou.le.nres) then
368 kupa=mod(lll,chain_length)
369 iprzes=(kkk-1)*chain_length+lll
370 if (kupa.eq.0) kupa=chain_length
371 c write (iout,*) "kupa", kupa
372 cref(j,iprzes,i)=chain_rep(j,kupa,icha)
373 cref(j,iprzes+nres,i)=chain_rep(j,kupa+nres,icha)
380 C-koniec robienia kopii
383 write (iout,*) "nowa struktura", nperm
385 write (iout,110) restyp(itype(i)),i,cref(1,i,kkk),
387 &cref(3,i,kkk),cref(1,nres+i,kkk),
388 &cref(2,nres+i,kkk),cref(3,nres+i,kkk)
390 100 format (//' alpha-carbon coordinates ',
391 & ' centroid coordinates'/
392 1 ' ', 6X,'X',11X,'Y',11X,'Z',
393 & 10X,'X',11X,'Y',11X,'Z')
394 110 format (a,'(',i3,')',6f12.5)
400 bfrag(i,j)=bfrag(i,j)-ishift
406 hfrag(i,j)=hfrag(i,j)-ishift
412 c---------------------------------------------------------------------------
413 subroutine int_from_cart(lside,lprn)
414 implicit real*8 (a-h,o-z)
419 include 'COMMON.LOCAL'
421 include 'COMMON.CHAIN'
422 include 'COMMON.INTERACT'
423 include 'COMMON.IOUNITS'
425 include 'COMMON.NAMES'
426 include 'COMMON.CONTROL'
427 include 'COMMON.SETUP'
431 dimension sccor(3,20)
434 if(me.eq.king.or..not.out1file)then
437 & 'Internal coordinates calculated from crystal structure.'
439 write (iout,'(8a)') ' Res ',' dvb',' Theta',
440 & ' Gamma',' Dsc_id',' Dsc',' Alpha',
443 write (iout,'(4a)') ' Res ',' dvb',' Theta',
450 if (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0) then
451 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
454 vbld(i+1)=dist(i,i+1)
455 vbld_inv(i+1)=1.0d0/vbld(i+1)
456 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
457 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
459 c if (unres_pdb) then
460 c if (itype(1).eq.21) then
461 c theta(3)=90.0d0*deg2rad
462 c phi(4)=180.0d0*deg2rad
464 c vbld_inv(2)=1.0d0/vbld(2)
466 c if (itype(nres).eq.21) then
467 c theta(nres)=90.0d0*deg2rad
468 c phi(nres)=180.0d0*deg2rad
470 c vbld_inv(nres)=1.0d0/vbld(2)
476 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
477 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
481 C 10/03/12 Adam: Correction for zero SC-SC bond length
482 if (itype(i).ne.10 .and. itype(i).ne.ntyp1. and. di.eq.0.0d0)
485 if (itype(i).ne.10) then
486 vbld_inv(i+nres)=1.0d0/di
488 vbld_inv(i+nres)=0.0d0
491 alph(i)=alpha(nres+i,i,maxres2)
492 omeg(i)=beta(nres+i,i,maxres2,i+1)
494 if(me.eq.king.or..not.out1file)then
496 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
497 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
498 & rad2deg*alph(i),rad2deg*omeg(i)
504 if(me.eq.king.or..not.out1file)
505 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
506 & rad2deg*theta(i),rad2deg*phi(i)
511 c-------------------------------------------------------------------------------
512 subroutine sc_loc_geom(lprn)
513 implicit real*8 (a-h,o-z)
518 include 'COMMON.LOCAL'
520 include 'COMMON.CHAIN'
521 include 'COMMON.INTERACT'
522 include 'COMMON.IOUNITS'
524 include 'COMMON.NAMES'
525 include 'COMMON.CONTROL'
526 include 'COMMON.SETUP'
527 double precision x_prime(3),y_prime(3),z_prime(3)
531 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
535 if (itype(i).ne.10) then
537 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
541 dc_norm(j,i+nres)=0.0d0
546 costtab(i+1) =dcos(theta(i+1))
547 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
548 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
549 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
550 cosfac2=0.5d0/(1.0d0+costtab(i+1))
551 cosfac=dsqrt(cosfac2)
552 sinfac2=0.5d0/(1.0d0-costtab(i+1))
553 sinfac=dsqrt(sinfac2)
557 C Compute the axes of tghe local cartesian coordinates system; store in
558 c x_prime, y_prime and z_prime
566 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
567 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
569 call vecpr(x_prime,y_prime,z_prime)
571 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
572 C to local coordinate system. Store in xx, yy, zz.
578 xx = xx + x_prime(j)*dc_norm(j,i+nres)
579 yy = yy + y_prime(j)*dc_norm(j,i+nres)
580 zz = zz + z_prime(j)*dc_norm(j,i+nres)
595 if(me.eq.king.or..not.out1file)
596 & write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),
602 c---------------------------------------------------------------------------
603 subroutine sccenter(ires,nscat,sccor)
604 implicit real*8 (a-h,o-z)
606 include 'COMMON.CHAIN'
607 dimension sccor(3,20)
611 sccmj=sccmj+sccor(j,i)
613 dc(j,ires)=sccmj/nscat
617 c---------------------------------------------------------------------------
618 subroutine bond_regular
619 implicit real*8 (a-h,o-z)
622 include 'COMMON.LOCAL'
623 include 'COMMON.CALC'
624 include 'COMMON.INTERACT'
625 include 'COMMON.CHAIN'
628 vbld_inv(i+1)=1.0d0/vbld(i+1)
629 vbld(i+1+nres)=dsc(itype(i+1))
630 vbld_inv(i+1+nres)=dsc_inv(itype(i+1))
631 c print *,vbld(i+1),vbld(i+1+nres)