1 | !**************************************************************
|
---|
2 | !
|
---|
3 | ! This file contains the subroutines: redseq
|
---|
4 | !
|
---|
5 | ! Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
6 | ! Shura Hayryan, Chin-Ku
|
---|
7 | ! Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
8 | ! Jan H. Meinke, Sandipan Mohanty
|
---|
9 | !
|
---|
10 | ! **************************************************************
|
---|
11 |
|
---|
12 |
|
---|
13 | subroutine redseq
|
---|
14 |
|
---|
15 | ! ............................................................
|
---|
16 | ! PURPOSE: read 'lunseq' 'seqfil', extract names of molecules,
|
---|
17 | ! sequences
|
---|
18 | !
|
---|
19 | ! Molecules are separated by lines containing char. '#',
|
---|
20 | ! a name for the molecule may follow '#' on this line
|
---|
21 | ! Residue names can be of 1-4 characters to be separated by ' '
|
---|
22 | !
|
---|
23 | ! Returns: ntlml,nmml,irsml1,irsml2,seq
|
---|
24 | !
|
---|
25 | ! CALLS: ibegst,iendst,iopfil,tolost
|
---|
26 | ! ............................................................
|
---|
27 |
|
---|
28 | include 'INCL.H'
|
---|
29 |
|
---|
30 | ! Function definitions
|
---|
31 | integer iofil, iendst, ibegst, iopfil
|
---|
32 |
|
---|
33 | character blnk,res*4,line*132,hlin*132
|
---|
34 | integer i, i1, i2, ifirs, ie, id, ib, ic, ii, l, lg, nln, nrs
|
---|
35 | data blnk/' '/
|
---|
36 |
|
---|
37 | if (iopfil(lunseq,seqfil,'old','formatted').le.izero) then
|
---|
38 | write (logString, '(a,/,a,i3,2a)')
|
---|
39 | & ' redseq> ERROR opening sequence file:',
|
---|
40 | & ' LUN=',lunseq,' FILE=',seqfil(1:iendst(seqfil))
|
---|
41 | stop
|
---|
42 | endif
|
---|
43 |
|
---|
44 | ! ntlml=0
|
---|
45 | if (ntlml.gt.0) then
|
---|
46 | nrs = irsml2(ntlml)
|
---|
47 | else
|
---|
48 | nrs = 0
|
---|
49 | endif
|
---|
50 | nln=0
|
---|
51 | 1 line=blnk
|
---|
52 | nln=nln+1
|
---|
53 | read (lunseq,'(a)',err=4,end=3) line
|
---|
54 | lg=iendst(line)
|
---|
55 |
|
---|
56 | if (lg.gt.0) then ! line not empty
|
---|
57 |
|
---|
58 | ic = index(line(1:lg),'#')
|
---|
59 |
|
---|
60 | if (ic.gt.0) then ! found '#'
|
---|
61 |
|
---|
62 | ! ____________________________________ new molecule
|
---|
63 |
|
---|
64 | if (ntlml.gt.0) then ! check previous molecule
|
---|
65 |
|
---|
66 | irsml2(ntlml) = nrs
|
---|
67 |
|
---|
68 | if ((nrs-irsml1(ntlml)+1).eq.0) then
|
---|
69 | write (logString, '(2a)') ' redseq> IGNORE molecule: ',
|
---|
70 | & nmml(ntlml)(1:iendst(nmml(ntlml)))
|
---|
71 | ntlml=ntlml-1
|
---|
72 | endif
|
---|
73 | endif
|
---|
74 | ntlml=ntlml+1
|
---|
75 | if (ntlml.gt.mxml) then
|
---|
76 | write (logString, '(a,i4,2a)')
|
---|
77 | & ' redseq> NUMBER of molecules > '
|
---|
78 | & ,mxml,' in ',seqfil(1:iendst(seqfil))
|
---|
79 | close(lunseq)
|
---|
80 | stop
|
---|
81 | endif
|
---|
82 | nmml(ntlml)=blnk
|
---|
83 | irsml1(ntlml)=nrs+1
|
---|
84 | ic=ic+1
|
---|
85 |
|
---|
86 | if (ic.le.lg) then
|
---|
87 | ! ___________________________________ extract name of molecule
|
---|
88 |
|
---|
89 | hlin=blnk
|
---|
90 | hlin(1:)=line(ic:lg)
|
---|
91 | i1=ibegst(hlin)
|
---|
92 | if (i1.gt.0) then
|
---|
93 | i2=iendst(hlin)
|
---|
94 | l=i2-i1+1
|
---|
95 | if (l.gt.80) i2=i2-l+80
|
---|
96 | nmml(ntlml)(1:)=hlin(i1:i2)
|
---|
97 | else
|
---|
98 | write(nmml(ntlml)(1:4),'(i4)') ntlml
|
---|
99 | endif
|
---|
100 | else
|
---|
101 | write(nmml(ntlml)(1:4),'(i4)') ntlml
|
---|
102 | endif
|
---|
103 |
|
---|
104 | else ! no '#'
|
---|
105 |
|
---|
106 | ! _________________________________________ sequence
|
---|
107 |
|
---|
108 | ib=ibegst(line)
|
---|
109 | if (ib.eq.0) goto 1 ! empty line
|
---|
110 |
|
---|
111 | if (ntlml.eq.0) then
|
---|
112 | ntlml=1
|
---|
113 | nmml(1)(1:)=' 1'
|
---|
114 | endif
|
---|
115 |
|
---|
116 | ie=iendst(line)
|
---|
117 | ! ___________________________________ extract names of residues
|
---|
118 | 2 id=index(line(ib:ie),blnk)-1 ! find next separator
|
---|
119 | if (id.gt.0) then
|
---|
120 | ii=ib+id-1
|
---|
121 | else
|
---|
122 | ii=ie
|
---|
123 | id=ie-ib+1
|
---|
124 | endif
|
---|
125 |
|
---|
126 | if (id.gt.4) then
|
---|
127 | write (logString, '(4a)') ' redseq> INVALID residue NAME >',
|
---|
128 | & line(ib:ii),'< in ',
|
---|
129 | & seqfil(1:iendst(seqfil))
|
---|
130 | close(lunseq)
|
---|
131 | stop
|
---|
132 | else
|
---|
133 |
|
---|
134 | nrs=nrs+1
|
---|
135 | if (nrs.gt.mxrs) then
|
---|
136 | write (logString, '(a,i4,2a)')
|
---|
137 | & ' redseq> NUMBER of residues > '
|
---|
138 | & ,mxrs,' in ',seqfil(1:iendst(seqfil))
|
---|
139 | close(lunseq)
|
---|
140 | stop
|
---|
141 | endif
|
---|
142 |
|
---|
143 | seq(nrs)=blnk
|
---|
144 | seq(nrs)(1:)=line(ib:ii)
|
---|
145 |
|
---|
146 | endif
|
---|
147 |
|
---|
148 | ii=ii+1
|
---|
149 | do i=ii,ie
|
---|
150 | if (line(i:i).ne.blnk) then
|
---|
151 | ib=i
|
---|
152 | goto 2
|
---|
153 | endif
|
---|
154 | enddo
|
---|
155 |
|
---|
156 | endif
|
---|
157 |
|
---|
158 | endif
|
---|
159 |
|
---|
160 | goto 1
|
---|
161 |
|
---|
162 | 3 close(lunseq)
|
---|
163 | ! ___________________________________ output
|
---|
164 |
|
---|
165 | if (nrs.eq.0) then
|
---|
166 | write (logString, '(2a)') ' redseq> no residues found in ',
|
---|
167 | & seqfil(1:iendst(seqfil))
|
---|
168 | stop
|
---|
169 | else
|
---|
170 |
|
---|
171 | do i=1,ntlml
|
---|
172 |
|
---|
173 | ifirs=irsml1(i)
|
---|
174 |
|
---|
175 | if (.not.flex) then
|
---|
176 | res=seq(ifirs)
|
---|
177 | call tolost(res)
|
---|
178 | if (res(1:3).eq.'pro') seq(irsml1(i))='pron' ! only ECEPP/3
|
---|
179 | endif
|
---|
180 |
|
---|
181 | if (i.eq.ntlml) then ! Check last molecule
|
---|
182 | if ((nrs-ifirs+1).eq.0) then
|
---|
183 | write (logString, '(2a)') ' redseq> IGNORE molecule '
|
---|
184 | & ,nmml(ntlml)(1:iendst(nmml(ntlml)))
|
---|
185 | ntlml=ntlml-1
|
---|
186 | if (ntlml.eq.0) then
|
---|
187 | write (logString, '(2a)')
|
---|
188 | & ' redseq> no residues found in ',
|
---|
189 | & seqfil(1:iendst(seqfil))
|
---|
190 | stop
|
---|
191 | endif
|
---|
192 | return
|
---|
193 | endif
|
---|
194 | irsml2(i)=nrs
|
---|
195 | endif
|
---|
196 |
|
---|
197 | ! write (logString, '(/,a,i4,2a)') ' redseq> ',irsml2(i)-irsml1(i)+1,
|
---|
198 | ! & ' residue(s) in molecule: ',
|
---|
199 | ! & nmml(i)(1:iendst(nmml(i)))
|
---|
200 | ! write (logString, '(15(1x,a))') (seq(j),j=irsml1(i),irsml2(i))
|
---|
201 |
|
---|
202 | enddo
|
---|
203 |
|
---|
204 | endif
|
---|
205 | return
|
---|
206 | ! _______________________________________________ error
|
---|
207 |
|
---|
208 | 4 write (logString, '(a,i4,2a)') ' redseq> ERROR reading line No. ',nln,
|
---|
209 | & ' in ',seqfil(1:iendst(seqfil))
|
---|
210 | close(lunseq)
|
---|
211 | stop
|
---|
212 |
|
---|
213 | end
|
---|
214 |
|
---|