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,ifree
24 double precision dcj!,efree_temp
38 read (ipdbin,'(a80)',end=10) card
39 c write (iout,'(a)') card
41 if (card(:5).eq.'HELIX') then
44 read(card(22:25),*) hfrag(1,nhfrag)
45 read(card(34:37),*) hfrag(2,nhfrag)
47 if (card(:5).eq.'SHEET') then
50 read(card(24:26),*) bfrag(1,nbfrag)
51 read(card(35:37),*) bfrag(2,nbfrag)
52 !rc----------------------------------------
53 !rc to be corrected !!!
54 bfrag(3,nbfrag)=bfrag(1,nbfrag)
55 bfrag(4,nbfrag)=bfrag(2,nbfrag)
56 !rc----------------------------------------
58 if (card(:3).eq.'END') then
60 else if (card(:3).eq.'TER') then
63 itype(ires_old-1)=ntyp1
69 write (iout,*) "Chain ended",ires,ishift,ires_old
72 dc(j,ires)=sccor(j,iii)
75 call sccenter(ires,iii,sccor)
81 c if (index(card,"FREE ENERGY").gt.0) then
82 c ifree=index(card,"FREE ENERGY")+12
83 c read(card(ifree:),*,err=1115,end=1115) efree_temp
86 ! Fish out the ATOM cards.
87 if (index(card(1:4),'ATOM').gt.0) then
89 read (card(12:16),*) atom
90 c write (2,'(a)') card
91 c write (iout,*) "ibeg",ibeg
92 c write (iout,*) "! ",atom," !",ires
93 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
94 read (card(23:26),*) ires
95 read (card(18:20),'(a3)') res
96 c write (iout,*) "ires",ires,ires-ishift+ishift1,
97 c & " ires_old",ires_old
98 c write (iout,*) "ishift",ishift," ishift1",ishift1
99 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
100 if (ires-ishift+ishift1.ne.ires_old) then
101 ! Calculate the CM of the preceding residue.
102 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
104 c write (iout,*) "Calculating sidechain center iii",iii
105 c write (iout,*) "ires",ires
107 c write (iout,'(i5,3f10.5)') ires,(sccor(j,iii),j=1,3)
109 dc(j,ires_old)=sccor(j,iii)
112 call sccenter(ires_old,iii,sccor)
118 if (res.eq.'Cl-' .or. res.eq.'Na+') then
121 else if (ibeg.eq.1) then
122 c write (iout,*) "BEG ires",ires
124 if (res.ne.'GLY' .and. res.ne. 'ACE') then
128 ires=ires-ishift+ishift1
130 ! write (iout,*) "ishift",ishift," ires",ires,&
131 ! " ires_old",ires_old
133 else if (ibeg.eq.2) then
135 ishift=-ires_old+ires-1 !!!!!
136 ishift1=ishift1-1 !!!!!
137 c write (iout,*) "New chain started",ires,ishift,ishift1,"!"
138 ires=ires-ishift+ishift1
142 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
143 ires=ires-ishift+ishift1
146 if (res.eq.'ACE' .or. res.eq.'NHE') then
149 itype(ires)=rescode(ires,res,0)
152 ires=ires-ishift+ishift1
154 c write (iout,*) "ires_old",ires_old," ires",ires
155 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
158 c write (2,*) "ires",ires," res ",res!," ity"!,ity
159 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
160 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
161 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
162 ! write (iout,*) "backbone ",atom
164 write (iout,'(i6,i3,2x,a,3f8.3)')
165 & ires,itype(ires),res,(c(j,ires),j=1,3)
169 sccor(j,iii)=c(j,ires)
171 c write (2,*) card(23:27),ires,itype(ires),iii
172 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
173 & atom.ne.'N' .and. atom.ne.'C' .and.
174 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
175 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
176 ! write (iout,*) "sidechain ",atom
178 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
179 c write (2,*) "iii",iii
183 10 if(me.eq.king.or..not.out1file)
184 & write (iout,'(a,i5)') ' Nres: ',ires
185 c write (iout,*) "iii",iii
186 C Calculate dummy residue coordinates inside the "chain" of a multichain
189 c write (iout,*) "dc"
191 c write (iout,'(i5,3f10.5)') i,(dc(j,i),j=1,3)
194 c write (iout,*) i,itype(i),itype(i+1),ntyp1,iterter(i)
195 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
196 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
197 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
198 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
199 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
201 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
202 c print *,i,'tu dochodze'
203 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
211 c(j,i)=c(j,i-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
215 dcj=(c(j,i-2)-c(j,i-3))/2.0
216 if (dcj.eq.0) dcj=1.23591524223
222 else !itype(i+1).eq.ntyp1
224 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
225 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
232 c(j,i)=c(j,i+1)-1.9d0*e2(j)
236 dcj=(c(j,i+3)-c(j,i+2))/2.0
237 if (dcj.eq.0) dcj=1.23591524223
243 endif !itype(i+1).eq.ntyp1
244 endif !itype.eq.ntyp1
246 write (iout,*) "After loop in readpbd"
247 C Calculate the CM of the last side chain.
248 if (.not. sccalc) then
251 dc(j,ires)=sccor(j,iii)
254 c write (iout,*) "Calling sccenter iii",iii
255 call sccenter(ires,iii,sccor)
260 if (itype(nres).ne.10) then
264 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
265 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
272 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
276 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
277 if (dcj.eq.0) dcj=1.23591524223
278 c(j,nres)=c(j,nres-1)+dcj
279 c(j,2*nres)=c(j,nres)
290 c(j,2*nres)=c(j,nres)
292 if (itype(1).eq.ntyp1) then
296 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
297 call refsys(2,3,4,e1,e2,e3,fail)
304 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
308 dcj=(c(j,4)-c(j,3))/2.0
314 C Calculate internal coordinates.
315 if(me.eq.king.or..not.out1file)then
317 & "Cartesian coordinates of the reference structure"
318 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
319 & "Residue ","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
321 write (iout,'(a3,1x,i4,3f8.3,5x,3f8.3)')
322 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
323 & (c(j,ires+nres),j=1,3)
329 zero=zero.or.itype(ires).eq.0
332 write (iout,'(2a)') "Gaps in PDB coordinates detected;",
333 & " look for ZERO in the control output above."
334 write (iout,'(2a)') "Repair the PDB file using MODELLER",
335 & " or other softwared and resubmit."
339 c write(iout,*)"before int_from_cart nres",nres
340 call int_from_cart(.true.,.false.)
347 dc(j,i)=c(j,i+1)-c(j,i)
348 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
350 c write (iout,*) i,(dc(j,i),j=1,3),(dc_norm(j,i),j=1,3),
355 dc(j,i+nres)=c(j,i+nres)-c(j,i)
356 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
358 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
361 call sc_loc_geom(.false.)
362 call int_from_cart1(.false.)
364 C Copy the coordinates to reference coordinates
368 cref(j,i+nres)=c(j,i+nres)
371 100 format (//' alpha-carbon coordinates ',
372 & ' centroid coordinates'/
373 1 ' ', 7X,'X',11X,'Y',11X,'Z',
374 & 10X,'X',11X,'Y',11X,'Z')
375 110 format (a,'(',i4,')',6f12.5)
379 bfrag(i,j)=bfrag(i,j)-ishift
385 hfrag(i,j)=hfrag(i,j)-ishift
390 c---------------------------------------------------------------------------
391 subroutine readpdb_template(k)
392 C Read the PDB file for read_constr_homology with read2sigma
393 C and convert the peptide geometry into virtual-chain geometry.
396 include 'COMMON.LOCAL'
398 include 'COMMON.CHAIN'
399 include 'COMMON.INTERACT'
400 include 'COMMON.IOUNITS'
402 include 'COMMON.NAMES'
403 include 'COMMON.CONTROL'
404 include 'COMMON.FRAG'
405 include 'COMMON.SETUP'
406 integer i,j,k,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
408 logical lprn /.false./,fail
409 double precision e1(3),e2(3),e3(3)
410 double precision dcj,efree_temp
414 double precision sccor(3,20)
415 integer rescode,iterter(maxres)
422 c write (2,*) "UNRES_PDB",unres_pdb
430 read (ipdbin,'(a80)',end=10) card
431 if (card(:3).eq.'END') then
433 else if (card(:3).eq.'TER') then
436 itype(ires_old-1)=ntyp1
437 iterter(ires_old-1)=1
438 itype(ires_old)=ntyp1
441 c write (iout,*) "Chain ended",ires,ishift,ires_old
444 dc(j,ires)=sccor(j,iii)
447 call sccenter(ires,iii,sccor)
450 C Fish out the ATOM cards.
451 if (index(card(1:4),'ATOM').gt.0) then
452 read (card(12:16),*) atom
453 c write (iout,*) "! ",atom," !",ires
454 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
455 read (card(23:26),*) ires
456 read (card(18:20),'(a3)') res
457 c write (iout,*) "ires",ires,ires-ishift+ishift1,
458 c & " ires_old",ires_old
459 c write (iout,*) "ishift",ishift," ishift1",ishift1
460 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
461 if (ires-ishift+ishift1.ne.ires_old) then
462 C Calculate the CM of the preceding residue.
466 dc(j,ires_old)=sccor(j,iii)
469 call sccenter(ires_old,iii,sccor)
474 if (res.eq.'Cl-' .or. res.eq.'Na+') then
477 else if (ibeg.eq.1) then
478 c write (iout,*) "BEG ires",ires
480 if (res.ne.'GLY' .and. res.ne. 'ACE') then
484 ires=ires-ishift+ishift1
486 c write (iout,*) "ishift",ishift," ires",ires,
487 c & " ires_old",ires_old
488 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
490 else if (ibeg.eq.2) then
492 ishift=-ires_old+ires-1
494 c write (iout,*) "New chain started",ires,ishift
497 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
498 ires=ires-ishift+ishift1
501 if (res.eq.'ACE' .or. res.eq.'NHE') then
504 itype(ires)=rescode(ires,res,0)
507 ires=ires-ishift+ishift1
509 c write (iout,*) "ires_old",ires_old," ires",ires
510 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
513 c write (2,*) "ires",ires," res ",res," ity",ity
514 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
515 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
516 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
517 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
519 write (iout,'(2i3,2x,a,3f8.3)')
520 & ires,itype(ires),res,(c(j,ires),j=1,3)
524 sccor(j,iii)=c(j,ires)
526 if (ishift.ne.0) then
527 ires_ca=ires+ishift-ishift1
531 c write (*,*) card(23:27),ires,itype(ires)
532 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
533 & atom.ne.'N' .and. atom.ne.'C' .and.
534 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
535 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
536 c write (iout,*) "sidechain ",atom
538 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
542 10 if(me.eq.king.or..not.out1file)
543 & write (iout,'(a,i5)') ' Nres: ',ires
544 C Calculate dummy residue coordinates inside the "chain" of a multichain
548 c write (iout,*) i,itype(i),itype(i+1)
549 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
550 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
551 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
552 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
553 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
555 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
556 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
563 c(j,i)=c(j,i-1)-1.9d0*e2(j)
567 dcj=(c(j,i-2)-c(j,i-3))/2.0
568 if (dcj.eq.0) dcj=1.23591524223
573 else !itype(i+1).eq.ntyp1
575 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
576 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
583 c(j,i)=c(j,i+1)-1.9d0*e2(j)
587 dcj=(c(j,i+3)-c(j,i+2))/2.0
588 if (dcj.eq.0) dcj=1.23591524223
593 endif !itype(i+1).eq.ntyp1
594 endif !itype.eq.ntyp1
596 C Calculate the CM of the last side chain.
599 dc(j,ires)=sccor(j,iii)
602 call sccenter(ires,iii,sccor)
606 if (itype(nres).ne.10) then
610 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
611 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
618 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
622 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
623 if (dcj.eq.0) dcj=1.23591524223
624 c(j,nres)=c(j,nres-1)+dcj
625 c(j,2*nres)=c(j,nres)
636 c(j,2*nres)=c(j,nres)
638 if (itype(1).eq.ntyp1) then
642 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
643 call refsys(2,3,4,e1,e2,e3,fail)
650 c(j,1)=c(j,2)-1.9d0*e2(j)
654 dcj=(c(j,4)-c(j,3))/2.0
660 C Copy the coordinates to reference coordinates
666 C Calculate internal coordinates.
667 if (out_template_coord) then
669 & "Cartesian coordinates of the reference structure"
670 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
671 & "Residue ","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
673 write (iout,'(a3,1x,i4,3f8.3,5x,3f8.3)')
674 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
675 & (c(j,ires+nres),j=1,3)
678 C Calculate internal coordinates.
679 call int_from_cart(.true.,out_template_coord)
680 call sc_loc_geom(.false.)
687 dc(j,i)=c(j,i+1)-c(j,i)
688 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
693 dc(j,i+nres)=c(j,i+nres)-c(j,i)
694 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
696 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
702 cref(j,i+nres)=c(j,i+nres)