[bd2278d] | 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 | ! **************************************************************
|
---|
[e40e335] | 11 |
|
---|
| 12 |
|
---|
| 13 | subroutine redseq
|
---|
| 14 |
|
---|
[bd2278d] | 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 | ! ............................................................
|
---|
[e40e335] | 27 |
|
---|
| 28 | include 'INCL.H'
|
---|
| 29 |
|
---|
[cb47b9c] | 30 | ! Function definitions
|
---|
| 31 | integer iofil, iendst, ibegst, iopfil
|
---|
| 32 |
|
---|
[e40e335] | 33 | character blnk,res*4,line*132,hlin*132
|
---|
[cb47b9c] | 34 | integer i, i1, i2, ifirs, ie, id, ib, ic, ii, l, lg, nln, nrs
|
---|
[e40e335] | 35 | data blnk/' '/
|
---|
| 36 |
|
---|
| 37 | if (iopfil(lunseq,seqfil,'old','formatted').le.izero) then
|
---|
[38d77eb] | 38 | write (logString, '(a,/,a,i3,2a)')
|
---|
[bd2278d] | 39 | & ' redseq> ERROR opening sequence file:',
|
---|
| 40 | & ' LUN=',lunseq,' FILE=',seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 41 | stop
|
---|
| 42 | endif
|
---|
| 43 |
|
---|
[bd2278d] | 44 | ! ntlml=0
|
---|
[e40e335] | 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 |
|
---|
[bd2278d] | 62 | ! ____________________________________ new molecule
|
---|
[e40e335] | 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
|
---|
[38d77eb] | 69 | write (logString, '(2a)') ' redseq> IGNORE molecule: ',
|
---|
[bd2278d] | 70 | & nmml(ntlml)(1:iendst(nmml(ntlml)))
|
---|
[e40e335] | 71 | ntlml=ntlml-1
|
---|
| 72 | endif
|
---|
| 73 | endif
|
---|
| 74 | ntlml=ntlml+1
|
---|
| 75 | if (ntlml.gt.mxml) then
|
---|
[38d77eb] | 76 | write (logString, '(a,i4,2a)')
|
---|
| 77 | & ' redseq> NUMBER of molecules > '
|
---|
[bd2278d] | 78 | & ,mxml,' in ',seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 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
|
---|
[bd2278d] | 87 | ! ___________________________________ extract name of molecule
|
---|
[e40e335] | 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 |
|
---|
[bd2278d] | 106 | ! _________________________________________ sequence
|
---|
[e40e335] | 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)
|
---|
[bd2278d] | 117 | ! ___________________________________ extract names of residues
|
---|
[e40e335] | 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
|
---|
[38d77eb] | 127 | write (logString, '(4a)') ' redseq> INVALID residue NAME >',
|
---|
[bd2278d] | 128 | & line(ib:ii),'< in ',
|
---|
| 129 | & seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 130 | close(lunseq)
|
---|
| 131 | stop
|
---|
| 132 | else
|
---|
| 133 |
|
---|
| 134 | nrs=nrs+1
|
---|
| 135 | if (nrs.gt.mxrs) then
|
---|
[38d77eb] | 136 | write (logString, '(a,i4,2a)')
|
---|
| 137 | & ' redseq> NUMBER of residues > '
|
---|
[bd2278d] | 138 | & ,mxrs,' in ',seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 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)
|
---|
[bd2278d] | 163 | ! ___________________________________ output
|
---|
[e40e335] | 164 |
|
---|
| 165 | if (nrs.eq.0) then
|
---|
[38d77eb] | 166 | write (logString, '(2a)') ' redseq> no residues found in ',
|
---|
[bd2278d] | 167 | & seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 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
|
---|
[38d77eb] | 183 | write (logString, '(2a)') ' redseq> IGNORE molecule '
|
---|
[bd2278d] | 184 | & ,nmml(ntlml)(1:iendst(nmml(ntlml)))
|
---|
[e40e335] | 185 | ntlml=ntlml-1
|
---|
| 186 | if (ntlml.eq.0) then
|
---|
[38d77eb] | 187 | write (logString, '(2a)')
|
---|
| 188 | & ' redseq> no residues found in ',
|
---|
| 189 | & seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 190 | stop
|
---|
| 191 | endif
|
---|
| 192 | return
|
---|
| 193 | endif
|
---|
| 194 | irsml2(i)=nrs
|
---|
| 195 | endif
|
---|
| 196 |
|
---|
[38d77eb] | 197 | ! write (logString, '(/,a,i4,2a)') ' redseq> ',irsml2(i)-irsml1(i)+1,
|
---|
[bd2278d] | 198 | ! & ' residue(s) in molecule: ',
|
---|
| 199 | ! & nmml(i)(1:iendst(nmml(i)))
|
---|
[38d77eb] | 200 | ! write (logString, '(15(1x,a))') (seq(j),j=irsml1(i),irsml2(i))
|
---|
[e40e335] | 201 |
|
---|
| 202 | enddo
|
---|
| 203 |
|
---|
| 204 | endif
|
---|
| 205 | return
|
---|
[bd2278d] | 206 | ! _______________________________________________ error
|
---|
[e40e335] | 207 |
|
---|
[38d77eb] | 208 | 4 write (logString, '(a,i4,2a)') ' redseq> ERROR reading line No. ',nln,
|
---|
[bd2278d] | 209 | & ' in ',seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 210 | close(lunseq)
|
---|
| 211 | stop
|
---|
| 212 |
|
---|
| 213 | end
|
---|
| 214 |
|
---|