1 subroutine chain_symmetry(nchain,nres,itype,chain_border,
2 & chain_length,npermchain,tabpermchain)
4 c Determine chain symmetry. nperm is the number of permutations and
5 c tabperchain contains the allowed permutations of the chains.
9 include "COMMON.IOUNITS"
10 integer nchain,nres,itype(nres),chain_border(2,maxchain),
11 & chain_length(nchain),itemp(maxchain),
12 & npermchain,tabpermchain(maxchain,maxperm),
13 & tabperm(maxchain,maxperm),mapchain(maxchain),
14 & iequiv(maxchain,maxres),iflag(maxres)
15 integer i,j,k,l,ii,nchain_group,nequiv(maxchain),iieq,
20 c print*,"npermchain",npermchain," tabpermchain",tabpermchain(1,1)
24 c Look for equivalent chains
27 write(iout,*) "nchain",nchain
29 write(iout,*) "chain",i," from",chain_border(1,i),
30 & " to",chain_border(2,i)
32 & "sequence ",(itype(j),j=chain_border(1,i),chain_border(2,i))
40 if (iflag(i).gt.0) cycle
42 nchain_group=nchain_group+1
44 iequiv(iieq,nchain_group)=i
46 if (iflag(j).gt.0.or.chain_length(i).ne.chain_length(j)) cycle
48 c do while(k.lt.chain_length(i) .and.
49 c & itype(chain_border(1,i)+k).eq.itype(chain_border(1,j)+k))
50 do k=0,chain_length(i)-1
52 if (itype(chain_border(1,i)+k).ne.
53 & itype(chain_border(1,j)+k)) exit
55 if (k.lt.chain_length(i)) cycle
58 iequiv(iieq,nchain_group)=j
60 nequiv(nchain_group)=iieq
62 write(iout,*) "Number of equivalent chain groups:",nchain_group
63 write(iout,*) "Equivalent chain groups"
65 write(iout,*) "group",i," #members",nequiv(i)," chains",
66 & (iequiv(j,i),j=1,nequiv(i))
72 mapchain(ind)=iequiv(j,i)
75 write (iout,*) "mapchain"
77 write (iout,*) i,mapchain(i)
81 call permut(nequiv(i),nperm,tabperm)
87 tabpermchain(k,j)=iequiv(tabperm(k,j),i)
92 npermchain=npermchain*nperm
98 tabpermchain(l,ind)=tabpermchain(l,j)
101 tabpermchain(ii+l,ind)=iequiv(tabperm(l,k),i)
110 itemp(mapchain(j))=tabpermchain(j,i)
113 tabpermchain(j,i)=itemp(j)
116 write(iout,*) "Number of chain permutations",npermchain
117 write(iout,*) "Permutations"
119 write(iout,'(20i4)') (tabpermchain(j,i),j=1,nchain)
123 c---------------------------------------------------------------------
124 integer function tperm(i,iperm,tabpermchain)
128 integer tabpermchain(maxchain,maxperm)
132 tperm=tabpermchain(i,iperm)