2 C Read the PDB file and convert the peptide geometry into virtual-chain
9 include 'COMMON.INTERACT'
10 include 'COMMON.IOUNITS'
12 include 'COMMON.NAMES'
13 include 'COMMON.CONTROL'
15 include 'COMMON.SETUP'
16 include 'COMMON.SBRIDGE'
17 character*3 seq,atom,res
19 double precision sccor(3,50)
20 double precision e1(3),e2(3),e3(3)
21 integer rescode,iterter(maxres),cou
23 integer i,j,iii,ires,ires_old,ishift,ibeg
35 read (ipdbin,'(a80)',end=10) card
36 if (card(:5).eq.'HELIX') then
39 read(card(22:25),*) hfrag(1,nhfrag)
40 read(card(34:37),*) hfrag(2,nhfrag)
42 if (card(:5).eq.'SHEET') then
45 read(card(24:26),*) bfrag(1,nbfrag)
46 read(card(35:37),*) bfrag(2,nbfrag)
47 crc----------------------------------------
48 crc to be corrected !!!
49 bfrag(3,nbfrag)=bfrag(1,nbfrag)
50 bfrag(4,nbfrag)=bfrag(2,nbfrag)
51 crc----------------------------------------
53 if (card(:3).eq.'END') then
55 else if (card(:3).eq.'TER') then
58 itype(ires_old-1)=ntyp1
63 write (iout,*) "Chain ended",ires,ishift,ires_old
66 dc(j,ires)=sccor(j,iii)
69 call sccenter(ires,iii,sccor)
72 C Fish out the ATOM cards.
73 if (index(card(1:4),'ATOM').gt.0) then
74 read (card(14:16),'(a3)') atom
75 if (atom.eq.'CA' .or. atom.eq.'CH3') then
76 C Calculate the CM of the preceding residue.
80 dc(j,ires+nres)=sccor(j,iii)
83 call sccenter(ires,iii,sccor)
87 c write (iout,'(a80)') card
88 read (card(23:26),*) ires
89 read (card(18:20),'(a3)') res
92 if (res.ne.'GLY' .and. res.ne. 'ACE') then
96 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
98 else if (ibeg.eq.2) then
100 ishift=-ires_old+ires-1
101 c write (iout,*) "New chain started",ires,ishift
105 c write (2,*) "ires",ires," ishift",ishift
106 if (res.eq.'ACE') then
109 itype(ires)=rescode(ires,res,0)
111 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
112 read(card(61:66),*) bfac(ires)
113 c if(me.eq.king.or..not.out1file)
114 c & write (iout,'(2i3,2x,a,3f8.3)')
115 c & ires,itype(ires),res,(c(j,ires),j=1,3)
118 sccor(j,iii)=c(j,ires)
120 else if (atom.ne.'O '.and.atom(1:1).ne.'H' .and.
121 & atom.ne.'N ' .and. atom.ne.'C ') then
123 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
127 10 if(me.eq.king.or..not.out1file)
128 & write (iout,'(a,i5)') ' Nres: ',ires
129 C Calculate dummy residue coordinates inside the "chain" of a multichain
133 c write (iout,*) i,itype(i),itype(i+1),ntyp1,iterter(i)
134 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
135 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
136 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
137 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
138 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
140 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
141 print *,i,'tu dochodze'
142 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
150 c(j,i)=c(j,i-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
154 dcj=(c(j,i-2)-c(j,i-3))/2.0
155 if (dcj.eq.0) dcj=1.23591524223
160 else !itype(i+1).eq.ntyp1
162 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
163 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
170 c(j,i)=c(j,i+1)-1.9d0*e2(j)
174 dcj=(c(j,i+3)-c(j,i+2))/2.0
175 if (dcj.eq.0) dcj=1.23591524223
180 endif !itype(i+1).eq.ntyp1
181 endif !itype.eq.ntyp1
183 write (iout,*) "After loop in readpbd"
184 C Calculate the CM of the last side chain.
187 dc(j,ires)=sccor(j,iii)
190 call sccenter(ires,iii,sccor)
194 if (itype(nres).ne.10) then
198 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
199 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
206 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
210 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
211 if (dcj.eq.0) dcj=1.23591524223
212 c(j,nres)=c(j,nres-1)+dcj
213 c(j,2*nres)=c(j,nres)
224 c(j,2*nres)=c(j,nres)
226 if (itype(1).eq.ntyp1) then
230 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
231 call refsys(2,3,4,e1,e2,e3,fail)
238 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
242 dcj=(c(j,4)-c(j,3))/2.0
248 C Calculate internal coordinates.
249 if(me.eq.king.or..not.out1file)then
251 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
252 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
253 & (c(j,nres+ires),j=1,3)
257 c write(iout,*)"before int_from_cart nres",nres
258 call int_from_cart(.true.,.false.)
265 dc(j,i)=c(j,i+1)-c(j,i)
266 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
268 c write (iout,*) i,(dc(j,i),j=1,3),(dc_norm(j,i),j=1,3),
273 dc(j,i+nres)=c(j,i+nres)-c(j,i)
274 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
276 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
279 call sc_loc_geom(.false.)
280 call int_from_cart1(.false.)
282 C Copy the coordinates to reference coordinates
286 cref(j,i+nres)=c(j,i+nres)
289 100 format (//' alpha-carbon coordinates ',
290 & ' centroid coordinates'/
291 1 ' ', 6X,'X',11X,'Y',11X,'Z',
292 & 10X,'X',11X,'Y',11X,'Z')
293 110 format (a,'(',i3,')',6f12.5)
297 bfrag(i,j)=bfrag(i,j)-ishift
303 hfrag(i,j)=hfrag(i,j)-ishift
308 c---------------------------------------------------------------------------
309 subroutine readpdb_template(k)
310 C Read the PDB file for read_constr_homology with read2sigma
311 C and convert the peptide geometry into virtual-chain geometry.
314 include 'COMMON.LOCAL'
316 include 'COMMON.CHAIN'
317 include 'COMMON.INTERACT'
318 include 'COMMON.IOUNITS'
320 include 'COMMON.NAMES'
321 include 'COMMON.CONTROL'
322 include 'COMMON.FRAG'
323 include 'COMMON.SETUP'
324 integer i,j,k,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
326 logical lprn /.false./,fail
327 double precision e1(3),e2(3),e3(3)
328 double precision dcj,efree_temp
332 double precision sccor(3,20)
333 integer rescode,iterter(maxres)
340 c write (2,*) "UNRES_PDB",unres_pdb
348 read (ipdbin,'(a80)',end=10) card
349 if (card(:3).eq.'END') then
351 else if (card(:3).eq.'TER') then
354 itype(ires_old-1)=ntyp1
355 iterter(ires_old-1)=1
356 itype(ires_old)=ntyp1
359 c write (iout,*) "Chain ended",ires,ishift,ires_old
362 dc(j,ires)=sccor(j,iii)
365 call sccenter(ires,iii,sccor)
368 C Fish out the ATOM cards.
369 if (index(card(1:4),'ATOM').gt.0) then
370 read (card(12:16),*) atom
371 c write (iout,*) "! ",atom," !",ires
372 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
373 read (card(23:26),*) ires
374 read (card(18:20),'(a3)') res
375 c write (iout,*) "ires",ires,ires-ishift+ishift1,
376 c & " ires_old",ires_old
377 c write (iout,*) "ishift",ishift," ishift1",ishift1
378 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
379 if (ires-ishift+ishift1.ne.ires_old) then
380 C Calculate the CM of the preceding residue.
384 dc(j,ires)=sccor(j,iii)
387 call sccenter(ires_old,iii,sccor)
392 if (res.eq.'Cl-' .or. res.eq.'Na+') then
395 else if (ibeg.eq.1) then
396 c write (iout,*) "BEG ires",ires
398 if (res.ne.'GLY' .and. res.ne. 'ACE') then
402 ires=ires-ishift+ishift1
404 c write (iout,*) "ishift",ishift," ires",ires,
405 c & " ires_old",ires_old
406 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
408 else if (ibeg.eq.2) then
410 ishift=-ires_old+ires-1
412 c write (iout,*) "New chain started",ires,ishift
415 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
416 ires=ires-ishift+ishift1
419 if (res.eq.'ACE' .or. res.eq.'NHE') then
422 itype(ires)=rescode(ires,res,0)
425 ires=ires-ishift+ishift1
427 c write (iout,*) "ires_old",ires_old," ires",ires
428 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
431 c write (2,*) "ires",ires," res ",res," ity",ity
432 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
433 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
434 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
435 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
437 write (iout,'(2i3,2x,a,3f8.3)')
438 & ires,itype(ires),res,(c(j,ires),j=1,3)
442 sccor(j,iii)=c(j,ires)
444 if (ishift.ne.0) then
445 ires_ca=ires+ishift-ishift1
449 c write (*,*) card(23:27),ires,itype(ires)
450 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
451 & atom.ne.'N' .and. atom.ne.'C' .and.
452 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
453 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
454 c write (iout,*) "sidechain ",atom
456 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
460 10 if(me.eq.king.or..not.out1file)
461 & write (iout,'(a,i5)') ' Nres: ',ires
462 C Calculate dummy residue coordinates inside the "chain" of a multichain
466 c write (iout,*) i,itype(i),itype(i+1)
467 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
468 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
469 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
470 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
471 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
473 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
474 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
481 c(j,i)=c(j,i-1)-1.9d0*e2(j)
485 dcj=(c(j,i-2)-c(j,i-3))/2.0
486 if (dcj.eq.0) dcj=1.23591524223
491 else !itype(i+1).eq.ntyp1
493 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
494 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
501 c(j,i)=c(j,i+1)-1.9d0*e2(j)
505 dcj=(c(j,i+3)-c(j,i+2))/2.0
506 if (dcj.eq.0) dcj=1.23591524223
511 endif !itype(i+1).eq.ntyp1
512 endif !itype.eq.ntyp1
514 C Calculate the CM of the last side chain.
517 dc(j,ires)=sccor(j,iii)
520 call sccenter(ires,iii,sccor)
524 if (itype(nres).ne.10) then
528 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
529 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
536 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
540 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
541 if (dcj.eq.0) dcj=1.23591524223
542 c(j,nres)=c(j,nres-1)+dcj
543 c(j,2*nres)=c(j,nres)
554 c(j,2*nres)=c(j,nres)
556 if (itype(1).eq.ntyp1) then
560 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
561 call refsys(2,3,4,e1,e2,e3,fail)
568 c(j,1)=c(j,2)-1.9d0*e2(j)
572 dcj=(c(j,4)-c(j,3))/2.0
578 C Copy the coordinates to reference coordinates
584 C Calculate internal coordinates.
585 if (out_template_coord) then
587 & "Cartesian coordinates of the reference structure"
588 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
589 & "Residue ","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
591 write (iout,'(a3,1x,i4,3f8.3,5x,3f8.3)')
592 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
593 & (c(j,ires+nres),j=1,3)
596 C Calculate internal coordinates.
597 call int_from_cart(.true.,.true.)
598 call sc_loc_geom(.false.)
605 dc(j,i)=c(j,i+1)-c(j,i)
606 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
611 dc(j,i+nres)=c(j,i+nres)-c(j,i)
612 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
614 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
620 cref(j,i+nres)=c(j,i+nres)