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 character*3 seq,atom,res
19 double precision e1(3),e2(3),e3(3)
27 read (ipdbin,'(a80)',end=10) card
28 if (card(:5).eq.'HELIX') then
31 read(card(22:25),*) hfrag(1,nhfrag)
32 read(card(34:37),*) hfrag(2,nhfrag)
34 if (card(:5).eq.'SHEET') then
37 read(card(24:26),*) bfrag(1,nbfrag)
38 read(card(35:37),*) bfrag(2,nbfrag)
39 crc----------------------------------------
40 crc to be corrected !!!
41 bfrag(3,nbfrag)=bfrag(1,nbfrag)
42 bfrag(4,nbfrag)=bfrag(2,nbfrag)
43 crc----------------------------------------
45 if (card(:3).eq.'END') then
47 else if (card(:3).eq.'TER') then
50 itype(ires_old-1)=ntyp1
53 write (iout,*) "Chain ended",ires,ishift,ires_old
56 dc(j,ires)=sccor(j,iii)
59 call sccenter(ires,iii,sccor)
62 C Fish out the ATOM cards.
63 if (index(card(1:4),'ATOM').gt.0) then
64 read (card(14:16),'(a3)') atom
65 if (atom.eq.'CA' .or. atom.eq.'CH3') then
66 C Calculate the CM of the preceding residue.
70 dc(j,ires+nres)=sccor(j,iii)
73 call sccenter(ires,iii,sccor)
77 c write (iout,'(a80)') card
78 read (card(24:26),*) ires
79 read (card(18:20),'(a3)') res
82 if (res.ne.'GLY' .and. res.ne. 'ACE') then
86 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
88 else if (ibeg.eq.2) then
90 ishift=-ires_old+ires-1
91 c write (iout,*) "New chain started",ires,ishift
95 c write (2,*) "ires",ires," ishift",ishift
96 if (res.eq.'ACE') then
99 itype(ires)=rescode(ires,res,0)
101 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
102 if(me.eq.king.or..not.out1file)
103 & write (iout,'(2i3,2x,a,3f8.3)')
104 & ires,itype(ires),res,(c(j,ires),j=1,3)
107 sccor(j,iii)=c(j,ires)
109 else if (atom.ne.'O '.and.atom(1:1).ne.'H' .and.
110 & atom.ne.'N ' .and. atom.ne.'C ') then
112 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
116 10 if(me.eq.king.or..not.out1file)
117 & write (iout,'(a,i5)') ' Nres: ',ires
118 C Calculate dummy residue coordinates inside the "chain" of a multichain
122 write (iout,*) i,itype(i),itype(i+1)
123 if (itype(i).eq.ntyp1) then
124 if (itype(i+1).eq.ntyp1) then
125 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
126 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
127 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
129 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
130 print *,i,'tu dochodze'
131 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
139 c(j,i)=c(j,i-1)-1.9d0*e2(j)
143 dcj=(c(j,i-2)-c(j,i-3))/2.0
148 else !itype(i+1).eq.ntyp1
150 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
151 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
158 c(j,i)=c(j,i+1)-1.9d0*e2(j)
162 dcj=(c(j,i+3)-c(j,i+2))/2.0
167 endif !itype(i+1).eq.ntyp1
168 endif !itype.eq.ntyp1
170 C Calculate the CM of the last side chain.
173 dc(j,ires)=sccor(j,iii)
176 call sccenter(ires,iii,sccor)
180 if (itype(nres).ne.10) then
184 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
185 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
192 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
196 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
197 c(j,nres)=c(j,nres-1)+dcj
198 c(j,2*nres)=c(j,nres)
209 c(j,2*nres)=c(j,nres)
211 if (itype(1).eq.ntyp1) then
215 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
216 call refsys(2,3,4,e1,e2,e3,fail)
223 c(j,1)=c(j,2)-1.9d0*e2(j)
227 dcj=(c(j,4)-c(j,3))/2.0
233 C Calculate internal coordinates.
234 if(me.eq.king.or..not.out1file)then
236 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
237 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
238 & (c(j,nres+ires),j=1,3)
241 call int_from_cart(.true.,.false.)
242 call sc_loc_geom(.true.)
249 dc(j,i)=c(j,i+1)-c(j,i)
250 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
255 dc(j,i+nres)=c(j,i+nres)-c(j,i)
256 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
258 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
262 C Copy the coordinates to reference coordinates
263 C Splits to single chain if occurs
269 cc write (iout,*) "spraw lancuchy",(c(j,i),j=1,3)
271 if ((itype(i-1).eq.ntyp1).and.(i.gt.2)) then
274 c write (iout,*) "spraw lancuchy",(c(j,i),j=1,3)
280 cref(j,i+nres,cou)=c(j,i+nres)
282 chain_rep(j,lll,kkk)=c(j,i)
283 chain_rep(j,lll+nres,kkk)=c(j,i+nres)
287 write (iout,*) chain_length
288 if (chain_length.eq.0) chain_length=nres
290 chain_rep(j,chain_length,symetr)=chain_rep(j,chain_length,1)
291 chain_rep(j,chain_length+nres,symetr)
292 &=chain_rep(j,chain_length+nres,1)
295 c write (iout,*) "spraw lancuchy",chain_length,symetr
297 c do kkk=1,chain_length
298 c write (iout,*) itype(kkk),(chain_rep(j,kkk,i), j=1,3)
302 C makes copy of chains
303 write (iout,*) "symetr", symetr
305 if (symetr.gt.1) then
312 write(iout,*) (tabperm(i,kkk),kkk=1,4)
318 c write (iout,*) i,icha
319 do lll=1,chain_length
321 if (cou.le.nres) then
323 kupa=mod(lll,chain_length)
324 iprzes=(kkk-1)*chain_length+lll
325 if (kupa.eq.0) kupa=chain_length
326 c write (iout,*) "kupa", kupa
327 cref(j,iprzes,i)=chain_rep(j,kupa,icha)
328 cref(j,iprzes+nres,i)=chain_rep(j,kupa+nres,icha)
335 C-koniec robienia kopii
338 write (iout,*) "nowa struktura", nperm
340 write (iout,110) restyp(itype(i)),i,cref(1,i,kkk),
342 &cref(3,i,kkk),cref(1,nres+i,kkk),
343 &cref(2,nres+i,kkk),cref(3,nres+i,kkk)
345 100 format (//' alpha-carbon coordinates ',
346 & ' centroid coordinates'/
347 1 ' ', 6X,'X',11X,'Y',11X,'Z',
348 & 10X,'X',11X,'Y',11X,'Z')
349 110 format (a,'(',i3,')',6f12.5)
355 bfrag(i,j)=bfrag(i,j)-ishift
361 hfrag(i,j)=hfrag(i,j)-ishift
367 c---------------------------------------------------------------------------
368 subroutine int_from_cart(lside,lprn)
369 implicit real*8 (a-h,o-z)
374 include 'COMMON.LOCAL'
376 include 'COMMON.CHAIN'
377 include 'COMMON.INTERACT'
378 include 'COMMON.IOUNITS'
380 include 'COMMON.NAMES'
381 include 'COMMON.CONTROL'
382 include 'COMMON.SETUP'
383 character*3 seq,atom,res
385 dimension sccor(3,20)
389 if(me.eq.king.or..not.out1file)then
393 & 'Internal coordinates calculated from crystal structure.'
395 write (iout,'(8a)') ' Res ',' dvb',' Theta',
396 & ' Phi',' Dsc_id',' Dsc',' Alpha',
399 write (iout,'(4a)') ' Res ',' dvb',' Theta',
408 if (iti.ne.ntyp1 .and. itype(i+1).ne.ntyp1 .and.
409 & (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0)) then
410 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
413 vbld(i+1)=dist(i,i+1)
414 vbld_inv(i+1)=1.0d0/vbld(i+1)
415 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
416 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
418 c if (unres_pdb) then
419 c if (itype(1).eq.21) then
420 c theta(3)=90.0d0*deg2rad
421 c phi(4)=180.0d0*deg2rad
423 c vbld_inv(2)=1.0d0/vbld(2)
425 c if (itype(nres).eq.21) then
426 c theta(nres)=90.0d0*deg2rad
427 c phi(nres)=180.0d0*deg2rad
429 c vbld_inv(nres)=1.0d0/vbld(2)
435 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
436 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
441 if (itype(i).ne.10) then
442 vbld_inv(i+nres)=1.0d0/di
444 vbld_inv(i+nres)=0.0d0
447 alph(i)=alpha(nres+i,i,maxres2)
448 omeg(i)=beta(nres+i,i,maxres2,i+1)
450 if(me.eq.king.or..not.out1file)then
452 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
453 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
454 & rad2deg*alph(i),rad2deg*omeg(i)
460 if(me.eq.king.or..not.out1file)
461 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
462 & rad2deg*theta(i),rad2deg*phi(i)
467 c-------------------------------------------------------------------------------
468 subroutine sc_loc_geom(lprn)
469 implicit real*8 (a-h,o-z)
474 include 'COMMON.LOCAL'
476 include 'COMMON.CHAIN'
477 include 'COMMON.INTERACT'
478 include 'COMMON.IOUNITS'
480 include 'COMMON.NAMES'
481 include 'COMMON.CONTROL'
482 include 'COMMON.SETUP'
483 double precision x_prime(3),y_prime(3),z_prime(3)
487 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
491 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
493 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
497 dc_norm(j,i+nres)=0.0d0
502 costtab(i+1) =dcos(theta(i+1))
503 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
504 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
505 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
506 cosfac2=0.5d0/(1.0d0+costtab(i+1))
507 cosfac=dsqrt(cosfac2)
508 sinfac2=0.5d0/(1.0d0-costtab(i+1))
509 sinfac=dsqrt(sinfac2)
511 if (it.ne.10 .and. itype(i).ne.ntyp1) then
513 C Compute the axes of tghe local cartesian coordinates system; store in
514 c x_prime, y_prime and z_prime
522 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
523 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
525 call vecpr(x_prime,y_prime,z_prime)
527 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
528 C to local coordinate system. Store in xx, yy, zz.
534 xx = xx + x_prime(j)*dc_norm(j,i+nres)
535 yy = yy + y_prime(j)*dc_norm(j,i+nres)
536 zz = zz + z_prime(j)*dc_norm(j,i+nres)
552 if(me.eq.king.or..not.out1file)
553 & write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),
556 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),yyref(i),
563 c---------------------------------------------------------------------------
564 subroutine sccenter(ires,nscat,sccor)
565 implicit real*8 (a-h,o-z)
567 include 'COMMON.CHAIN'
568 dimension sccor(3,20)
572 sccmj=sccmj+sccor(j,i)
574 dc(j,ires)=sccmj/nscat
578 c---------------------------------------------------------------------------
579 subroutine bond_regular
580 implicit real*8 (a-h,o-z)
583 include 'COMMON.LOCAL'
584 include 'COMMON.CALC'
585 include 'COMMON.INTERACT'
586 include 'COMMON.CHAIN'
589 vbld_inv(i+1)=1.0d0/vbld(i+1)
590 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
591 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
592 c print *,vbld(i+1),vbld(i+1+nres)