       SUBROUTINE DRWANG(DGX,DGY,XWIDTH,YHIGHT,IMAIN,INCHN,RESNAM,      DRWA001
     &    SEQNO,EVALUE,VALUE,OTHCHN,OTHNAM,OTHSEQ)                      DRWA002
C-----------------------------------------------------------------------DRWA003
C                                                                       DRWA004
C  SUBROUTINE DRWANG  -  Draw distorted bond angles                     DRWA005
C                                                                       DRWA006
C----------------------------------------------------------------------+DRWA007
                                                                        DRWA008
CHECK v.3.2-->                                                          DRWA009
C     -    SEQNO,EVALUE,VALUE)                                          DRWA010
CHECK v.3.2<--                                                          DRWA011
                                                                        DRWA012
      INCLUDE 'bplot.inc'                                               DRWA013
                                                                        DRWA014
CHECK v.3.2-->                                                          DRWA015
C      CHARACTER*1   INCHN                                              DRWA016
C      CHARACTER*3   RESNAM                                             DRWA017
C      CHARACTER*5   NUMBER, SEQNO                                      DRWA018
      CHARACTER*1   INCHN, OTHCHN                                       DRWA019
      CHARACTER*3   OTHNAM, RESNAM                                      DRWA020
      CHARACTER*5   NUMBER, OTHSEQ, SEQNO                               DRWA021
CHECK v.3.2<--                                                          DRWA022
      CHARACTER*8   LANG                                                DRWA023
CHECK v.3.2-->                                                          DRWA024
C      CHARACTER*10  RESID                                              DRWA025
C      INTEGER       DPOS1, DPOS2, IMAIN, I1, I2, SPOS                  DRWA026
      CHARACTER*10  OTHID, RESID                                        DRWA027
      INTEGER       DPOS1, DPOS2, IMAIN, I1, I2, OI1, OI2, SPOS         DRWA028
CHECK v.3.2<--                                                          DRWA029
      REAL          ANGLE, BLUE, DGX, DGY, DX, DY, EANGLE, EVALUE,      DRWA030
     &              EXTEND, GREEN, RED, VALUE, SCALE, XSTART, XWIDTH,   DRWA031
     &              X1, X2, YHIGHT, YSTART, Y1, Y2                      DRWA032
                                                                        DRWA033
      DATA EXTEND / 0.25 /                                              DRWA034
                                                                        DRWA035
C---- Initialise variables                                              DRWA036
      ANGLE = VALUE * RADDEG                                            DRWA037
      EANGLE = EVALUE * RADDEG                                          DRWA038
      XSTART = DGX + XWIDTH / 2.0                                       DRWA039
      YSTART = DGY + 0.4 * YHIGHT                                       DRWA040
      SCALE = XWIDTH / DGLENA                                           DRWA041
                                                                        DRWA042
CTESTING                                                                DRWA043
C---- Draw a box around the region                                      DRWA044
C      CALL PSHADE(1.0)                                                 DRWA045
C      CALL PSBBOX(DGX,DGY,DGX,DGY+YHIGHT,DGX+XWIDTH,DGY+YHIGHT,        DRWA046
C     -    DGX+XWIDTH,DGY)                                              DRWA047
CTESTING                                                                DRWA048
                                                                        DRWA049
C---- Print the residue ID                                              DRWA050
      RESID = INCHN // ' ' // RESNAM // SEQNO                           DRWA051
      IF (INCHN.EQ.' ') THEN                                            DRWA052
          I1 = 3                                                        DRWA053
      ELSE                                                              DRWA054
          I1 = 1                                                        DRWA055
      ENDIF                                                             DRWA056
      IF (RESID(9:10).EQ.'  ') THEN                                     DRWA057
          I2 = 8                                                        DRWA058
      ELSE IF (RESID(10:10).EQ.' ') THEN                                DRWA059
          I2 = 9                                                        DRWA060
      ELSE                                                              DRWA061
          I2 = 10                                                       DRWA062
      ENDIF                                                             DRWA063
                                                                        DRWA064
