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
24 double precision dcj,efree_temp
37 read (ipdbin,'(a80)',end=10) card
38 c write (iout,'(a)') card
39 if (card(:5).eq.'HELIX') then
42 read(card(22:25),*) hfrag(1,nhfrag)
43 read(card(34:37),*) hfrag(2,nhfrag)
45 if (card(:5).eq.'SHEET') then
48 read(card(24:26),*) bfrag(1,nbfrag)
49 read(card(35:37),*) bfrag(2,nbfrag)
50 !rc----------------------------------------
51 !rc to be corrected !!!
52 bfrag(3,nbfrag)=bfrag(1,nbfrag)
53 bfrag(4,nbfrag)=bfrag(2,nbfrag)
54 !rc----------------------------------------
56 if (card(:3).eq.'END') then
58 else if (card(:3).eq.'TER') then
61 itype(ires_old-1)=ntyp1
67 write (iout,*) "Chain ended",ires,ishift,ires_old
70 dc(j,ires)=sccor(j,iii)
73 call sccenter(ires,iii,sccor)
79 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
80 ! Fish out the ATOM cards.
81 if (index(card(1:4),'ATOM').gt.0) then
83 read (card(12:16),*) atom
84 c write (2,'(a)') card
85 c write (iout,*) "ibeg",ibeg
86 c write (iout,*) "! ",atom," !",ires
87 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
88 read (card(23:26),*) ires
89 read (card(18:20),'(a3)') res
90 c write (iout,*) "ires",ires,ires-ishift+ishift1,
91 c & " ires_old",ires_old
92 c write (iout,*) "ishift",ishift," ishift1",ishift1
93 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
94 if (ires-ishift+ishift1.ne.ires_old) then
95 ! Calculate the CM of the preceding residue.
96 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
98 c write (iout,*) "Calculating sidechain center iii",iii
101 dc(j,ires+nres)=sccor(j,iii)
104 call sccenter(ires_old,iii,sccor)
110 if (res.eq.'Cl-' .or. res.eq.'Na+') then
113 else if (ibeg.eq.1) then
114 c write (iout,*) "BEG ires",ires
116 if (res.ne.'GLY' .and. res.ne. 'ACE') then
120 ires=ires-ishift+ishift1
122 ! write (iout,*) "ishift",ishift," ires",ires,&
123 ! " ires_old",ires_old
125 else if (ibeg.eq.2) then
127 ishift=-ires_old+ires-1 !!!!!
128 ishift1=ishift1-1 !!!!!
129 c write (iout,*) "New chain started",ires,ishift,ishift1,"!"
130 ires=ires-ishift+ishift1
134 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
135 ires=ires-ishift+ishift1
138 if (res.eq.'ACE' .or. res.eq.'NHE') then
141 itype(ires)=rescode(ires,res,0)
144 ires=ires-ishift+ishift1
146 c write (iout,*) "ires_old",ires_old," ires",ires
147 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
150 c write (2,*) "ires",ires," res ",res!," ity"!,ity
151 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
152 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
153 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
154 ! write (iout,*) "backbone ",atom
156 write (iout,'(2i3,2x,a,3f8.3)')
157 & ires,itype(ires),res,(c(j,ires),j=1,3)
161 sccor(j,iii)=c(j,ires)
163 c write (2,*) card(23:27),ires,itype(ires),iii
164 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
165 & atom.ne.'N' .and. atom.ne.'C' .and.
166 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
167 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
168 ! write (iout,*) "sidechain ",atom
170 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
171 c write (2,*) "iii",iii
175 10 if(me.eq.king.or..not.out1file)
176 & write (iout,'(a,i5)') ' Nres: ',ires
177 c write (iout,*) "iii",iii
178 C Calculate dummy residue coordinates inside the "chain" of a multichain
182 c write (iout,*) i,itype(i),itype(i+1),ntyp1,iterter(i)
183 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
184 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
185 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
186 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
187 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
189 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
190 print *,i,'tu dochodze'
191 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
199 c(j,i)=c(j,i-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
203 dcj=(c(j,i-2)-c(j,i-3))/2.0
204 if (dcj.eq.0) dcj=1.23591524223
210 else !itype(i+1).eq.ntyp1
212 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
213 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
220 c(j,i)=c(j,i+1)-1.9d0*e2(j)
224 dcj=(c(j,i+3)-c(j,i+2))/2.0
225 if (dcj.eq.0) dcj=1.23591524223
231 endif !itype(i+1).eq.ntyp1
232 endif !itype.eq.ntyp1
234 write (iout,*) "After loop in readpbd"
235 C Calculate the CM of the last side chain.
236 if (.not. sccalc) then
239 dc(j,ires)=sccor(j,iii)
242 c write (iout,*) "Calling sccenter iii",iii
243 call sccenter(ires,iii,sccor)
248 if (itype(nres).ne.10) then
252 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
253 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
260 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
264 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
265 if (dcj.eq.0) dcj=1.23591524223
266 c(j,nres)=c(j,nres-1)+dcj
267 c(j,2*nres)=c(j,nres)
278 c(j,2*nres)=c(j,nres)
280 if (itype(1).eq.ntyp1) then
284 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
285 call refsys(2,3,4,e1,e2,e3,fail)
292 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
296 dcj=(c(j,4)-c(j,3))/2.0
302 C Calculate internal coordinates.
303 if(me.eq.king.or..not.out1file)then
305 & "Cartesian coordinates of the reference structure"
306 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
307 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
309 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
310 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
311 & (c(j,ires+nres),j=1,3)
315 c write(iout,*)"before int_from_cart nres",nres
316 call int_from_cart(.true.,.false.)
323 dc(j,i)=c(j,i+1)-c(j,i)
324 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
326 c write (iout,*) i,(dc(j,i),j=1,3),(dc_norm(j,i),j=1,3),
331 dc(j,i+nres)=c(j,i+nres)-c(j,i)
332 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
334 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
337 call sc_loc_geom(.false.)
338 call int_from_cart1(.false.)
340 C Copy the coordinates to reference coordinates
344 cref(j,i+nres)=c(j,i+nres)
347 100 format (//' alpha-carbon coordinates ',
348 & ' centroid coordinates'/
349 1 ' ', 6X,'X',11X,'Y',11X,'Z',
350 & 10X,'X',11X,'Y',11X,'Z')
351 110 format (a,'(',i3,')',6f12.5)
355 bfrag(i,j)=bfrag(i,j)-ishift
361 hfrag(i,j)=hfrag(i,j)-ishift
366 c---------------------------------------------------------------------------
367 subroutine readpdb_template(k)
368 C Read the PDB file for read_constr_homology with read2sigma
369 C and convert the peptide geometry into virtual-chain geometry.
372 include 'COMMON.LOCAL'
374 include 'COMMON.CHAIN'
375 include 'COMMON.INTERACT'
376 include 'COMMON.IOUNITS'
378 include 'COMMON.NAMES'
379 include 'COMMON.CONTROL'
380 include 'COMMON.FRAG'
381 include 'COMMON.SETUP'
382 integer i,j,k,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
384 logical lprn /.false./,fail
385 double precision e1(3),e2(3),e3(3)
386 double precision dcj,efree_temp
390 double precision sccor(3,20)
391 integer rescode,iterter(maxres)
398 c write (2,*) "UNRES_PDB",unres_pdb
406 read (ipdbin,'(a80)',end=10) card
407 if (card(:3).eq.'END') then
409 else if (card(:3).eq.'TER') then
412 itype(ires_old-1)=ntyp1
413 iterter(ires_old-1)=1
414 itype(ires_old)=ntyp1
417 c write (iout,*) "Chain ended",ires,ishift,ires_old
420 dc(j,ires)=sccor(j,iii)
423 call sccenter(ires,iii,sccor)
426 C Fish out the ATOM cards.
427 if (index(card(1:4),'ATOM').gt.0) then
428 read (card(12:16),*) atom
429 c write (iout,*) "! ",atom," !",ires
430 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
431 read (card(23:26),*) ires
432 read (card(18:20),'(a3)') res
433 c write (iout,*) "ires",ires,ires-ishift+ishift1,
434 c & " ires_old",ires_old
435 c write (iout,*) "ishift",ishift," ishift1",ishift1
436 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
437 if (ires-ishift+ishift1.ne.ires_old) then
438 C Calculate the CM of the preceding residue.
442 dc(j,ires)=sccor(j,iii)
445 call sccenter(ires_old,iii,sccor)
450 if (res.eq.'Cl-' .or. res.eq.'Na+') then
453 else if (ibeg.eq.1) then
454 c write (iout,*) "BEG ires",ires
456 if (res.ne.'GLY' .and. res.ne. 'ACE') then
460 ires=ires-ishift+ishift1
462 c write (iout,*) "ishift",ishift," ires",ires,
463 c & " ires_old",ires_old
464 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
466 else if (ibeg.eq.2) then
468 ishift=-ires_old+ires-1
470 c write (iout,*) "New chain started",ires,ishift
473 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
474 ires=ires-ishift+ishift1
477 if (res.eq.'ACE' .or. res.eq.'NHE') then
480 itype(ires)=rescode(ires,res,0)
483 ires=ires-ishift+ishift1
485 c write (iout,*) "ires_old",ires_old," ires",ires
486 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
489 c write (2,*) "ires",ires," res ",res," ity",ity
490 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
491 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
492 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
493 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
495 write (iout,'(2i3,2x,a,3f8.3)')
496 & ires,itype(ires),res,(c(j,ires),j=1,3)
500 sccor(j,iii)=c(j,ires)
502 if (ishift.ne.0) then
503 ires_ca=ires+ishift-ishift1
507 c write (*,*) card(23:27),ires,itype(ires)
508 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
509 & atom.ne.'N' .and. atom.ne.'C' .and.
510 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
511 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
512 c write (iout,*) "sidechain ",atom
514 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
518 10 if(me.eq.king.or..not.out1file)
519 & write (iout,'(a,i5)') ' Nres: ',ires
520 C Calculate dummy residue coordinates inside the "chain" of a multichain
524 c write (iout,*) i,itype(i),itype(i+1)
525 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
526 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
527 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
528 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
529 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
531 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
532 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
539 c(j,i)=c(j,i-1)-1.9d0*e2(j)
543 dcj=(c(j,i-2)-c(j,i-3))/2.0
544 if (dcj.eq.0) dcj=1.23591524223
549 else !itype(i+1).eq.ntyp1
551 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
552 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
559 c(j,i)=c(j,i+1)-1.9d0*e2(j)
563 dcj=(c(j,i+3)-c(j,i+2))/2.0
564 if (dcj.eq.0) dcj=1.23591524223
569 endif !itype(i+1).eq.ntyp1
570 endif !itype.eq.ntyp1
572 C Calculate the CM of the last side chain.
575 dc(j,ires)=sccor(j,iii)
578 call sccenter(ires,iii,sccor)
582 if (itype(nres).ne.10) then
586 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
587 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
594 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
598 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
599 if (dcj.eq.0) dcj=1.23591524223
600 c(j,nres)=c(j,nres-1)+dcj
601 c(j,2*nres)=c(j,nres)
612 c(j,2*nres)=c(j,nres)
614 if (itype(1).eq.ntyp1) then
618 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
619 call refsys(2,3,4,e1,e2,e3,fail)
626 c(j,1)=c(j,2)-1.9d0*e2(j)
630 dcj=(c(j,4)-c(j,3))/2.0
636 C Copy the coordinates to reference coordinates
642 C Calculate internal coordinates.
643 if (out_template_coord) then
645 & "Cartesian coordinates of the reference structure"
646 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
647 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
649 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
650 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
651 & (c(j,ires+nres),j=1,3)
654 C Calculate internal coordinates.
655 call int_from_cart(.true.,.true.)
656 call sc_loc_geom(.false.)
663 dc(j,i)=c(j,i+1)-c(j,i)
664 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
669 dc(j,i+nres)=c(j,i+nres)-c(j,i)
670 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
672 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
678 cref(j,i+nres)=c(j,i+nres)