1 subroutine readpdb_template(k)
2 C Read the PDB file for read_constr_homology with read2sigma
3 C and convert the peptide geometry into virtual-chain geometry.
9 include 'COMMON.INTERACT'
10 include 'COMMON.IOUNITS'
12 include 'COMMON.NAMES'
13 include 'COMMON.CONTROL'
15 include 'COMMON.SETUP'
16 integer i,j,k,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
18 logical lprn /.false./,fail
19 double precision e1(3),e2(3),e3(3)
20 double precision dcj,efree_temp
24 double precision sccor(3,20)
25 integer rescode,iterter(maxres)
32 c write (2,*) "UNRES_PDB",unres_pdb
40 read (ipdbin,'(a80)',end=10) card
41 if (card(:3).eq.'END') then
43 else if (card(:3).eq.'TER') then
46 itype(ires_old-1)=ntyp1
51 c write (iout,*) "Chain ended",ires,ishift,ires_old
54 dc(j,ires)=sccor(j,iii)
57 call sccenter(ires,iii,sccor)
60 C Fish out the ATOM cards.
61 if (index(card(1:4),'ATOM').gt.0) then
62 read (card(12:16),*) atom
63 c write (iout,*) "! ",atom," !",ires
64 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
65 read (card(23:26),*) ires
66 read (card(18:20),'(a3)') res
67 c write (iout,*) "ires",ires,ires-ishift+ishift1,
68 c & " ires_old",ires_old
69 c write (iout,*) "ishift",ishift," ishift1",ishift1
70 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
71 if (ires-ishift+ishift1.ne.ires_old) then
72 C Calculate the CM of the preceding residue.
76 dc(j,ires_old)=sccor(j,iii)
79 call sccenter(ires_old,iii,sccor)
84 if (res.eq.'Cl-' .or. res.eq.'Na+') then
87 else if (ibeg.eq.1) then
88 c write (iout,*) "BEG ires",ires
90 if (res.ne.'GLY' .and. res.ne. 'ACE') then
94 ires=ires-ishift+ishift1
96 c write (iout,*) "ishift",ishift," ires",ires,
97 c & " ires_old",ires_old
98 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
100 else if (ibeg.eq.2) then
102 ishift=-ires_old+ires-1
104 c write (iout,*) "New chain started",ires,ishift
107 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
108 ires=ires-ishift+ishift1
111 if (res.eq.'ACE' .or. res.eq.'NHE') then
114 itype(ires)=rescode(ires,res,0)
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 ,ires,res, (c(j,ires),j=1,3)
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)
152 10 if(me.eq.king.or..not.out1file)
153 & write (iout,'(a,i5)') ' Nres: ',ires
154 C Calculate dummy residue coordinates inside the "chain" of a multichain
158 c write (iout,*) i,itype(i),itype(i+1)
159 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
160 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
161 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
162 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
163 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
165 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
166 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
173 c(j,i)=c(j,i-1)-1.9d0*e2(j)
177 dcj=(c(j,i-2)-c(j,i-3))/2.0
178 if (dcj.eq.0) dcj=1.23591524223
183 else !itype(i+1).eq.ntyp1
185 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
186 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
193 c(j,i)=c(j,i+1)-1.9d0*e2(j)
197 dcj=(c(j,i+3)-c(j,i+2))/2.0
198 if (dcj.eq.0) dcj=1.23591524223
203 endif !itype(i+1).eq.ntyp1
204 endif !itype.eq.ntyp1
206 C Calculate the CM of the last side chain.
209 dc(j,ires)=sccor(j,iii)
212 call sccenter(ires,iii,sccor)
216 if (itype(nres).ne.10) then
220 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
221 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
228 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
232 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
233 if (dcj.eq.0) dcj=1.23591524223
234 c(j,nres)=c(j,nres-1)+dcj
235 c(j,2*nres)=c(j,nres)
246 c(j,2*nres)=c(j,nres)
248 if (itype(1).eq.ntyp1) then
252 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
253 call refsys(2,3,4,e1,e2,e3,fail)
260 c(j,1)=c(j,2)-1.9d0*e2(j)
264 dcj=(c(j,4)-c(j,3))/2.0
270 C Copy the coordinates to reference coordinates
276 C Calculate internal coordinates.
277 if (out_template_coord) then
279 & "Cartesian coordinates of the reference structure"
280 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
281 & "Residue ","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
283 write (iout,'(a3,1x,i4,3f8.3,5x,3f8.3)')
284 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
285 & (c(j,ires+nres),j=1,3)
288 C Calculate internal coordinates.
289 call int_from_cart(.true.,out_template_coord)
290 call sc_loc_geom(.false.)
297 dc(j,i)=c(j,i+1)-c(j,i)
298 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
303 dc(j,i+nres)=c(j,i+nres)-c(j,i)
304 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
306 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
312 cref(j,i+nres)=c(j,i+nres)