



      SUBROUTINE PUC001 (IATARR,NUM,Q,PHI,TPA)





















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       MAXNUM
      PARAMETER     (MAXNUM=10)
      REAL          PI
      PARAMETER     (PI=3.141593)
      INTEGER       NUM, IATARR(NUM), INUM, IDIM, IPUC, NQ
      REAL          Q(*), PHI(*), R(3,MAXNUM), RP(3), RPP(3), CEN(3),
     +              TPN, N(3), Z(MAXNUM), GVFDP3, X, Y, TPA, TPA2







      TPA=0.0



      IF (NUM.LE.0.OR.NUM.GT.MAXNUM) THEN
         CALL GVSTTE ('?M1351')
         GOTO 998
      END IF



      DO 100 INUM=1,NUM
         R(1,INUM)=XCOORD(IATARR(INUM))
         R(2,INUM)=YCOORD(IATARR(INUM))
         R(3,INUM)=ZCOORD(IATARR(INUM))
  100 CONTINUE



      CALL GVSRT0 (CEN,3)
      DO 200 INUM=1,NUM
         DO 190 IDIM=1,3
            CEN(IDIM)=CEN(IDIM)+R(IDIM,INUM)
  190    CONTINUE
  200 CONTINUE
      DO 210 IDIM=1,3
         CEN(IDIM)=CEN(IDIM)/FLOAT(NUM)
  210 CONTINUE



      DO 300 INUM=1,NUM
         DO 290 IDIM=1,3
            R(IDIM,INUM)=R(IDIM,INUM)-CEN(IDIM)
  290    CONTINUE
  300 CONTINUE



      CALL GVSRT0 (RP,3)
      CALL GVSRT0 (RPP,3)
      TPN=2.0*PI/FLOAT(NUM)
      DO 400 INUM=1,NUM
         DO 390 IDIM=1,3
            RP(IDIM)=RP(IDIM)+R(IDIM,INUM)*SIN(TPN*FLOAT(INUM-1))
            RPP(IDIM)=RPP(IDIM)+R(IDIM,INUM)*COS(TPN*FLOAT(INUM-1))
  390    CONTINUE
  400 CONTINUE



      CALL GVSCP3 (N,RP,RPP)
      CALL GVSNM3 (N)



      DO 500 INUM=1,NUM
         Z(INUM)=GVFDP3(N,R(1,INUM))
  500 CONTINUE



      DO 600 IPUC=2,(NUM-1)/2
         X=0.0
         Y=0.0
         DO 590 INUM=1,NUM
            X=X+Z(INUM)*COS(TPN*FLOAT(IPUC*(INUM-1)))
            Y=Y+Z(INUM)*SIN(TPN*FLOAT(IPUC*(INUM-1)))
  590    CONTINUE
         X=SQRT(2.0/FLOAT(NUM))*X
         Y=SQRT(2.0/FLOAT(NUM))*Y
         Q(IPUC-1)=SQRT(X*X+Y*Y)
         PHI(IPUC-1)=180.0/PI*ATAN2(Y,X)
  600 CONTINUE
      NQ=(NUM-1)/2-1



      IF (NUM/2*2.EQ.NUM) THEN
         IPUC=NUM/2-1
         X=0.0
         Y=-1.0
         DO 700 INUM=1,NUM
            X=X+Z(INUM)*Y
            Y=-Y
  700    CONTINUE
         Q(IPUC)=1.0/SQRT(FLOAT(NUM))*X
         NQ=IPUC
      END IF



      TPA=0.0
      DO 800 INUM=1,NUM
         TPA=TPA+Z(INUM)**2
  800 CONTINUE
      TPA=SQRT(TPA)
      TPA2=0.0
      DO 810 IPUC=1,NQ
         TPA2=TPA2+Q(IPUC)**2
  810 CONTINUE
      TPA2=SQRT(TPA2)
      IF (MAX(TPA,TPA2).GT.0.001) THEN
         IF (ABS(TPA-TPA2)/MAX(TPA,TPA2).GT.0.01) THEN
            CALL GVSTTR2 ('?M1352',TPA,TPA2)
         END IF
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE PUC002 (IAA,Q,PHI)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, I
      REAL          Q, PHI
      LOGICAL       WIFIRR, CH4EQCH4







      Q=0.0
      PHI=0.0



      IF (.NOT.WIFIRR(IAA)) THEN
         CALL GVSTTB ('?M1353')
         GOTO 998
      END IF
      IF (.NOT.CH4EQCH4(ONESA3(IAA),'PRO ').AND.
     +    .NOT.CH4EQCH4(ONESA3(IAA),'HYP ')) THEN
         CALL GVSTTB ('?M1354')
         GOTO 998
      END IF
      I=PNTAAS(IAA)
      IF (ISATOK(I+0).AND.
     +     ISATOK(I+1).AND.
     +     ISATOK(I+4).AND.
     +     ISATOK(I+5).AND. 
     +     ISATOK(I+6)) THEN
         CALL PUC005 (I+0,I+1,I+4,I+5,I+6,Q,PHI)
      ELSE
         CALL GVSTTI ('?M1355',IAA)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE PUC003 (LUN)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, LUN
      REAL          Q, PHI, TR, BX, CHI001, GVFRTD
      LOGICAL       CH4EQCH4







      DO 100 IAA=1,NUMAAF



         IF (CH4EQCH4(ONESA3(IAA),'PRO ').OR.
     +       CH4EQCH4(ONESA3(IAA),'HYP ')) THEN
            CALL PUC002 (IAA,Q,PHI)
            BX=2.0*XBFACT(PNTAAS(IAA)+5)/
     +           (XBFACT(PNTAAS(IAA)+4)+XBFACT(PNTAAS(IAA)+6))
            TR=CHI001(PNTAAS(IAA)+6,PNTAAS(IAA)+0,PNTAAS(IAA)+1,
     +           PNTAAS(IAA)+4)
            TR=GVFRTD(TR)
            CALL GVSFMT ('?FMT1381')
            WRITE (LUN,FMT,ERR=999) FILNMS(62)(1:30),IAA,Q,PHI,TR,BX
         END IF
  100 CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSTTE ('?M1356')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE PUC004



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       LUN, IERR
      LOGICAL       GVFISF







      CALL GVSCLF (1)
      CALL GETFILE (1,'?FILNAM',' ',IERR)
      IF (IERR.NE.0) GOTO 999



      CALL GVSROF (LUN,IERR)
      IF (IERR.NE.0) GOTO 999
      CALL GVSOPF ('PUCSTAT.DAT',LUN,'UNKNOWN')



   40 CONTINUE
      CALL GVSCTB (LINE2,80)



      CALL GETLINE (1,LINE2,IERR)
      IF (IERR.NE.0) GOTO 998
      IF (LINE2(1:1).NE.'/') GOTO 40
      CALL MOL712 (LINE2)



      IF (.NOT.GVFISF(LINE2)) THEN
         CALL GVST6C ('?SYM011',LINE2,.TRUE.)
         GOTO 40
      END IF



      FILNMS(62)=LINE2
      CALL TEXSTORE (LINE2)
      CALL MOL015 (LINE2)
      IF (NUMAAF.LT.1) then
         CALL GVSTTE ('?AOORPUC')
      ELSE
         CALL PUC003 (LUN)
      END IF
      GOTO 40



  999 CONTINUE
      CALL GVSEIW ('PUC004')



  998 CONTINUE
      CALL GVSCLF (LUN)


      RETURN
      END
      SUBROUTINE PUC005 (IAT1,IAT2,IAT3,IAT4,IAT5,Q,PHI)



















      IMPLICIT      NONE 
      INCLUDE       'BIGINC.INC'
      INTEGER       IAT1, IAT2, IAT3, IAT4, IAT5, IATARR(5), I
      REAL          Q,PHI,QARR(1),PHIARR(1),TPA







      IATARR(1)=IAT1
      IATARR(2)=IAT2
      IATARR(3)=IAT3
      IATARR(4)=IAT4
      IATARR(5)=IAT5
      DO 100 I=1,5
         IF (IATARR(I).LT.1.OR.IATARR(I).GT.NUMATF) THEN
            CALL GVSTTB ('?M1357')
            Q=0.0
            PHI=0.0
            TPA=0.0
         END IF
  100 CONTINUE
      CALL PUC001 (IATARR,5,QARR,PHIARR,TPA)
      Q=QARR(1)
      PHI=PHIARR(1)





      RETURN
      END
      SUBROUTINE PUC010



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IAA, IPHI, GVFLEN
      CHARACTER*4   QUAL
      REAL          Q, PHI
      CHARACTER*42  CONF(20), MES
      LOGICAL       CH4EQCH4
      DATA CONF /'half-chair N/C-delta (18 degrees)',
     +           'envelop C-delta (36 degrees)',
     +           'half-chair C-delta/C-gamma (54 degrees)',
     +           'envelop C-gamma (72 degrees)',
     +           'half-chair C-gamma/C-beta (90 degrees)',
     +           'envelop C-beta (108 degrees)',
     +           'half-chair C-beta/C-alpha (126 degrees)',
     +           'envelop C-alpha (144 degrees)',
     +           'half-chair C-alpha/N (162 degrees)',
     +           'envelop N (180 degrees)',
     +           'half-chair N/C-delta (-162 degrees)',
     +           'envelop C-delta (-144 degrees)',
     +           'half-chair C-delta/C-gamma (-126 degrees)',
     +           'envelop C-gamma (-108 degrees)',
     +           'half-chair C-gamma/C-beta (-90 degrees)',
     +           'envelop C-beta (-72 degrees)',
     +           'half-chair C-beta/C-alpha (-54 degrees)',
     +           'envelop C-alpha (-36 degrees)',
     +           'half-chair C-alpha/N (-18 degrees)',
     +           'envelop N (0 degrees)'/







      DO 20 IAA=1,NUMAAF
         IF (CH4EQCH4(ONESA3(IAA),'PRO ').OR.
     +       CH4EQCH4(ONESA3(IAA),'HYP ')) GOTO 10
   20 CONTINUE
      CALL PDBMES ('PUCNOPRO')
      GOTO 998



   10 CONTINUE



      CALL GVSRT0 (PRPVAL,MAXAA)



      CALL CDB013 ('PUC1ERR','PUC1NEU','PUC1GOO')
      CALL CDB014 (1,'PUCLOW','POOR')
      CALL CDB014 (2,'PUCHIGH','BAD')



      DO 100 IAA=1,NUMAAF
         IF (CH4EQCH4(ONESA3(IAA),'PRO ').OR.
     +       CH4EQCH4(ONESA3(IAA),'HYP ')) THEN
            CALL PUC002 (IAA,Q,PHI)
            IF (Q.LT.0.20.OR.Q.GT.0.45) THEN
               IF (Q.GT.0.45) THEN
                  PRPVAL(IAA)=2.0
                  QUAL='HIGH'
                  CALL PDBS51 (IAA,4.1,4.0,100.0)
               ELSE
                  PRPVAL(IAA)=1.0
                  QUAL='LOW'
                  CALL PDBS51 (IAA,4.1,4.0,100.0)
               END IF
               CALL PDBC92A (IAA,0)
               WRITE (LINE2,PDBFMT,ERR=999) LINE92(1:GVFLEN(LINE92)),
     +          Q,QUAL
               CALL PDBC93 (LINE2)
            END IF
         END IF
  100 CONTINUE



      CALL CDB012



      CALL GVSRT0 (PRPVAL,MAXAA)



      CALL CDB013 ('PUC2ERR','PUC2NEU','PUC2GOO')
      CALL CDB014 (1,'PUCPHASE','POOR')
      DO 200 IAA=1,NUMAAF
         IF (CH4EQCH4(ONESA3(IAA),'PRO ').OR.
     +       CH4EQCH4(ONESA3(IAA),'HYP ')) THEN
            CALL PUC002 (IAA,Q,PHI)
            IF (Q.GT.0.20.AND.
     +           ABS(PHI-76.0).GT.23.0.AND.
     +           ABS(PHI+89.0).GT.23.0) THEN
               IPHI=NINT(PHI/18.0)
               IF (IPHI.LE.0) IPHI=IPHI+20
               MES=CONF(IPHI)
               CALL PDBS51 (IAA,4.1,4.0,100.0)
               CALL PDBC92A (IAA,0)
               WRITE (LINE2,PDBFMT,ERR=999) LINE92(1:GVFLEN(LINE92)),
     +          PHI,MES(1:GVFLEN(MES))
               CALL PDBC93 (LINE2)
               PRPVAL(IAA)=1.0
            END IF
         END IF
  200 CONTINUE



      CALL CDB012
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('PUC010')



  998 CONTINUE

     
      RETURN
      END
