c
c
c     ###################################################
c     ##  COPYRIGHT (C)  1994  by  Jay William Ponder  ##
c     ###################################################
c
c     #################################################################
c     ##                                                             ##
c     ##  subroutine setradii  --  atomic radii and side chain list  ##
c     ##                                                             ##
c     #################################################################
c
c
c     "setradii" assigns an atomic radius to each protein atom
c      and sets a flag for each atom that is part of a side chain
c
c     literature references :
c
c     C. Chothia, "The Nature of the Accessible and Buried Surfaces
c     in Proteins", Journal of Molecular Biology, 105, 1-14 (1975)
c
c     T.J. Richmond and F.M. Richards, "Packing of alpha-Helices:
c     Geometrical Constraints and Contact Areas", Journal of Molecular
c     Biology, 119, 537-555 (1978)
c
c
      subroutine setradii (surftyp,radius,schain)
      implicit none
      include 'sizes.i'
      include 'iounit.i'
      include 'pdb.i'
      integer i
      real*8 atomrad(7),cyrus(7),fred(7)
      real*8 probe,radius(maxatm)
      character*3 resname
      character*4 atmname
      character*8 surftyp
      logical schain(maxatm)
c
c     atomic radius values for the protein atom types, listed in
c     the order: hydrogen, trigonal carbon, tetrahedral carbon,
c     trigonal nitrogen, tetrahedral nitrogen, oxygen, sulfur
c
      data cyrus /  0.00d0,  1.76d0,  1.87d0,  1.65d0,  1.50d0,
     &              1.40d0,  1.85d0 /
      data fred  /  0.00d0,  1.70d0,  1.90d0,  1.70d0,  1.70d0,
     &              1.40d0,  1.80d0 /
c
c
c     decide which set of atom radii and residue areas to use
c
      if (surftyp .eq. 'CHOTHIA ') then
         do i = 1, 7
            atomrad(i) = cyrus(i)
         end do
      else if (surftyp .eq. 'RICHARDS') then
         do i = 1, 7
            atomrad(i) = fred(i)
         end do
      end if
c
c     store a list of sidechain atoms including alpha carbon
c
      do i = 1, npdb
         schain(i) = .true.
         atmname = atmnam(i)
         if (atmname .eq. ' N  ')  schain(i) = .false.
         if (atmname .eq. ' C  ')  schain(i) = .false.
         if (atmname .eq. ' O  ')  schain(i) = .false.
         if (atmname .eq. ' H  ')  schain(i) = .false.
         if (atmname .eq. '1H  ')  schain(i) = .false.
         if (atmname .eq. '2H  ')  schain(i) = .false.
         if (atmname .eq. '3H  ')  schain(i) = .false.
         if (atmname .eq. ' OXT')  schain(i) = .false.
      end do
c
c     assign an atomic radius to each of the atoms
c
      do i = 1, npdb
         atmname = atmnam(i)
         resname = resnam(i)
c
c     hydrogen, oxygen, sulfur and nitrogen atomic radii
c
         if (atmname(2:2) .eq. 'H') then
            radius(i) = atomrad(1)
         else if (atmname(2:2) .eq. 'O') then
            radius(i) = atomrad(6)
         else if (atmname(2:2) .eq. 'S') then
            radius(i) = atomrad(7)
         else if (atmname(2:2) .eq. 'N') then
            radius(i) = atomrad(4)
            if (atmname.eq.' NZ ' .and. resname.eq.'LYS')
     &         radius(i) = atomrad(5)
            if (atmname.eq.' N  ' .and. resnum(i).eq.1)
     &         radius(i) = atomrad(5)
c
c     carbon atom radii for various environments
c
         else if (atmname .eq. ' C  ') then
            radius(i) = atomrad(2)
         else if (atmname .eq. ' CA ') then
            radius(i) = atomrad(3)
         else if (atmname .eq. ' CB ') then
            radius(i) = atomrad(3)
         else if (resname.eq.'PHE' .or. resname.eq.'TYR' .or.
     &            resname.eq.'TRP' .or. resname.eq.'HIS') then
            radius(i) = atomrad(2)
         else if (atmname.eq.' CG ' .and. resname.eq.'ASP') then
            radius(i) = atomrad(2)
         else if (atmname.eq.' CG ' .and. resname.eq.'ASN') then
            radius(i) = atomrad(2)
         else if (atmname.eq.' CD ' .and. resname.eq.'GLU') then
            radius(i) = atomrad(2)
         else if (atmname.eq.' CD ' .and. resname.eq.'GLN') then
            radius(i) = atomrad(2)
         else if (atmname.eq.' CZ ' .and. resname.eq.'ARG') then
            radius(i) = atomrad(2)
         else if (atmname(2:2) .eq. 'C') then
            radius(i) = atomrad(3)
c
c     deuterium, NMR averaged H's, and ASN/GLN O/N ambiguity
c
         else if (atmname(2:2) .eq. 'D') then
            radius(i) = atomrad(1)
         else if (atmname(2:2) .eq. 'Q') then
            radius(i) = atomrad(1)
         else if (atmname(2:2) .eq. 'A') then
            radius(i) = atomrad(4)
c
c     print a warning if the radius of this atom is unassigned
c
         else
            radius(i) = 0.0d0
            write (iout,10)  atmname,resnum(i),resname
   10       format (/,' ACCESS  --  Unassigned Radius Set to Zero',
     &                 ' for Atom ',a4,' in',i5,'-',a3)
         end if
      end do
c
c     for solvent accessibility, add probe size to each radius
c
      probe = 1.4d0
      do i = 1, npdb
         if (radius(i) .ne. 0.0d0)  radius(i) = radius(i) + probe
      end do
      return
      end
