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)
30 c write (iout,*) "READPDB: UNRES_PDB",unres_pdb
35 read (ipdbin,'(a80)',end=10) card
36 write (iout,*) "card",card
37 do while (card(:3).eq.'END' .or. card(:3).eq.'TER')
38 read (ipdbin,'(a80)',end=10) card
39 write (iout,*) "card",card
42 if (card(:3).eq.'END' .or.
43 & card(:6).eq.'REMARK'.and.prevcard(:3).eq.'TER') goto 10
45 c write (iout,*) "prevcard ",prevcard
46 c write (iout,*) "card ",card
48 if (card(:3).eq.'TER') then
51 itype(ires_old-1)=ntyp1
56 c write (iout,*) "Chain ended",ires,ishift,ires_old
57 c write (iout,*) "nscat",iii
60 dc(j,ires)=sccor(j,iii)
63 call sccenter(ires,iii,sccor)
66 C Fish out the ATOM cards.
67 if (index(card(1:4),'ATOM').gt.0) then
68 read (card(12:16),*) atom
69 c write (iout,*) "! ",atom," !",ires
70 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
71 read (card(23:26),*) ires
72 read (card(18:20),'(a3)') res
73 c write (iout,*) "ires",ires,ires-ishift+ishift1,
74 c & " ires_old",ires_old
75 c write (iout,*) "ishift",ishift," ishift1",ishift1
76 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
77 if (ires-ishift+ishift1.ne.ires_old) then
78 C Calculate the CM of the preceding residue.
79 if (res.eq.'Cl-' .or. res.eq.'Na+') then
86 dc(j,ires)=sccor(j,iii)
89 call sccenter(ires_old,iii,sccor)
95 c write (iout,*) "BEG ires",ires
97 if (res.ne.'GLY' .and. res.ne. 'ACE') then
101 ires=ires-ishift+ishift1
103 c write (iout,*) "ishift",ishift," ires",ires,
104 c & " ires_old",ires_old
105 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
107 else if (ibeg.eq.2) then
109 ishift=-ires_old+ires-1
111 c write (iout,*) "New chain started",ires,ishift
114 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
115 ires=ires-ishift+ishift1
118 if (res.eq.'ACE' .or. res.eq.'NHE') then
121 itype(ires)=rescode(ires,res,0,.true.)
122 if (itype(ires).eq.0) stop
125 ires=ires-ishift+ishift1
127 c write (iout,*) "ires_old",ires_old," ires",ires
128 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
131 c write (2,*) "ires",ires," res ",res," ity",ity
132 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
133 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
134 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
135 c write (iout,*) "backbone ",atom
137 write (iout,'(2i3,2x,a,3f8.3)')
138 & ires,itype(ires),res,(c(j,ires),j=1,3)
142 sccor(j,iii)=c(j,ires)
144 if (ishift.ne.0) then
145 ires_ca=ires+ishift-ishift1
149 c write (*,*) card(23:27),ires,itype(ires)
150 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
151 & atom.ne.'N' .and. atom.ne.'C' .and.
152 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
153 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
154 c write (iout,*) "sidechain ",atom
156 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
160 c write (iout,*) "iii",iii
161 read (ipdbin,'(a80)',end=10) card
163 10 write (iout,'(a,i5)') ' Nres: ',ires
164 if (ires.eq.0) return1
165 C Calculate dummy residue coordinates inside the "chain" of a multichain
169 c write (iout,*) i,itype(i),itype(i+1)
170 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
171 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
172 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
173 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
174 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
176 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
177 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
184 c(j,i)=c(j,i-1)-1.9d0*e2(j)
188 dcj=(c(j,i-2)-c(j,i-3))/2.0
189 if (dcj.eq.0) dcj=1.23591524223
194 else !itype(i+1).eq.ntyp1
196 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
197 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
204 c(j,i)=c(j,i+1)-1.9d0*e2(j)
208 dcj=(c(j,i+3)-c(j,i+2))/2.0
209 if (dcj.eq.0) dcj=1.23591524223
214 endif !itype(i+1).eq.ntyp1
215 endif !itype.eq.ntyp1
217 C Calculate the CM of the last side chain.
220 dc(j,ires)=sccor(j,iii)
223 call sccenter(ires,iii,sccor)
227 if (itype(nres).ne.10) then
231 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
232 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
239 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
243 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
244 if (dcj.eq.0) dcj=1.23591524223
245 c(j,nres)=c(j,nres-1)+dcj
246 c(j,2*nres)=c(j,nres)
257 c(j,2*nres)=c(j,nres)
259 if (itype(1).eq.ntyp1) then
263 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
264 call refsys(2,3,4,e1,e2,e3,fail)
271 c(j,1)=c(j,2)-1.9d0*e2(j)
275 dcj=(c(j,4)-c(j,3))/2.0
281 C Copy the coordinates to reference coordinates
287 C Calculate internal coordinates.
290 & "Cartesian coordinates of the reference structure"
291 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
292 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
294 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
295 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
296 & (c(j,ires+nres),j=1,3)
299 C Calculate internal coordinates.
301 & "Backbone and SC coordinates as read from the PDB"
303 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
304 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
305 & (c(j,nres+ires),j=1,3)
307 call int_from_cart(.true.,.false.)
308 call sc_loc_geom(.false.)
311 dc(j,i)=c(j,i+1)-c(j,i)
312 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
317 dc(j,i+nres)=c(j,i+nres)-c(j,i)
318 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
320 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
324 C Calculate internal coordinates.
326 c write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
327 c & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
328 c & (c(j,nres+ires),j=1,3)
330 C print *,"before int_from_cart"
331 call int_from_cart(.true.,.false.)
332 call sc_loc_geom(.true.)
334 C Copy the coordinates to reference coordinates
335 C Splits to single chain if occurs
339 & "Cartesian coordinates of the reference structure"
340 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
341 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
343 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
344 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
345 & (c(j,ires+nres),j=1,3)
348 call int_from_cart(.true.,lprn)
349 call sc_loc_geom(lprn)
353 c---------------------------------------------------------------------------
354 subroutine int_from_cart(lside,lprn)
357 include 'DIMENSIONS.ZSCOPT'
358 include 'COMMON.LOCAL'
360 include 'COMMON.CHAIN'
361 include 'COMMON.INTERACT'
362 include 'COMMON.IOUNITS'
364 include 'COMMON.NAMES'
366 double precision dist,alpha,beta,di
367 character*3 seq,atom,res
369 double precision sccor(3,20)
374 & 'Internal coordinates of the reference structure.'
376 write (iout,'(8a)') 'Residue',' dvb',' Theta',
377 & ' Phi',' Dsc_id',' Dsc',' Alpha',
380 write (iout,'(4a)') 'Residue',' dvb',' Theta',
386 if (iti.ne.ntyp1 .and. itype(i+1).ne.ntyp1 .and.
387 & (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.6.5D0)) then
388 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
391 vbld(i+1)=dist(i,i+1)
392 vbld_inv(i+1)=1.0d0/vbld(i+1)
393 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
394 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
396 dc(j,i)=c(j,i+1)-c(j,i)
397 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
403 c(j,maxres2)=0.5D0*(c(j,i-1)+c(j,i+1))
408 if (itype(i).ne.10) then
409 vbld_inv(i+nres)=1.0d0/di
411 dc(j,i+nres)=c(j,i+nres)-c(j,i)
412 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
415 vbld_inv(i+nres)=0.0d0
418 dc_norm(j,i+nres)=0.0d0
422 alph(i)=alpha(nres+i,i,maxres2)
423 omeg(i)=beta(nres+i,i,maxres2,i+1)
426 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
427 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),di,
428 & rad2deg*alph(i),rad2deg*omeg(i)
435 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
436 & rad2deg*theta(i),rad2deg*phi(i)
441 c-------------------------------------------------------------------------------
442 subroutine sc_loc_geom(lprn)
443 implicit real*8 (a-h,o-z)
445 include 'DIMENSIONS.ZSCOPT'
446 include 'COMMON.LOCAL'
448 include 'COMMON.CHAIN'
449 include 'COMMON.INTERACT'
450 include 'COMMON.IOUNITS'
452 include 'COMMON.NAMES'
453 include 'COMMON.CONTROL'
454 double precision x_prime(3),y_prime(3),z_prime(3)
458 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
462 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
464 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
468 dc_norm(j,i+nres)=0.0d0
473 costtab(i+1) =dcos(theta(i+1))
474 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
475 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
476 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
477 cosfac2=0.5d0/(1.0d0+costtab(i+1))
478 cosfac=dsqrt(cosfac2)
479 sinfac2=0.5d0/(1.0d0-costtab(i+1))
480 sinfac=dsqrt(sinfac2)
482 if (it.ne.10 .and. itype(i).ne.ntyp1) then
484 C Compute the axes of tghe local cartesian coordinates system; store in
485 c x_prime, y_prime and z_prime
493 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
494 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
496 call vecpr(x_prime,y_prime,z_prime)
498 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
499 C to local coordinate system. Store in xx, yy, zz.
505 xx = xx + x_prime(j)*dc_norm(j,i+nres)
506 yy = yy + y_prime(j)*dc_norm(j,i+nres)
507 zz = zz + z_prime(j)*dc_norm(j,i+nres)
522 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxtab(i),yytab(i),
528 c---------------------------------------------------------------------------
529 subroutine sccenter(ires,nscat,sccor)
532 include 'DIMENSIONS.ZSCOPT'
533 include 'COMMON.CHAIN'
534 integer ires,nscat,i,j
535 double precision sccmj
536 double precision sccor(3,20)
540 sccmj=sccmj+sccor(j,i)
542 dc(j,ires)=sccmj/nscat