      SUBROUTINE DRWLIN(DGX,DGY,XWIDTH,YHIGHT,IMAIN,INCHN,RESNAM,       DRWL001
     &    SEQNO,EVALUE,VALUE,OTHCHN,OTHNAM,OTHSEQ)                      DRWL002
C-----------------------------------------------------------------------DRWL003
C                                                                       DRWL004
C  SUBROUTINE DRWLIN  -  Draw distorted bond lengths                    DRWL005
C                                                                       DRWL006
C----------------------------------------------------------------------+DRWL007
                                                                        DRWL008
CHECK v.3.2-->                                                          DRWL009
C     -    SEQNO,EVALUE,VALUE)                                          DRWL010
CHECK v.3.2<--                                                          DRWL011
                                                                        DRWL012
      INCLUDE 'bplot.inc'                                               DRWL013
                                                                        DRWL014
CHECK v.3.2-->                                                          DRWL015
C      CHARACTER*1   INCHN                                              DRWL016
C      CHARACTER*3   RESNAM                                             DRWL017
C      CHARACTER*5   NUMBER, SEQNO                                      DRWL018
C      CHARACTER*10  RESID                                              DRWL019
C      INTEGER       DPOS, IMAIN, I1, I2, SPOS                          DRWL020
      CHARACTER*1   INCHN, OTHCHN                                       DRWL021
      CHARACTER*3   OTHNAM, RESNAM                                      DRWL022
      CHARACTER*5   NUMBER, OTHSEQ, SEQNO                               DRWL023
      CHARACTER*10  OTHID, RESID                                        DRWL024
      INTEGER       DPOS, IMAIN, I1, I2, OI1, OI2, SPOS                 DRWL025
CHECK v.3.2<--                                                          DRWL026
      REAL          BLUE, DGX, DGY, DY, EVALUE, GREEN, RED, VALUE,      DRWL027
     &              XHALF, XSTART, XWIDTH, X1, X2, YHIGHT, YSTART, Y1,  DRWL028
     &              Y2                                                  DRWL029
                                                                        DRWL030
C---- Initialise variables                                              DRWL031
      XSTART = DGX + (XWIDTH / DGLENL) * (DGLENL - EVALUE) / 2.0        DRWL032
      YSTART = DGY + 0.6 * YHIGHT                                       DRWL033
                                                                        DRWL034
C---- Format the residue ID for printing                                DRWL035
      RESID = INCHN // ' ' // RESNAM // SEQNO                           DRWL036
      IF (INCHN.EQ.' ') THEN                                            DRWL037
          I1 = 3                                                        DRWL038
      ELSE                                                              DRWL039
          I1 = 1                                                        DRWL040
      ENDIF                                                             DRWL041
      IF (RESID(9:10).EQ.'  ') THEN                                     DRWL042
          I2 = 8                                                        DRWL043
      ELSE IF (RESID(10:10).EQ.' ') THEN                                DRWL044
          I2 = 9                                                        DRWL045
      ELSE                                                              DRWL046
          I2 = 10                                                       DRWL047
      ENDIF                                                             DRWL048
                                                                        DRWL049
CHECK v.3.2-->                                                          DRWL050
CC---- Print the residue name(s)                                        DRWL051
C      CALL PSCTXT(DGX + XWIDTH / 2.0,DGY + 0.275 * YHIGHT,10.0,        DRWL052
C     -    RESID(I1:I2))                                                DRWL053
                                                                        DRWL054
