c23456789012345678901234567890123456789012345678901234567890123456789012
      program search
c This program takes as input a PDB file listing phi, psi
c for each residue and produces an output file listing these
c angles only for chosen amino acids.
      character*80 line
      character*3 res, ra
      character*6 blank
      character*10 trash
      real  phi, psi
      logical string

      string(ra) = ra.eq.'ALA' .or. ra.eq.'VAL' .or. ra.eq.'LEU'
     *               .or. ra.eq.'ILE'
      blank = '      '
c      open (unit = 5, file = 'ALL.pda', form = 'formatted',
c     +      access = 'sequential', status = 'old')
   10 read (5,'(a80)',END=990) line
      res = line(3:5)
      if (string(res)) go to 50
      res = line(4:6)
      if (string(res)) go to 50
c For multichain proteins, the following four code lines are needed
      res = line(5:7) 
      if (string(res)) go to 50
      res = line(6:8) 
      if (string(res)) go to 50

c The following lines ensure that no Phi, Psi angles
c will be missing

c      res = line(5:7)
c      if (string(res)) go to 50
c      res = line(6:9)
c      if (string(res)) go to 50
      go to 10
   50 continue

      if (line(11:16).ne.blank .and. line(22:27).ne.blank) then
         open (2, form='formatted', file='help')
         write (2,'(a80)') line
         close (2)

         open (2, form='formatted', file='help')
         read (2,'(a10,2f10.1)') trash, phi, psi
         close (2)
         write (6,'(1x,2f10.1)') phi, psi
      endif

      go to 10
  990 continue
      close(5)
      stop
      end
