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 include 'COMMON.SBRIDGE'
17 character*3 seq,atom,res
20 double precision e1(3),e2(3),e3(3)
21 integer rescode,iterter(maxres),cou
32 read (ipdbin,'(a80)',end=10) card
33 if (card(:5).eq.'HELIX') then
36 read(card(22:25),*) hfrag(1,nhfrag)
37 read(card(34:37),*) hfrag(2,nhfrag)
39 if (card(:5).eq.'SHEET') then
42 read(card(24:26),*) bfrag(1,nbfrag)
43 read(card(35:37),*) bfrag(2,nbfrag)
44 crc----------------------------------------
45 crc to be corrected !!!
46 bfrag(3,nbfrag)=bfrag(1,nbfrag)
47 bfrag(4,nbfrag)=bfrag(2,nbfrag)
48 crc----------------------------------------
50 if (card(:3).eq.'END') then
52 else if (card(:3).eq.'TER') then
55 itype(ires_old-1)=ntyp1
60 write (iout,*) "Chain ended",ires,ishift,ires_old
63 dc(j,ires)=sccor(j,iii)
66 call sccenter(ires,iii,sccor)
69 C Fish out the ATOM cards.
70 if (index(card(1:4),'ATOM').gt.0) then
71 read (card(14:16),'(a3)') atom
72 if (atom.eq.'CA' .or. atom.eq.'CH3') then
73 C Calculate the CM of the preceding residue.
77 dc(j,ires+nres)=sccor(j,iii)
80 call sccenter(ires,iii,sccor)
84 c write (iout,'(a80)') card
85 read (card(23:26),*) ires
86 read (card(18:20),'(a3)') res
89 if (res.ne.'GLY' .and. res.ne. 'ACE') then
93 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
95 else if (ibeg.eq.2) then
97 ishift=-ires_old+ires-1
98 c write (iout,*) "New chain started",ires,ishift
102 c write (2,*) "ires",ires," ishift",ishift
103 if (res.eq.'ACE') then
106 itype(ires)=rescode(ires,res,0)
108 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
109 read(card(61:66),*) bfac(ires)
110 if(me.eq.king.or..not.out1file)
111 & write (iout,'(2i3,2x,a,3f8.3)')
112 & ires,itype(ires),res,(c(j,ires),j=1,3)
115 sccor(j,iii)=c(j,ires)
117 else if (atom.ne.'O '.and.atom(1:1).ne.'H' .and.
118 & atom.ne.'N ' .and. atom.ne.'C ') then
120 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
124 10 if(me.eq.king.or..not.out1file)
125 & write (iout,'(a,i5)') ' Nres: ',ires
126 C Calculate dummy residue coordinates inside the "chain" of a multichain
130 c write (iout,*) i,itype(i),itype(i+1),ntyp1,iterter(i)
131 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
132 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
133 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
134 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
135 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
137 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
138 print *,i,'tu dochodze'
139 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
147 c(j,i)=c(j,i-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
151 dcj=(c(j,i-2)-c(j,i-3))/2.0
152 if (dcj.eq.0) dcj=1.23591524223
157 else !itype(i+1).eq.ntyp1
159 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
160 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
167 c(j,i)=c(j,i+1)-1.9d0*e2(j)
171 dcj=(c(j,i+3)-c(j,i+2))/2.0
172 if (dcj.eq.0) dcj=1.23591524223
177 endif !itype(i+1).eq.ntyp1
178 endif !itype.eq.ntyp1
180 write (iout,*) "After loop in readpbd"
181 C Calculate the CM of the last side chain.
184 dc(j,ires)=sccor(j,iii)
187 call sccenter(ires,iii,sccor)
191 if (itype(nres).ne.10) then
195 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
196 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
203 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
207 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
208 if (dcj.eq.0) dcj=1.23591524223
209 c(j,nres)=c(j,nres-1)+dcj
210 c(j,2*nres)=c(j,nres)
221 c(j,2*nres)=c(j,nres)
223 if (itype(1).eq.ntyp1) then
227 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
228 call refsys(2,3,4,e1,e2,e3,fail)
235 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
239 dcj=(c(j,4)-c(j,3))/2.0
245 C Calculate internal coordinates.
246 if(me.eq.king.or..not.out1file)then
248 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
249 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
250 & (c(j,nres+ires),j=1,3)
254 write(iout,*)"before int_from_cart nres",nres
255 call int_from_cart(.true.,.true.)
262 dc(j,i)=c(j,i+1)-c(j,i)
263 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
265 write (iout,*) i,(dc(j,i),j=1,3),(dc_norm(j,i),j=1,3),
270 dc(j,i+nres)=c(j,i+nres)-c(j,i)
271 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
273 write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
276 call sc_loc_geom(.true.)
277 call int_from_cart1(.true.)
279 C Copy the coordinates to reference coordinates
283 cref(j,i+nres)=c(j,i+nres)
286 100 format (//' alpha-carbon coordinates ',
287 & ' centroid coordinates'/
288 1 ' ', 6X,'X',11X,'Y',11X,'Z',
289 & 10X,'X',11X,'Y',11X,'Z')
290 110 format (a,'(',i3,')',6f12.5)
294 bfrag(i,j)=bfrag(i,j)-ishift
300 hfrag(i,j)=hfrag(i,j)-ishift
305 c---------------------------------------------------------------------------
306 subroutine int_from_cart(lside,lprn)
307 implicit real*8 (a-h,o-z)
312 include 'COMMON.LOCAL'
314 include 'COMMON.CHAIN'
315 include 'COMMON.INTERACT'
316 include 'COMMON.IOUNITS'
318 include 'COMMON.NAMES'
319 include 'COMMON.CONTROL'
320 include 'COMMON.SETUP'
321 character*3 seq,atom,res
323 dimension sccor(3,50)
327 if(me.eq.king.or..not.out1file)then
331 & 'Internal coordinates calculated from crystal structure.'
333 write (iout,'(8a)') ' Res ',' dvb',' Theta',
334 & ' Phi',' Dsc_id',' Dsc',' Alpha',
337 write (iout,'(4a)') ' Res ',' dvb',' Theta',
346 if (iti.ne.ntyp1 .and. itype(i+1).ne.ntyp1 .and.
347 & (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0)) then
348 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
351 vbld(i+1)=dist(i,i+1)
352 vbld_inv(i+1)=1.0d0/vbld(i+1)
353 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
354 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
356 c if (unres_pdb) then
357 c if (itype(1).eq.21) then
358 c theta(3)=90.0d0*deg2rad
359 c phi(4)=180.0d0*deg2rad
361 c vbld_inv(2)=1.0d0/vbld(2)
363 c if (itype(nres).eq.21) then
364 c theta(nres)=90.0d0*deg2rad
365 c phi(nres)=180.0d0*deg2rad
367 c vbld_inv(nres)=1.0d0/vbld(2)
374 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
375 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
380 if (itype(i).ne.10) then
381 vbld_inv(i+nres)=1.0d0/di
383 vbld_inv(i+nres)=0.0d0
386 alph(i)=alpha(nres+i,i,maxres2)
387 omeg(i)=beta(nres+i,i,maxres2,i+1)
389 if(me.eq.king.or..not.out1file)then
391 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
392 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
393 & rad2deg*alph(i),rad2deg*omeg(i)
399 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
400 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
401 & rad2deg*alph(i),rad2deg*omeg(i)
406 if(me.eq.king.or..not.out1file)
407 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
408 & rad2deg*theta(i),rad2deg*phi(i)
413 c-------------------------------------------------------------------------------
414 subroutine sc_loc_geom(lprn)
415 implicit real*8 (a-h,o-z)
420 include 'COMMON.LOCAL'
422 include 'COMMON.CHAIN'
423 include 'COMMON.INTERACT'
424 include 'COMMON.IOUNITS'
426 include 'COMMON.NAMES'
427 include 'COMMON.CONTROL'
428 include 'COMMON.SETUP'
429 double precision x_prime(3),y_prime(3),z_prime(3)
433 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
437 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
439 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
443 dc_norm(j,i+nres)=0.0d0
448 costtab(i+1) =dcos(theta(i+1))
449 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
450 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
451 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
452 cosfac2=0.5d0/(1.0d0+costtab(i+1))
453 cosfac=dsqrt(cosfac2)
454 sinfac2=0.5d0/(1.0d0-costtab(i+1))
455 sinfac=dsqrt(sinfac2)
457 write (iout,*) "i",i," costab",costtab(i+1),
458 & " sintab",sinttab(i+1)
459 write (iout,*) "dc_norm_b",(dc_norm(j,i-1),j=1,3)
460 write (iout,*) "dc_norm_s",(dc_norm(j,i+nres),j=1,3)
461 if (it.ne.10 .and. itype(i).ne.ntyp1) then
463 C Compute the axes of tghe local cartesian coordinates system; store in
464 c x_prime, y_prime and z_prime
472 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
473 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
475 write (iout,*) "x_prime",(x_prime(j),j=1,3)
476 write (iout,*) "y_prime",(y_prime(j),j=1,3)
477 call vecpr(x_prime,y_prime,z_prime)
478 write (iout,*) "z_prime",(z_prime(j),j=1,3)
480 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
481 C to local coordinate system. Store in xx, yy, zz.
487 xx = xx + x_prime(j)*dc_norm(j,i+nres)
488 yy = yy + y_prime(j)*dc_norm(j,i+nres)
489 zz = zz + z_prime(j)*dc_norm(j,i+nres)
505 if(me.eq.king.or..not.out1file)
506 & write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),
509 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),yyref(i),
516 c---------------------------------------------------------------------------
517 subroutine sccenter(ires,nscat,sccor)
518 implicit real*8 (a-h,o-z)
520 include 'COMMON.CHAIN'
521 dimension sccor(3,50)
525 sccmj=sccmj+sccor(j,i)
527 dc(j,ires)=sccmj/nscat
531 c---------------------------------------------------------------------------
532 subroutine bond_regular
533 implicit real*8 (a-h,o-z)
536 include 'COMMON.LOCAL'
537 include 'COMMON.CALC'
538 include 'COMMON.INTERACT'
539 include 'COMMON.CHAIN'
542 vbld_inv(i+1)=1.0d0/vbld(i+1)
543 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
544 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
545 c print *,vbld(i+1),vbld(i+1+nres)