source: redseq.f@ bd2278d

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

Reformatting comments and continuation marks.

Fortran 90 and higher use ! to mark comments no matter where they are in the
code. The only valid continuation marker is &.
I also added the SMMP.kdevelop.filelist to the repository to make it easier
to use kdevelop.

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

  • Property mode set to 100644
File size: 5.4 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 character blnk,res*4,line*132,hlin*132
31 data blnk/' '/
32
33 if (iopfil(lunseq,seqfil,'old','formatted').le.izero) then
34 write (*,'(a,/,a,i3,2a)')
35 & ' redseq> ERROR opening sequence file:',
36 & ' LUN=',lunseq,' FILE=',seqfil(1:iendst(seqfil))
37 stop
38 endif
39
40! ntlml=0
41 if (ntlml.gt.0) then
42 nrs = irsml2(ntlml)
43 else
44 nrs = 0
45 endif
46 nln=0
47 1 line=blnk
48 nln=nln+1
49 read (lunseq,'(a)',err=4,end=3) line
50 lg=iendst(line)
51
52 if (lg.gt.0) then ! line not empty
53
54 ic = index(line(1:lg),'#')
55
56 if (ic.gt.0) then ! found '#'
57
58! ____________________________________ new molecule
59
60 if (ntlml.gt.0) then ! check previous molecule
61
62 irsml2(ntlml) = nrs
63
64 if ((nrs-irsml1(ntlml)+1).eq.0) then
65 write(*,'(2a)') ' redseq> IGNORE molecule: ',
66 & nmml(ntlml)(1:iendst(nmml(ntlml)))
67 ntlml=ntlml-1
68 endif
69 endif
70 ntlml=ntlml+1
71 if (ntlml.gt.mxml) then
72 write(*,'(a,i4,2a)')' redseq> NUMBER of molecules > '
73 & ,mxml,' in ',seqfil(1:iendst(seqfil))
74 close(lunseq)
75 stop
76 endif
77 nmml(ntlml)=blnk
78 irsml1(ntlml)=nrs+1
79 ic=ic+1
80
81 if (ic.le.lg) then
82! ___________________________________ extract name of molecule
83
84 hlin=blnk
85 hlin(1:)=line(ic:lg)
86 i1=ibegst(hlin)
87 if (i1.gt.0) then
88 i2=iendst(hlin)
89 l=i2-i1+1
90 if (l.gt.80) i2=i2-l+80
91 nmml(ntlml)(1:)=hlin(i1:i2)
92 else
93 write(nmml(ntlml)(1:4),'(i4)') ntlml
94 endif
95 else
96 write(nmml(ntlml)(1:4),'(i4)') ntlml
97 endif
98
99 else ! no '#'
100
101! _________________________________________ sequence
102
103 ib=ibegst(line)
104 if (ib.eq.0) goto 1 ! empty line
105
106 if (ntlml.eq.0) then
107 ntlml=1
108 nmml(1)(1:)=' 1'
109 endif
110
111 ie=iendst(line)
112! ___________________________________ extract names of residues
113 2 id=index(line(ib:ie),blnk)-1 ! find next separator
114 if (id.gt.0) then
115 ii=ib+id-1
116 else
117 ii=ie
118 id=ie-ib+1
119 endif
120
121 if (id.gt.4) then
122 write (*,'(4a)') ' redseq> INVALID residue NAME >',
123 & line(ib:ii),'< in ',
124 & seqfil(1:iendst(seqfil))
125 close(lunseq)
126 stop
127 else
128
129 nrs=nrs+1
130 if (nrs.gt.mxrs) then
131 write(*,'(a,i4,2a)') ' redseq> NUMBER of residues > '
132 & ,mxrs,' in ',seqfil(1:iendst(seqfil))
133 close(lunseq)
134 stop
135 endif
136
137 seq(nrs)=blnk
138 seq(nrs)(1:)=line(ib:ii)
139
140 endif
141
142 ii=ii+1
143 do i=ii,ie
144 if (line(i:i).ne.blnk) then
145 ib=i
146 goto 2
147 endif
148 enddo
149
150 endif
151
152 endif
153
154 goto 1
155
156 3 close(lunseq)
157! ___________________________________ output
158
159 if (nrs.eq.0) then
160 write (*,'(2a)') ' redseq> no residues found in ',
161 & seqfil(1:iendst(seqfil))
162 stop
163 else
164
165 do i=1,ntlml
166
167 ifirs=irsml1(i)
168
169 if (.not.flex) then
170 res=seq(ifirs)
171 call tolost(res)
172 if (res(1:3).eq.'pro') seq(irsml1(i))='pron' ! only ECEPP/3
173 endif
174
175 if (i.eq.ntlml) then ! Check last molecule
176 if ((nrs-ifirs+1).eq.0) then
177 write(*,'(2a)') ' redseq> IGNORE molecule '
178 & ,nmml(ntlml)(1:iendst(nmml(ntlml)))
179 ntlml=ntlml-1
180 if (ntlml.eq.0) then
181 write (*,'(2a)') ' redseq> no residues found in ',
182 & seqfil(1:iendst(seqfil))
183 stop
184 endif
185 return
186 endif
187 irsml2(i)=nrs
188 endif
189
190! write (*,'(/,a,i4,2a)') ' redseq> ',irsml2(i)-irsml1(i)+1,
191! & ' residue(s) in molecule: ',
192! & nmml(i)(1:iendst(nmml(i)))
193! write (*,'(15(1x,a))') (seq(j),j=irsml1(i),irsml2(i))
194
195 enddo
196
197 endif
198 return
199! _______________________________________________ error
200
201 4 write (*,'(a,i4,2a)') ' redseq> ERROR reading line No. ',nln,
202 & ' in ',seqfil(1:iendst(seqfil))
203 close(lunseq)
204 stop
205
206 end
207
Note: See TracBrowser for help on using the repository browser.