Merge branch 'adasko' of mmka.chem.univ.gda.pl:unres into adasko
[unres.git] / source / cluster / wham / src-M / readpdb.f
index 62f3f2b..725065a 100644 (file)
@@ -23,7 +23,7 @@ C geometry.
         else if (card(:3).eq.'TER') then
 C End current chain
           ires_old=ires+1 
-          itype(ires_old)=21
+          itype(ires_old)=ntyp1
           ibeg=2
 c          write (iout,*) "Chain ended",ires,ishift,ires_old
           call sccenter(ires,iii,sccor)
@@ -44,7 +44,7 @@ c            write (iout,'(a80)') card
               ishift=ires-1
               if (res.ne.'GLY' .and. res.ne. 'ACE') then
                 ishift=ishift-1
-                itype(1)=21
+                itype(1)=ntyp1
               endif
 c              write (iout,*) "ires",ires," ibeg",ibeg," ishift",ishift
               ibeg=0          
@@ -81,7 +81,7 @@ C system
       nres=ires
       do i=2,nres-1
 c        write (iout,*) i,itype(i)
-        if (itype(i).eq.21) then
+        if (itype(i).eq.ntyp1) then
 c          write (iout,*) "dummy",i,itype(i)
           do j=1,3
             c(j,i)=((c(j,i-1)+c(j,i+1))/2+2*c(j,i-1)-c(j,i-2))/2
@@ -96,7 +96,7 @@ C Calculate the CM of the last side chain.
       nstart_sup=1
       if (itype(nres).ne.10) then
         nres=nres+1
-        itype(nres)=21
+        itype(nres)=ntyp1
         do j=1,3
           dcj=c(j,nres-2)-c(j,nres-3)
           c(j,nres)=c(j,nres-1)+dcj
@@ -112,7 +112,7 @@ C Calculate the CM of the last side chain.
         c(j,nres+1)=c(j,1)
         c(j,2*nres)=c(j,nres)
       enddo
-      if (itype(1).eq.21) then
+      if (itype(1).eq.ntyp1) then
         nsup=nsup-1
         nstart_sup=2
         do j=1,3
@@ -144,11 +144,88 @@ c     &   vbld_inv(i+nres)
       enddo
 c      call chainbuild
 C Copy the coordinates to reference coordinates
-      do i=1,2*nres
+c      do i=1,2*nres
+c        do j=1,3
+c          cref(j,i)=c(j,i)
+c        enddo
+c      enddo
+
+      kkk=1
+      lll=0
+      cou=1
+      do i=1,nres
+      lll=lll+1
+cc      write (iout,*) "spraw lancuchy",(c(j,i),j=1,3)
+      if (i.gt.1) then
+      if ((itype(i-1).eq.ntyp1).and.(i.gt.2)) then
+      chain_length=lll-1
+      kkk=kkk+1
+c       write (iout,*) "spraw lancuchy",(c(j,i),j=1,3)
+      lll=1
+      endif
+      endif
         do j=1,3
-          cref(j,i)=c(j,i)
+          cref(j,i,cou)=c(j,i)
+          cref(j,i+nres,cou)=c(j,i+nres)
+          if (i.le.nres) then
+          chain_rep(j,lll,kkk)=c(j,i)
+          chain_rep(j,lll+nres,kkk)=c(j,i+nres)
+          endif
+         enddo
+      enddo
+      do j=1,3
+      chain_rep(j,chain_length,symetr)=chain_rep(j,chain_length,1)
+      chain_rep(j,chain_length+nres,symetr)
+     &=chain_rep(j,chain_length+nres,1)
+      enddo
+
+      if (symetr.gt.1) then
+       call permut(symetr)
+       nperm=1
+       do i=1,symetr
+       nperm=nperm*i
+       enddo
+c       do i=1,nperm
+c       write(iout,*) "tabperm", (tabperm(i,kkk),kkk=1,4)
+c       enddo
+       do i=1,nperm
+        cou=0
+        do kkk=1,symetr
+         icha=tabperm(i,kkk)
+c         write (iout,*) i,icha
+         do lll=1,chain_length
+          cou=cou+1
+           if (cou.le.nres) then
+           do j=1,3
+            kupa=mod(lll,chain_length)
+            iprzes=(kkk-1)*chain_length+lll
+            if (kupa.eq.0) kupa=chain_length
+c            write (iout,*) "kupa", kupa
+            cref(j,iprzes,i)=chain_rep(j,kupa,icha)
+            cref(j,iprzes+nres,i)=chain_rep(j,kupa+nres,icha)
+          enddo
+          endif
+         enddo
         enddo
+       enddo
+       endif
+
+C-koniec robienia kopidm
+      do kkk=1,nperm
+      write (iout,*) "nowa struktura", nperm
+      do i=1,nres
+        write (iout,110) restyp(itype(i)),i,cref(1,i,kkk),
+     &cref(2,i,kkk),
+     &cref(3,i,kkk),cref(1,nres+i,kkk),
+     &cref(2,nres+i,kkk),cref(3,nres+i,kkk)
       enddo
+  100 format (//'              alpha-carbon coordinates       ',
+     &          '     centroid coordinates'/
+     1          '       ', 6X,'X',11X,'Y',11X,'Z',
+     &                          10X,'X',11X,'Y',11X,'Z')
+  110 format (a,'(',i3,')',6f12.5)
+       enddo
+
 
       ishift_pdb=ishift
       return