292fa0236d5fbbe4ca40af27ddaca12f3737320f
[unres.git] /
1       subroutine read_ref_structure(*)
2 C
3 C Read the reference structure from the PDB file or from a PDB file or in the form of the dihedral
4 C angles.
5 C
6       implicit none
7       include 'DIMENSIONS'
8       include 'DIMENSIONS.ZSCOPT'
9       include 'DIMENSIONS.COMPAR'
10       include 'COMMON.IOUNITS'
11       include 'COMMON.GEO'
12       include 'COMMON.VAR'
13       include 'COMMON.INTERACT'
14       include 'COMMON.LOCAL'
15       include 'COMMON.NAMES'
16       include 'COMMON.CHAIN'
17       include 'COMMON.FFIELD'
18       include 'COMMON.SBRIDGE'
19       include 'COMMON.HEADER'
20       include 'COMMON.CONTROL'
21       include 'COMMON.CONTACTS1'
22       include 'COMMON.PEPTCONT'
23       include 'COMMON.TIME1'
24       include 'COMMON.COMPAR'
25       character*4 sequence(maxres)
26       integer rescode
27       double precision x(maxvar)
28       integer itype_pdb(maxres)
29       logical seq_comp
30       integer i,j,k,nres_pdb,iaux
31       double precision ddsc,dist
32       integer nnt_old,nct_old
33       integer ilen,kkk
34       external ilen
35 C
36       nres0=nres
37       nnt_old=nnt
38       nct_old=nct
39       write (iout,*) "pdbref",pdbref
40       if (pdbref) then
41         read(inp,'(a)') pdbfile
42         write (iout,'(2a,1h.)') 'PDB data will be read from file ',
43      &    pdbfile(:ilen(pdbfile))
44         open(ipdbin,file=pdbfile,status='old',err=33)
45         goto 34 
46   33    write (iout,'(a)') 'Error opening PDB file.'
47         return1
48   34    continue
49         do i=1,nres
50           itype_pdb(i)=itype(i)
51         enddo
52         call readpdb(.true.)
53         do i=1,nres
54           iaux=itype_pdb(i)
55           itype_pdb(i)=itype(i)
56           itype(i)=iaux
57         enddo
58         close (ipdbin)
59         do kkk=1,nperm
60         nres_pdb=nres
61         nres=nres0
62         nstart_seq=nnt
63         if (nsup.le.(nct-nnt+1)) then
64           do i=0,nct-nnt+1-nsup
65             if (seq_comp(itype(nnt+i),itype_pdb(nstart_sup),
66      &        nsup)) then
67               do j=nnt+nsup-1,nnt,-1
68                 do k=1,3
69                   cref(k,nres+j+i,kkk)=cref(k,nres_pdb+j,kkk)
70                 enddo
71               enddo
72               do j=nnt+nsup-1,nnt,-1
73                 do k=1,3
74                   cref(k,j+i,kkk)=cref(k,j,kkk)
75                 enddo
76                 phi_ref(j+i)=phi_ref(j)
77                 theta_ref(j+i)=theta_ref(j)
78                 alph_ref(j+i)=alph_ref(j)
79                 omeg_ref(j+i)=omeg_ref(j)
80               enddo
81 #ifdef DEBUG
82               do j=nnt,nct
83                 write (iout,'(i5,3f10.5,5x,3f10.5)') 
84      &            j,(cref(k,j,kkk),k=1,3),(cref(k,j+nres,kkk),k=1,3)
85               enddo
86 #endif
87               nstart_seq=nnt+i
88               nstart_sup=nnt+i
89               goto 111
90             endif
91           enddo
92           write (iout,'(a)') 
93      &            'Error - sequences to be superposed do not match.'
94           return1
95         else
96           do i=0,nsup-(nct-nnt+1)
97             if (seq_comp(itype(nnt),itype_pdb(nstart_sup+i),
98      &        nct-nnt+1)) 
99      &      then
100               nstart_sup=nstart_sup+i
101               nsup=nct-nnt+1
102               goto 111
103             endif
104           enddo 
105           write (iout,'(a)') 
106      &            'Error - sequences to be superposed do not match.'
107         endif
108         enddo
109   111   continue
110         write (iout,'(a,i5)') 
111      &   'Experimental structure begins at residue',nstart_seq
112       else
113         call read_angles(inp,*38)
114         goto 39
115    38   write (iout,'(a)') 'Error reading reference structure.'
116         return1
117    39   call chainbuild 
118         kkk=1    
119         nstart_sup=nnt
120         nstart_seq=nnt
121         nsup=nct-nnt+1
122         do i=1,2*nres
123           do j=1,3
124             cref(j,i,kkk)=c(j,i)
125           enddo
126         enddo
127       endif
128       nend_sup=nstart_sup+nsup-1
129       do i=1,2*nres
130         do j=1,3
131           c(j,i)=cref(j,i,kkk)
132         enddo
133       enddo
134       do i=1,nres
135         do j=1,3
136           dc(j,nres+i)=cref(j,nres+i,kkk)-cref(j,i,kkk)
137         enddo
138         if (itype(i).ne.10) then
139           ddsc = dist(i,nres+i)
140           do j=1,3
141             dc_norm(j,nres+i)=dc(j,nres+i)/ddsc
142           enddo
143         else
144           do j=1,3
145             dc_norm(j,nres+i)=0.0d0
146           enddo
147         endif
148 c        write (iout,*) "i",i," dc_norm",(dc_norm(k,nres+i),k=1,3),
149 c         " norm",dc_norm(1,nres+i)**2+dc_norm(2,nres+i)**2+
150 c         dc_norm(3,nres+i)**2
151         do j=1,3
152           dc(j,i)=c(j,i+1)-c(j,i)
153         enddo
154         ddsc = dist(i,i+1)
155         do j=1,3
156           dc_norm(j,i)=dc(j,i)/ddsc
157         enddo
158       enddo
159 c      print *,"Calling contact"
160       call contact(.true.,ncont_ref,icont_ref(1,1),
161      &  nstart_sup,nend_sup)
162 c      print *,"Calling elecont"
163       call elecont(.true.,ncont_pept_ref,
164      &   icont_pept_ref(1,1),
165      &   nstart_sup,nend_sup)
166        write (iout,'(a,i3,a,i3,a,i3,a)')
167      &    'Number of residues to be superposed:',nsup,
168      &    ' (from residue',nstart_sup,' to residue',
169      &    nend_sup,').'
170       nnt=nnt_old
171       nct=nct_old
172       return
173       end