CHECK v.3.2-->                                                          DRWA065
CC---- Print the residue name(s)                                        DRWA066
C      CALL PSCTXT(DGX + XWIDTH / 2.0,DGY + 0.2 * YHIGHT,10.0,          DRWA067
C     -    RESID(I1:I2))                                                DRWA068
                                                                        DRWA069
C---- If this bond spans two residues, then form name of other residue  DRWA070
      IF (OTHNAM.NE.' ') THEN                                           DRWA071
          OTHID = OTHCHN // ' ' // OTHNAM // OTHSEQ                     DRWA072
          IF (OTHCHN.EQ.' ') THEN                                       DRWA073
              OI1 = 3                                                   DRWA074
          ELSE                                                          DRWA075
              OI1 = 1                                                   DRWA076
          ENDIF                                                         DRWA077
          IF (OTHID(9:10).EQ.'  ') THEN                                 DRWA078
              OI2 = 8                                                   DRWA079
          ELSE IF (OTHID(10:10).EQ.' ') THEN                            DRWA080
              OI2 = 9                                                   DRWA081
          ELSE                                                          DRWA082
              OI2 = 10                                                  DRWA083
          ENDIF                                                         DRWA084
          CALL PSCTXT(DGX + XWIDTH / 2.0,DGY + 0.2 * YHIGHT,8.0,        DRWA085
     &        RESID(I1:I2) // ' - ' // OTHID(OI1:OI2))                  DRWA086
                                                                        DRWA087
C---- Otherwise print the single residue name                           DRWA088
      ELSE                                                              DRWA089
          CALL PSCTXT(DGX + XWIDTH / 2.0,DGY + 0.2 * YHIGHT,10.0,       DRWA090
     &        RESID(I1:I2))                                             DRWA091
      ENDIF                                                             DRWA092
CHECK v.3.2<--                                                          DRWA093
                                                                        DRWA094
C---- Plot the bonds making up the "ideal" bond angle                   DRWA095
      CALL PSLWID(0.1)                                                  DRWA096
      X1 = (1.0 + EXTEND) * DGSTDL * SIN(EANGLE / 2.0)                  DRWA097
      X2 = XSTART + X1 * SCALE                                          DRWA098
      X1 = XSTART - X1 * SCALE                                          DRWA099
      Y1 = (1.0 + EXTEND) * DGSTDL * COS(EANGLE / 2.0)                  DRWA100
      Y1 = YSTART + Y1 * SCALE                                          DRWA101
                                                                        DRWA102
C---- Plot the bond angle type, atoms 1 & 3                             DRWA103
      LANG = LENANG(IMAIN)                                              DRWA104
      DPOS1 = INDEX(LANG,'-')                                           DRWA105
      LANG(DPOS1:DPOS1) = '*'                                           DRWA106
      DPOS2 = INDEX(LANG,'-')                                           DRWA107
      SPOS = INDEX(LANG,' ')                                            DRWA108
      DY = 0.08 * YHIGHT                                                DRWA109
      CALL PSCTXT(X1,Y1 + DY,8.0,LENANG(IMAIN)(1:DPOS1-1))              DRWA110
      CALL PSCTXT(X2,Y1 + DY,8.0,LENANG(IMAIN)(DPOS2+1:SPOS-1))         DRWA111
                                                                        DRWA112
C---- Plot name of atom 2                                               DRWA113
      DY = 0.06 * YHIGHT                                                DRWA114
      CALL PSCTXT(XSTART,YSTART - DY,8.0,LENANG(IMAIN)(DPOS1+1:DPOS2-1))DRWA115
                                                                        DRWA116
C---- Plot the bonds making up the "ideal" bond angle                   DRWA117
      IF (INCOLR(PLTYPE)) THEN                                          DRWA118
          RED = RGB(1,COLPLT(PLTYPE,2))                                 DRWA119
          GREEN = RGB(2,COLPLT(PLTYPE,2))                               DRWA120
          BLUE = RGB(3,COLPLT(PLTYPE,2))                                DRWA121
          CALL PSCOLB(RED,GREEN,BLUE)                                   DRWA122
      ENDIF                                                             DRWA123
      CALL PSLINE(XSTART,YSTART,X1,Y1)                                  DRWA124
      CALL PSLINE(XSTART,YSTART,X2,Y1)                                  DRWA125
                                                                        DRWA126
C---- Plot the "ideal" value                                            DRWA127
      DY = 0.1 * YHIGHT                                                 DRWA128
      WRITE(NUMBER,110) EVALUE                                          DRWA129
 110  FORMAT(F5.1)                                                      DRWA130
      CALL PSCTXT(XSTART,Y1 + DY,7.0,NUMBER)                            DRWA131
                                                                        DRWA132
C---- Plot the difference between the ideal and the actual              DRWA133
      DX = 0.05 * XWIDTH                                                DRWA134
      DY = 0.1 * YHIGHT                                                 DRWA135
      WRITE(NUMBER,110) ABS(EVALUE - VALUE)                             DRWA136
      IF (INCOLR(PLTYPE)) THEN                                          DRWA137
          RED = RGB(1,COLPLT(PLTYPE,4))                                 DRWA138
          GREEN = RGB(2,COLPLT(PLTYPE,4))                               DRWA139
          BLUE = RGB(3,COLPLT(PLTYPE,4))                                DRWA140
          CALL PSCOLB(RED,GREEN,BLUE)                                   DRWA141
      ENDIF                                                             DRWA142
      CALL PSCTXT(X2 + DX,Y1 - DY,6.0,NUMBER)                           DRWA143
                                                                        DRWA144
C---- Plot the bonds of the actual bond angle                           DRWA145
      CALL PSLWID(2.0)                                                  DRWA146
      X1 = DGSTDL * SIN(EANGLE / 2.0)                                   DRWA147
      X1 = XSTART - X1 * SCALE                                          DRWA148
      X2 = DGSTDL * SIN(ANGLE - EANGLE / 2.0)                           DRWA149
      X2 = XSTART + X2 * SCALE                                          DRWA150
      Y1 = DGSTDL * COS(EANGLE / 2.0)                                   DRWA151
      Y1 = YSTART + Y1 * SCALE                                          DRWA152
      Y2 = DGSTDL * COS(ANGLE - EANGLE / 2.0)                           DRWA153
      Y2 = YSTART + Y2 * SCALE                                          DRWA154
      IF (INCOLR(PLTYPE)) THEN                                          DRWA155
          RED = RGB(1,COLPLT(PLTYPE,3))                                 DRWA156
          GREEN = RGB(2,COLPLT(PLTYPE,3))                               DRWA157
          BLUE = RGB(3,COLPLT(PLTYPE,3))                                DRWA158
          CALL PSCOLB(RED,GREEN,BLUE)                                   DRWA159
      ENDIF                                                             DRWA160
      CALL PSLINE(XSTART,YSTART,X1,Y1)                                  DRWA161
      CALL PSLINE(XSTART,YSTART,X2,Y2)                                  DRWA162
                                                                        DRWA163
C---- Plot the actual value                                             DRWA164
      DY = 0.20 * YHIGHT                                                DRWA165
      WRITE(NUMBER,110) VALUE                                           DRWA166
      CALL PSCTXT(XSTART,YSTART + DY,8.0,NUMBER)                        DRWA167
      IF (INCOLR(PLTYPE)) CALL PSCOLB(0.0,0.0,0.0)                      DRWA168
                                                                        DRWA169
      RETURN                                                            DRWA170
      END                                                               DRWA171
