2 C Read the PDB file and convert the peptide geometry into virtual-chain
4 implicit real*8 (a-h,o-z)
9 include 'COMMON.INTERACT'
10 include 'COMMON.IOUNITS'
12 include 'COMMON.NAMES'
13 include 'COMMON.CONTROL'
14 include 'COMMON.DISTFIT'
15 include 'COMMON.SETUP'
16 include 'COMMON.SBRIDGE'
17 character*3 seq,atom,res
20 double precision e1(3),e2(3),e3(3)
21 integer rescode,iterter(maxres),cou
32 read (ipdbin,'(a80)',end=10) 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 crc----------------------------------------
45 crc to be corrected !!!
46 bfrag(3,nbfrag)=bfrag(1,nbfrag)
47 bfrag(4,nbfrag)=bfrag(2,nbfrag)
48 crc----------------------------------------
50 if (card(:3).eq.'END') then
52 else if (card(:3).eq.'TER') then
55 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)
69 C Fish out the ATOM cards.
70 if (index(card(1:4),'ATOM').gt.0) then
71 read (card(14:16),'(a3)') atom
72 if (atom.eq.'CA' .or. atom.eq.'CH3') then
73 C Calculate the CM of the preceding residue.
77 dc(j,ires+nres)=sccor(j,iii)
80 call sccenter(ires,iii,sccor)
84 c write (iout,'(a80)') card
85 read (card(23:26),*) ires
86 read (card(18:20),'(a3)') res
89 if (res.ne.'GLY' .and. res.ne. 'ACE') then
93 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
95 else if (ibeg.eq.2) then
97 ishift=-ires_old+ires-1
98 c write (iout,*) "New chain started",ires,ishift
102 c write (2,*) "ires",ires," ishift",ishift
103 if (res.eq.'ACE') then
106 itype(ires)=rescode(ires,res,0)
108 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
109 read(card(61:66),*) bfac(ires)
110 c if(me.eq.king.or..not.out1file)
111 c & write (iout,'(2i3,2x,a,3f8.3)')
112 c & ires,itype(ires),res,(c(j,ires),j=1,3)
115 sccor(j,iii)=c(j,ires)
117 else if (atom.ne.'O '.and.atom(1:1).ne.'H' .and.
118 & atom.ne.'N ' .and. atom.ne.'C ') then
120 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
124 10 if(me.eq.king.or..not.out1file)
125 & write (iout,'(a,i5)') ' Nres: ',ires
126 C Calculate dummy residue coordinates inside the "chain" of a multichain
130 c write (iout,*) i,itype(i),itype(i+1),ntyp1,iterter(i)
131 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
132 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
133 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
134 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
135 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
137 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
138 print *,i,'tu dochodze'
139 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
147 c(j,i)=c(j,i-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
151 dcj=(c(j,i-2)-c(j,i-3))/2.0
152 if (dcj.eq.0) dcj=1.23591524223
157 else !itype(i+1).eq.ntyp1
159 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
160 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
167 c(j,i)=c(j,i+1)-1.9d0*e2(j)
171 dcj=(c(j,i+3)-c(j,i+2))/2.0
172 if (dcj.eq.0) dcj=1.23591524223
177 endif !itype(i+1).eq.ntyp1
178 endif !itype.eq.ntyp1
180 write (iout,*) "After loop in readpbd"
181 C Calculate the CM of the last side chain.
184 dc(j,ires)=sccor(j,iii)
187 call sccenter(ires,iii,sccor)
191 if (itype(nres).ne.10) then
195 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
196 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
203 c(j,nres)=c(j,nres-1)+1.9d0*(-e1(j)+e2(j))/sqrt(2.0d0)
207 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
208 if (dcj.eq.0) dcj=1.23591524223
209 c(j,nres)=c(j,nres-1)+dcj
210 c(j,2*nres)=c(j,nres)
221 c(j,2*nres)=c(j,nres)
223 if (itype(1).eq.ntyp1) then
227 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
228 call refsys(2,3,4,e1,e2,e3,fail)
235 c(j,1)=c(j,2)+1.9d0*(e1(j)-e2(j))/dsqrt(2.0d0)
239 dcj=(c(j,4)-c(j,3))/2.0
245 C Calculate internal coordinates.
246 if(me.eq.king.or..not.out1file)then
248 write (iout,'(2i3,2x,a,3f8.3,5x,3f8.3)')
249 & ires,itype(ires),restyp(itype(ires)),(c(j,ires),j=1,3),
250 & (c(j,nres+ires),j=1,3)
254 c write(iout,*)"before int_from_cart nres",nres
255 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)
265 c write (iout,*) i,(dc(j,i),j=1,3),(dc_norm(j,i),j=1,3),
270 dc(j,i+nres)=c(j,i+nres)-c(j,i)
271 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
273 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
276 call sc_loc_geom(.false.)
277 call int_from_cart1(.false.)
279 C Copy the coordinates to reference coordinates
283 cref(j,i+nres)=c(j,i+nres)
286 100 format (//' alpha-carbon coordinates ',
287 & ' centroid coordinates'/
288 1 ' ', 6X,'X',11X,'Y',11X,'Z',
289 & 10X,'X',11X,'Y',11X,'Z')
290 110 format (a,'(',i3,')',6f12.5)
294 bfrag(i,j)=bfrag(i,j)-ishift
300 hfrag(i,j)=hfrag(i,j)-ishift
305 c---------------------------------------------------------------------------
306 subroutine int_from_cart(lside,lprn)
307 implicit real*8 (a-h,o-z)
312 include 'COMMON.LOCAL'
314 include 'COMMON.CHAIN'
315 include 'COMMON.INTERACT'
316 include 'COMMON.IOUNITS'
318 include 'COMMON.NAMES'
319 include 'COMMON.CONTROL'
320 include 'COMMON.SETUP'
321 character*3 seq,atom,res
323 dimension sccor(3,50)
327 if(me.eq.king.or..not.out1file)then
331 & 'Internal coordinates calculated from crystal structure.'
333 write (iout,'(8a)') ' Res ',' dvb',' Theta',
334 & ' Phi',' Dsc_id',' Dsc',' Alpha',
337 write (iout,'(4a)') ' Res ',' dvb',' Theta',
346 if (iti.ne.ntyp1 .and. itype(i+1).ne.ntyp1 .and.
347 & (dist(i,i+1).lt.2.0D0 .or. dist(i,i+1).gt.5.0D0)) then
348 write (iout,'(a,i4)') 'Bad Cartesians for residue',i
351 vbld(i+1)=dist(i,i+1)
352 vbld_inv(i+1)=1.0d0/vbld(i+1)
353 c write (iout,*) "i",i+1," vbld",vbld(i+1)," vbld_inv",
355 if (i.gt.1) theta(i+1)=alpha(i-1,i,i+1)
356 if (i.gt.2) phi(i+1)=beta(i-2,i-1,i,i+1)
358 c if (unres_pdb) then
359 c if (itype(1).eq.21) then
360 c theta(3)=90.0d0*deg2rad
361 c phi(4)=180.0d0*deg2rad
363 c vbld_inv(2)=1.0d0/vbld(2)
365 c if (itype(nres).eq.21) then
366 c theta(nres)=90.0d0*deg2rad
367 c phi(nres)=180.0d0*deg2rad
369 c vbld_inv(nres)=1.0d0/vbld(2)
376 c(j,maxres2)=0.5D0*(2*c(j,i)+(c(j,i-1)-c(j,i))*vbld_inv(i)
377 & +(c(j,i+1)-c(j,i))*vbld_inv(i+1))
382 if (itype(i).ne.10) then
383 vbld_inv(i+nres)=1.0d0/di
385 vbld_inv(i+nres)=0.0d0
388 alph(i)=alpha(nres+i,i,maxres2)
389 omeg(i)=beta(nres+i,i,maxres2,i+1)
391 if(me.eq.king.or..not.out1file)then
393 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
394 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
395 & rad2deg*alph(i),rad2deg*omeg(i)
401 write (iout,'(a3,i4,7f10.3)') restyp(iti),i,vbld(i),
402 & rad2deg*theta(i),rad2deg*phi(i),dsc(iti),vbld(nres+i),
403 & rad2deg*alph(i),rad2deg*omeg(i)
408 if(me.eq.king.or..not.out1file)
409 & write (iout,'(a3,i4,7f10.3)') restyp(iti),i,dist(i,i-1),
410 & rad2deg*theta(i),rad2deg*phi(i)
415 c-------------------------------------------------------------------------------
416 subroutine sc_loc_geom(lprn)
417 implicit real*8 (a-h,o-z)
422 include 'COMMON.LOCAL'
424 include 'COMMON.CHAIN'
425 include 'COMMON.INTERACT'
426 include 'COMMON.IOUNITS'
428 include 'COMMON.NAMES'
429 include 'COMMON.CONTROL'
430 include 'COMMON.SETUP'
431 double precision x_prime(3),y_prime(3),z_prime(3)
435 dc_norm(j,i)=vbld_inv(i+1)*(c(j,i+1)-c(j,i))
437 c write (iout,*) "i",i," dc",(dc_norm(j,i),j=1,3),
438 c & " vbld",vbld_inv(i+1)
441 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
443 dc_norm(j,i+nres)=vbld_inv(i+nres)*(c(j,i+nres)-c(j,i))
445 c write (iout,*) "i",i," dc",(dc_norm(j,i+nres),j=1,3),
446 c & " vbld",vbld_inv(i+nres)
449 dc_norm(j,i+nres)=0.0d0
454 costtab(i+1) =dcos(theta(i+1))
455 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
456 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
457 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
458 cosfac2=0.5d0/(1.0d0+costtab(i+1))
459 cosfac=dsqrt(cosfac2)
460 sinfac2=0.5d0/(1.0d0-costtab(i+1))
461 sinfac=dsqrt(sinfac2)
463 c write (iout,*) "i",i," costab",costtab(i+1),
464 c & " sintab",sinttab(i+1)
465 c write (iout,*) "dc_norm_b",(dc_norm(j,i-1),j=1,3)
466 c write (iout,*) "dc_norm_s",(dc_norm(j,i+nres),j=1,3)
467 if (it.ne.10 .and. itype(i).ne.ntyp1) then
469 C Compute the axes of tghe local cartesian coordinates system; store in
470 c x_prime, y_prime and z_prime
478 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
479 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
481 c write (iout,*) "x_prime",(x_prime(j),j=1,3)
482 c write (iout,*) "y_prime",(y_prime(j),j=1,3)
483 call vecpr(x_prime,y_prime,z_prime)
484 c write (iout,*) "z_prime",(z_prime(j),j=1,3)
486 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
487 C to local coordinate system. Store in xx, yy, zz.
493 xx = xx + x_prime(j)*dc_norm(j,i+nres)
494 yy = yy + y_prime(j)*dc_norm(j,i+nres)
495 zz = zz + z_prime(j)*dc_norm(j,i+nres)
509 if (me.eq.king.or..not.out1file) then
511 write (iout,*) "xxref,yyref,zzref"
513 write (iout,'(a3,i4,3f10.5)')
514 & restyp(itype(i)),i,xxref(i),yyref(i),zzref(i)
522 c---------------------------------------------------------------------------
523 subroutine sccenter(ires,nscat,sccor)
524 implicit real*8 (a-h,o-z)
526 include 'COMMON.CHAIN'
527 dimension sccor(3,50)
531 sccmj=sccmj+sccor(j,i)
533 dc(j,ires)=sccmj/nscat
537 c---------------------------------------------------------------------------
538 subroutine bond_regular
539 implicit real*8 (a-h,o-z)
542 include 'COMMON.LOCAL'
543 include 'COMMON.CALC'
544 include 'COMMON.INTERACT'
545 include 'COMMON.CHAIN'
549 vbld(i+1+nres)=dsc(iabs(itype(i+1)))
550 vbld_inv(i+1+nres)=dsc_inv(iabs(itype(i+1)))
551 c print *,vbld(i+1),vbld(i+1+nres)
553 c Adam 2/26/20 Alter virtual bonds for non-blocking end groups of each chain
559 vbld_inv(i1)=vbld_inv(i1)*2
562 vbld(i2+1)=vbld(i2+1)/2
563 vbld_inv(i2+1)=vbld_inv(i2+1)*2
568 c---------------------------------------------------------------------------
569 subroutine readpdb_template(k)
570 C Read the PDB file for read_constr_homology with read2sigma
571 C and convert the peptide geometry into virtual-chain geometry.
572 implicit real*8 (a-h,o-z)
574 include 'COMMON.LOCAL'
576 include 'COMMON.CHAIN'
577 include 'COMMON.INTERACT'
578 include 'COMMON.IOUNITS'
580 include 'COMMON.NAMES'
581 include 'COMMON.CONTROL'
582 include 'COMMON.DISTFIT'
583 include 'COMMON.SETUP'
584 integer i,j,ibeg,ishift1,ires,iii,ires_old,ishift,ity,
586 logical lprn /.false./,fail
587 double precision e1(3),e2(3),e3(3)
588 double precision dcj,efree_temp
592 double precision sccor(3,20)
593 integer rescode,iterter(maxres)
600 c write (2,*) "UNRES_PDB",unres_pdb
608 read (ipdbin,'(a80)',end=10) card
609 if (card(:3).eq.'END') then
611 else if (card(:3).eq.'TER') then
614 itype(ires_old-1)=ntyp1
615 iterter(ires_old-1)=1
616 itype(ires_old)=ntyp1
619 c write (iout,*) "Chain ended",ires,ishift,ires_old
622 dc(j,ires)=sccor(j,iii)
625 call sccenter(ires,iii,sccor)
628 C Fish out the ATOM cards.
629 if (index(card(1:4),'ATOM').gt.0) then
630 read (card(12:16),*) atom
631 c write (iout,*) "! ",atom," !",ires
632 c if (atom.eq.'CA' .or. atom.eq.'CH3') then
633 read (card(23:26),*) ires
634 read (card(18:20),'(a3)') res
635 c write (iout,*) "ires",ires,ires-ishift+ishift1,
636 c & " ires_old",ires_old
637 c write (iout,*) "ishift",ishift," ishift1",ishift1
638 c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
639 if (ires-ishift+ishift1.ne.ires_old) then
640 C Calculate the CM of the preceding residue.
644 dc(j,ires)=sccor(j,iii)
647 call sccenter(ires_old,iii,sccor)
652 if (res.eq.'Cl-' .or. res.eq.'Na+') then
655 else if (ibeg.eq.1) then
656 c write (iout,*) "BEG ires",ires
658 if (res.ne.'GLY' .and. res.ne. 'ACE') then
662 ires=ires-ishift+ishift1
664 c write (iout,*) "ishift",ishift," ires",ires,
665 c & " ires_old",ires_old
666 c write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
668 else if (ibeg.eq.2) then
670 ishift=-ires_old+ires-1
672 c write (iout,*) "New chain started",ires,ishift
675 ishift=ishift-(ires-ishift+ishift1-ires_old-1)
676 ires=ires-ishift+ishift1
679 if (res.eq.'ACE' .or. res.eq.'NHE') then
682 itype(ires)=rescode(ires,res,0)
685 ires=ires-ishift+ishift1
687 c write (iout,*) "ires_old",ires_old," ires",ires
688 c if (card(27:27).eq."A" .or. card(27:27).eq."B") then
691 c write (2,*) "ires",ires," res ",res," ity",ity
692 if (atom.eq.'CA' .or. atom.eq.'CH3' .or.
693 & res.eq.'NHE'.and.atom(:2).eq.'HN') then
694 read(card(31:54),'(3f8.3)') (c(j,ires),j=1,3)
695 c write (iout,*) "backbone ",atom ,ires,res, (c(j,ires),j=1,3)
697 write (iout,'(2i3,2x,a,3f8.3)')
698 & ires,itype(ires),res,(c(j,ires),j=1,3)
702 sccor(j,iii)=c(j,ires)
704 if (ishift.ne.0) then
705 ires_ca=ires+ishift-ishift1
709 c write (*,*) card(23:27),ires,itype(ires)
710 else if (atom.ne.'O'.and.atom(1:1).ne.'H' .and.
711 & atom.ne.'N' .and. atom.ne.'C' .and.
712 & atom(:2).ne.'1H' .and. atom(:2).ne.'2H' .and.
713 & atom.ne.'OXT' .and. atom(:2).ne.'3H') then
714 c write (iout,*) "sidechain ",atom
716 read(card(31:54),'(3f8.3)') (sccor(j,iii),j=1,3)
720 10 if(me.eq.king.or..not.out1file)
721 & write (iout,'(a,i5)') ' Nres: ',ires
722 C Calculate dummy residue coordinates inside the "chain" of a multichain
726 c write (iout,*) i,itype(i),itype(i+1)
727 if (itype(i).eq.ntyp1.and.iterter(i).eq.1) then
728 if (itype(i+1).eq.ntyp1.and.iterter(i+1).eq.1 ) then
729 C 16/01/2014 by Adasko: Adding to dummy atoms in the chain
730 C first is connected prevous chain (itype(i+1).eq.ntyp1)=true
731 C second dummy atom is conected to next chain itype(i+1).eq.ntyp1=false
733 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
734 call refsys(i-3,i-2,i-1,e1,e2,e3,fail)
741 c(j,i)=c(j,i-1)-1.9d0*e2(j)
745 dcj=(c(j,i-2)-c(j,i-3))/2.0
746 if (dcj.eq.0) dcj=1.23591524223
751 else !itype(i+1).eq.ntyp1
753 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
754 call refsys(i+1,i+2,i+3,e1,e2,e3,fail)
761 c(j,i)=c(j,i+1)-1.9d0*e2(j)
765 dcj=(c(j,i+3)-c(j,i+2))/2.0
766 if (dcj.eq.0) dcj=1.23591524223
771 endif !itype(i+1).eq.ntyp1
772 endif !itype.eq.ntyp1
774 C Calculate the CM of the last side chain.
777 dc(j,ires)=sccor(j,iii)
780 call sccenter(ires,iii,sccor)
784 if (itype(nres).ne.10) then
788 C 2/15/2013 by Adam: corrected insertion of the last dummy residue
789 call refsys(nres-3,nres-2,nres-1,e1,e2,e3,fail)
796 c(j,nres)=c(j,nres-1)-1.9d0*e2(j)
800 dcj=(c(j,nres-2)-c(j,nres-3))/2.0
801 if (dcj.eq.0) dcj=1.23591524223
802 c(j,nres)=c(j,nres-1)+dcj
803 c(j,2*nres)=c(j,nres)
814 c(j,2*nres)=c(j,nres)
816 if (itype(1).eq.ntyp1) then
820 C 2/15/2013 by Adam: corrected insertion of the first dummy residue
821 call refsys(2,3,4,e1,e2,e3,fail)
828 c(j,1)=c(j,2)-1.9d0*e2(j)
832 dcj=(c(j,4)-c(j,3))/2.0
838 C Copy the coordinates to reference coordinates
844 C Calculate internal coordinates.
845 if (out_template_coord) then
847 & "Cartesian coordinates of the reference structure"
848 write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
849 & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
851 write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
852 & restyp(itype(ires)),ires,(c(j,ires),j=1,3),
853 & (c(j,ires+nres),j=1,3)
856 C Calculate internal coordinates.
857 call int_from_cart(.true.,.true.)
858 call sc_loc_geom(.false.)
865 dc(j,i)=c(j,i+1)-c(j,i)
866 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
871 dc(j,i+nres)=c(j,i+nres)-c(j,i)
872 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
874 c write (iout,*) i,(dc(j,i+nres),j=1,3),(dc_norm(j,i+nres),j=1,3),
880 cref(j,i+nres)=c(j,i+nres)