c
c
c     ###################################################
c     ##  COPYRIGHT (C)  1994  by  Jay William Ponder  ##
c     ###################################################
c
c     ##################################################################
c     ##                                                              ##
c     ##  program select  --  edit EMBL PDB_Select list for Abstract  ##
c     ##                                                              ##
c     ##################################################################
c
c
      program select
      implicit none
      include 'iounit.i'
      integer ipdb,idat
      integer thresh,lower,upper
      integer freeunit,trimtext
      character*1 chain
      character*4 pdbname
      character*60 pdbfile,datafile
      character*80 record
c
c
c     open the listing of Protein Data Bank summaries
c
      call initial
      ipdb = freeunit ()
   10 continue
      write (iout,20)
   20 format (' Enter Name of File EMBL PDB_Select List :  ',$)
      read (input,30)  pdbfile
   30 format (a60)
      open (unit=ipdb,file=pdbfile,status='old',err=10)
      idat = freeunit ()
      datafile = 'abstract.dat'
      call version (datafile,'new')
      open (unit=idat,file=datafile,status='new')
c
c     get the desired similarity threshold cutoff bounds
c
      lower = 0
      upper = 0
      write (iout,40)
   40 format (' Enter the Bounds for Similarity Threshold :  ',$)
      read (input,50)  record
   50 format (a80)
      read (record,*)  lower,upper
      if (upper .lt. lower)  upper = lower
c
c     read in the summary of each protein structure
c
      dowhile (.true.)
         read (ipdb,60,end=120,err=110)  thresh,pdbname,chain
   60    format (i5,3x,a4,a1)
         call lowcase (pdbname)
         if (pdbname(1:1).lt.'0' .or. pdbname(1:1).gt.'9')  goto 110
         if ((pdbname(2:2).lt.'a'.or.pdbname(2:2).gt.'z') .and.
     &       (pdbname(2:2).lt.'0'.or.pdbname(2:2).gt.'9'))  goto 110
         if ((pdbname(3:3).lt.'a'.or.pdbname(3:3).gt.'z') .and.
     &       (pdbname(3:3).lt.'0'.or.pdbname(3:3).gt.'9'))  goto 110
         if ((pdbname(4:4).lt.'a'.or.pdbname(4:4).gt.'z') .and.
     &       (pdbname(4:4).lt.'0'.or.pdbname(4:4).gt.'9'))  goto 110
         if (thresh.ge.lower .and. thresh.le.upper) then
            write (idat,70)  pdbname
   70       format (a4)
            if (chain .eq. '_') then
               write (idat,80)
   80          format ()
            else
               write (idat,90)  chain
   90          format (a1)
            end if
            write (idat,100)
  100       format (//,'Y')
         end if
  110    continue
      end do
  120 continue
      close (unit=ipdb)
      close (unit=idat)
      write (iout,130)  datafile(1:trimtext(datafile))
  130 format (/,' Input File for ABSTRACT written to :  ',a)
      end
