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
36 read (ipdbin,'(a80)',end=10) card
37 c write (iout,'(a)') card
38 if (card(:5).eq.'HELIX') then
41 read(card(22:25),*) hfrag(1,nhfrag)
42 read(card(34:37),*) hfrag(2,nhfrag)
44 if (card(:5).eq.'SHEET') then
47 read(card(24:26),*) bfrag(1,nbfrag)
48 read(card(35:37),*) bfrag(2,nbfrag)
49 !rc----------------------------------------
50 !rc to be corrected !!!
51 bfrag(3,nbfrag)=bfrag(1,nbfrag)
52 bfrag(4,nbfrag)=bfrag(2,nbfrag)
53 !rc----------------------------------------
55 if (card(:3).eq.'END') then
57 else if (card(:3).eq.'TER') then
60 itype(ires_old-1)=ntyp1
66 write (iout,*) "Chain ended",ires,ishift,ires_old
69 dc(j,ires)=sccor(j,iii)
72 call sccenter(ires,iii,sccor)
77 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
78 ! Fish out the ATOM cards.
79 if (index(card(1:4),'ATOM').gt.0) then
80 read (card(12:16),*) atom
81 c write (2,'(a)') card
82 c write (iout,*) "ibeg",ibeg
83 c write (iout,*) "! ",atom," !",ires
84 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
85 read (card(23:26),*) ires
86 read (card(18:20),'(a3)') res
87 c write (iout,*) "ires",ires,ires-ishift+ishift1,
88 c & " ires_old",ires_old
89 c write (iout,*) "ishift",ishift," ishift1",ishift1
90 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
91 if (ires-ishift+ishift1.ne.ires_old) then
92 ! Calculate the CM of the preceding residue.
93 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
95 c write (iout,*) "Calculating sidechain center iii",iii
98 dc(j,ires+nres)=sccor(j,iii)
101 call sccenter(ires_old,iii,sccor)
106 if (res.eq.'Cl-' .or. res.eq.'Na+') then
109 else if (ibeg.eq.1) then
110 c write (iout,*) "BEG ires",ires
112 if (res.ne.'GLY' .and. res.ne. 'ACE') then
116 ires=ires-ishift+ishift1
118 ! write (iout,*) "ishift",ishift," ires",ires,&
119 ! " ires_old",ires_old
121 else if (ibeg.eq.2) then
123 ishift=-ires_old+ires-1 !!!!!
124 ishift1=ishift1-1 !!!!!
125 c write (iout,*) "New chain started",ires,ishift,ishift1,"!"
126 ires=ires-ishift+ishift1
130 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
131 ires=ires-ishift+ishift1
134 if (res.eq.'ACE' .or. res.eq.'NHE') then
137 itype(ires)=rescode(ires,res,0)
140 ires=ires-ishift+ishift1
142 c write (iout,*) "ires_old",ires_old," ires",ires
143 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
146 c write (2,*) "ires",ires," res ",res!," ity"!,ity
147 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
148 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
149 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
150 ! write (iout,*) "backbone ",atom
152 write (iout,'(2i3,2x,a,3f8.3)')
153 & ires,itype(ires),res,(c(j,ires),j=1,3)
157 sccor(j,iii)=c(j,ires)
159 c write (2,*) card(23:27),ires,itype(ires),iii
160 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
161 & atom.ne.'N' .and. atom.ne.'C' .and.
162 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
163 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
164 ! write (iout,*) "sidechain ",atom
166 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
167 c write (2,*) "iii",iii
171 10 if(me.eq.king.or..not.out1file)
172 & write (iout,'(a,i5)') ' Nres: ',ires
173 c write (iout,*) "iii",iii
174 C Calculate dummy residue coordinates inside the "chain" of a multichain
178 c write (iout,*) i,itype(i),itype(i+1),ntyp1,iterter(i)
179 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
180 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
181 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
182 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
183 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
185 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
186 print *,i,'tu dochodze'
187 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
195 c(j,i)=c(j,i-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
199 dcj=(c(j,i-2)-c(j,i-3))/2.0
200 if (dcj.eq.0) dcj=1.23591524223
205 else !itype(i+1).eq.ntyp1
207 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
208 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
215 c(j,i)=c(j,i+1)-1.9d0*e2(j)
219 dcj=(c(j,i+3)-c(j,i+2))/2.0
220 if (dcj.eq.0) dcj=1.23591524223
225 endif !itype(i+1).eq.ntyp1
226 endif !itype.eq.ntyp1
228 write (iout,*) "After loop in readpbd"
229 C Calculate the CM of the last side chain.
232 dc(j,ires)=sccor(j,iii)
235 c write (iout,*) "Calling sccenter iii",iii
236 call sccenter(ires,iii,sccor)
240 if (itype(nres).ne.10) then
244 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
245 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
252 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
256 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
257 if (dcj.eq.0) dcj=1.23591524223
258 c(j,nres)=c(j,nres-1)+dcj
259 c(j,2*nres)=c(j,nres)
270 c(j,2*nres)=c(j,nres)
272 if (itype(1).eq.ntyp1) then
276 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
277 call refsys(2,3,4,e1,e2,e3,fail)
284 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
288 dcj=(c(j,4)-c(j,3))/2.0
294 C Calculate internal coordinates.
295 if(me.eq.king.or..not.out1file)then
297 & "Cartesian coordinates of the reference structure"
298 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
299 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
301 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
302 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
303 & (c(j,ires+nres),j=1,3)
307 c write(iout,*)"before int_from_cart nres",nres
308 call int_from_cart(.true.,.false.)
315 dc(j,i)=c(j,i+1)-c(j,i)
316 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
318 c write (iout,*) i,(dc(j,i),j=1,3),(dc_norm(j,i),j=1,3),
323 dc(j,i+nres)=c(j,i+nres)-c(j,i)
324 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
326 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
329 call sc_loc_geom(.false.)
330 call int_from_cart1(.false.)
332 C Copy the coordinates to reference coordinates
336 cref(j,i+nres)=c(j,i+nres)
339 100 format (//' alpha-carbon coordinates ',
340 & ' centroid coordinates'/
341 1 ' ', 6X,'X',11X,'Y',11X,'Z',
342 & 10X,'X',11X,'Y',11X,'Z')
343 110 format (a,'(',i3,')',6f12.5)
347 bfrag(i,j)=bfrag(i,j)-ishift
353 hfrag(i,j)=hfrag(i,j)-ishift
358 c---------------------------------------------------------------------------
359 subroutine readpdb_template(k)
360 C Read the PDB file for read_constr_homology with read2sigma
361 C and convert the peptide geometry into virtual-chain geometry.
364 include 'COMMON.LOCAL'
366 include 'COMMON.CHAIN'
367 include 'COMMON.INTERACT'
368 include 'COMMON.IOUNITS'
370 include 'COMMON.NAMES'
371 include 'COMMON.CONTROL'
372 include 'COMMON.FRAG'
373 include 'COMMON.SETUP'
374 integer i,j,k,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
376 logical lprn /.false./,fail
377 double precision e1(3),e2(3),e3(3)
378 double precision dcj,efree_temp
382 double precision sccor(3,20)
383 integer rescode,iterter(maxres)
390 c write (2,*) "UNRES_PDB",unres_pdb
398 read (ipdbin,'(a80)',end=10) card
399 if (card(:3).eq.'END') then
401 else if (card(:3).eq.'TER') then
404 itype(ires_old-1)=ntyp1
405 iterter(ires_old-1)=1
406 itype(ires_old)=ntyp1
409 c write (iout,*) "Chain ended",ires,ishift,ires_old
412 dc(j,ires)=sccor(j,iii)
415 call sccenter(ires,iii,sccor)
418 C Fish out the ATOM cards.
419 if (index(card(1:4),'ATOM').gt.0) then
420 read (card(12:16),*) atom
421 c write (iout,*) "! ",atom," !",ires
422 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
423 read (card(23:26),*) ires
424 read (card(18:20),'(a3)') res
425 c write (iout,*) "ires",ires,ires-ishift+ishift1,
426 c & " ires_old",ires_old
427 c write (iout,*) "ishift",ishift," ishift1",ishift1
428 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
429 if (ires-ishift+ishift1.ne.ires_old) then
430 C Calculate the CM of the preceding residue.
434 dc(j,ires)=sccor(j,iii)
437 call sccenter(ires_old,iii,sccor)
442 if (res.eq.'Cl-' .or. res.eq.'Na+') then
445 else if (ibeg.eq.1) then
446 c write (iout,*) "BEG ires",ires
448 if (res.ne.'GLY' .and. res.ne. 'ACE') then
452 ires=ires-ishift+ishift1
454 c write (iout,*) "ishift",ishift," ires",ires,
455 c & " ires_old",ires_old
456 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
458 else if (ibeg.eq.2) then
460 ishift=-ires_old+ires-1
462 c write (iout,*) "New chain started",ires,ishift
465 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
466 ires=ires-ishift+ishift1
469 if (res.eq.'ACE' .or. res.eq.'NHE') then
472 itype(ires)=rescode(ires,res,0)
475 ires=ires-ishift+ishift1
477 c write (iout,*) "ires_old",ires_old," ires",ires
478 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
481 c write (2,*) "ires",ires," res ",res," ity",ity
482 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
483 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
484 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
485 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
487 write (iout,'(2i3,2x,a,3f8.3)')
488 & ires,itype(ires),res,(c(j,ires),j=1,3)
492 sccor(j,iii)=c(j,ires)
494 if (ishift.ne.0) then
495 ires_ca=ires+ishift-ishift1
499 c write (*,*) card(23:27),ires,itype(ires)
500 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
501 & atom.ne.'N' .and. atom.ne.'C' .and.
502 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
503 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
504 c write (iout,*) "sidechain ",atom
506 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
510 10 if(me.eq.king.or..not.out1file)
511 & write (iout,'(a,i5)') ' Nres: ',ires
512 C Calculate dummy residue coordinates inside the "chain" of a multichain
516 c write (iout,*) i,itype(i),itype(i+1)
517 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
518 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
519 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
520 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
521 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
523 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
524 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
531 c(j,i)=c(j,i-1)-1.9d0*e2(j)
535 dcj=(c(j,i-2)-c(j,i-3))/2.0
536 if (dcj.eq.0) dcj=1.23591524223
541 else !itype(i+1).eq.ntyp1
543 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
544 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
551 c(j,i)=c(j,i+1)-1.9d0*e2(j)
555 dcj=(c(j,i+3)-c(j,i+2))/2.0
556 if (dcj.eq.0) dcj=1.23591524223
561 endif !itype(i+1).eq.ntyp1
562 endif !itype.eq.ntyp1
564 C Calculate the CM of the last side chain.
567 dc(j,ires)=sccor(j,iii)
570 call sccenter(ires,iii,sccor)
574 if (itype(nres).ne.10) then
578 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
579 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
586 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
590 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
591 if (dcj.eq.0) dcj=1.23591524223
592 c(j,nres)=c(j,nres-1)+dcj
593 c(j,2*nres)=c(j,nres)
604 c(j,2*nres)=c(j,nres)
606 if (itype(1).eq.ntyp1) then
610 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
611 call refsys(2,3,4,e1,e2,e3,fail)
618 c(j,1)=c(j,2)-1.9d0*e2(j)
622 dcj=(c(j,4)-c(j,3))/2.0
628 C Copy the coordinates to reference coordinates
634 C Calculate internal coordinates.
635 if (out_template_coord) then
637 & "Cartesian coordinates of the reference structure"
638 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
639 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
641 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
642 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
643 & (c(j,ires+nres),j=1,3)
646 C Calculate internal coordinates.
647 call int_from_cart(.true.,.true.)
648 call sc_loc_geom(.false.)
655 dc(j,i)=c(j,i+1)-c(j,i)
656 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
661 dc(j,i+nres)=c(j,i+nres)-c(j,i)
662 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
664 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
670 cref(j,i+nres)=c(j,i+nres)