1 subroutine readpdb(lprn,iprot,efree_temp,*)
2 C Read the PDB file and convert the peptide geometry into virtual-chain
6 include 'DIMENSIONS.ZSCOPT'
7 include 'COMMON.CONTROL'
10 include 'COMMON.CHAIN'
11 include 'COMMON.INTERACT'
12 include 'COMMON.IOUNITS'
14 include 'COMMON.NAMES'
16 integer i,j,iprot,ibeg,ishift1,ires,iires,iii,ires_old,ishift,ity,
19 double precision e1(3),e2(3),e3(3)
20 double precision dcj,efree_temp
21 character*3 seq,atom,res
22 character*80 card,prevcard
23 double precision sccor(3,20)
24 integer rescode,iterter(maxres)
29 c write (iout,*) "READPDB: UNRES_PDB",unres_pdb
34 read (ipdbin,'(a80)',end=10) card
35 do while (card(:3).eq.'END' .or. card(:3).eq.'TER')
36 read (ipdbin,'(a80)',end=10) card
39 if (card(:3).eq.'END' .or.
40 & card(:3).eq.'TER'.and.prevcard(:5).eq.'REMARK') goto 10
41 if (card(:3).eq.'TER') then
44 itype(ires_old-1)=ntyp1
49 c write (iout,*) "Chain ended",ires,ishift,ires_old
52 dc(j,ires)=sccor(j,iii)
55 call sccenter(ires,iii,sccor)
59 C Fish out the ATOM cards.
60 if (index(card(1:4),'ATOM').gt.0) then
61 read (card(12:16),*) atom
62 c write (iout,*) "! ",atom," !",ires
63 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
64 read (card(23:26),*) ires
65 read (card(18:20),'(a3)') res
66 c write (iout,*) "ires",ires,ires-ishift+ishift1,
67 c & " ires_old",ires_old
68 c write (iout,*) "ishift",ishift," ishift1",ishift1
69 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
70 if (ires-ishift+ishift1.ne.ires_old) then
71 C Calculate the CM of the preceding residue.
75 dc(j,ires)=sccor(j,iii)
78 call sccenter(ires_old,iii,sccor)
83 if (res.eq.'Cl-' .or. res.eq.'Na+') then
86 else if (ibeg.eq.1) then
87 c write (iout,*) "BEG ires",ires
89 if (res.ne.'GLY' .and. res.ne. 'ACE') then
93 ires=ires-ishift+ishift1
95 c write (iout,*) "ishift",ishift," ires",ires,
96 c & " ires_old",ires_old
97 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
99 else if (ibeg.eq.2) then
101 ishift=-ires_old+ires-1
103 c write (iout,*) "New chain started",ires,ishift
106 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
107 ires=ires-ishift+ishift1
110 if (res.eq.'ACE' .or. res.eq.'NHE') then
113 itype(ires)=rescode(ires,res,0,.true.)
114 if (itype(ires).eq.0) stop
117 ires=ires-ishift+ishift1
119 c write (iout,*) "ires_old",ires_old," ires",ires
120 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
123 c write (2,*) "ires",ires," res ",res," ity",ity
124 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
125 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
126 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
127 c write (iout,*) "backbone ",atom
129 write (iout,'(2i3,2x,a,3f8.3)')
130 & ires,itype(ires),res,(c(j,ires),j=1,3)
134 sccor(j,iii)=c(j,ires)
136 if (ishift.ne.0) then
137 ires_ca=ires+ishift-ishift1
141 c write (*,*) card(23:27),ires,itype(ires)
142 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
143 & atom.ne.'N' .and. atom.ne.'C' .and.
144 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
145 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
146 c write (iout,*) "sidechain ",atom
148 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
151 read (ipdbin,'(a80)',end=10) card
153 10 write (iout,'(a,i5)') ' Nres: ',ires
154 if (ires.eq.0) return1
155 C Calculate dummy residue coordinates inside the "chain" of a multichain
159 c write (iout,*) i,itype(i),itype(i+1)
160 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
161 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
162 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
163 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
164 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
166 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
167 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
174 c(j,i)=c(j,i-1)-1.9d0*e2(j)
178 dcj=(c(j,i-2)-c(j,i-3))/2.0
179 if (dcj.eq.0) dcj=1.23591524223
184 else !itype(i+1).eq.ntyp1
186 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
187 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
194 c(j,i)=c(j,i+1)-1.9d0*e2(j)
198 dcj=(c(j,i+3)-c(j,i+2))/2.0
199 if (dcj.eq.0) dcj=1.23591524223
204 endif !itype(i+1).eq.ntyp1
205 endif !itype.eq.ntyp1
207 C Calculate the CM of the last side chain.
210 dc(j,ires)=sccor(j,iii)
213 call sccenter(ires,iii,sccor)
217 if (itype(nres).ne.10) then
221 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
222 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
229 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
233 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
234 if (dcj.eq.0) dcj=1.23591524223
235 c(j,nres)=c(j,nres-1)+dcj
236 c(j,2*nres)=c(j,nres)
247 c(j,2*nres)=c(j,nres)
249 if (itype(1).eq.ntyp1) then
253 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
254 call refsys(2,3,4,e1,e2,e3,fail)
261 c(j,1)=c(j,2)-1.9d0*e2(j)
265 dcj=(c(j,4)-c(j,3))/2.0
271 C Copy the coordinates to reference coordinates
277 C Calculate internal coordinates.
280 & "Cartesian coordinates of the reference structure"
281 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
282 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
284 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
285 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
286 & (c(j,ires+nres),j=1,3)
289 C Calculate internal coordinates.
291 & "Backbone and SC coordinates as read from the PDB"
293 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
294 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
295 & (c(j,nres+ires),j=1,3)
297 call int_from_cart(.true.,.false.)
298 call sc_loc_geom(.false.)
301 dc(j,i)=c(j,i+1)-c(j,i)
302 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
307 dc(j,i+nres)=c(j,i+nres)-c(j,i)
308 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
310 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
314 C Calculate internal coordinates.
316 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
317 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
318 & (c(j,nres+ires),j=1,3)
320 C print *,"before int_from_cart"
321 call int_from_cart(.true.,.false.)
322 call sc_loc_geom(.true.)
324 C Copy the coordinates to reference coordinates
325 C Splits to single chain if occurs
329 & "Cartesian coordinates of the reference structure"
330 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
331 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
333 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
334 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
335 & (c(j,ires+nres),j=1,3)
338 call int_from_cart(.true.,lprn)
339 call sc_loc_geom(lprn)
343 c---------------------------------------------------------------------------
344 subroutine int_from_cart(lside,lprn)
347 include 'DIMENSIONS.ZSCOPT'
348 include 'COMMON.LOCAL'
350 include 'COMMON.CHAIN'
351 include 'COMMON.INTERACT'
352 include 'COMMON.IOUNITS'
354 include 'COMMON.NAMES'
356 double precision dist,alpha,beta,di
357 character*3 seq,atom,res
359 double precision sccor(3,20)
364 & 'Internal coordinates of the reference structure.'
366 write (iout,'(8a)') 'Residue',' dvb',' Theta',
367 & ' Phi',' Dsc_id',' Dsc',' Alpha',
370 write (iout,'(4a)') 'Residue',' dvb',' Theta',
376 if (iti.ne.ntyp1 .and. itype(i+1).ne.ntyp1 .and.
377 & (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.6.5D0)) then
378 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
381 vbld(i+1)=dist(i,i+1)
382 vbld_inv(i+1)=1.0d0/vbld(i+1)
383 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
384 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
386 dc(j,i)=c(j,i+1)-c(j,i)
387 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
393 c(j,maxres2)=0.5D0*(c(j,i-1)+c(j,i+1))
398 if (itype(i).ne.10) then
399 vbld_inv(i+nres)=1.0d0/di
401 dc(j,i+nres)=c(j,i+nres)-c(j,i)
402 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
405 vbld_inv(i+nres)=0.0d0
408 dc_norm(j,i+nres)=0.0d0
412 alph(i)=alpha(nres+i,i,maxres2)
413 omeg(i)=beta(nres+i,i,maxres2,i+1)
416 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
417 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),di,
418 & rad2deg*alph(i),rad2deg*omeg(i)
425 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
426 & rad2deg*theta(i),rad2deg*phi(i)
431 c-------------------------------------------------------------------------------
432 subroutine sc_loc_geom(lprn)
433 implicit real*8 (a-h,o-z)
435 include 'DIMENSIONS.ZSCOPT'
436 include 'COMMON.LOCAL'
438 include 'COMMON.CHAIN'
439 include 'COMMON.INTERACT'
440 include 'COMMON.IOUNITS'
442 include 'COMMON.NAMES'
443 include 'COMMON.CONTROL'
444 double precision x_prime(3),y_prime(3),z_prime(3)
448 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
452 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
454 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
458 dc_norm(j,i+nres)=0.0d0
463 costtab(i+1) =dcos(theta(i+1))
464 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
465 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
466 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
467 cosfac2=0.5d0/(1.0d0+costtab(i+1))
468 cosfac=dsqrt(cosfac2)
469 sinfac2=0.5d0/(1.0d0-costtab(i+1))
470 sinfac=dsqrt(sinfac2)
472 if (it.ne.10 .and. itype(i).ne.ntyp1) then
474 C Compute the axes of tghe local cartesian coordinates system; store in
475 c x_prime, y_prime and z_prime
483 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
484 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
486 call vecpr(x_prime,y_prime,z_prime)
488 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
489 C to local coordinate system. Store in xx, yy, zz.
495 xx = xx + x_prime(j)*dc_norm(j,i+nres)
496 yy = yy + y_prime(j)*dc_norm(j,i+nres)
497 zz = zz + z_prime(j)*dc_norm(j,i+nres)
512 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxtab(i),yytab(i),
518 c---------------------------------------------------------------------------
519 subroutine sccenter(ires,nscat,sccor)
522 include 'DIMENSIONS.ZSCOPT'
523 include 'COMMON.CHAIN'
524 integer ires,nscat,i,j
525 double precision sccmj
526 double precision sccor(3,20)
530 sccmj=sccmj+sccor(j,i)
532 dc(j,ires)=sccmj/nscat