2 C Read the PDB file and convert the peptide geometry into virtual-chain
6 include 'DIMENSIONS.ZSCOPT'
7 include 'COMMON.CONTROL'
10 include 'COMMON.CHAIN'
11 include 'COMMON.INTERACT'
12 include 'COMMON.IOUNITS'
14 include 'COMMON.NAMES'
15 include 'COMMON.SBRIDGE'
17 character*3 seq,atom,res
19 double precision sccor(3,50)
20 integer i,j,iii,ibeg,ishift,ishift1,ity,ires,ires_old
22 integer rescode,kkk,lll,icha,cou,kupa,iprzes
23 logical lsecondary,sccalc
24 integer iterter(maxres)
25 double precision efree_temp
31 read (ipdbin,'(a80)',end=10) card
32 ! write (iout,'(a)') card
33 if (card(:5).eq.'HELIX') then
36 read(card(22:25),*) hfrag(1,nhfrag)
37 read(card(34:37),*) hfrag(2,nhfrag)
39 if (card(:5).eq.'SHEET') then
42 read(card(24:26),*) bfrag(1,nbfrag)
43 read(card(35:37),*) bfrag(2,nbfrag)
44 !rc----------------------------------------
45 !rc to be corrected !!!
46 bfrag(3,nbfrag)=bfrag(1,nbfrag)
47 bfrag(4,nbfrag)=bfrag(2,nbfrag)
48 !rc----------------------------------------
50 if (card(:3).eq.'END') then
52 else if (card(:3).eq.'TER') then
55 itype(ires_old-1)=ntyp1
61 ! write (iout,*) "Chain ended",ires,ishift,ires_old
64 dc(j,ires)=sccor(j,iii)
67 call sccenter(ires,iii,sccor)
73 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
74 ! Fish out the ATOM cards.
75 if (index(card(1:4),'ATOM').gt.0) then
77 read (card(12:16),*) atom
78 c write (2,'(a)') card
79 ! write (iout,*) "! ",atom," !",ires
80 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
81 read (card(23:26),*) ires
82 read (card(18:20),'(a3)') res
83 ! write (iout,*) "ires",ires,ires-ishift+ishift1,
84 ! & " ires_old",ires_old
85 ! write (iout,*) "ishift",ishift," ishift1",ishift1
86 ! write (iout,*) "IRES",ires-ishift+ishift1,ires_old
87 if (ires-ishift+ishift1.ne.ires_old) then
88 ! Calculate the CM of the preceding residue.
89 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
91 ! write (iout,*) "Calculating sidechain center iii",iii
94 dc(j,ires+nres)=sccor(j,iii)
97 call sccenter(ires_old,iii,sccor)
103 if (res.eq.'Cl-' .or. res.eq.'Na+') then
106 else if (ibeg.eq.1) then
107 c write (iout,*) "BEG ires",ires
109 if (res.ne.'GLY' .and. res.ne. 'ACE') then
113 ires=ires-ishift+ishift1
115 ! write (iout,*) "ishift",ishift," ires",ires,&
116 ! " ires_old",ires_old
118 else if (ibeg.eq.2) then
120 ishift=-ires_old+ires-1 !!!!!
121 ishift1=ishift1-1 !!!!!
122 ! write (iout,*) "New chain started",ires,ishift,ishift1,"!"
123 ires=ires-ishift+ishift1
127 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
128 ires=ires-ishift+ishift1
131 if (res.eq.'ACE' .or. res.eq.'NHE') then
134 itype(ires)=rescode(ires,res,0)
137 ires=ires-ishift+ishift1
139 ! write (iout,*) "ires_old",ires_old," ires",ires
140 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
143 ! write (2,*) "ires",ires," res ",res!," ity"!,ity
144 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
145 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
146 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
147 ! write (iout,*) "backbone ",atom
149 write (iout,'(2i3,2x,a,3f8.3)')
150 & ires,itype(ires),res,(c(j,ires),j=1,3)
154 sccor(j,iii)=c(j,ires)
156 c write (2,*) card(23:27),ires,itype(ires),iii
157 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
158 & atom.ne.'N' .and. atom.ne.'C' .and.
159 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
160 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
161 ! write (iout,*) "sidechain ",atom
163 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
164 c write (2,*) "iii",iii
168 10 write (iout,'(a,i5)') ' Nres: ',ires
169 C Calculate dummy residue coordinates inside the "chain" of a multichain
173 c write (iout,*) i,itype(i)
175 if (itype(i).eq.ntyp1) then
176 if (itype(i+1).eq.ntyp1) then
177 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
178 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
179 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
180 C if (unres_pdb) then
181 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
182 C call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
189 C c(j,i)=c(j,i-1)-1.9d0*e2(j)
193 dcj=(c(j,i-2)-c(j,i-3))/2.0
198 else !itype(i+1).eq.ntyp1
199 C if (unres_pdb) then
200 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
201 C call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
208 C c(j,i)=c(j,i+1)-1.9d0*e2(j)
212 dcj=(c(j,i+3)-c(j,i+2))/2.0
217 endif !itype(i+1).eq.ntyp1
218 endif !itype.eq.ntyp1
220 C Calculate the CM of the last side chain.
221 if (.not. sccalc) call sccenter(ires,iii,sccor)
224 if (itype(nres).ne.10) then
228 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
229 c(j,nres)=c(j,nres-1)+dcj
230 c(j,2*nres)=c(j,nres)
240 c(j,2*nres)=c(j,nres)
242 if (itype(1).eq.ntyp1) then
246 dcj=(c(j,4)-c(j,3))/2.0
251 C Calculate internal coordinates.
254 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
255 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
256 & (c(j,nres+ires),j=1,3)
258 call int_from_cart(.true.,.false.)
262 dc(j,i)=c(j,i+1)-c(j,i)
263 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
268 dc(j,i+nres)=c(j,i+nres)-c(j,i)
269 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
271 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
275 C Copy the coordinates to reference coordinates
279 cref(j,i+nres)=c(j,i+nres)
282 100 format ('Residue alpha-carbon coordinates ',
283 & ' centroid coordinates'/
284 1 ' ', 6X,'X',7X,'Y',7X,'Z',
285 & 12X,'X',7X,'Y',7X,'Z')
286 110 format (a,'(',i3,')',6f12.5)
291 c---------------------------------------------------------------------------
292 subroutine int_from_cart(lside,lprn)
295 include 'DIMENSIONS.ZSCOPT'
296 include 'COMMON.LOCAL'
298 include 'COMMON.CHAIN'
299 include 'COMMON.INTERACT'
300 include 'COMMON.IOUNITS'
302 include 'COMMON.NAMES'
303 character*3 seq,atom,res
305 double precision sccor(3,50)
307 double precision dist,alpha,beta,di
312 & 'Internal coordinates calculated from crystal structure.'
314 write (iout,'(8a)') ' Res ',' dvb',' Theta',
315 & ' Phi',' Dsc_id',' Dsc',' Alpha',
318 write (iout,'(4a)') ' Res ',' dvb',' Theta',
324 c write (iout,*) i,i-1,(c(j,i),j=1,3),(c(j,i-1),j=1,3),dist(i,i-1)
325 if (itype(i-1).ne.ntyp1 .and. itype(i).ne.ntyp1 .and.
326 & (dist(i,i-1).lt.1.0D0 .or. dist(i,i-1).gt.6.0D0)) then
327 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
331 vbld_inv(i)=1.0d0/vbld(i)
332 theta(i+1)=alpha(i-1,i,i+1)
333 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
335 c if (itype(1).eq.ntyp1) then
337 c c(j,1)=c(j,2)+(c(j,3)-c(j,4))
340 c if (itype(nres).eq.ntyp1) then
342 c c(j,nres)=c(j,nres-1)+(c(j,nres-2)-c(j,nres-3))
348 c(j,maxres2)=0.5D0*(c(j,i-1)+c(j,i+1))
353 if (itype(i).ne.10) then
354 vbld_inv(i+nres)=1.0d0/di
356 vbld_inv(i+nres)=0.0d0
359 alph(i)=alpha(nres+i,i,maxres2)
360 omeg(i)=beta(nres+i,i,maxres2,i+1)
363 alph(i)=alpha(nres+i,i,maxres2)
364 omeg(i)=beta(nres+i,i,maxres2,i+1)
367 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
368 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),di,
369 & rad2deg*alph(i),rad2deg*omeg(i)
374 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
375 & rad2deg*theta(i),rad2deg*phi(i)
380 c---------------------------------------------------------------------------
381 subroutine sccenter(ires,nscat,sccor)
384 include 'COMMON.CHAIN'
385 integer ires,nscat,i,j
386 double precision sccor(3,50),sccmj
390 sccmj=sccmj+sccor(j,i)
392 dc(j,ires)=sccmj/nscat
396 c---------------------------------------------------------------------------
397 subroutine sc_loc_geom(lprn)
398 implicit real*8 (a-h,o-z)
400 include 'DIMENSIONS.ZSCOPT'
401 include 'COMMON.LOCAL'
403 include 'COMMON.CHAIN'
404 include 'COMMON.INTERACT'
405 include 'COMMON.IOUNITS'
407 include 'COMMON.NAMES'
408 include 'COMMON.CONTROL'
409 include 'COMMON.SETUP'
410 double precision x_prime(3),y_prime(3),z_prime(3)
414 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
418 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
420 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
424 dc_norm(j,i+nres)=0.0d0
429 costtab(i+1) =dcos(theta(i+1))
430 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
431 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
432 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
433 cosfac2=0.5d0/(1.0d0+costtab(i+1))
434 cosfac=dsqrt(cosfac2)
435 sinfac2=0.5d0/(1.0d0-costtab(i+1))
436 sinfac=dsqrt(sinfac2)
438 if (it.ne.10 .and. itype(i).ne.ntyp1) then
440 C Compute the axes of tghe local cartesian coordinates system; store in
441 c x_prime, y_prime and z_prime
449 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
450 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
452 c write (iout,*) "x_prime",(x_prime(j),j=1,3)
453 c write (iout,*) "y_prime",(y_prime(j),j=1,3)
454 call vecpr(x_prime,y_prime,z_prime)
455 c write (iout,*) "z_prime",(z_prime(j),j=1,3)
457 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
458 C to local coordinate system. Store in xx, yy, zz.
464 xx = xx + x_prime(j)*dc_norm(j,i+nres)
465 yy = yy + y_prime(j)*dc_norm(j,i+nres)
466 zz = zz + z_prime(j)*dc_norm(j,i+nres)
479 write (iout,*) "xxref,yyref,zzref"
482 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),yyref(i),
488 c---------------------------------------------------------------------------
489 subroutine bond_regular
493 include 'COMMON.LOCAL'
494 include 'COMMON.INTERACT'
495 include 'COMMON.CHAIN'
500 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
501 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
502 c print *,vbld(i+1),vbld(i+1+nres)
504 c Adam 2/26/20 Alter virtual bonds for non-blocking end groups of each chain
510 vbld_inv(i1)=vbld_inv(i1)*2
513 vbld(i2+1)=vbld(i2+1)/2
514 vbld_inv(i2+1)=vbld_inv(i2+1)*2
519 c---------------------------------------------------------------------------
520 subroutine readpdb_template(k)
521 C Read the PDB file for read_constr_homology with read2sigma
522 C and convert the peptide geometry into virtual-chain geometry.
523 implicit real*8 (a-h,o-z)
525 include 'DIMENSIONS.ZSCOPT'
526 include 'COMMON.LOCAL'
528 include 'COMMON.CHAIN'
529 include 'COMMON.INTERACT'
530 include 'COMMON.IOUNITS'
532 include 'COMMON.NAMES'
533 include 'COMMON.CONTROL'
534 include 'COMMON.SETUP'
535 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
536 logical lprn /.false./,fail
537 double precision e1(3),e2(3),e3(3)
538 double precision dcj,efree_temp
542 double precision sccor(3,20)
543 integer rescode,iterter(maxres)
550 c write (2,*) "UNRES_PDB",unres_pdb
558 read (ipdbin,'(a80)',end=10) card
559 if (card(:3).eq.'END') then
561 else if (card(:3).eq.'TER') then
564 itype(ires_old-1)=ntyp1
565 iterter(ires_old-1)=1
566 itype(ires_old)=ntyp1
569 c write (iout,*) "Chain ended",ires,ishift,ires_old
572 dc(j,ires)=sccor(j,iii)
575 call sccenter(ires,iii,sccor)
578 C Fish out the ATOM cards.
579 if (index(card(1:4),'ATOM').gt.0) then
580 read (card(12:16),*) atom
581 c write (iout,*) "! ",atom," !",ires
582 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
583 read (card(23:26),*) ires
584 read (card(18:20),'(a3)') res
585 c write (iout,*) "ires",ires,ires-ishift+ishift1,
586 c & " ires_old",ires_old
587 c write (iout,*) "ishift",ishift," ishift1",ishift1
588 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
589 if (ires-ishift+ishift1.ne.ires_old) then
590 C Calculate the CM of the preceding residue.
594 dc(j,ires)=sccor(j,iii)
597 call sccenter(ires_old,iii,sccor)
602 if (res.eq.'Cl-' .or. res.eq.'Na+') then
605 else if (ibeg.eq.1) then
606 c write (iout,*) "BEG ires",ires
608 if (res.ne.'GLY' .and. res.ne. 'ACE') then
612 ires=ires-ishift+ishift1
614 c write (iout,*) "ishift",ishift," ires",ires,
615 c & " ires_old",ires_old
616 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
618 else if (ibeg.eq.2) then
620 ishift=-ires_old+ires-1
622 c write (iout,*) "New chain started",ires,ishift
625 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
626 ires=ires-ishift+ishift1
629 if (res.eq.'ACE' .or. res.eq.'NHE') then
632 itype(ires)=rescode(ires,res,0)
635 ires=ires-ishift+ishift1
637 c write (iout,*) "ires_old",ires_old," ires",ires
638 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
641 c write (2,*) "ires",ires," res ",res," ity",ity
642 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
643 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
644 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
645 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
647 write (iout,'(2i3,2x,a,3f8.3)')
648 & ires,itype(ires),res,(c(j,ires),j=1,3)
652 sccor(j,iii)=c(j,ires)
654 if (ishift.ne.0) then
655 ires_ca=ires+ishift-ishift1
659 c write (*,*) card(23:27),ires,itype(ires)
660 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
661 & atom.ne.'N' .and. atom.ne.'C' .and.
662 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
663 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
664 c write (iout,*) "sidechain ",atom
666 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
670 10 write (iout,'(a,i5)') ' Nres: ',ires
671 C Calculate dummy residue coordinates inside the "chain" of a multichain
675 c write (iout,*) i,itype(i),itype(i+1)
676 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
677 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
678 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
679 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
680 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
682 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
683 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
690 c(j,i)=c(j,i-1)-1.9d0*e2(j)
694 dcj=(c(j,i-2)-c(j,i-3))/2.0
695 if (dcj.eq.0) dcj=1.23591524223
700 else !itype(i+1).eq.ntyp1
702 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
703 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
710 c(j,i)=c(j,i+1)-1.9d0*e2(j)
714 dcj=(c(j,i+3)-c(j,i+2))/2.0
715 if (dcj.eq.0) dcj=1.23591524223
720 endif !itype(i+1).eq.ntyp1
721 endif !itype.eq.ntyp1
723 C Calculate the CM of the last side chain.
726 dc(j,ires)=sccor(j,iii)
729 call sccenter(ires,iii,sccor)
733 if (itype(nres).ne.10) then
737 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
738 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
745 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
749 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
750 if (dcj.eq.0) dcj=1.23591524223
751 c(j,nres)=c(j,nres-1)+dcj
752 c(j,2*nres)=c(j,nres)
763 c(j,2*nres)=c(j,nres)
765 if (itype(1).eq.ntyp1) then
769 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
770 call refsys(2,3,4,e1,e2,e3,fail)
777 c(j,1)=c(j,2)-1.9d0*e2(j)
781 dcj=(c(j,4)-c(j,3))/2.0
787 C Copy the coordinates to reference coordinates
793 C Calculate internal coordinates.
794 if (out_template_coord) then
796 & "Cartesian coordinates of the reference structure"
797 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
798 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
800 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
801 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
802 & (c(j,ires+nres),j=1,3)
805 C Calculate internal coordinates.
806 c call int_from_cart1(.false.)
807 call int_from_cart(.true.,.true.)
808 call sc_loc_geom(.true.)
815 dc(j,i)=c(j,i+1)-c(j,i)
816 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
821 dc(j,i+nres)=c(j,i+nres)-c(j,i)
822 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
824 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
830 cref(j,i+nres)=c(j,i+nres)