C---- If this bond spans two residues, then form name of other residue  DRWL055
      IF (OTHNAM.NE.' ') THEN                                           DRWL056
          OTHID = OTHCHN // ' ' // OTHNAM // OTHSEQ                     DRWL057
          IF (OTHCHN.EQ.' ') THEN                                       DRWL058
              OI1 = 3                                                   DRWL059
          ELSE                                                          DRWL060
              OI1 = 1                                                   DRWL061
          ENDIF                                                         DRWL062
          IF (OTHID(9:10).EQ.'  ') THEN                                 DRWL063
              OI2 = 8                                                   DRWL064
          ELSE IF (OTHID(10:10).EQ.' ') THEN                            DRWL065
              OI2 = 9                                                   DRWL066
          ELSE                                                          DRWL067
              OI2 = 10                                                  DRWL068
          ENDIF                                                         DRWL069
          CALL PSCTXT(DGX + XWIDTH / 2.0,DGY + 0.275 * YHIGHT,8.0,      DRWL070
     &        RESID(I1:I2) // ' - ' // OTHID(OI1:OI2))                  DRWL071
                                                                        DRWL072
C---- Otherwise print the single residue name                           DRWL073
      ELSE                                                              DRWL074
          CALL PSCTXT(DGX + XWIDTH / 2.0,DGY + 0.275 * YHIGHT,10.0,     DRWL075
     &        RESID(I1:I2))                                             DRWL076
      ENDIF                                                             DRWL077
CHECK v.3.2<--                                                          DRWL078
                                                                        DRWL079
C---- Calculate the "ideal" bond                                        DRWL080
      CALL PSLWID(0.1)                                                  DRWL081
      X1 = XSTART                                                       DRWL082
      X2 = XSTART + (EVALUE / DGLENL) * XWIDTH                          DRWL083
      XHALF = (X1 + X2) / 2.0                                           DRWL084
      DY = 0.1 * YHIGHT                                                 DRWL085
      Y1 = YSTART - DY                                                  DRWL086
      Y2 = YSTART + DY                                                  DRWL087
                                                                        DRWL088
C---- Plot the bond type                                                DRWL089
      DPOS = INDEX(LENANG(IMAIN),'-')                                   DRWL090
      SPOS = INDEX(LENANG(IMAIN),' ')                                   DRWL091
      DY = 0.25 * YHIGHT                                                DRWL092
      CALL PSCTXT(X1,YSTART + DY,8.0,LENANG(IMAIN)(1:DPOS-1))           DRWL093
      CALL PSCTXT(X2,YSTART + DY,8.0,LENANG(IMAIN)(DPOS+1:SPOS-1))      DRWL094
                                                                        DRWL095
C---- Plot the "ideal bond                                              DRWL096
      IF (INCOLR(PLTYPE)) THEN                                          DRWL097
          RED = RGB(1,COLPLT(PLTYPE,2))                                 DRWL098
          GREEN = RGB(2,COLPLT(PLTYPE,2))                               DRWL099
          BLUE = RGB(3,COLPLT(PLTYPE,2))                                DRWL100
          CALL PSCOLB(RED,GREEN,BLUE)                                   DRWL101
      ENDIF                                                             DRWL102
      CALL PSLINE(X1,YSTART,X2,YSTART)                                  DRWL103
      CALL PSLINE(X1,Y1,X1,Y2)                                          DRWL104
      CALL PSLINE(X2,Y1,X2,Y2)                                          DRWL105
                                                                        DRWL106
C---- Plot the "ideal" length                                           DRWL107
      WRITE(NUMBER,110) EVALUE                                          DRWL108
 110  FORMAT(F5.3)                                                      DRWL109
      CALL PSCTXT(XHALF,YSTART + DY,7.0,NUMBER)                         DRWL110
                                                                        DRWL111
C---- Plot the actual bond - end markers                                DRWL112
      CALL PSLWID(0.2)                                                  DRWL113
      IF (INCOLR(PLTYPE)) THEN                                          DRWL114
          RED = RGB(1,COLPLT(PLTYPE,3))                                 DRWL115
          GREEN = RGB(2,COLPLT(PLTYPE,3))                               DRWL116
          BLUE = RGB(3,COLPLT(PLTYPE,3))                                DRWL117
          CALL PSCOLB(RED,GREEN,BLUE)                                   DRWL118
      ENDIF                                                             DRWL119
      X1 = XSTART                                                       DRWL120
      X2 = XSTART + (VALUE / DGLENL) * XWIDTH                           DRWL121
      IF (X2.GT.DGX + XWIDTH) X2 = DGX + XWIDTH                         DRWL122
      XHALF = (X1 + X2) / 2.0                                           DRWL123
      DY = 0.1 * YHIGHT / 2.0                                           DRWL124
      Y1 = YSTART - DY                                                  DRWL125
      Y2 = YSTART + DY                                                  DRWL126
      IF (INCOLR(PLTYPE)) CALL PSLINE(X1,Y1,X1,Y2)                      DRWL127
      CALL PSLINE(X2,Y1,X2,Y2)                                          DRWL128
                                                                        DRWL129
C---- Plot the actual bond                                              DRWL130
      CALL PSLWID(0.1)                                                  DRWL131
      DY = DY / 2.0                                                     DRWL132
      Y1 = YSTART - DY                                                  DRWL133
      Y2 = YSTART + DY                                                  DRWL134
      CALL PSHADE(0.0,COLPLT(PLTYPE,3),RGB,MXCOLR,INCOLR(PLTYPE))       DRWL135
      CALL PSBBOX(X1,Y1,X1,Y2,X2,Y2,X2,Y1)                              DRWL136
                                                                        DRWL137
C---- Plot the actual length                                            DRWL138
      DY = 0.12 * YHIGHT                                                DRWL139
      IF (INCOLR(PLTYPE)) THEN                                          DRWL140
          CALL PSCOLB(RED,GREEN,BLUE)                                   DRWL141
      ENDIF                                                             DRWL142
      WRITE(NUMBER,110) VALUE                                           DRWL143
      CALL PSCTXT(XHALF,YSTART - DY,8.0,NUMBER)                         DRWL144
                                                                        DRWL145
C---- Plot the difference between the ideal and the actual              DRWL146
      DY = 0.12 * YHIGHT                                                DRWL147
      WRITE(NUMBER,110) ABS(EVALUE - VALUE)                             DRWL148
      IF (INCOLR(PLTYPE)) THEN                                          DRWL149
          RED = RGB(1,COLPLT(PLTYPE,4))                                 DRWL150
          GREEN = RGB(2,COLPLT(PLTYPE,4))                               DRWL151
          BLUE = RGB(3,COLPLT(PLTYPE,4))                                DRWL152
          CALL PSCOLB(RED,GREEN,BLUE)                                   DRWL153
      ENDIF                                                             DRWL154
      CALL PSCTXT(XHALF,YSTART + DY,6.0,NUMBER)                         DRWL155
      IF (INCOLR(PLTYPE)) CALL PSCOLB(0.0,0.0,0.0)                      DRWL156
                                                                        DRWL157
      RETURN                                                            DRWL158
      END                                                               DRWL159
