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,ibeg
34 read (ipdbin,'(a80)',end=10) card
35 if (card(:5).eq.'HELIX') then
38 read(card(22:25),*) hfrag(1,nhfrag)
39 read(card(34:37),*) hfrag(2,nhfrag)
41 if (card(:5).eq.'SHEET') then
44 read(card(24:26),*) bfrag(1,nbfrag)
45 read(card(35:37),*) bfrag(2,nbfrag)
46 crc----------------------------------------
47 crc to be corrected !!!
48 bfrag(3,nbfrag)=bfrag(1,nbfrag)
49 bfrag(4,nbfrag)=bfrag(2,nbfrag)
50 crc----------------------------------------
52 if (card(:3).eq.'END') then
54 else if (card(:3).eq.'TER') then
57 itype(ires_old-1)=ntyp1
62 write (iout,*) "Chain ended",ires,ishift,ires_old
65 dc(j,ires)=sccor(j,iii)
68 call sccenter(ires,iii,sccor)
71 C Fish out the ATOM cards.
72 if (index(card(1:4),'ATOM').gt.0) then
73 read (card(14:16),'(a3)') atom
74 if (atom.eq.'CA' .or. atom.eq.'CH3') then
75 C Calculate the CM of the preceding residue.
79 dc(j,ires+nres)=sccor(j,iii)
82 call sccenter(ires,iii,sccor)
86 c write (iout,'(a80)') card
87 read (card(23:26),*) ires
88 read (card(18:20),'(a3)') res
91 if (res.ne.'GLY' .and. res.ne. 'ACE') then
95 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
97 else if (ibeg.eq.2) then
99 ishift=-ires_old+ires-1
100 c write (iout,*) "New chain started",ires,ishift
104 c write (2,*) "ires",ires," ishift",ishift
105 if (res.eq.'ACE') then
108 itype(ires)=rescode(ires,res,0)
110 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
111 read(card(61:66),*) bfac(ires)
112 c if(me.eq.king.or..not.out1file)
113 c & write (iout,'(2i3,2x,a,3f8.3)')
114 c & ires,itype(ires),res,(c(j,ires),j=1,3)
117 sccor(j,iii)=c(j,ires)
119 else if (atom.ne.'O '.and.atom(1:1).ne.'H' .and.
120 & atom.ne.'N ' .and. atom.ne.'C ') then
122 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
126 10 if(me.eq.king.or..not.out1file)
127 & write (iout,'(a,i5)') ' Nres: ',ires
128 C Calculate dummy residue coordinates inside the "chain" of a multichain
132 c write (iout,*) i,itype(i),itype(i+1),ntyp1,iterter(i)
133 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
134 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
135 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
136 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
137 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
139 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
140 print *,i,'tu dochodze'
141 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
149 c(j,i)=c(j,i-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
153 dcj=(c(j,i-2)-c(j,i-3))/2.0
154 if (dcj.eq.0) dcj=1.23591524223
159 else !itype(i+1).eq.ntyp1
161 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
162 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
169 c(j,i)=c(j,i+1)-1.9d0*e2(j)
173 dcj=(c(j,i+3)-c(j,i+2))/2.0
174 if (dcj.eq.0) dcj=1.23591524223
179 endif !itype(i+1).eq.ntyp1
180 endif !itype.eq.ntyp1
182 write (iout,*) "After loop in readpbd"
183 C Calculate the CM of the last side chain.
186 dc(j,ires)=sccor(j,iii)
189 call sccenter(ires,iii,sccor)
193 if (itype(nres).ne.10) then
197 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
198 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
205 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
209 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
210 if (dcj.eq.0) dcj=1.23591524223
211 c(j,nres)=c(j,nres-1)+dcj
212 c(j,2*nres)=c(j,nres)
223 c(j,2*nres)=c(j,nres)
225 if (itype(1).eq.ntyp1) then
229 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
230 call refsys(2,3,4,e1,e2,e3,fail)
237 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
241 dcj=(c(j,4)-c(j,3))/2.0
247 C Calculate internal coordinates.
248 if(me.eq.king.or..not.out1file)then
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)
256 c write(iout,*)"before int_from_cart nres",nres
257 call int_from_cart(.true.,.false.)
264 dc(j,i)=c(j,i+1)-c(j,i)
265 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
267 c write (iout,*) i,(dc(j,i),j=1,3),(dc_norm(j,i),j=1,3),
272 dc(j,i+nres)=c(j,i+nres)-c(j,i)
273 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
275 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
278 call sc_loc_geom(.false.)
279 call int_from_cart1(.false.)
281 C Copy the coordinates to reference coordinates
285 cref(j,i+nres)=c(j,i+nres)
288 100 format (//' alpha-carbon coordinates ',
289 & ' centroid coordinates'/
290 1 ' ', 6X,'X',11X,'Y',11X,'Z',
291 & 10X,'X',11X,'Y',11X,'Z')
292 110 format (a,'(',i3,')',6f12.5)
296 bfrag(i,j)=bfrag(i,j)-ishift
302 hfrag(i,j)=hfrag(i,j)-ishift
307 c---------------------------------------------------------------------------
308 subroutine int_from_cart(lside,lprn)
314 include 'COMMON.LOCAL'
316 include 'COMMON.CHAIN'
317 include 'COMMON.INTERACT'
318 include 'COMMON.IOUNITS'
320 include 'COMMON.NAMES'
321 include 'COMMON.CONTROL'
322 include 'COMMON.SETUP'
323 double precision dist,alpha,beta
324 character*3 seq,atom,res
326 double precision sccor(3,50)
330 double precision di,cosfac2,sinfac2,cosfac,sinfac
332 if(me.eq.king.or..not.out1file)then
336 & 'Internal coordinates calculated from crystal structure.'
338 write (iout,'(8a)') ' Res ',' dvb',' Theta',
339 & ' Phi',' Dsc_id',' Dsc',' Alpha',
342 write (iout,'(4a)') ' Res ',' dvb',' Theta',
351 if (iti.ne.ntyp1 .and. itype(i+1).ne.ntyp1 .and.
352 & (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0)) then
353 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
356 vbld(i+1)=dist(i,i+1)
357 vbld_inv(i+1)=1.0d0/vbld(i+1)
358 c write (iout,*) "i",i+1," vbld",vbld(i+1)," vbld_inv",
360 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
361 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
363 c if (unres_pdb) then
364 c if (itype(1).eq.21) then
365 c theta(3)=90.0d0*deg2rad
366 c phi(4)=180.0d0*deg2rad
368 c vbld_inv(2)=1.0d0/vbld(2)
370 c if (itype(nres).eq.21) then
371 c theta(nres)=90.0d0*deg2rad
372 c phi(nres)=180.0d0*deg2rad
374 c vbld_inv(nres)=1.0d0/vbld(2)
381 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
382 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
387 if (itype(i).ne.10) then
388 vbld_inv(i+nres)=1.0d0/di
390 vbld_inv(i+nres)=0.0d0
393 alph(i)=alpha(nres+i,i,maxres2)
394 omeg(i)=beta(nres+i,i,maxres2,i+1)
396 if(me.eq.king.or..not.out1file)then
398 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
399 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
400 & rad2deg*alph(i),rad2deg*omeg(i)
406 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
407 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
408 & rad2deg*alph(i),rad2deg*omeg(i)
413 if(me.eq.king.or..not.out1file)
414 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
415 & rad2deg*theta(i),rad2deg*phi(i)
420 c-------------------------------------------------------------------------------
421 subroutine sc_loc_geom(lprn)
427 include 'COMMON.LOCAL'
429 include 'COMMON.CHAIN'
430 include 'COMMON.INTERACT'
431 include 'COMMON.IOUNITS'
433 include 'COMMON.NAMES'
434 include 'COMMON.CONTROL'
435 include 'COMMON.SETUP'
436 double precision x_prime(3),y_prime(3),z_prime(3)
439 double precision xx,yy,zz,cosfac,cosfac2,sinfac,sinfac2
442 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
444 c write (iout,*) "i",i," dc",(dc_norm(j,i),j=1,3),
445 c & " vbld",vbld_inv(i+1)
448 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
450 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
452 c write (iout,*) "i",i," dc",(dc_norm(j,i+nres),j=1,3),
453 c & " vbld",vbld_inv(i+nres)
456 dc_norm(j,i+nres)=0.0d0
461 costtab(i+1) =dcos(theta(i+1))
462 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
463 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
464 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
465 cosfac2=0.5d0/(1.0d0+costtab(i+1))
466 cosfac=dsqrt(cosfac2)
467 sinfac2=0.5d0/(1.0d0-costtab(i+1))
468 sinfac=dsqrt(sinfac2)
470 c write (iout,*) "i",i," costab",costtab(i+1),
471 c & " sintab",sinttab(i+1)
472 c write (iout,*) "dc_norm_b",(dc_norm(j,i-1),j=1,3)
473 c write (iout,*) "dc_norm_s",(dc_norm(j,i+nres),j=1,3)
474 if (it.ne.10 .and. itype(i).ne.ntyp1) then
476 C Compute the axes of tghe local cartesian coordinates system; store in
477 c x_prime, y_prime and z_prime
485 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
486 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
488 c write (iout,*) "x_prime",(x_prime(j),j=1,3)
489 c write (iout,*) "y_prime",(y_prime(j),j=1,3)
490 call vecpr(x_prime,y_prime,z_prime)
491 c write (iout,*) "z_prime",(z_prime(j),j=1,3)
493 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
494 C to local coordinate system. Store in xx, yy, zz.
500 xx = xx + x_prime(j)*dc_norm(j,i+nres)
501 yy = yy + y_prime(j)*dc_norm(j,i+nres)
502 zz = zz + z_prime(j)*dc_norm(j,i+nres)
516 if (me.eq.king.or..not.out1file) then
518 write (iout,*) "xxref,yyref,zzref"
520 write (iout,'(a3,i4,3f10.5)')
521 & restyp(itype(i)),i,xxref(i),yyref(i),zzref(i)
529 c---------------------------------------------------------------------------
530 subroutine sccenter(ires,nscat,sccor)
533 include 'COMMON.CHAIN'
534 integer i,j,ires,nscat
535 double precision sccor(3,50)
536 double precision sccmj
540 sccmj=sccmj+sccor(j,i)
542 dc(j,ires)=sccmj/nscat
546 c---------------------------------------------------------------------------
547 subroutine bond_regular
551 include 'COMMON.LOCAL'
552 include 'COMMON.INTERACT'
553 include 'COMMON.CHAIN'
558 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
559 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
560 c print *,vbld(i+1),vbld(i+1+nres)
562 c Adam 2/26/20 Alter virtual bonds for non-blocking end groups of each chain
568 vbld_inv(i1)=vbld_inv(i1)*2
571 vbld(i2+1)=vbld(i2+1)/2
572 vbld_inv(i2+1)=vbld_inv(i2+1)*2
577 c---------------------------------------------------------------------------
578 subroutine readpdb_template(k)
579 C Read the PDB file for read_constr_homology with read2sigma
580 C and convert the peptide geometry into virtual-chain geometry.
583 include 'COMMON.LOCAL'
585 include 'COMMON.CHAIN'
586 include 'COMMON.INTERACT'
587 include 'COMMON.IOUNITS'
589 include 'COMMON.NAMES'
590 include 'COMMON.CONTROL'
591 include 'COMMON.FRAG'
592 include 'COMMON.SETUP'
593 integer i,j,k,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
595 logical lprn /.false./,fail
596 double precision e1(3),e2(3),e3(3)
597 double precision dcj,efree_temp
601 double precision sccor(3,20)
602 integer rescode,iterter(maxres)
609 c write (2,*) "UNRES_PDB",unres_pdb
617 read (ipdbin,'(a80)',end=10) card
618 if (card(:3).eq.'END') then
620 else if (card(:3).eq.'TER') then
623 itype(ires_old-1)=ntyp1
624 iterter(ires_old-1)=1
625 itype(ires_old)=ntyp1
628 c write (iout,*) "Chain ended",ires,ishift,ires_old
631 dc(j,ires)=sccor(j,iii)
634 call sccenter(ires,iii,sccor)
637 C Fish out the ATOM cards.
638 if (index(card(1:4),'ATOM').gt.0) then
639 read (card(12:16),*) atom
640 c write (iout,*) "! ",atom," !",ires
641 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
642 read (card(23:26),*) ires
643 read (card(18:20),'(a3)') res
644 c write (iout,*) "ires",ires,ires-ishift+ishift1,
645 c & " ires_old",ires_old
646 c write (iout,*) "ishift",ishift," ishift1",ishift1
647 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
648 if (ires-ishift+ishift1.ne.ires_old) then
649 C Calculate the CM of the preceding residue.
653 dc(j,ires)=sccor(j,iii)
656 call sccenter(ires_old,iii,sccor)
661 if (res.eq.'Cl-' .or. res.eq.'Na+') then
664 else if (ibeg.eq.1) then
665 c write (iout,*) "BEG ires",ires
667 if (res.ne.'GLY' .and. res.ne. 'ACE') then
671 ires=ires-ishift+ishift1
673 c write (iout,*) "ishift",ishift," ires",ires,
674 c & " ires_old",ires_old
675 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
677 else if (ibeg.eq.2) then
679 ishift=-ires_old+ires-1
681 c write (iout,*) "New chain started",ires,ishift
684 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
685 ires=ires-ishift+ishift1
688 if (res.eq.'ACE' .or. res.eq.'NHE') then
691 itype(ires)=rescode(ires,res,0)
694 ires=ires-ishift+ishift1
696 c write (iout,*) "ires_old",ires_old," ires",ires
697 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
700 c write (2,*) "ires",ires," res ",res," ity",ity
701 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
702 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
703 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
704 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
706 write (iout,'(2i3,2x,a,3f8.3)')
707 & ires,itype(ires),res,(c(j,ires),j=1,3)
711 sccor(j,iii)=c(j,ires)
713 if (ishift.ne.0) then
714 ires_ca=ires+ishift-ishift1
718 c write (*,*) card(23:27),ires,itype(ires)
719 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
720 & atom.ne.'N' .and. atom.ne.'C' .and.
721 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
722 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
723 c write (iout,*) "sidechain ",atom
725 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
729 10 if(me.eq.king.or..not.out1file)
730 & write (iout,'(a,i5)') ' Nres: ',ires
731 C Calculate dummy residue coordinates inside the "chain" of a multichain
735 c write (iout,*) i,itype(i),itype(i+1)
736 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
737 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
738 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
739 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
740 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
742 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
743 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
750 c(j,i)=c(j,i-1)-1.9d0*e2(j)
754 dcj=(c(j,i-2)-c(j,i-3))/2.0
755 if (dcj.eq.0) dcj=1.23591524223
760 else !itype(i+1).eq.ntyp1
762 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
763 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
770 c(j,i)=c(j,i+1)-1.9d0*e2(j)
774 dcj=(c(j,i+3)-c(j,i+2))/2.0
775 if (dcj.eq.0) dcj=1.23591524223
780 endif !itype(i+1).eq.ntyp1
781 endif !itype.eq.ntyp1
783 C Calculate the CM of the last side chain.
786 dc(j,ires)=sccor(j,iii)
789 call sccenter(ires,iii,sccor)
793 if (itype(nres).ne.10) then
797 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
798 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
805 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
809 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
810 if (dcj.eq.0) dcj=1.23591524223
811 c(j,nres)=c(j,nres-1)+dcj
812 c(j,2*nres)=c(j,nres)
823 c(j,2*nres)=c(j,nres)
825 if (itype(1).eq.ntyp1) then
829 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
830 call refsys(2,3,4,e1,e2,e3,fail)
837 c(j,1)=c(j,2)-1.9d0*e2(j)
841 dcj=(c(j,4)-c(j,3))/2.0
847 C Copy the coordinates to reference coordinates
853 C Calculate internal coordinates.
854 if (out_template_coord) then
856 & "Cartesian coordinates of the reference structure"
857 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
858 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
860 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
861 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
862 & (c(j,ires+nres),j=1,3)
865 C Calculate internal coordinates.
866 call int_from_cart(.true.,.true.)
867 call sc_loc_geom(.false.)
874 dc(j,i)=c(j,i+1)-c(j,i)
875 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
880 dc(j,i+nres)=c(j,i+nres)-c(j,i)
881 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
883 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
889 cref(j,i+nres)=c(j,i+nres)