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'
16 character*3 seq,atom,res
18 double precision sccor(3,50)
19 integer i,j,iii,ibeg,ishift,ishift1,ity,ires,ires_old
21 integer rescode,kkk,lll,icha,cou,kupa,iprzes
25 read (ipdbin,'(a80)',end=10) card
26 if (card(:3).eq.'END') then
28 else if (card(:3).eq.'TER') then
32 itype(ires_old-1)=ntyp1
35 c write (iout,*) "Chain ended",ires,ishift,ires_old
36 call sccenter(ires,iii,sccor)
38 C Fish out the ATOM cards.
39 if (index(card(1:4),'ATOM').gt.0) then
40 read (card(14:16),'(a3)') atom
41 if (atom.eq.'CA' .or. atom.eq.'CH3') then
42 C Calculate the CM of the preceding residue.
44 call sccenter(ires,iii,sccor)
47 c write (iout,'(a80)') card
48 read (card(23:26),*) ires
49 read (card(18:20),'(a3)') res
52 if (res.ne.'GLY' .and. res.ne. 'ACE') then
56 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
58 else if (ibeg.eq.2) then
60 ishift=-ires_old+ires-1
61 c write (iout,*) "New chain started",ires,ishift
65 c write (2,*) "ires",ires," ishift",ishift
66 if (res.eq.'ACE') then
69 itype(ires)=rescode(ires,res,0)
71 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
72 read(card(61:66),*) bfac(ires)
73 c write (iout,'(2i3,2x,a,3f8.3,5x,f8.3)')
74 c & ires,itype(ires),res,(c(j,ires),j=1,3),bfac(ires)
77 sccor(j,iii)=c(j,ires)
79 else if (atom.ne.'O '.and.atom(1:1).ne.'H' .and.
80 & atom(1:1).ne.'Q' .and. atom(1:2).ne.'1H' .and.
81 & atom(1:2).ne.'2H' .and. atom(1:2).ne.'3H' .and.
82 & atom.ne.'N ' .and. atom.ne.'C ' .and.
83 & atom.ne.'OXT' ) then
85 c write (iout,*) res,ires,iii,atom
86 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
87 c write (iout,'(3f8.3)') (sccor(j,iii),j=1,3)
91 10 write (iout,'(a,i5)') ' Nres: ',ires
92 C Calculate dummy residue coordinates inside the "chain" of a multichain
96 c write (iout,*) i,itype(i)
98 if (itype(i).eq.ntyp1) then
99 if (itype(i+1).eq.ntyp1) then
100 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
101 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
102 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
103 C if (unres_pdb) then
104 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
105 C call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
112 C c(j,i)=c(j,i-1)-1.9d0*e2(j)
116 dcj=(c(j,i-2)-c(j,i-3))/2.0
121 else !itype(i+1).eq.ntyp1
122 C if (unres_pdb) then
123 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
124 C call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
131 C c(j,i)=c(j,i+1)-1.9d0*e2(j)
135 dcj=(c(j,i+3)-c(j,i+2))/2.0
140 endif !itype(i+1).eq.ntyp1
141 endif !itype.eq.ntyp1
143 C Calculate the CM of the last side chain.
144 call sccenter(ires,iii,sccor)
147 if (itype(nres).ne.10) then
151 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
152 c(j,nres)=c(j,nres-1)+dcj
153 c(j,2*nres)=c(j,nres)
163 c(j,2*nres)=c(j,nres)
165 if (itype(1).eq.ntyp1) then
169 dcj=(c(j,4)-c(j,3))/2.0
174 C Calculate internal coordinates.
177 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
178 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
179 & (c(j,nres+ires),j=1,3)
181 call int_from_cart(.true.,.false.)
185 dc(j,i)=c(j,i+1)-c(j,i)
186 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
191 dc(j,i+nres)=c(j,i+nres)-c(j,i)
192 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
194 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
198 C Copy the coordinates to reference coordinates
202 cref(j,i+nres)=c(j,i+nres)
205 100 format ('Residue alpha-carbon coordinates ',
206 & ' centroid coordinates'/
207 1 ' ', 6X,'X',7X,'Y',7X,'Z',
208 & 12X,'X',7X,'Y',7X,'Z')
209 110 format (a,'(',i3,')',6f12.5)
214 c---------------------------------------------------------------------------
215 subroutine int_from_cart(lside,lprn)
218 include 'DIMENSIONS.ZSCOPT'
219 include 'COMMON.LOCAL'
221 include 'COMMON.CHAIN'
222 include 'COMMON.INTERACT'
223 include 'COMMON.IOUNITS'
225 include 'COMMON.NAMES'
226 character*3 seq,atom,res
228 double precision sccor(3,50)
230 double precision dist,alpha,beta,di
235 & 'Internal coordinates calculated from crystal structure.'
237 write (iout,'(8a)') ' Res ',' dvb',' Theta',
238 & ' Phi',' Dsc_id',' Dsc',' Alpha',
241 write (iout,'(4a)') ' Res ',' dvb',' Theta',
247 c write (iout,*) i,i-1,(c(j,i),j=1,3),(c(j,i-1),j=1,3),dist(i,i-1)
248 if (itype(i-1).ne.ntyp1 .and. itype(i).ne.ntyp1 .and.
249 & (dist(i,i-1).lt.1.0D0 .or. dist(i,i-1).gt.6.0D0)) then
250 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
254 vbld_inv(i)=1.0d0/vbld(i)
255 theta(i+1)=alpha(i-1,i,i+1)
256 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
258 c if (itype(1).eq.ntyp1) then
260 c c(j,1)=c(j,2)+(c(j,3)-c(j,4))
263 c if (itype(nres).eq.ntyp1) then
265 c c(j,nres)=c(j,nres-1)+(c(j,nres-2)-c(j,nres-3))
271 c(j,maxres2)=0.5D0*(c(j,i-1)+c(j,i+1))
276 if (itype(i).ne.10) then
277 vbld_inv(i+nres)=1.0d0/di
279 vbld_inv(i+nres)=0.0d0
282 alph(i)=alpha(nres+i,i,maxres2)
283 omeg(i)=beta(nres+i,i,maxres2,i+1)
286 alph(i)=alpha(nres+i,i,maxres2)
287 omeg(i)=beta(nres+i,i,maxres2,i+1)
290 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
291 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),di,
292 & rad2deg*alph(i),rad2deg*omeg(i)
297 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
298 & rad2deg*theta(i),rad2deg*phi(i)
303 c---------------------------------------------------------------------------
304 subroutine sccenter(ires,nscat,sccor)
307 include 'COMMON.CHAIN'
308 integer ires,nscat,i,j
309 double precision sccor(3,50),sccmj
313 sccmj=sccmj+sccor(j,i)
315 dc(j,ires)=sccmj/nscat
319 c---------------------------------------------------------------------------
320 subroutine sc_loc_geom(lprn)
321 implicit real*8 (a-h,o-z)
323 include 'DIMENSIONS.ZSCOPT'
324 include 'COMMON.LOCAL'
326 include 'COMMON.CHAIN'
327 include 'COMMON.INTERACT'
328 include 'COMMON.IOUNITS'
330 include 'COMMON.NAMES'
331 include 'COMMON.CONTROL'
332 include 'COMMON.SETUP'
333 double precision x_prime(3),y_prime(3),z_prime(3)
337 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
341 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
343 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
347 dc_norm(j,i+nres)=0.0d0
352 costtab(i+1) =dcos(theta(i+1))
353 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
354 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
355 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
356 cosfac2=0.5d0/(1.0d0+costtab(i+1))
357 cosfac=dsqrt(cosfac2)
358 sinfac2=0.5d0/(1.0d0-costtab(i+1))
359 sinfac=dsqrt(sinfac2)
361 if (it.ne.10 .and. itype(i).ne.ntyp1) then
363 C Compute the axes of tghe local cartesian coordinates system; store in
364 c x_prime, y_prime and z_prime
372 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
373 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
375 c write (iout,*) "x_prime",(x_prime(j),j=1,3)
376 c write (iout,*) "y_prime",(y_prime(j),j=1,3)
377 call vecpr(x_prime,y_prime,z_prime)
378 c write (iout,*) "z_prime",(z_prime(j),j=1,3)
380 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
381 C to local coordinate system. Store in xx, yy, zz.
387 xx = xx + x_prime(j)*dc_norm(j,i+nres)
388 yy = yy + y_prime(j)*dc_norm(j,i+nres)
389 zz = zz + z_prime(j)*dc_norm(j,i+nres)
402 write (iout,*) "xxref,yyref,zzref"
405 write (iout,'(a3,i4,3f10.5)') restyp(iti),i,xxref(i),yyref(i),
411 c---------------------------------------------------------------------------
412 subroutine bond_regular
413 implicit real*8 (a-h,o-z)
416 include 'COMMON.LOCAL'
417 include 'COMMON.CALC'
418 include 'COMMON.INTERACT'
419 include 'COMMON.CHAIN'
422 vbld_inv(i+1)=1.0d0/vbld(i+1)
423 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
424 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
425 c print *,vbld(i+1),vbld(i+1+nres)
429 c---------------------------------------------------------------------------
430 subroutine readpdb_template(k)
431 C Read the PDB file for read_constr_homology with read2sigma
432 C and convert the peptide geometry into virtual-chain geometry.
433 implicit real*8 (a-h,o-z)
435 include 'DIMENSIONS.ZSCOPT'
436 include 'COMMON.LOCAL'
438 include 'COMMON.CHAIN'
439 include 'COMMON.INTERACT'
440 include 'COMMON.IOUNITS'
442 include 'COMMON.NAMES'
443 include 'COMMON.CONTROL'
444 include 'COMMON.SETUP'
445 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity
446 logical lprn /.false./,fail
447 double precision e1(3),e2(3),e3(3)
448 double precision dcj,efree_temp
452 double precision sccor(3,20)
453 integer rescode,iterter(maxres)
460 c write (2,*) "UNRES_PDB",unres_pdb
468 read (ipdbin,'(a80)',end=10) card
469 if (card(:3).eq.'END') then
471 else if (card(:3).eq.'TER') then
474 itype(ires_old-1)=ntyp1
475 iterter(ires_old-1)=1
476 itype(ires_old)=ntyp1
479 c write (iout,*) "Chain ended",ires,ishift,ires_old
482 dc(j,ires)=sccor(j,iii)
485 call sccenter(ires,iii,sccor)
488 C Fish out the ATOM cards.
489 if (index(card(1:4),'ATOM').gt.0) then
490 read (card(12:16),*) atom
491 c write (iout,*) "! ",atom," !",ires
492 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
493 read (card(23:26),*) ires
494 read (card(18:20),'(a3)') res
495 c write (iout,*) "ires",ires,ires-ishift+ishift1,
496 c & " ires_old",ires_old
497 c write (iout,*) "ishift",ishift," ishift1",ishift1
498 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
499 if (ires-ishift+ishift1.ne.ires_old) then
500 C Calculate the CM of the preceding residue.
504 dc(j,ires)=sccor(j,iii)
507 call sccenter(ires_old,iii,sccor)
512 if (res.eq.'Cl-' .or. res.eq.'Na+') then
515 else if (ibeg.eq.1) then
516 c write (iout,*) "BEG ires",ires
518 if (res.ne.'GLY' .and. res.ne. 'ACE') then
522 ires=ires-ishift+ishift1
524 c write (iout,*) "ishift",ishift," ires",ires,
525 c & " ires_old",ires_old
526 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
528 else if (ibeg.eq.2) then
530 ishift=-ires_old+ires-1
532 c write (iout,*) "New chain started",ires,ishift
535 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
536 ires=ires-ishift+ishift1
539 if (res.eq.'ACE' .or. res.eq.'NHE') then
542 itype(ires)=rescode(ires,res,0)
545 ires=ires-ishift+ishift1
547 c write (iout,*) "ires_old",ires_old," ires",ires
548 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
551 c write (2,*) "ires",ires," res ",res," ity",ity
552 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
553 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
554 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
555 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
557 write (iout,'(2i3,2x,a,3f8.3)')
558 & ires,itype(ires),res,(c(j,ires),j=1,3)
562 sccor(j,iii)=c(j,ires)
564 if (ishift.ne.0) then
565 ires_ca=ires+ishift-ishift1
569 c write (*,*) card(23:27),ires,itype(ires)
570 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
571 & atom.ne.'N' .and. atom.ne.'C' .and.
572 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
573 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
574 c write (iout,*) "sidechain ",atom
576 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
580 10 write (iout,'(a,i5)') ' Nres: ',ires
581 C Calculate dummy residue coordinates inside the "chain" of a multichain
585 c write (iout,*) i,itype(i),itype(i+1)
586 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
587 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
588 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
589 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
590 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
592 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
593 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
600 c(j,i)=c(j,i-1)-1.9d0*e2(j)
604 dcj=(c(j,i-2)-c(j,i-3))/2.0
605 if (dcj.eq.0) dcj=1.23591524223
610 else !itype(i+1).eq.ntyp1
612 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
613 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
620 c(j,i)=c(j,i+1)-1.9d0*e2(j)
624 dcj=(c(j,i+3)-c(j,i+2))/2.0
625 if (dcj.eq.0) dcj=1.23591524223
630 endif !itype(i+1).eq.ntyp1
631 endif !itype.eq.ntyp1
633 C Calculate the CM of the last side chain.
636 dc(j,ires)=sccor(j,iii)
639 call sccenter(ires,iii,sccor)
643 if (itype(nres).ne.10) then
647 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
648 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
655 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
659 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
660 if (dcj.eq.0) dcj=1.23591524223
661 c(j,nres)=c(j,nres-1)+dcj
662 c(j,2*nres)=c(j,nres)
673 c(j,2*nres)=c(j,nres)
675 if (itype(1).eq.ntyp1) then
679 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
680 call refsys(2,3,4,e1,e2,e3,fail)
687 c(j,1)=c(j,2)-1.9d0*e2(j)
691 dcj=(c(j,4)-c(j,3))/2.0
697 C Copy the coordinates to reference coordinates
703 C Calculate internal coordinates.
704 if (out_template_coord) then
706 & "Cartesian coordinates of the reference structure"
707 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
708 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
710 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
711 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
712 & (c(j,ires+nres),j=1,3)
715 C Calculate internal coordinates.
716 c call int_from_cart1(.false.)
717 call int_from_cart(.true.,.true.)
718 call sc_loc_geom(.true.)
725 dc(j,i)=c(j,i+1)-c(j,i)
726 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
731 dc(j,i+nres)=c(j,i+nres)-c(j,i)
732 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
734 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
740 cref(j,i+nres)=c(j,i+nres)