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
39 read (ipdbin,'(a80)',end=10) card
40 c write (iout,'(a)') card
42 if (card(:5).eq.'HELIX') then
45 read(card(22:25),*) hfrag(1,nhfrag)
46 read(card(34:37),*) hfrag(2,nhfrag)
48 if (card(:5).eq.'SHEET') then
51 read(card(24:26),*) bfrag(1,nbfrag)
52 read(card(35:37),*) bfrag(2,nbfrag)
53 !rc----------------------------------------
54 !rc to be corrected !!!
55 bfrag(3,nbfrag)=bfrag(1,nbfrag)
56 bfrag(4,nbfrag)=bfrag(2,nbfrag)
57 !rc----------------------------------------
59 if (card(:3).eq.'END') then
61 else if (card(:3).eq.'TER') then
64 itype(ires_old-1)=ntyp1
70 write (iout,*) "Chain ended",ires,ishift,ires_old,ibeg
73 dc(j,ires)=sccor(j,iii)
76 call sccenter(ires,iii,sccor)
82 c if (index(card,"FREE ENERGY").gt.0) then
83 c ifree=index(card,"FREE ENERGY")+12
84 c read(card(ifree:),*,err=1115,end=1115) efree_temp
87 ! Fish out the ATOM cards.
88 if (index(card(1:4),'ATOM').gt.0) then
90 read (card(12:16),*) atom
91 c write (2,'(a)') card
92 c write (iout,*) "ibeg",ibeg
93 c write (iout,*) "! ",atom," !",ires
94 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
95 read (card(23:26),*) ires
96 read (card(18:20),'(a3)') res
97 c write (iout,*) "ires",ires,ires-ishift+ishift1,
98 c & " ires_old",ires_old
99 c write (iout,*) "ishift",ishift," ishift1",ishift1
100 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
101 if (ires-ishift+ishift1.ne.ires_old) then
102 ! Calculate the CM of the preceding residue.
103 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
105 c write (iout,*) "Calculating sidechain center iii",iii
106 c write (iout,*) "ires",ires
108 c write (iout,'(i5,3f10.5)') ires,(sccor(j,iii),j=1,3)
110 dc(j,ires_old)=sccor(j,iii)
113 call sccenter(ires_old,iii,sccor)
119 c write (iout,*) "ibeg",ibeg
120 if (res.eq.'Cl-' .or. res.eq.'Na+') then
123 else if (ibeg.eq.1) then
124 c write (iout,*) "BEG ires",ires
126 if (res.ne.'GLY' .and. res.ne. 'ACE') then
130 ires=ires-ishift+ishift1
132 ! write (iout,*) "ishift",ishift," ires",ires,&
133 ! " ires_old",ires_old
135 else if (ibeg.eq.2) then
137 ishift=-ires_old+ires-1 !!!!!
138 c ishift1=ishift1-1 !!!!!
139 c write (iout,*) "New chain started",ires,ires_old,ishift,
141 ires=ires-ishift+ishift1
142 write (iout,*) "New chain started ires",ires
147 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
148 ires=ires-ishift+ishift1
151 if (res.eq.'ACE' .or. res.eq.'NHE') then
154 itype(ires)=rescode(ires,res,0)
157 ires=ires-ishift+ishift1
159 c write (iout,*) "ires_old",ires_old," ires",ires
160 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
163 c write (2,*) "ires",ires," res ",res!," ity"!,ity
164 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
165 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
166 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
167 read(card(61:66),*) bfac(ires)
168 c write (iout,*) "backbone ",atom
169 c write (iout,*) ires,res,(c(j,ires),j=1,3)
171 write (iout,'(i6,i3,2x,a,3f8.3)')
172 & ires,itype(ires),res,(c(j,ires),j=1,3)
176 sccor(j,iii)=c(j,ires)
178 c write (2,*) card(23:27),ires,itype(ires),iii
179 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
180 & atom.ne.'N' .and. atom.ne.'C' .and.
181 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
182 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
183 ! write (iout,*) "sidechain ",atom
185 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
186 c write (2,*) "iii",iii
190 10 if(me.eq.king.or..not.out1file)
191 & write (iout,'(a,i7)') ' Nres: ',ires
192 c write (iout,*) "iii",iii
193 C Calculate dummy residue coordinates inside the "chain" of a multichain
196 c write (iout,*) "dc"
198 c write (iout,'(i5,3f10.5)') i,(dc(j,i),j=1,3)
201 c write (iout,*) i,itype(i),itype(i+1),ntyp1,iterter(i)
202 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
203 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
204 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
205 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
206 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
208 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
209 c print *,i,'tu dochodze'
210 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
218 c(j,i)=c(j,i-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
222 dcj=(c(j,i-2)-c(j,i-3))/2.0
223 if (dcj.eq.0) dcj=1.23591524223
229 else !itype(i+1).eq.ntyp1
231 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
232 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
239 c(j,i)=c(j,i+1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
243 dcj=(c(j,i+3)-c(j,i+2))/2.0
244 if (dcj.eq.0) dcj=1.23591524223
250 endif !itype(i+1).eq.ntyp1
251 endif !itype.eq.ntyp1
253 write (iout,*) "After loop in readpbd"
254 C Calculate the CM of the last side chain.
255 if (.not. sccalc) then
258 dc(j,ires)=sccor(j,iii)
261 c write (iout,*) "Calling sccenter iii",iii
262 call sccenter(ires,iii,sccor)
267 if (itype(nres).ne.10) then
271 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
272 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
279 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
283 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
284 if (dcj.eq.0) dcj=1.23591524223
285 c(j,nres)=c(j,nres-1)+dcj
286 c(j,2*nres)=c(j,nres)
297 c(j,2*nres)=c(j,nres)
299 if (itype(1).eq.ntyp1) then
303 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
304 call refsys(2,3,4,e1,e2,e3,fail)
311 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
315 dcj=(c(j,4)-c(j,3))/2.0
321 C Calculate internal coordinates.
322 if(me.eq.king.or..not.out1file)then
324 & "Cartesian coordinates of the reference structure"
325 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
326 & "Residue ","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
328 write (iout,'(a3,1x,i6,3f8.3,5x,3f8.3)')
329 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
330 & (c(j,ires+nres),j=1,3)
336 zero=zero.or.itype(ires).eq.0
339 write (iout,'(2a)') "Gaps in PDB coordinates detected;",
340 & " look for ZERO in the control output above."
341 write (iout,'(2a)') "Repair the PDB file using MODELLER",
342 & " or other softwared and resubmit."
346 c write(iout,*)"before int_from_cart nres",nres
347 call int_from_cart(.true.,.false.)
355 dc(j,i)=c(j,i+1)-c(j,i)
356 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
358 c write (iout,*) i,(dc(j,i),j=1,3),(dc_norm(j,i),j=1,3),
363 dc(j,i+nres)=c(j,i+nres)-c(j,i)
364 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
366 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
369 call sc_loc_geom(.false.)
370 call int_from_cart1(.false.)
372 C Copy the coordinates to reference coordinates
376 cref(j,i+nres)=c(j,i+nres)
379 100 format (//' alpha-carbon coordinates ',
380 & ' centroid coordinates'/
381 1 ' ', 7X,'X',11X,'Y',11X,'Z',
382 & 10X,'X',11X,'Y',11X,'Z')
383 110 format (a,'(',i4,')',6f12.5)
387 bfrag(i,j)=bfrag(i,j)-ishift
393 hfrag(i,j)=hfrag(i,j)-ishift
398 c---------------------------------------------------------------------------
399 subroutine readpdb_template(k)
400 C Read the PDB file for read_constr_homology with read2sigma
401 C and convert the peptide geometry into virtual-chain geometry.
404 include 'COMMON.LOCAL'
406 include 'COMMON.CHAIN'
407 include 'COMMON.INTERACT'
408 include 'COMMON.IOUNITS'
410 include 'COMMON.NAMES'
411 include 'COMMON.CONTROL'
412 include 'COMMON.FRAG'
413 include 'COMMON.SETUP'
414 integer i,j,k,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
416 logical lprn /.false./,fail
417 double precision e1(3),e2(3),e3(3)
418 double precision dcj,efree_temp
422 double precision sccor(3,50)
423 integer rescode,iterter(maxres)
431 c write (2,*) "UNRES_PDB",unres_pdb
439 read (ipdbin,'(a80)',end=10) card
440 if (card(:3).eq.'END') then
442 else if (card(:3).eq.'TER') then
445 itype(ires_old-1)=ntyp1
446 iterter(ires_old-1)=1
447 itype(ires_old)=ntyp1
450 c write (iout,*) "Chain ended",ires,ishift,ires_old
453 dc(j,ires)=sccor(j,iii)
456 call sccenter(ires,iii,sccor)
459 C Fish out the ATOM cards.
460 if (index(card(1:4),'ATOM').gt.0) then
461 read (card(12:16),*) atom
462 c write (iout,*) "! ",atom," !",ires
463 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
464 read (card(23:26),*) ires
465 read (card(18:20),'(a3)') res
466 c write (iout,*) "ires",ires,ires-ishift+ishift1,
467 c & " ires_old",ires_old
468 c write (iout,*) "ishift",ishift," ishift1",ishift1
469 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
470 if (ires-ishift+ishift1.ne.ires_old) then
471 C Calculate the CM of the preceding residue.
475 dc(j,ires_old)=sccor(j,iii)
478 call sccenter(ires_old,iii,sccor)
483 if (res.eq.'Cl-' .or. res.eq.'Na+') then
486 else if (ibeg.eq.1) then
487 c write (iout,*) "BEG ires",ires
489 if (res.ne.'GLY' .and. res.ne. 'ACE') then
493 ires=ires-ishift+ishift1
495 c write (iout,*) "ishift",ishift," ires",ires,
496 c & " ires_old",ires_old
497 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
499 else if (ibeg.eq.2) then
501 ishift=-ires_old+ires-1
503 c write (iout,*) "New chain started",ires,ishift
506 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
507 ires=ires-ishift+ishift1
510 if (res.eq.'ACE' .or. res.eq.'NHE') then
513 itype(ires)=rescode(ires,res,0)
516 ires=ires-ishift+ishift1
518 c write (iout,*) "ires_old",ires_old," ires",ires
519 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
522 c write (2,*) "ires",ires," res ",res," ity",ity
523 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
524 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
525 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
526 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
528 write (iout,'(2i3,2x,a,3f8.3)')
529 & ires,itype(ires),res,(c(j,ires),j=1,3)
533 sccor(j,iii)=c(j,ires)
535 if (ishift.ne.0) then
536 ires_ca=ires+ishift-ishift1
540 c write (*,*) card(23:27),ires,itype(ires)
541 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
542 & atom.ne.'N' .and. atom.ne.'C' .and.
543 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
544 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
545 c write (iout,*) "sidechain ",atom
547 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
551 10 if(me.eq.king.or..not.out1file)
552 & write (iout,'(a,i7)') ' Nres: ',ires
553 C Calculate dummy residue coordinates inside the "chain" of a multichain
557 c write (iout,*) i,itype(i),itype(i+1)
558 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
559 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
560 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
561 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
562 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
564 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
565 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
572 c(j,i)=c(j,i-1)-1.9d0*e2(j)
576 dcj=(c(j,i-2)-c(j,i-3))/2.0
577 if (dcj.eq.0) dcj=1.23591524223
582 else !itype(i+1).eq.ntyp1
584 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
585 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
592 c(j,i)=c(j,i+1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
596 dcj=(c(j,i+3)-c(j,i+2))/2.0
597 if (dcj.eq.0) dcj=1.23591524223
602 endif !itype(i+1).eq.ntyp1
603 endif !itype.eq.ntyp1
605 C Calculate the CM of the last side chain.
608 dc(j,ires)=sccor(j,iii)
611 call sccenter(ires,iii,sccor)
615 if (itype(nres).ne.10) then
619 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
620 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
627 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
631 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
632 if (dcj.eq.0) dcj=1.23591524223
633 c(j,nres)=c(j,nres-1)+dcj
634 c(j,2*nres)=c(j,nres)
645 c(j,2*nres)=c(j,nres)
647 if (itype(1).eq.ntyp1) then
651 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
652 call refsys(2,3,4,e1,e2,e3,fail)
659 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
663 dcj=(c(j,4)-c(j,3))/2.0
669 C Copy the coordinates to reference coordinates
675 C Calculate internal coordinates.
676 if (out_template_coord) then
678 & "Cartesian coordinates of the reference structure"
679 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
680 & "Residue ","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
682 write (iout,'(a3,1x,i4,3f8.3,5x,3f8.3)')
683 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
684 & (c(j,ires+nres),j=1,3)
689 zero=zero.or.itype(ires).eq.0
692 write (iout,'(2a)') "Gaps in PDB coordinates detected;",
693 & " look for ZERO in the control output above."
694 write (iout,'(2a)') "Repair the PDB file using MODELLER",
695 & " or other softwared and resubmit."
699 C Calculate internal coordinates.
700 call int_from_cart(.true.,out_template_coord)
701 call sc_loc_geom(.false.)
709 dc(j,i)=c(j,i+1)-c(j,i)
710 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
715 dc(j,i+nres)=c(j,i+nres)-c(j,i)
716 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
718 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
724 cref(j,i+nres)=c(j,i+nres)