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
24 integer iterter(maxres)
25 double precision efree_temp
30 read (ipdbin,'(a80)',end=10) card
31 ! write (iout,'(a)') card
32 if (card(:5).eq.'HELIX') then
35 read(card(22:25),*) hfrag(1,nhfrag)
36 read(card(34:37),*) hfrag(2,nhfrag)
38 if (card(:5).eq.'SHEET') then
41 read(card(24:26),*) bfrag(1,nbfrag)
42 read(card(35:37),*) bfrag(2,nbfrag)
43 !rc----------------------------------------
44 !rc to be corrected !!!
45 bfrag(3,nbfrag)=bfrag(1,nbfrag)
46 bfrag(4,nbfrag)=bfrag(2,nbfrag)
47 !rc----------------------------------------
49 if (card(:3).eq.'END') then
51 else if (card(:3).eq.'TER') then
54 itype(ires_old-1)=ntyp1
60 ! write (iout,*) "Chain ended",ires,ishift,ires_old
63 dc(j,ires)=sccor(j,iii)
66 call sccenter(ires,iii,sccor)
71 if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
72 ! Fish out the ATOM cards.
73 if (index(card(1:4),'ATOM').gt.0) then
74 read (card(12:16),*) atom
75 c write (2,'(a)') card
76 ! write (iout,*) "! ",atom," !",ires
77 ! if (atom.eq.'CA' .or. atom.eq.'CH3') then
78 read (card(23:26),*) ires
79 read (card(18:20),'(a3)') res
80 ! write (iout,*) "ires",ires,ires-ishift+ishift1,
81 ! & " ires_old",ires_old
82 ! write (iout,*) "ishift",ishift," ishift1",ishift1
83 ! write (iout,*) "IRES",ires-ishift+ishift1,ires_old
84 if (ires-ishift+ishift1.ne.ires_old) then
85 ! Calculate the CM of the preceding residue.
86 ! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
88 ! write (iout,*) "Calculating sidechain center iii",iii
91 dc(j,ires+nres)=sccor(j,iii)
94 call sccenter(ires_old,iii,sccor)
99 if (res.eq.'Cl-' .or. res.eq.'Na+') then
102 else if (ibeg.eq.1) then
103 c write (iout,*) "BEG ires",ires
105 if (res.ne.'GLY' .and. res.ne. 'ACE') then
109 ires=ires-ishift+ishift1
111 ! write (iout,*) "ishift",ishift," ires",ires,&
112 ! " ires_old",ires_old
114 else if (ibeg.eq.2) then
116 ishift=-ires_old+ires-1 !!!!!
117 ishift1=ishift1-1 !!!!!
118 ! write (iout,*) "New chain started",ires,ishift,ishift1,"!"
119 ires=ires-ishift+ishift1
123 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
124 ires=ires-ishift+ishift1
127 if (res.eq.'ACE' .or. res.eq.'NHE') then
130 itype(ires)=rescode(ires,res,0)
133 ires=ires-ishift+ishift1
135 ! write (iout,*) "ires_old",ires_old," ires",ires
136 if (card(27:27).eq."A" .or. card(27:27).eq."B") then
139 ! write (2,*) "ires",ires," res ",res!," ity"!,ity
140 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
141 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
142 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
143 ! write (iout,*) "backbone ",atom
145 write (iout,'(2i3,2x,a,3f8.3)')
146 & ires,itype(ires),res,(c(j,ires),j=1,3)
150 sccor(j,iii)=c(j,ires)
152 c write (2,*) card(23:27),ires,itype(ires),iii
153 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
154 & atom.ne.'N' .and. atom.ne.'C' .and.
155 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
156 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
157 ! write (iout,*) "sidechain ",atom
159 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
160 c write (2,*) "iii",iii
164 10 write (iout,'(a,i5)') ' Nres: ',ires
165 C Calculate dummy residue coordinates inside the "chain" of a multichain
169 c write (iout,*) i,itype(i)
171 if (itype(i).eq.ntyp1) then
172 if (itype(i+1).eq.ntyp1) then
173 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
174 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
175 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
176 C if (unres_pdb) then
177 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
178 C call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
185 C c(j,i)=c(j,i-1)-1.9d0*e2(j)
189 dcj=(c(j,i-2)-c(j,i-3))/2.0
194 else !itype(i+1).eq.ntyp1
195 C if (unres_pdb) then
196 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
197 C call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
204 C c(j,i)=c(j,i+1)-1.9d0*e2(j)
208 dcj=(c(j,i+3)-c(j,i+2))/2.0
213 endif !itype(i+1).eq.ntyp1
214 endif !itype.eq.ntyp1
216 C Calculate the CM of the last side chain.
217 call sccenter(ires,iii,sccor)
220 if (itype(nres).ne.10) then
224 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
225 c(j,nres)=c(j,nres-1)+dcj
226 c(j,2*nres)=c(j,nres)
236 c(j,2*nres)=c(j,nres)
238 if (itype(1).eq.ntyp1) then
242 dcj=(c(j,4)-c(j,3))/2.0
247 C Calculate internal coordinates.
250 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
251 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
252 & (c(j,nres+ires),j=1,3)
254 call int_from_cart(.true.,.false.)
258 dc(j,i)=c(j,i+1)-c(j,i)
259 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
264 dc(j,i+nres)=c(j,i+nres)-c(j,i)
265 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
267 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
271 C Copy the coordinates to reference coordinates
275 cref(j,i+nres)=c(j,i+nres)
278 100 format ('Residue alpha-carbon coordinates ',
279 & ' centroid coordinates'/
280 1 ' ', 6X,'X',7X,'Y',7X,'Z',
281 & 12X,'X',7X,'Y',7X,'Z')
282 110 format (a,'(',i3,')',6f12.5)
287 c---------------------------------------------------------------------------
288 subroutine int_from_cart(lside,lprn)
291 include 'DIMENSIONS.ZSCOPT'
292 include 'COMMON.LOCAL'
294 include 'COMMON.CHAIN'
295 include 'COMMON.INTERACT'
296 include 'COMMON.IOUNITS'
298 include 'COMMON.NAMES'
299 character*3 seq,atom,res
301 double precision sccor(3,50)
303 double precision dist,alpha,beta,di
308 & 'Internal coordinates calculated from crystal structure.'
310 write (iout,'(8a)') ' Res ',' dvb',' Theta',
311 & ' Phi',' Dsc_id',' Dsc',' Alpha',
314 write (iout,'(4a)') ' Res ',' dvb',' Theta',
320 c write (iout,*) i,i-1,(c(j,i),j=1,3),(c(j,i-1),j=1,3),dist(i,i-1)
321 if (itype(i-1).ne.ntyp1 .and. itype(i).ne.ntyp1 .and.
322 & (dist(i,i-1).lt.1.0D0 .or. dist(i,i-1).gt.6.0D0)) then
323 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
327 vbld_inv(i)=1.0d0/vbld(i)
328 theta(i+1)=alpha(i-1,i,i+1)
329 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
331 c if (itype(1).eq.ntyp1) then
333 c c(j,1)=c(j,2)+(c(j,3)-c(j,4))
336 c if (itype(nres).eq.ntyp1) then
338 c c(j,nres)=c(j,nres-1)+(c(j,nres-2)-c(j,nres-3))
344 c(j,maxres2)=0.5D0*(c(j,i-1)+c(j,i+1))
349 if (itype(i).ne.10) then
350 vbld_inv(i+nres)=1.0d0/di
352 vbld_inv(i+nres)=0.0d0
355 alph(i)=alpha(nres+i,i,maxres2)
356 omeg(i)=beta(nres+i,i,maxres2,i+1)
359 alph(i)=alpha(nres+i,i,maxres2)
360 omeg(i)=beta(nres+i,i,maxres2,i+1)
363 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
364 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),di,
365 & rad2deg*alph(i),rad2deg*omeg(i)
370 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
371 & rad2deg*theta(i),rad2deg*phi(i)
376 c---------------------------------------------------------------------------
377 subroutine sccenter(ires,nscat,sccor)
380 include 'COMMON.CHAIN'
381 integer ires,nscat,i,j
382 double precision sccor(3,50),sccmj
386 sccmj=sccmj+sccor(j,i)
388 dc(j,ires)=sccmj/nscat
392 c---------------------------------------------------------------------------
393 subroutine sc_loc_geom(lprn)
394 implicit real*8 (a-h,o-z)
396 include 'DIMENSIONS.ZSCOPT'
397 include 'COMMON.LOCAL'
399 include 'COMMON.CHAIN'
400 include 'COMMON.INTERACT'
401 include 'COMMON.IOUNITS'
403 include 'COMMON.NAMES'
404 include 'COMMON.CONTROL'
405 include 'COMMON.SETUP'
406 double precision x_prime(3),y_prime(3),z_prime(3)
410 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
414 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
416 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
420 dc_norm(j,i+nres)=0.0d0
425 costtab(i+1) =dcos(theta(i+1))
426 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
427 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
428 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
429 cosfac2=0.5d0/(1.0d0+costtab(i+1))
430 cosfac=dsqrt(cosfac2)
431 sinfac2=0.5d0/(1.0d0-costtab(i+1))
432 sinfac=dsqrt(sinfac2)
434 if (it.ne.10 .and. itype(i).ne.ntyp1) then
436 C Compute the axes of tghe local cartesian coordinates system; store in
437 c x_prime, y_prime and z_prime
445 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
446 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
448 c write (iout,*) "x_prime",(x_prime(j),j=1,3)
449 c write (iout,*) "y_prime",(y_prime(j),j=1,3)
450 call vecpr(x_prime,y_prime,z_prime)
451 c write (iout,*) "z_prime",(z_prime(j),j=1,3)
453 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
454 C to local coordinate system. Store in xx, yy, zz.
460 xx = xx + x_prime(j)*dc_norm(j,i+nres)
461 yy = yy + y_prime(j)*dc_norm(j,i+nres)
462 zz = zz + z_prime(j)*dc_norm(j,i+nres)
475 write (iout,*) "xxref,yyref,zzref"
478 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),yyref(i),
484 c---------------------------------------------------------------------------
485 subroutine bond_regular
489 include 'COMMON.LOCAL'
490 include 'COMMON.INTERACT'
491 include 'COMMON.CHAIN'
496 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
497 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
498 c print *,vbld(i+1),vbld(i+1+nres)
500 c Adam 2/26/20 Alter virtual bonds for non-blocking end groups of each chain
506 vbld_inv(i1)=vbld_inv(i1)*2
509 vbld(i2+1)=vbld(i2+1)/2
510 vbld_inv(i2+1)=vbld_inv(i2+1)*2
515 c---------------------------------------------------------------------------
516 subroutine readpdb_template(k)
517 C Read the PDB file for read_constr_homology with read2sigma
518 C and convert the peptide geometry into virtual-chain geometry.
519 implicit real*8 (a-h,o-z)
521 include 'DIMENSIONS.ZSCOPT'
522 include 'COMMON.LOCAL'
524 include 'COMMON.CHAIN'
525 include 'COMMON.INTERACT'
526 include 'COMMON.IOUNITS'
528 include 'COMMON.NAMES'
529 include 'COMMON.CONTROL'
530 include 'COMMON.SETUP'
531 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
532 logical lprn /.false./,fail
533 double precision e1(3),e2(3),e3(3)
534 double precision dcj,efree_temp
538 double precision sccor(3,20)
539 integer rescode,iterter(maxres)
546 c write (2,*) "UNRES_PDB",unres_pdb
554 read (ipdbin,'(a80)',end=10) card
555 if (card(:3).eq.'END') then
557 else if (card(:3).eq.'TER') then
560 itype(ires_old-1)=ntyp1
561 iterter(ires_old-1)=1
562 itype(ires_old)=ntyp1
565 c write (iout,*) "Chain ended",ires,ishift,ires_old
568 dc(j,ires)=sccor(j,iii)
571 call sccenter(ires,iii,sccor)
574 C Fish out the ATOM cards.
575 if (index(card(1:4),'ATOM').gt.0) then
576 read (card(12:16),*) atom
577 c write (iout,*) "! ",atom," !",ires
578 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
579 read (card(23:26),*) ires
580 read (card(18:20),'(a3)') res
581 c write (iout,*) "ires",ires,ires-ishift+ishift1,
582 c & " ires_old",ires_old
583 c write (iout,*) "ishift",ishift," ishift1",ishift1
584 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
585 if (ires-ishift+ishift1.ne.ires_old) then
586 C Calculate the CM of the preceding residue.
590 dc(j,ires)=sccor(j,iii)
593 call sccenter(ires_old,iii,sccor)
598 if (res.eq.'Cl-' .or. res.eq.'Na+') then
601 else if (ibeg.eq.1) then
602 c write (iout,*) "BEG ires",ires
604 if (res.ne.'GLY' .and. res.ne. 'ACE') then
608 ires=ires-ishift+ishift1
610 c write (iout,*) "ishift",ishift," ires",ires,
611 c & " ires_old",ires_old
612 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
614 else if (ibeg.eq.2) then
616 ishift=-ires_old+ires-1
618 c write (iout,*) "New chain started",ires,ishift
621 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
622 ires=ires-ishift+ishift1
625 if (res.eq.'ACE' .or. res.eq.'NHE') then
628 itype(ires)=rescode(ires,res,0)
631 ires=ires-ishift+ishift1
633 c write (iout,*) "ires_old",ires_old," ires",ires
634 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
637 c write (2,*) "ires",ires," res ",res," ity",ity
638 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
639 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
640 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
641 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
643 write (iout,'(2i3,2x,a,3f8.3)')
644 & ires,itype(ires),res,(c(j,ires),j=1,3)
648 sccor(j,iii)=c(j,ires)
650 if (ishift.ne.0) then
651 ires_ca=ires+ishift-ishift1
655 c write (*,*) card(23:27),ires,itype(ires)
656 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
657 & atom.ne.'N' .and. atom.ne.'C' .and.
658 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
659 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
660 c write (iout,*) "sidechain ",atom
662 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
666 10 write (iout,'(a,i5)') ' Nres: ',ires
667 C Calculate dummy residue coordinates inside the "chain" of a multichain
671 c write (iout,*) i,itype(i),itype(i+1)
672 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
673 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
674 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
675 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
676 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
678 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
679 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
686 c(j,i)=c(j,i-1)-1.9d0*e2(j)
690 dcj=(c(j,i-2)-c(j,i-3))/2.0
691 if (dcj.eq.0) dcj=1.23591524223
696 else !itype(i+1).eq.ntyp1
698 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
699 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
706 c(j,i)=c(j,i+1)-1.9d0*e2(j)
710 dcj=(c(j,i+3)-c(j,i+2))/2.0
711 if (dcj.eq.0) dcj=1.23591524223
716 endif !itype(i+1).eq.ntyp1
717 endif !itype.eq.ntyp1
719 C Calculate the CM of the last side chain.
722 dc(j,ires)=sccor(j,iii)
725 call sccenter(ires,iii,sccor)
729 if (itype(nres).ne.10) then
733 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
734 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
741 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
745 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
746 if (dcj.eq.0) dcj=1.23591524223
747 c(j,nres)=c(j,nres-1)+dcj
748 c(j,2*nres)=c(j,nres)
759 c(j,2*nres)=c(j,nres)
761 if (itype(1).eq.ntyp1) then
765 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
766 call refsys(2,3,4,e1,e2,e3,fail)
773 c(j,1)=c(j,2)-1.9d0*e2(j)
777 dcj=(c(j,4)-c(j,3))/2.0
783 C Copy the coordinates to reference coordinates
789 C Calculate internal coordinates.
790 if (out_template_coord) then
792 & "Cartesian coordinates of the reference structure"
793 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
794 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
796 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
797 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
798 & (c(j,ires+nres),j=1,3)
801 C Calculate internal coordinates.
802 c call int_from_cart1(.false.)
803 call int_from_cart(.true.,.true.)
804 call sc_loc_geom(.true.)
811 dc(j,i)=c(j,i+1)-c(j,i)
812 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
817 dc(j,i+nres)=c(j,i+nres)-c(j,i)
818 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
820 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
826 cref(j,i+nres)=c(j,i+nres)