[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
|
---|
| 38 | write (*,'(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
|
---|
| 69 | write(*,'(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
|
---|
| 76 | write(*,'(a,i4,2a)')' redseq> NUMBER of molecules > '
|
---|
[bd2278d] | 77 | & ,mxml,' in ',seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 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
|
---|
[bd2278d] | 86 | ! ___________________________________ extract name of molecule
|
---|
[e40e335] | 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 |
|
---|
[bd2278d] | 105 | ! _________________________________________ sequence
|
---|
[e40e335] | 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)
|
---|
[bd2278d] | 116 | ! ___________________________________ extract names of residues
|
---|
[e40e335] | 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 >',
|
---|
[bd2278d] | 127 | & line(ib:ii),'< in ',
|
---|
| 128 | & seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 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 > '
|
---|
[bd2278d] | 136 | & ,mxrs,' in ',seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 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)
|
---|
[bd2278d] | 161 | ! ___________________________________ output
|
---|
[e40e335] | 162 |
|
---|
| 163 | if (nrs.eq.0) then
|
---|
| 164 | write (*,'(2a)') ' redseq> no residues found in ',
|
---|
[bd2278d] | 165 | & seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 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 '
|
---|
[bd2278d] | 182 | & ,nmml(ntlml)(1:iendst(nmml(ntlml)))
|
---|
[e40e335] | 183 | ntlml=ntlml-1
|
---|
| 184 | if (ntlml.eq.0) then
|
---|
| 185 | write (*,'(2a)') ' redseq> no residues found in ',
|
---|
[bd2278d] | 186 | & seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 187 | stop
|
---|
| 188 | endif
|
---|
| 189 | return
|
---|
| 190 | endif
|
---|
| 191 | irsml2(i)=nrs
|
---|
| 192 | endif
|
---|
| 193 |
|
---|
[bd2278d] | 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))
|
---|
[e40e335] | 198 |
|
---|
| 199 | enddo
|
---|
| 200 |
|
---|
| 201 | endif
|
---|
| 202 | return
|
---|
[bd2278d] | 203 | ! _______________________________________________ error
|
---|
[e40e335] | 204 |
|
---|
| 205 | 4 write (*,'(a,i4,2a)') ' redseq> ERROR reading line No. ',nln,
|
---|
[bd2278d] | 206 | & ' in ',seqfil(1:iendst(seqfil))
|
---|
[e40e335] | 207 | close(lunseq)
|
---|
| 208 | stop
|
---|
| 209 |
|
---|
| 210 | end
|
---|
| 211 |
|
---|