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,ishift1,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 c if (index(card(1:4),'ATOM').gt.0) then
74 c read (card(14:16),'(a3)') atom
75 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
76 C Calculate the CM of the preceding residue.
77 read (card(23:26),*) ires
78 read (card(18:20),'(a3)') res
79 if (ires-ishift+ishift1.ne.ires_old) then
83 dc(j,ires+nres)=sccor(j,iii)
86 call sccenter(ires,iii,sccor)
90 c write (iout,'(a80)') card
93 if (res.ne.'GLY' .and. res.ne. 'ACE') then
97 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
99 else if (ibeg.eq.2) then
101 ishift=-ires_old+ires-1
102 c write (iout,*) "New chain started",ires,ishift
107 c write (2,*) "ires",ires," ishift",ish
109 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
110 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
111 if (res.eq.'ACE') then
114 itype(ires)=rescode(ires,res,0)
116 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
117 read(card(61:66),*) bfac(ires)
118 c if(me.eq.king.or..not.out1file)
119 c & write (iout,'(2i3,2x,a,3f8.3)')
120 c & ires,itype(ires),res,(c(j,ires),j=1,3)
123 sccor(j,iii)=c(j,ires)
125 else if (atom.ne.'O '.and.atom(1:1).ne.'H' .and.
126 & atom.ne.'N ' .and. atom.ne.'C ') then
128 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
131 10 if(me.eq.king.or..not.out1file)
132 & write (iout,'(a,i5)') ' Nres: ',ires
133 C Calculate dummy residue coordinates inside the "chain" of a multichain
137 c write (iout,*) i,itype(i),itype(i+1),ntyp1,iterter(i)
138 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
139 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
140 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
141 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
142 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
144 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
145 print *,i,'tu dochodze'
146 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
154 c(j,i)=c(j,i-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
158 dcj=(c(j,i-2)-c(j,i-3))/2.0
159 if (dcj.eq.0) dcj=1.23591524223
164 else !itype(i+1).eq.ntyp1
166 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
167 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
174 c(j,i)=c(j,i+1)-1.9d0*e2(j)
178 dcj=(c(j,i+3)-c(j,i+2))/2.0
179 if (dcj.eq.0) dcj=1.23591524223
184 endif !itype(i+1).eq.ntyp1
185 endif !itype.eq.ntyp1
187 write (iout,*) "After loop in readpbd"
188 C Calculate the CM of the last side chain.
191 dc(j,ires)=sccor(j,iii)
194 call sccenter(ires,iii,sccor)
198 if (itype(nres).ne.10) then
202 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
203 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
210 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
214 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
215 if (dcj.eq.0) dcj=1.23591524223
216 c(j,nres)=c(j,nres-1)+dcj
217 c(j,2*nres)=c(j,nres)
228 c(j,2*nres)=c(j,nres)
230 if (itype(1).eq.ntyp1) then
234 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
235 call refsys(2,3,4,e1,e2,e3,fail)
242 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
246 dcj=(c(j,4)-c(j,3))/2.0
252 C Calculate internal coordinates.
253 if(me.eq.king.or..not.out1file)then
255 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
256 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
257 & (c(j,nres+ires),j=1,3)
261 c write(iout,*)"before int_from_cart nres",nres
262 call int_from_cart(.true.,.false.)
269 dc(j,i)=c(j,i+1)-c(j,i)
270 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
272 c write (iout,*) i,(dc(j,i),j=1,3),(dc_norm(j,i),j=1,3),
277 dc(j,i+nres)=c(j,i+nres)-c(j,i)
278 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
280 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
283 call sc_loc_geom(.false.)
284 call int_from_cart1(.false.)
286 C Copy the coordinates to reference coordinates
290 cref(j,i+nres)=c(j,i+nres)
293 100 format (//' alpha-carbon coordinates ',
294 & ' centroid coordinates'/
295 1 ' ', 6X,'X',11X,'Y',11X,'Z',
296 & 10X,'X',11X,'Y',11X,'Z')
297 110 format (a,'(',i3,')',6f12.5)
301 bfrag(i,j)=bfrag(i,j)-ishift
307 hfrag(i,j)=hfrag(i,j)-ishift
312 c---------------------------------------------------------------------------
313 subroutine readpdb_template(k)
314 C Read the PDB file for read_constr_homology with read2sigma
315 C and convert the peptide geometry into virtual-chain geometry.
318 include 'COMMON.LOCAL'
320 include 'COMMON.CHAIN'
321 include 'COMMON.INTERACT'
322 include 'COMMON.IOUNITS'
324 include 'COMMON.NAMES'
325 include 'COMMON.CONTROL'
326 include 'COMMON.FRAG'
327 include 'COMMON.SETUP'
328 integer i,j,k,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
330 logical lprn /.false./,fail
331 double precision e1(3),e2(3),e3(3)
332 double precision dcj,efree_temp
336 double precision sccor(3,20)
337 integer rescode,iterter(maxres)
344 c write (2,*) "UNRES_PDB",unres_pdb
352 read (ipdbin,'(a80)',end=10) card
353 if (card(:3).eq.'END') then
355 else if (card(:3).eq.'TER') then
358 itype(ires_old-1)=ntyp1
359 iterter(ires_old-1)=1
360 itype(ires_old)=ntyp1
363 c write (iout,*) "Chain ended",ires,ishift,ires_old
366 dc(j,ires)=sccor(j,iii)
369 call sccenter(ires,iii,sccor)
372 C Fish out the ATOM cards.
373 if (index(card(1:4),'ATOM').gt.0) then
374 read (card(12:16),*) atom
375 c write (iout,*) "! ",atom," !",ires
376 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
377 read (card(23:26),*) ires
378 read (card(18:20),'(a3)') res
379 c write (iout,*) "ires",ires,ires-ishift+ishift1,
380 c & " ires_old",ires_old
381 c write (iout,*) "ishift",ishift," ishift1",ishift1
382 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
383 if (ires-ishift+ishift1.ne.ires_old) then
384 C Calculate the CM of the preceding residue.
388 dc(j,ires)=sccor(j,iii)
391 call sccenter(ires_old,iii,sccor)
396 if (res.eq.'Cl-' .or. res.eq.'Na+') then
399 else if (ibeg.eq.1) then
400 c write (iout,*) "BEG ires",ires
402 if (res.ne.'GLY' .and. res.ne. 'ACE') then
406 ires=ires-ishift+ishift1
408 c write (iout,*) "ishift",ishift," ires",ires,
409 c & " ires_old",ires_old
410 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
412 else if (ibeg.eq.2) then
414 ishift=-ires_old+ires-1
416 c write (iout,*) "New chain started",ires,ishift
419 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
420 ires=ires-ishift+ishift1
423 if (res.eq.'ACE' .or. res.eq.'NHE') then
426 itype(ires)=rescode(ires,res,0)
429 ires=ires-ishift+ishift1
431 c write (iout,*) "ires_old",ires_old," ires",ires
432 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
435 c write (2,*) "ires",ires," res ",res," ity",ity
436 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
437 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
438 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
439 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
441 write (iout,'(2i3,2x,a,3f8.3)')
442 & ires,itype(ires),res,(c(j,ires),j=1,3)
446 sccor(j,iii)=c(j,ires)
448 if (ishift.ne.0) then
449 ires_ca=ires+ishift-ishift1
453 c write (*,*) card(23:27),ires,itype(ires)
454 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
455 & atom.ne.'N' .and. atom.ne.'C' .and.
456 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
457 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
458 c write (iout,*) "sidechain ",atom
460 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
464 10 if(me.eq.king.or..not.out1file)
465 & write (iout,'(a,i5)') ' Nres: ',ires
466 C Calculate dummy residue coordinates inside the "chain" of a multichain
470 c write (iout,*) i,itype(i),itype(i+1)
471 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
472 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
473 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
474 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
475 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
477 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
478 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
485 c(j,i)=c(j,i-1)-1.9d0*e2(j)
489 dcj=(c(j,i-2)-c(j,i-3))/2.0
490 if (dcj.eq.0) dcj=1.23591524223
495 else !itype(i+1).eq.ntyp1
497 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
498 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
505 c(j,i)=c(j,i+1)-1.9d0*e2(j)
509 dcj=(c(j,i+3)-c(j,i+2))/2.0
510 if (dcj.eq.0) dcj=1.23591524223
515 endif !itype(i+1).eq.ntyp1
516 endif !itype.eq.ntyp1
518 C Calculate the CM of the last side chain.
521 dc(j,ires)=sccor(j,iii)
524 call sccenter(ires,iii,sccor)
528 if (itype(nres).ne.10) then
532 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
533 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
540 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
544 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
545 if (dcj.eq.0) dcj=1.23591524223
546 c(j,nres)=c(j,nres-1)+dcj
547 c(j,2*nres)=c(j,nres)
558 c(j,2*nres)=c(j,nres)
560 if (itype(1).eq.ntyp1) then
564 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
565 call refsys(2,3,4,e1,e2,e3,fail)
572 c(j,1)=c(j,2)-1.9d0*e2(j)
576 dcj=(c(j,4)-c(j,3))/2.0
582 C Copy the coordinates to reference coordinates
588 C Calculate internal coordinates.
589 if (out_template_coord) then
591 & "Cartesian coordinates of the reference structure"
592 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
593 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
595 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
596 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
597 & (c(j,ires+nres),j=1,3)
600 C Calculate internal coordinates.
601 call int_from_cart(.true.,.true.)
602 call sc_loc_geom(.false.)
609 dc(j,i)=c(j,i+1)-c(j,i)
610 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
615 dc(j,i+nres)=c(j,i+nres)-c(j,i)
616 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
618 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
624 cref(j,i+nres)=c(j,i+nres)