source: redseq.f@ cb47b9c

Last change on this file since cb47b9c was cb47b9c, checked in by baerbaer <baerbaer@…>, 14 years ago

Explicitly declare variables.

All variables should be declared so that we can remove the implicit statements
from the beginning of the INCL.H file.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/smmp/trunk@25 26dc1dd8-5c4e-0410-9ffe-d298b4865968

  • Property mode set to 100644
File size: 5.5 KB
Line 
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 (*,'(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(*,'(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(*,'(a,i4,2a)')' redseq> NUMBER of molecules > '
77 & ,mxml,' in ',seqfil(1:iendst(seqfil))
78 close(lunseq)
79 stop
80 endif
81 nmml(ntlml)=blnk
82 irsml1(ntlml)=nrs+1
83 ic=ic+1
84
85 if (ic.le.lg) then
86! ___________________________________ extract name of molecule
87
88 hlin=blnk
89 hlin(1:)=line(ic:lg)
90 i1=ibegst(hlin)
91 if (i1.gt.0) then
92 i2=iendst(hlin)
93 l=i2-i1+1
94 if (l.gt.80) i2=i2-l+80
95 nmml(ntlml)(1:)=hlin(i1:i2)
96 else
97 write(nmml(ntlml)(1:4),'(i4)') ntlml
98 endif
99 else
100 write(nmml(ntlml)(1:4),'(i4)') ntlml
101 endif
102
103 else ! no '#'
104
105! _________________________________________ sequence
106
107 ib=ibegst(line)
108 if (ib.eq.0) goto 1 ! empty line
109
110 if (ntlml.eq.0) then
111 ntlml=1
112 nmml(1)(1:)=' 1'
113 endif
114
115 ie=iendst(line)
116! ___________________________________ extract names of residues
117 2 id=index(line(ib:ie),blnk)-1 ! find next separator
118 if (id.gt.0) then
119 ii=ib+id-1
120 else
121 ii=ie
122 id=ie-ib+1
123 endif
124
125 if (id.gt.4) then
126 write (*,'(4a)') ' redseq> INVALID residue NAME >',
127 & line(ib:ii),'< in ',
128 & seqfil(1:iendst(seqfil))
129 close(lunseq)
130 stop
131 else
132
133 nrs=nrs+1
134 if (nrs.gt.mxrs) then
135 write(*,'(a,i4,2a)') ' redseq> NUMBER of residues > '
136 & ,mxrs,' in ',seqfil(1:iendst(seqfil))
137 close(lunseq)
138 stop
139 endif
140
141 seq(nrs)=blnk
142 seq(nrs)(1:)=line(ib:ii)
143
144 endif
145
146 ii=ii+1
147 do i=ii,ie
148 if (line(i:i).ne.blnk) then
149 ib=i
150 goto 2
151 endif
152 enddo
153
154 endif
155
156 endif
157
158 goto 1
159
160 3 close(lunseq)
161! ___________________________________ output
162
163 if (nrs.eq.0) then
164 write (*,'(2a)') ' redseq> no residues found in ',
165 & seqfil(1:iendst(seqfil))
166 stop
167 else
168
169 do i=1,ntlml
170
171 ifirs=irsml1(i)
172
173 if (.not.flex) then
174 res=seq(ifirs)
175 call tolost(res)
176 if (res(1:3).eq.'pro') seq(irsml1(i))='pron' ! only ECEPP/3
177 endif
178
179 if (i.eq.ntlml) then ! Check last molecule
180 if ((nrs-ifirs+1).eq.0) then
181 write(*,'(2a)') ' redseq> IGNORE molecule '
182 & ,nmml(ntlml)(1:iendst(nmml(ntlml)))
183 ntlml=ntlml-1
184 if (ntlml.eq.0) then
185 write (*,'(2a)') ' redseq> no residues found in ',
186 & seqfil(1:iendst(seqfil))
187 stop
188 endif
189 return
190 endif
191 irsml2(i)=nrs
192 endif
193
194! write (*,'(/,a,i4,2a)') ' redseq> ',irsml2(i)-irsml1(i)+1,
195! & ' residue(s) in molecule: ',
196! & nmml(i)(1:iendst(nmml(i)))
197! write (*,'(15(1x,a))') (seq(j),j=irsml1(i),irsml2(i))
198
199 enddo
200
201 endif
202 return
203! _______________________________________________ error
204
205 4 write (*,'(a,i4,2a)') ' redseq> ERROR reading line No. ',nln,
206 & ' in ',seqfil(1:iendst(seqfil))
207 close(lunseq)
208 stop
209
210 end
211
Note: See TracBrowser for help on using the repository browser.