      PROGRAM PPLOT                                                     PPLO0001
c ----------------------------------------------------------------------PPLO0002
c                                                                       PPLO0003
c  Windows NT / Win 95 code                                             PPLO0004
c                                                                       PPLO0005
c  Bernhard Rupp 1996 - minor modifications.                            PPLO0006
c                                                                       PPLO0007
c  1.  comment lines restricted to 72 columns                           PPLO0008
c  2.  source code lines numbered                                       PPLO0009
c  3.  to read file name of input file as parameter otherwise ask       PPLO0010
c  4.  taken apart into subroutines                                     PPLO0011
c                                                                       PPLO0012
c      Changes are annotated by WINNT at the beginning of comment lines PPLO0013
c                                                                       PPLO0014
C-----------------------------------------------------------------------PPLO0015
C                                                                       PPLO0016
C  PPLOT.FOR  -  Plot of various stereochemical quality parameters      PPLO0017
C                Program accepts the filename of structure (in          PPLO0018
C                Brookhaven format) to be plotted, and its resolution   PPLO0019
C                                                                       PPLO0020
C                The data files need to have been generated by running  PPLO0021
C                the programs CLEAN, SECSTR, ANGLEN and NB on the       PPLO0022
C                original .pdb file for the structure in question. The  PPLO0023
C                output files that should have been produced will be    PPLO0024
C                .new, .rin, .lan, and .nb files, respectively.         PPLO0025
C                                                                       PPLO0026
C  Reference:-                                                          PPLO0027
C                                                                       PPLO0028
C  Laskowski R A, MacArthur M W, Moss D S & Thornton J M (1993).        PPLO0029
C  PROCHECK: a program to check the stereochemical quality of protein   PPLO0030
C  structures. J. Appl. Cryst., 26, 283-291.                            PPLO0031
C                                                                       PPLO0032
C                                                                       PPLO0033
C-----------------------------------------------------------------------PPLO0034
C                                                                       PPLO0035
C Compilation and linking (on unix)                                     PPLO0036
C -----------------------                                               PPLO0037
C                                                                       PPLO0038
C f77 -u -c pplot.f                                                     PPLO0039
C f77 -u -c ps.f                                                        PPLO0040
C f77 -o pplot pplot.o ps.o                                             PPLO0041
C                                                                       PPLO0042
C Compilation and linking (on VAX VMS)                                  PPLO0043
C -----------------------                                               PPLO0044
C                                                                       PPLO0045
C FORT PPLOT                                                            PPLO0046
C FORT PS                                                               PPLO0047
C LINK PPLOT, PS                                                        PPLO0048
C                                                                       PPLO0049
C-----------------------------------------------------------------------PPLO0050
C                                                                       PPLO0051
C  History:-                                                            PPLO0052
C                                                                       PPLO0053
C  Written by Roman Laskowski, University College, London, April 1992.  PPLO0054
C                                                                       PPLO0055
C  Based on four programs written by Malcolm MacArthur: bb.f, sc.f,     PPLO0056
C  pins.f, and astra.f.                                                 PPLO0057
C                                                                       PPLO0058
C  Original version was part of v.1.0 of the PROCHECK suite of programs.PPLO0059
C  Version 2.0 involved signif. amendment to convert Simpleplot calls   PPLO0060
C  to routines to write out PostScript files. These amendments have not PPLO0061
C  been identified in the code as they involved major rewrites of many  PPLO0062
C  routines. All old lines of code commented out by amendments          PPLO0063
C  between v.2.0 and v.3.0 have also been removed.                      PPLO0064
C                                                                       PPLO0065
C  Amendments subsequent to v.3.0 have been labelled by CHECK v.m.n-->  PPLO0066
C  and CHECK v.m.n<-- where m.n is the version number corresponding to  PPLO0067
C  the change                                                           PPLO0068
C                                                                       PPLO0069
C  v.1.0     Original version.             Roman Laskowski   April 1992 PPLO0070
C                                                                       PPLO0071
C  v.2.0     Amendments to allow any input filename for input .pdb file,PPLO0072
C            rather than the restricted format of p<code>.pdb.          PPLO0073
C            Removal of all calls to Simpleplot routines, and           PPLO0074
C            replacement by routines to directly write PostScript files.PPLO0075
C            Major changes to appearance of plot -in particular additionPPLO0076
C            of shading (incl. regions on Ramachandran plot), and       PPLO0077
C            replacement of old `pins' plot by the new Residues plot.   PPLO0078
C              Roman Laskowski Jul/Aug 1992                             PPLO0079
C                                                                       PPLO0080
C  v.2.0.1 - Bug-fix. Problem with certain compilers not liking         PPLO0081
C            uninitialised and unSAVEd variables                        PPLO0082
C              Roman Laskowski 12 Aug 1992                              PPLO0083
C            Change to allow non-numeric sequence numbers (eg P1P, etc) PPLO0084
C              Roman Laskowski 14 Aug 1992                              PPLO0085
C                                                                       PPLO0086
C  v.2.0.2 - Bug-fix. Border between ~b and ~l regions drawn in when it PPLO0087
C            shouldn't be on the Ramachandran plot                      PPLO0088
C              Roman Laskowski 19 Aug 1992                              PPLO0089
C                                                                       PPLO0090
C  v.2.1   - Addition of .sco output file for writing out the scores of PPLO0091
C            the various stereochemical parameters  (19-20 Oct 1992)    PPLO0092
C            Amendment to definition of what makes a Bad Contact by the PPLO0093
C            addition of a check on whether atoms belong to a donor-    PPLO0094
C            acceptor pair                          (9 Nov 1992)        PPLO0095
C            Amendment for Residues Plot to show residue numbers on     PPLO0096
C            x-axes rather than simple sequential numbering. Chain      PPLO0097
C            breaks also shown on this plot.                            PPLO0098
C            Addition of chain ID on residues plot. Removal of all      PPLO0099
C            references to accessibilities file     (1 Dec 1992)        PPLO0100
C            Allowance for cis-peptides. Omega torsion angles between   PPLO0101
C            -45 and +45 taken to be cis-peptides, and shown as such in PPLO0102
C            the output                             (6 Jan 1993)        PPLO0103
C            Allow upper limit on y-axis of Quality plots to increase   PPLO0104
C            when data point is off the end of the scale. Addition of   PPLO0105
C            marker identifying D-amino acids       (7 Jan 1993)        PPLO0106
C            Bug fix in routine READNB where leading zeros in sequence  PPLO0107
C            number not stripped off, so no bad contacts found for      PPLO0108
C            .out listing                           (7 Jan 1993)        PPLO0109
C            Initialisation of unitialised variables(8 Jan 1993)        PPLO0110
C            Correction of line-counts              (14 Jan 1993)       PPLO0111
C              Roman Laskowski Oct 93 - Jan 93                          PPLO0112
C                                                                       PPLO0113
C  v.2.1.1 - Bug-fix. Water atoms for some structures (eg 5pti)         PPLO0114
C            represented by residue type DOD, and atom types D1, O, and PPLO0115
C            D2. Program amended to ignore the hydrogens and            PPLO0116
C            water-water contacts                                       PPLO0117
C              Roman Laskowski (24 Jan 1993)                            PPLO0118
C                                                                       PPLO0119
C  v.2.1.2 - Bug-fix. On asterisks-only prints getting EOF on internal  PPLO0120
C            writes. Cause: range provided for character field was too  PPLO0121
C            small. Error now corrected.                                PPLO0122
C               Roman Laskowski (17 Feb 1993)                           PPLO0123
C                                                                       PPLO0124
C  v.2.1.3 - Addition of routines for IDITIS table (internal use only)  PPLO0125
C               Roman Laskowski ( 5 Mar 1993)                           PPLO0126
C            Addition of asterisks to error prints to be plucked        PPLO0127
C            out of the log files and displayed by the script file.     PPLO0128
C            Change of 'Better' and 'Worse' remarks on the plot stats   PPLO0129
C            to the less emotionally-charged 'Inside'                   PPLO0130
C               Roman Laskowski (26 Mar 1993)                           PPLO0131
C                                                                       PPLO0132
C  v.2.1.4 - Minor amendments suggested by George Sheldrick - mainly to PPLO0133
C            cope with compilation problems on the IBM RS/6000. Also    PPLO0134
C            amendment to change name of residue information files from PPLO0135
C            .res to .rin so as not to clash with SHELX .rin files      PPLO0136
C               Roman Laskowski (12 May 1993)                           PPLO0137
C                                                                       PPLO0138
C  v.2.2   - Addition of asterisk to show plot-files produced.          PPLO0139
C            Amendment to skip "plane" information in .lan file (info   PPLO0140
C            generated by the new version of anglen for plotting by     PPLO0141
C            bplot.f). New parameters written out to procheck.prm       PPLO0142
C            (not used here, but used by bplot.f)                       PPLO0143
C               Roman Laskowski (4-8 Nov 1993)                          PPLO0144
C                                                                       PPLO0145
C  v.3.0   - Removal of Chi1-Chi2 plot (now done by program tplot.f on aPPLO0146
C            residue-by-residue basis).                                 PPLO0147
C            Removal of MKEPAR routine which creates the parameter file PPLO0148
C            procheck.prm. The parameter file is now created by the     PPLO0149
C            script file that runs PROCHECK.                            PPLO0150
C            Amendments to PostScript to routines to ensure that any    PPLO0151
C            lines output to the output PostScript file are not longer  PPLO0152
C            than 80 characters (as some laser printers can't cope with PPLO0153
C            long lines!).                                              PPLO0154
C            Addition of new stereochemical parameter to Quality Plots  PPLO0155
C            and print-outs, being the protein's average log-odds score PPLO0156
C            based on phi-psi and chi1-chi2 dihedral angle pairings.    PPLO0157
C            Addition of plot of Ooi numbers to Residues Plot.          PPLO0158
C            Amendments to secondary structure "wiring diagram", to showPPLO0159
C            on a shaded background representing relative accessibility.PPLO0160
C            Rearrangements of Residues plot to include the G-factors onPPLO0161
C            the PROCHECKer board.                                      PPLO0162
C            Complete overhaul of parameter file, procheck.prm, and     PPLO0163
C            routines to read it. Addition of colour option for plots.  PPLO0164
C            Removal of Ramachandran plot to tplot.f.                   PPLO0165
C            Removal of all CHECK v.m.n comments and commented out linesPPLO0166
C            of code so that v.3.0 is new starting point for amendments.PPLO0167
C            Addition of option to accept a single chain-ID to restrict PPLO0168
C            all the plots to just the residues of a single chain.      PPLO0169
C              Roman Laskowski (14 Nov-14 Dec 1993)                     PPLO0170
C                                                                       PPLO0171
C  v.3.0.1 - Commented out unreferenced labels (producing compiler      PPLO0172
C            warnings      when compiling on Convex).                   PPLO0173
C              Roman Laskowski (6 Apr 1994)                             PPLO0174
C                                                                       PPLO0175
C  v.3.1   - Routines to pick up the calculated solvent accessibility   PPLO0176
C            from the .rsa file (if it is present) and use these rather PPLO0177
C            than the estimated accessibilities based on Ooi numbers.   PPLO0178
C            Transfer of FINKEY, GETCOL and GETNAM routines to ps.f.    PPLO0179
C            Minor bug-fix in "Highlighted residues" legend on Residue  PPLO0180
C            Properties plot.                                           PPLO0181
C            Addition of plot description to display of plot file name. PPLO0182
C              Roman Laskowski (7-19 Apr 1994)                          PPLO0183
C                                                                       PPLO0184
C  v.3.2   - Addition of identifying plot handle to each plot filename. PPLO0185
C            Addition of descriptive plot title to header of PostScript PPLO0186
C            file.                                                      PPLO0187
C            Addition of .sum file holding a summary page.              PPLO0188
C            Print of G-factor values on the Residue Properties plot.   PPLO0189
C            Addition of option to print plot filename on the plot      PPLO0190
C            itself. Chain ID made case-insensitive.                    PPLO0191
C            Addition of B-value standard deviations, both for the      PPLO0192
C            main-chain and side-chain atoms. Added to the options on   PPLO0193
C            the 3 main graphs in the Residue Properties plot.          PPLO0194
C            Change B-value plot headings to U-value if all values are  PPLO0195
C            very      small and hence clearly U-values.                PPLO0196
C            Correction of cis-peptide definition wherein a residue is  PPLO0197
C            defined as cis if the omega dihedral angle associated with PPLO0198
C            the PREVIOUS residue is near zero.                         PPLO0199
C              Roman Laskowski (25-30 Apr 1994)                         PPLO0200
C            Addition of option allowing plots of same type to be       PPLO0201
C            combined in a single PostScript file.                      PPLO0202
C              Roman Laskowski (12 Oct 1994)                            PPLO0203
C            Minor amendments to various statements to make them        PPLO0204
C            acceptable to f2c, and to deal with various uninitialised  PPLO0205
C            variables.(Amendments supplied by Dave Love at Daresbury). PPLO0206
C              David Love/Roman Laskowski (18 Oct 1994)                 PPLO0207
C                                                                       PPLO0208
C  v.3.3.2 - Output of summary statistics in html format                PPLO0209
C            Amendments to accessibility-reading routines to cope with  PPLO0210
C            new format of the .rsa files.                              PPLO0211
C              Roman Laskowski (21-28 Aug 1995)                         PPLO0212
C                                                                       PPLO0213
C  v.3.4   - Amendments to PSPAGE calls to comply with additional       PPLO0214
C            parameter (used by other programs).                        PPLO0215
C              Roman Laskowski (25 Mar 1996)                            PPLO0216
C            Transfer of routines to ps.f:- PINRNO, PINTIC, and DHELIX  PPLO0217
C              Roman Laskowski (10 Apr 1996)                            PPLO0218
C            Bug-fix on accessibility-shading when in colour.           PPLO0219
C            Increase of number of colours that can be user-defined.    PPLO0220
C              Roman Laskowski (24 Apr 1996)                            PPLO0221
C                                                                       PPLO0222
C-----------------------------------------------------------------------PPLO0223
C                                                                       PPLO0224
C Files                                                                 PPLO0225
C -----                                                                 PPLO0226
C                                                                       PPLO0227
C  1  <filename>.rin - File generated by program CLEAN, containing the  PPLO0228
C                      residue-by-residue information on the given      PPLO0229
C                      structure                                        PPLO0230
C  2  <filename>.nb  - File generated by program NB, containing list of PPLO0231
C                      non-bonded contacts                              PPLO0232
C  3  <filename>.sdh - File generated by TPLOT program containing the   PPLO0233
C                      residue-by-residue log-odds scores for various   PPLO0234
C                      properties                                       PPLO0235
C  4  <filename>.lan - File generated by program ANGLEN, holding all    PPLO0236
C                      mainchain bond lengths and bond angles           PPLO0237
C  7  <filename>.out - Output print file highlighting any residue-by-   PPLO0238
C                      residue values that differ from ideal means      PPLO0239
C  8  <filename>.sco - Output print containing the values of several    PPLO0240
C                      stereochemical parameters                        PPLO0241
C  9  <filename>.ast - Output print containing the maximum asterisk valsPPLO0242
C                      for each residue (for input to IDITIS tables)    PPLO0243
C 10  procheck.prm   - Input parameter file holding all the user-definedPPLO0244
C                      options                                          PPLO0245
C 11  <filename>_nn.ps - Output PostScript files, numbered nn = 01, 02, PPLO0246
C                      with the last-used number being picked up from   PPLO0247
C                      the ps.number file                               PPLO0248
C 12  ps.number      - Input file holding last-used number for the      PPLO0249
C                      PostScript files                                 PPLO0250
C 13  <filename>.rsa - Residue-accessibility file created by the naccessPPLO0251
C                      programs                                         PPLO0252
C 14  <filename>.sum - Output summary page showing summarised results   PPLO0253
C                      from all the plots                               PPLO0254
C 15  <filename>.html- Output html file giving summary statistics in    PPLO0255
C                      htlm format                                      PPLO0256
C                                                                       PPLO0257
C-----------------------------------------------------------------------PPLO0258
C                                                                       PPLO0259
C Subroutine calling tree                                               PPLO0260
C -----------------------                                               PPLO0261
C                                                                       PPLO0262
C MAIN        Read in parameters from procheck.prm or create if not founPPLO0263
C         --> PARAMS   --> FINKEY                                       PPLO0264
C                      --> GETCOL                                       PPLO0265
C         --> GETPSN                                                    PPLO0266
C                                                                       PPLO0267
C             Get filename and resolution of structure                  PPLO0268
C         --> GETCOD   --> GETNAM                                       PPLO0269
C         --> OPESUM                                                    PPLO0270
C         --> OPEHTM                                                    PPLO0271
C                                                                       PPLO0272
C             1st pass through data: Calculate means of all parameters  PPLO0273
C         --> MEANS    --> RAMREG                                       PPLO0274
C                                                                       PPLO0275
C             Read through the input data files to calculate maximum    PPLO0276
C             residue-by-residue values and overall means               PPLO0277
C         --> GETSDH                                                    PPLO0278
C         --> GETRSA                                                    PPLO0279
C         --> CALCS                                                     PPLO0280
C         --> GETNB    --> ISBAD                                        PPLO0281
C         --> GETLAN                                                    PPLO0282
C                                                                       PPLO0283
C             2nd pass through data: Calculate standard deviations of   PPLO0284
C             all parameters                                            PPLO0285
C         --> STDEVS                                                    PPLO0286
C         --> SCALCS                                                    PPLO0287
C                                                                       PPLO0288
C             Plot the Main-chain and Side-chain Properties plots       PPLO0289
C         --> QUALIT   --> PSNAME                                       PPLO0290
C                      --> PSOPEN                                       PPLO0291
C                      --> PSPAGE                                       PPLO0292
C                      --> PSLWID                                       PPLO0293
C                      --> PSCTXT                                       PPLO0294
C                      --> PSHADE                                       PPLO0295
C                      --> PSUBOX                                       PPLO0296
C                      --> AXES    --> PSLWID                           PPLO0297
C                                  --> PSLINE                           PPLO0298
C                                  --> PSCTXT                           PPLO0299
C                      --> PSRCTX                                       PPLO0300
C                      --> CURSHD  --> PSHADE                           PPLO0301
C                                  --> PSUBOX                           PPLO0302
C                                  --> PSLINE                           PPLO0303
C                      --> PSMARK  --> PSBBOX                           PPLO0304
C                                  --> PSTRIA                           PPLO0305
C                      --> PSBBOX                                       PPLO0306
C                      --> QSTAT   --> PSCTXT                           PPLO0307
C                                  --> QPUT    --> PSTEXT               PPLO0308
C                                              --> PSCTXT               PPLO0309
C                                  --> PSLWID                           PPLO0310
C                                  --> PSLINE                           PPLO0311
C                                  --> BANDIS                           PPLO0312
C                      --> PSENDP                                       PPLO0313
C                      --> PSCLOS                                       PPLO0314
C                                                                       PPLO0315
C             3rd pass through data: Produce the residue-by-residue     PPLO0316
C             listing and the Residues plot                             PPLO0317
C         --> PINS     --> ASTOPE                                       PPLO0318
C                      --> REASDH                                       PPLO0319
C                      --> REARSA                                       PPLO0320
C                      --> ASTPRN  --> ASTHED  --> ASTABL               PPLO0321
C                                              --> ASTOPT               PPLO0322
C                                              --> COLHD1               PPLO0323
C                                              --> COLHD2               PPLO0324
C                                              --> COLHD3               PPLO0325
C                                  --> RAMREG                           PPLO0326
C                                  --> ASTDEV                           PPLO0327
C                                  --> READNB  --> ISBAD                PPLO0328
C                      --> PSENDP                                       PPLO0329
C                      --> PSCLOS                                       PPLO0330
C                      --> PINPLT  --> PSNAME                           PPLO0331
C                                  --> PSOPEN                           PPLO0332
C                                  --> PSPAGE                           PPLO0333
C                                  --> PSLWID                           PPLO0334
C                                  --> PSCTXT                           PPLO0335
C                                  --> PSTEXT                           PPLO0336
C                                  --> ASTDEV                           PPLO0337
C                                  --> PINTIC  --> PSLWID               PPLO0338
C                                              --> PSLINE               PPLO0339
C                                  --> PINRAM  --> PSHADE               PPLO0340
C                                              --> PSTRIA               PPLO0341
C                                              --> PSBBOX               PPLO0342
C                                              --> PSTEXT               PPLO0343
C                                  --> PINCHQ  --> PSCALE               PPLO0344
C                                              --> PSBBOX               PPLO0345
C                                              --> PSTEXT               PPLO0346
C                                  --> ACCSHD  --> PSLWID               PPLO0347
C                                              --> PSCALE               PPLO0348
C                                              --> PSUBOX               PPLO0349
C                                  --> SSPLOT  --> PSLWID               PPLO0350
C                                              --> PSLINE               PPLO0351
C                                              --> PSHADE               PPLO0352
C                                              --> PSUBOX               PPLO0353
C                                              --> PSUTRI               PPLO0354
C                                              --> PSTEXT               PPLO0355
C                                              --> DHELIX  --> PSHADE   PPLO0356
C                                                          --> PSUBOX   PPLO0357
C                                                          --> PSLWID   PPLO0358
C                                  --> PINGRF  --> PSHADE               PPLO0359
C                                              --> PSUBOX               PPLO0360
C                                              --> AXES    --> PSLWID   PPLO0361
C                                                          --> PSLINE   PPLO0362
C                                                          --> PSCTXT   PPLO0363
C                                              --> PSLINE               PPLO0364
C                                              --> PSCTXT               PPLO0365
C                                              --> PSRCTX               PPLO0366
C                                  --> PINRNO  --> PSLWID               PPLO0367
C                                              --> PSLINE               PPLO0368
C                                              --> PSCTXT               PPLO0369
C                                  --> PINBOX  --> PSHADE               PPLO0370
C                                              --> PSBBOX               PPLO0371
C                      --> PINGFS  --> PSCALE                           PPLO0372
C                                  --> PSBBOX                           PPLO0373
C                                  --> PSTEXT                           PPLO0374
C                      --> ASTEND  --> ASTDEV                           PPLO0375
C                                  --> ASTHED  --> (see above)          PPLO0376
C                      --> ASTMEA  --> ASTDEV                           PPLO0377
C                                  --> ASTHED  --> (see above)          PPLO0378
C                      --> ASTKEY  --> ASTHED  --> (see above)          PPLO0379
C                      --> ASTLAN  --> ASTHED  --> (see above)          PPLO0380
C                                  --> ASTDEV                           PPLO0381
C                                  --> COLHD2                           PPLO0382
C                                  --> LANPRN  --> ASTHED (see above)   PPLO0383
C                                              --> ASTDEV               PPLO0384
C                                  --> ASTEND                           PPLO0385
C                                  --> ASTBLA  --> ASTHED (see above)   PPLO0386
C                                              --> ASTDEV               PPLO0387
C                      --> ASTBAD  --> ASTHED  --> (see above)          PPLO0388
C                                  --> ISBAD                            PPLO0389
C                      --> ASTATS  --> ASTHED  --> (see above)          PPLO0390
C                                  --> BANDIS                           PPLO0391
C                      --> HSTATS                                       PPLO0392
C                      --> MCLASS  --> ASTHED                           PPLO0393
C                      --> GFACTS  --> ASTHED                           PPLO0394
C                      --> GHTML                                        PPLO0395
C                                                                       PPLO0396
C             Write out overall seterochemical parameters               PPLO0397
C         --> WRIPAR                                                    PPLO0398
C         --> PUTPSN                                                    PPLO0399
C         --> WRISUM                                                    PPLO0400
C                                                                       PPLO0401
C-----------------------------------------------------------------------PPLO0402
        ! MS$DEBUG                                                      PPLO0403
                                                                        PPLO0404
      INCLUDE 'pplot.inc'                                               PPLO0405
                                                                        PPLO0406
WINNT - newfil is false for PPLOT                                       PPLO0407
      logical newfil                                                    PPLO0408
      newfil=.false.                                                    PPLO0409
                                                                        PPLO0410
C---- Read in the user-defined parameters                               PPLO0411
      CALL PARAMS                                                       PPLO0412
      IF (IFAIL) GO TO 990                                              PPLO0413
                                                                        PPLO0414
C---- Read in the last-used plot-number for the PostScript files        PPLO0415
      CALL GETPSN(IPLOT)                                                PPLO0416
                                                                        PPLO0417
C---- Initialise variables                                              PPLO0418
      BADCOP = 0.0                                                      PPLO0419
      IFAIL = .FALSE.                                                   PPLO0420
      ILINE = NLINES                                                    PPLO0421
      IPAGE = 0                                                         PPLO0422
                                                                        PPLO0423
C---- Read in the code of the Brookhaven file and the resolution        PPLO0424
      CALL GETCOD                                                       PPLO0425
      IF (IFAIL) GO TO 990                                              PPLO0426
                                                                        PPLO0427
CHECK v.3.2-->                                                          PPLO0428
C---- Open the summary file                                             PPLO0429
WINNT - newfil is false for PPLOT                                       PPLO0430
      CALL OPESUM(FILSUM,newfil,IFAIL)                                  PPLO0431
      IF (IFAIL) GO TO 990                                              PPLO0432
CHECK v.3.2<--                                                          PPLO0433
                                                                        PPLO0434
CHECK v.3.3.2-->                                                        PPLO0435
C---- Open the html file                                                PPLO0436
WINNT - newfil is false for PPLOT                                       PPLO0437
      CALL OPEHTM(FILHTM,newfil,IFAIL)                                  PPLO0438
      IF (IFAIL) GO TO 990                                              PPLO0439
CHECK v.3.3.2<--                                                        PPLO0440
                                                                        PPLO0441
C---- Read in the data and perform accumulations for the various mean   PPLO0442
C     values, and some of the deviations from ideal values              PPLO0443
      CALL MEANS                                                        PPLO0444
      IF (IFAIL) GO TO 990                                              PPLO0445
                                                                        PPLO0446
C---- Read through the log-odds scores file to find the final means     PPLO0447
      CALL GETSDH                                                       PPLO0448
      IF (IFAIL) GO TO 990                                              PPLO0449
                                                                        PPLO0450
CHECK v.3.1-->                                                          PPLO0451
C---- Read through the residue accessibilities in the .rsa file         PPLO0452
C     (if present) and calculate maximum and minimum values             PPLO0453
      CALL GETRSA                                                       PPLO0454
CHECK v.3.1<--                                                          PPLO0455
                                                                        PPLO0456
C---- Calculate the means and deviations from ideal values              PPLO0457
      CALL CALCS                                                        PPLO0458
                                                                        PPLO0459
C---- Read through the bond lengths and bond angles file to find the    PPLO0460
C     mean and maximum and minimum values                               PPLO0461
      CALL GETLAN                                                       PPLO0462
      IF (IFAIL) GO TO 990                                              PPLO0463
                                                                        PPLO0464
C---- Read through the non-bonded interactions file to pick up number   PPLO0465
C     of bad contacts per 100 residues                                  PPLO0466
      CALL GETNB(FILNB,NBAD,BADCOP,VWDIST,NONBON,NRESID,IFAIL)          PPLO0467
      IF (IFAIL) GO TO 990                                              PPLO0468
                                                                        PPLO0469
C---- Re-read the data for calculation of the various standard          PPLO0470
C     deviations required                                               PPLO0471
      CALL STDEVS                                                       PPLO0472
      IF (IFAIL) GO TO 990                                              PPLO0473
                                                                        PPLO0474
C---- Calculate the standard deviations                                 PPLO0475
      CALL SCALCS                                                       PPLO0476
                                                                        PPLO0477
C---- Plot all the stereochemical quality parameters                    PPLO0478
      CALL QUALIT                                                       PPLO0479
                                                                        PPLO0480
C---- Read through a third time and produce the pinplots                PPLO0481
      CALL PINS                                                         PPLO0482
                                                                        PPLO0483
C---- Write out the stereochemical parameters                           PPLO0484
      CALL WRIPAR                                                       PPLO0485
      IF (IFAIL) GO TO 990                                              PPLO0486
                                                                        PPLO0487
C---- Write out the current PostScript plot number                      PPLO0488
      CALL PUTPSN(IPLOT)                                                PPLO0489
                                                                        PPLO0490
CHECK v.3.2-->                                                          PPLO0491
C---- Write out data to the summary file                                PPLO0492
      CALL WRISUM                                                       PPLO0493
CHECK v.3.2<--                                                          PPLO0494
                                                                        PPLO0495
C---- Close the output file                                             PPLO0496
      CLOSE(7)                                                          PPLO0497
                                                                        PPLO0498
990   CONTINUE                                                          PPLO0499
      IF (IFAIL) THEN                                                   PPLO0500
          PRINT*, '* Program pplot terminated with error'               PPLO0501
CHECK v.3.2-->                                                          PPLO0502
          WRITE(14,*)                                                   PPLO0503
          WRITE(14,*) '*** Program pplot terminated with error. See lo',PPLO0504
     &        'g file:  pplot.log'                                      PPLO0505
          WRITE(14,*)                                                   PPLO0506
CHECK v.3.2<--                                                          PPLO0507
      ELSE                                                              PPLO0508
          PRINT*, '*'                                                   PPLO0509
          PRINT*, '* Detailed listing: ', FILOUT(1:ILEN + 4)            PPLO0510
          PRINT*, '*'                                                   PPLO0511
          PRINT*, '* Program complete'                                  PPLO0512
      ENDIF                                                             PPLO0513
      END                                                               PPLO0514
                                                                        PPLO0515
      SUBROUTINE PARAMS                                                 PARA0001
C-----------------------------------------------------------------------PARA0002
C                                                                       PARA0003
C  SUBROUTINE PARAMS  -  Read in program parameters from parameter file PARA0004
C                                                                       PARA0005
C----------------------------------------------------------------------+PARA0006
                                                                        PARA0007
      INCLUDE 'pplot.inc'                                               PARA0008
                                                                        PARA0009
      CHARACTER*1   YESNO                                               PARA0010
CHECK v.3.4-->                                                          PARA0011
      CHARACTER*80  IREC                                                PARA0012
CHECK v.3.4<--                                                          PARA0013
      INTEGER       I, ICOL, INUMB, INUMB1, INUMB2, INUMB3, LINE        PARA0014
CHECK v.3.4-->                                                          PARA0015
C      LOGICAL       ALLCOL, FINERR                                     PARA0016
      LOGICAL       ALLCOL, ENDCOL, FINERR                              PARA0017
CHECK v.3.4<--                                                          PARA0018
      REAL          RNUMB                                               PARA0019
                                                                        PARA0020
C---- Initialise variables and set default parameter values             PARA0021
      ALLCOL = .FALSE.                                                  PARA0022
      ASTONL = .FALSE.                                                  PARA0023
      BCLIST = .TRUE.                                                   PARA0024
      BSHADE(1) = .TRUE.                                                PARA0025
      BSHADE(2) = .TRUE.                                                PARA0026
      BSHADE(3) = .TRUE.                                                PARA0027
      CHAIN = ' '                                                       PARA0028
CHECK v.3.2-->                                                          PARA0029
      COMBPS = .FALSE.                                                  PARA0030
CHECK v.3.2<--                                                          PARA0031
      HEADIN = .TRUE.                                                   PARA0032
      INCOLR(1) = .FALSE.                                               PARA0033
      INCOLR(2) = .FALSE.                                               PARA0034
      INCOLR(3) = .FALSE.                                               PARA0035
      LINE = 0                                                          PARA0036
      NLINES = 66                                                       PARA0037
      NPLOTS = 0                                                        PARA0038
      ONLYHI = .FALSE.                                                  PARA0039
CHECK v.3.2-->                                                          PARA0040
      PLABEL = .TRUE.                                                   PARA0041
CHECK v.3.2<--                                                          PARA0042
      PLOTPN = .TRUE.                                                   PARA0043
      PLOTQ1 = .TRUE.                                                   PARA0044
      PLOTQ2 = .TRUE.                                                   PARA0045
      PLTNUM(1) = 1                                                     PARA0046
      PLTNUM(2) = 2                                                     PARA0047
      PLTNUM(3) = 3                                                     PARA0048
      SHOWAC = .TRUE.                                                   PARA0049
      STDLIM = 0.0                                                      PARA0050
CHECK v.3.2-->                                                          PARA0051
      WITHAN = .FALSE.                                                  PARA0052
CHECK v.3.2<--                                                          PARA0053
                                                                        PARA0054
C---- Open parameter file                                               PARA0055
      OPEN(UNIT=10, FILE='procheck.prm', STATUS='OLD',                  PARA0056
     &     FORM='FORMATTED', ACCESS='SEQUENTIAL',                       PARA0057
CVAX     -     CARRIAGECONTROL = 'LIST', READONLY,                      PARA0058
     &     ERR=900)                                                     PARA0059
      FINERR = .FALSE.                                                  PARA0060
      LINE = 0                                                          PARA0061
                                                                        PARA0062
C---- Read in the parameters                                            PARA0063
                                                                        PARA0064
C---- Check that have the right version number in the parameter file    PARA0065
CHECK v.3.2-->                                                          PARA0066
C      CALL FINKEY('PROCHECK v.3.0',14,LINE,FINERR)                     PARA0067
      CALL FINKEY('PROCHECK v.3.3',14,LINE,FINERR)                      PARA0068
      IF (FINERR) THEN                                                  PARA0069
          CALL FINKEY('PROCHECK v.3',12,LINE,FINERR)                    PARA0070
          IF (FINERR) THEN                                              PARA0071
              GO TO 901                                                 PARA0072
          ELSE                                                          PARA0073
              PRINT*, '* Warning. Parameter file not up-to-date'        PARA0074
              PRINT*, '*          Defaults will be used for missing',   PARA0075
     &            ' items'                                              PARA0076
          ENDIF                                                         PARA0077
      ENDIF                                                             PARA0078
CHECK v.3.2<--                                                          PARA0079
      IF (FINERR) GO TO 901                                             PARA0080
                                                                        PARA0081
C---- Find the colours key-word                                         PARA0082
      CALL FINKEY('Colours',7,LINE,FINERR)                              PARA0083
      IF (FINERR) GO TO 990                                             PARA0084
                                                                        PARA0085
C---- Read in all the RGB colours and corresponding colour names        PARA0086
CHECK v.3.4-->                                                          PARA0087
C      DO 100, ICOL = 1, MXCOLR                                         PARA0088
C          LINE = LINE + 1                                              PARA0089
C          READ(10,*,END=902,ERR=904) (RGB(I, ICOL), I = 1, 3),         PARA0090
C     -        COLNAM(ICOL)                                             PARA0091
C 100  CONTINUE                                                         PARA0092
      ENDCOL = .FALSE.                                                  PARA0093
      NCOLOR = MXCOLR                                                   PARA0094
      DO 100, ICOL = 1, MXCOLR                                          PARA0095
          IF (.NOT.ENDCOL) THEN                                         PARA0096
              LINE = LINE + 1                                           PARA0097
              READ(10,20,END=902,ERR=904) IREC                          PARA0098
 20           FORMAT(A)                                                 PARA0099
              IF (IREC.EQ.' ') THEN                                     PARA0100
                  ENDCOL = .TRUE.                                       PARA0101
              ELSE                                                      PARA0102
                  READ(IREC,*,ERR=904) (RGB(I,ICOL), I = 1, 3),         PARA0103
     &                COLNAM(ICOL)                                      PARA0104
                  NCOLOR = ICOL                                         PARA0105
              ENDIF                                                     PARA0106
          ENDIF                                                         PARA0107
                                                                        PARA0108
C----     If have reached end of colours then insert default            PARA0109
          IF (ENDCOL) THEN                                              PARA0110
              RGB(1,ICOL) = 0.0                                         PARA0111
              RGB(2,ICOL) = 0.0                                         PARA0112
              RGB(3,ICOL) = 0.0                                         PARA0113
              COLNAM(ICOL) = 'WHITE'                                    PARA0114
          ENDIF                                                         PARA0115
 100  CONTINUE                                                          PARA0116
CHECK v.3.4<--                                                          PARA0117
                                                                        PARA0118
C---- Determine whether all plots are to be in colour                   PARA0119
                                                                        PARA0120
C---- Find the colour-all-plots keywords                                PARA0121
      CALL FINKEY('Colour all plots?',17,LINE,FINERR)                   PARA0122
      IF (FINERR) GO TO 990                                             PARA0123
                                                                        PARA0124
C---- Determine whether all plots are to be in colour                   PARA0125
      LINE = LINE + 1                                                   PARA0126
      READ(10,120,END=902,ERR=904) YESNO                                PARA0127
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0128
          ALLCOL = .TRUE.                                               PARA0129
      ELSE                                                              PARA0130
          ALLCOL = .FALSE.                                              PARA0131
      ENDIF                                                             PARA0132
                                                                        PARA0133
C---- Determine which plots are to be produced                          PARA0134
                                                                        PARA0135
C---- Find the "Which plots" keyword                                    PARA0136
      CALL FINKEY('Which plots',11,LINE,FINERR)                         PARA0137
      IF (FINERR) GO TO 990                                             PARA0138
                                                                        PARA0139
C---- Skip the first 3 options as these done by tplot.f                 PARA0140
      DO 150, I = 1, 3                                                  PARA0141
          LINE = LINE + 1                                               PARA0142
          READ(10,120,END=902,ERR=904) YESNO                            PARA0143
 120      FORMAT(A)                                                     PARA0144
 150  CONTINUE                                                          PARA0145
                                                                        PARA0146
C---- 4. Main-chain parameters (Y/N)                                    PARA0147
      LINE = LINE + 1                                                   PARA0148
      READ(10,120,END=902,ERR=904) YESNO                                PARA0149
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0150
          PLOTQ1 = .TRUE.                                               PARA0151
          NPLOTS = NPLOTS + 1                                           PARA0152
      ELSE                                                              PARA0153
          PLOTQ1 = .FALSE.                                              PARA0154
      ENDIF                                                             PARA0155
                                                                        PARA0156
C---- 5. Side-chain parameters (Y/N)                                    PARA0157
      LINE = LINE + 1                                                   PARA0158
      READ(10,120,END=902,ERR=904) YESNO                                PARA0159
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0160
          PLOTQ2 = .TRUE.                                               PARA0161
          NPLOTS = NPLOTS + 1                                           PARA0162
      ELSE                                                              PARA0163
          PLOTQ2 = .FALSE.                                              PARA0164
      ENDIF                                                             PARA0165
                                                                        PARA0166
C---- 6. Residue properties (Y/N)                                       PARA0167
      LINE = LINE + 1                                                   PARA0168
      READ(10,120,END=902,ERR=904) YESNO                                PARA0169
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0170
          PLOTPN = .TRUE.                                               PARA0171
          NPLOTS = NPLOTS + 1                                           PARA0172
      ELSE                                                              PARA0173
          PLOTPN = .FALSE.                                              PARA0174
      ENDIF                                                             PARA0175
                                                                        PARA0176
C---- Check whether any plots are to be produced                        PARA0177
      IF (NPLOTS.GT.0) THEN                                             PARA0178
          NOPLOT = .FALSE.                                              PARA0179
      ELSE                                                              PARA0180
          NOPLOT = .TRUE.                                               PARA0181
      ENDIF                                                             PARA0182
                                                                        PARA0183
C---- Read in the plot parameters                                       PARA0184
                                                                        PARA0185
C---- Find the Main-chain Parameters key-word                           PARA0186
      CALL FINKEY('4. Main-chain param',19,LINE,FINERR)                 PARA0187
      IF (FINERR) GO TO 990                                             PARA0188
      PLTYPE = 1                                                        PARA0189
                                                                        PARA0190
C---- Plot options                                                      PARA0191
                                                                        PARA0192
C---- Background shading (Y/N)?                                         PARA0193
      LINE = LINE + 1                                                   PARA0194
      READ(10,120,END=902,ERR=904) YESNO                                PARA0195
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0196
          BSHADE(PLTYPE) = .TRUE.                                       PARA0197
      ELSE                                                              PARA0198
          BSHADE(PLTYPE) = .FALSE.                                      PARA0199
      ENDIF                                                             PARA0200
                                                                        PARA0201
C---- Produce a black-and-white or colour PostScript file               PARA0202
      LINE = LINE + 1                                                   PARA0203
      READ(10,120,END=902,ERR=904) YESNO                                PARA0204
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0205
          INCOLR(PLTYPE) = .TRUE.                                       PARA0206
      ELSE                                                              PARA0207
          INCOLR(PLTYPE) = .FALSE.                                      PARA0208
      ENDIF                                                             PARA0209
                                                                        PARA0210
C---- Get each of the user-defined colours for this plot                PARA0211
      DO 200, ICOL = 1, 3                                               PARA0212
          CALL GETCOL(COLPLT(PLTYPE,ICOL),LINE,COLNAM,MXCOLR)           PARA0213
 200  CONTINUE                                                          PARA0214
                                                                        PARA0215
C---- Find the Side-chain Parameters key-word                           PARA0216
      CALL FINKEY('5. Side-chain param',19,LINE,FINERR)                 PARA0217
      IF (FINERR) GO TO 990                                             PARA0218
      PLTYPE = 2                                                        PARA0219
                                                                        PARA0220
C---- Plot options                                                      PARA0221
                                                                        PARA0222
C---- Background shading (Y/N)?                                         PARA0223
      LINE = LINE + 1                                                   PARA0224
      READ(10,120,END=902,ERR=904) YESNO                                PARA0225
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0226
          BSHADE(PLTYPE) = .TRUE.                                       PARA0227
      ELSE                                                              PARA0228
          BSHADE(PLTYPE) = .FALSE.                                      PARA0229
      ENDIF                                                             PARA0230
                                                                        PARA0231
C---- Produce a black-and-white or colour PostScript file               PARA0232
      LINE = LINE + 1                                                   PARA0233
      READ(10,120,END=902,ERR=904) YESNO                                PARA0234
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0235
          INCOLR(PLTYPE) = .TRUE.                                       PARA0236
      ELSE                                                              PARA0237
          INCOLR(PLTYPE) = .FALSE.                                      PARA0238
      ENDIF                                                             PARA0239
                                                                        PARA0240
C---- Get each of the user-defined colours for this plot                PARA0241
      DO 300, ICOL = 1, 3                                               PARA0242
          CALL GETCOL(COLPLT(PLTYPE,ICOL),LINE,COLNAM,MXCOLR)           PARA0243
 300  CONTINUE                                                          PARA0244
                                                                        PARA0245
C---- 6. Residue properties plot                                        PARA0246
                                                                        PARA0247
C---- Find the key-word                                                 PARA0248
      CALL FINKEY('6. Residue properties',21,LINE,FINERR)               PARA0249
      IF (FINERR) GO TO 990                                             PARA0250
      PLTYPE = 3                                                        PARA0251
                                                                        PARA0252
C---- Which 3 plots are to appear on the Residues plot (1 - MXPLOT)     PARA0253
      NRGRAF = 0                                                        PARA0254
      LINE = LINE + 1                                                   PARA0255
      READ(10,*,END=902,ERR=904) INUMB1, INUMB2, INUMB3                 PARA0256
      IF (INUMB1.GE.0 .AND. INUMB1.LE.MXPLOT) PLTNUM(1) = INUMB1        PARA0257
      IF (PLTNUM(1).GT.0) NRGRAF = NRGRAF + 1                           PARA0258
      IF (INUMB2.GE.0 .AND. INUMB2.LE.MXPLOT) PLTNUM(2) = INUMB2        PARA0259
      IF (PLTNUM(2).GT.0) NRGRAF = NRGRAF + 1                           PARA0260
      IF (INUMB3.GE.0 .AND. INUMB3.LE.MXPLOT) PLTNUM(3) = INUMB3        PARA0261
      IF (PLTNUM(3).GT.0) NRGRAF = NRGRAF + 1                           PARA0262
                                                                        PARA0263
C---- Background shading (Y/N)?                                         PARA0264
      LINE = LINE + 1                                                   PARA0265
      READ(10,120,END=902,ERR=904) YESNO                                PARA0266
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0267
          BSHADE(PLTYPE) = .TRUE.                                       PARA0268
      ELSE                                                              PARA0269
          BSHADE(PLTYPE) = .FALSE.                                      PARA0270
      ENDIF                                                             PARA0271
                                                                        PARA0272
C---- No. of standard deviations for highlighting on Residues plot      PARA0273
      LINE = LINE + 1                                                   PARA0274
      READ(10,*,END=902,ERR=904) RNUMB                                  PARA0275
      LIMRES = RNUMB                                                    PARA0276
      IF (LIMRES.LT.0.0) LIMRES = 0.0                                   PARA0277
      IF (LIMRES.GT.99.9) LIMRES = 99.9                                 PARA0278
                                                                        PARA0279
C---- Shading showing estimated accessibility (Y/N)?                    PARA0280
      LINE = LINE + 1                                                   PARA0281
      READ(10,120,END=902,ERR=904) YESNO                                PARA0282
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0283
          SHOWAC = .TRUE.                                               PARA0284
      ELSE                                                              PARA0285
          SHOWAC = .FALSE.                                              PARA0286
      ENDIF                                                             PARA0287
                                                                        PARA0288
C---- Produce a black-and-white or colour PostScript file               PARA0289
      LINE = LINE + 1                                                   PARA0290
      READ(10,120,END=902,ERR=904) YESNO                                PARA0291
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0292
          INCOLR(PLTYPE) = .TRUE.                                       PARA0293
      ELSE                                                              PARA0294
          INCOLR(PLTYPE) = .FALSE.                                      PARA0295
      ENDIF                                                             PARA0296
                                                                        PARA0297
C---- Get each of the user-defined colours for this plot                PARA0298
      DO 400, ICOL = 1, 13                                              PARA0299
          CALL GETCOL(COLPLT(PLTYPE,ICOL),LINE,COLNAM,MXCOLR)           PARA0300
 400  CONTINUE                                                          PARA0301
                                                                        PARA0302
C---- Listing options                                                   PARA0303
                                                                        PARA0304
C---- Find the key-word                                                 PARA0305
      CALL FINKEY('Listing options',15,LINE,FINERR)                     PARA0306
      IF (FINERR) GO TO 990                                             PARA0307
                                                                        PARA0308
C---- Print explanatory test at head of printout (Y/N)                  PARA0309
      LINE = LINE + 1                                                   PARA0310
      READ(10,120,END=902,ERR=904) YESNO                                PARA0311
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0312
          HEADIN = .TRUE.                                               PARA0313
      ELSE                                                              PARA0314
          HEADIN = .FALSE.                                              PARA0315
      ENDIF                                                             PARA0316
      IF (YESNO.EQ.'X' .OR. YESNO.EQ.'x') THEN                          PARA0317
          IDITIS = .TRUE.                                               PARA0318
      ELSE                                                              PARA0319
          IDITIS = .FALSE.                                              PARA0320
      ENDIF                                                             PARA0321
                                                                        PARA0322
C---- Print only asterisks on printout (ie no values) (Y/N)             PARA0323
      LINE = LINE + 1                                                   PARA0324
      READ(10,120,END=902,ERR=904) YESNO                                PARA0325
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0326
          ASTONL = .TRUE.                                               PARA0327
      ELSE                                                              PARA0328
          ASTONL = .FALSE.                                              PARA0329
      ENDIF                                                             PARA0330
                                                                        PARA0331
C---- Print only highlighted residues (Y/N)                             PARA0332
      LINE = LINE + 1                                                   PARA0333
      READ(10,120,END=902,ERR=904) YESNO                                PARA0334
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0335
          ONLYHI = .TRUE.                                               PARA0336
      ELSE                                                              PARA0337
          ONLYHI = .FALSE.                                              PARA0338
      ENDIF                                                             PARA0339
                                                                        PARA0340
C---- Minimum deviation from the ideal. (Only parameters whose deviationPARA0341
C     the ideal value is greater than, or equal, to this number of standPARA0342
C     deviations will be printed).                                      PARA0343
      LINE = LINE + 1                                                   PARA0344
      READ(10,*,END=902,ERR=904) RNUMB                                  PARA0345
      STDLIM = RNUMB                                                    PARA0346
                                                                        PARA0347
C---- Number of lines per page of the asterisks listing                 PARA0348
      LINE = LINE + 1                                                   PARA0349
      READ(10,*,END=902,ERR=904) INUMB                                  PARA0350
      NLINES = INUMB                                                    PARA0351
                                                                        PARA0352
C---- List the bad contacts on the printout (Y/N)                       PARA0353
      LINE = LINE + 1                                                   PARA0354
      READ(10,120,END=902,ERR=904) YESNO                                PARA0355
      IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                          PARA0356
          BCLIST = .TRUE.                                               PARA0357
      ELSE                                                              PARA0358
          BCLIST = .FALSE.                                              PARA0359
      ENDIF                                                             PARA0360
                                                                        PARA0361
CHECK v.3.2-->                                                          PARA0362
C---- Find whether file-handles are required or not                     PARA0363
      CALL FINKEY('File-handles',12,LINE,FINERR)                        PARA0364
      IF (.NOT.FINERR) THEN                                             PARA0365
                                                                        PARA0366
C----     See whether the file-handle is required                       PARA0367
          LINE = LINE + 1                                               PARA0368
          READ(10,120,END=902,ERR=904) YESNO                            PARA0369
          IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                      PARA0370
              WITHAN = .TRUE.                                           PARA0371
          ELSE                                                          PARA0372
              WITHAN = .FALSE.                                          PARA0373
          ENDIF                                                         PARA0374
                                                                        PARA0375
C----     See whether plot filename to be printed on the plot itself    PARA0376
          LINE = LINE + 1                                               PARA0377
          READ(10,*,END=902,ERR=904)                                    PARA0378
          LINE = LINE + 1                                               PARA0379
          READ(10,120,END=902,ERR=904) YESNO                            PARA0380
          IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                      PARA0381
              PLABEL = .TRUE.                                           PARA0382
          ELSE                                                          PARA0383
              PLABEL = .FALSE.                                          PARA0384
          ENDIF                                                         PARA0385
                                                                        PARA0386
C----     See whether all pages of same plot to be combined in one      PARA0387
C         paginated PostScript file                                     PARA0388
          LINE = LINE + 1                                               PARA0389
          READ(10,120,END=902,ERR=904) YESNO                            PARA0390
          IF (YESNO.EQ.'Y' .OR. YESNO.EQ.'y') THEN                      PARA0391
              COMBPS = .TRUE.                                           PARA0392
          ELSE                                                          PARA0393
              COMBPS = .FALSE.                                          PARA0394
          ENDIF                                                         PARA0395
      ENDIF                                                             PARA0396
CHECK v.3.2<--                                                          PARA0397
                                                                        PARA0398
C---- If all plots are required to be in colour, then set all the       PARA0399
C     appropriate flags to TRUE                                         PARA0400
      IF (ALLCOL) THEN                                                  PARA0401
          DO 600, PLTYPE = 1, 3                                         PARA0402
              INCOLR(PLTYPE) = .TRUE.                                   PARA0403
 600      CONTINUE                                                      PARA0404
      ENDIF                                                             PARA0405
                                                                        PARA0406
      GO TO 999                                                         PARA0407
                                                                        PARA0408
                                                                        PARA0409
C---- Errors reading parameter file                                     PARA0410
900   CONTINUE                                                          PARA0411
      PRINT*, '* Parameters file (procheck.prm) not found.'             PARA0412
      GO TO 990                                                         PARA0413
                                                                        PARA0414
 901  CONTINUE                                                          PARA0415
      PRINT*, '* Failed to find correct version number in parameters ', PARA0416
     &        'file, procheck.prm'                                      PARA0417
      GO TO 990                                                         PARA0418
                                                                        PARA0419
902   CONTINUE                                                          PARA0420
      PRINT*, '* Premature end of parameters file, procheck.prm, ',     PARA0421
     &        'encountered at line', LINE                               PARA0422
      GO TO 990                                                         PARA0423
                                                                        PARA0424
904   CONTINUE                                                          PARA0425
      PRINT*, '* Error reading parameter file, procheck.prm, at ',      PARA0426
     &    'line', LINE                                                  PARA0427
      GO TO 990                                                         PARA0428
                                                                        PARA0429
C---- Close the parameter file                                          PARA0430
 990  CONTINUE                                                          PARA0431
      PRINT*, '* Default values have been assumed for the ',            PARA0432
     &    'parameters'                                                  PARA0433
      CLOSE(10)                                                         PARA0434
                                                                        PARA0435
999   CONTINUE                                                          PARA0436
      RETURN                                                            PARA0437
      END                                                               PARA0438
                                                                        PARA0439
                                                                        PARA0440
      SUBROUTINE GETCOD                                                 GETC0001
C-----------------------------------------------------------------------GETC0002
C                                                                       GETC0003
C  SUBROUTINE GETCOD  -  Read in the coordinates filename and the       GETC0004
C                        structure's resolution                         GETC0005
C                                                                       GETC0006
C----------------------------------------------------------------------+GETC0007
                                                                        GETC0008
      INCLUDE 'pplot.inc'                                               GETC0009
                                                                        GETC0010
WINNT - needed for system call to getarg                                GETC0011
      integer(2)  n1,status                                             GETC0012
CHECK v.3.2-->                                                          GETC0013
C      INTEGER       LINE                                               GETC0014
C      CHARACTER*1   LOWERA                                             GETC0015
C      CHARACTER*26  UPPER                                              GETC0016
C      INTEGER       LINE, N                                            GETC0017
CHECK v.3.2-->                                                          GETC0018
C      DATA  LOWERA / 'a' /                                             GETC0019
C     DATA  UPPER  / 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' /                     GETC0020
CHECK v.3.2<--                                                          GETC0021
WINNT - end   - unused variables removed                                GETC0022
      character cres*8                                                  GETC0023
c      CHARACTER*26  UPPER                                              GETC0024
CHECK v.3.2<--                                                          GETC0025
      LOGICAL       IERROR                                              GETC0026
                                                                        GETC0027
                                                                        GETC0028
C---- Initialise variables                                              GETC0029
      LINE = 0                                                          GETC0030
WINNT - accept file name, chain id and resol from command line if       GETC0031
c       provided else ask for it                                        GETC0032
      write(*,*) 'PPLOT - Windows NT version B.Rupp 1996'               GETC0033
      n1 = 1                                                            GETC0034
      CALL GETARG(n1, pdbfil, status)                                   GETC0035
      if (status.lt.1) then                                             GETC0036
         PRINT*, 'Enter filename containing coordinates of structure '  GETC0037
         READ(*,'(a)') PDBFIL                                           GETC0038
      else                                                              GETC0039
         write(*,*) 'File name parsed from command line : ',pdbfil      GETC0040
      end if                                                            GETC0041
C---- Accept name of original .pdb file holding the structure           GETC0042
C      PRINT*, 'Enter filename containing coordinates of structure'     GETC0043
C      READ(*,110,ERR=900) PDBFIL                                       GETC0044
C 110  FORMAT(A)                                                        GETC0045
WINNT - end                                                             GETC0046
C---- Peel off directory path and extension                             GETC0047
      CALL GETNAM(PDBFIL,ISTART,IEND,IERROR)                            GETC0048
      IF (IERROR) GO TO 990                                             GETC0049
                                                                        GETC0050
C---- Form names of other files that will be required in default directoGETC0051
      ILEN = IEND - ISTART + 1                                          GETC0052
      BLEN = ILEN                                                       GETC0053
      BRCODE = PDBFIL(ISTART:IEND)                                      GETC0054
      FILOUT = PDBFIL(ISTART:IEND) // '.out'                            GETC0055
      FILNB = PDBFIL(ISTART:IEND) // '.nb'                              GETC0056
      FILRIN = PDBFIL(ISTART:IEND) // '.rin'                            GETC0057
      FILRSA = PDBFIL(ISTART:IEND) // '.rsa'                            GETC0058
      FILLAN = PDBFIL(ISTART:IEND) // '.lan'                            GETC0059
      FILPS = PDBFIL(ISTART:IEND)                                       GETC0060
      FILSCO = PDBFIL(ISTART:IEND) // '.sco'                            GETC0061
      FILAST = PDBFIL(ISTART:IEND) // '.ast'                            GETC0062
      FILSDH = PDBFIL(ISTART:IEND) // '.sdh'                            GETC0063
CHECK v.3.2-->                                                          GETC0064
      FILSUM = PDBFIL(ISTART:IEND) // '.sum'                            GETC0065
CHECK v.3.2<--                                                          GETC0066
CHECK v.3.3.2-->                                                        GETC0067
      FILHTM = PDBFIL(ISTART:IEND) // '.html'                           GETC0068
CHECK v.3.3.2<--                                                        GETC0069
                                                                        GETC0070
C---- Accept chain-ID                                                   GETC0071
C      PRINT*, 'Enter required chain-ID, or leave blank for all'        GETC0072
C      READ(*,110,ERR=906) CHAIN                                        GETC0073
                                                                        GETC0074
CHECK v.3.2-->                                                          GETC0075
C---- Convert chain ID to upper-case if necessary                       GETC0076
C      N = ICHAR(CHAIN) - ICHAR(LOWERA) + 1                             GETC0077
C      IF (N.GE.1 .AND. N.LE.26) CHAIN = UPPER(N:N)                     GETC0078
CHECK v.3.2<--                                                          GETC0079
c --- get second parameter from command line                            GETC0080
      n1 = 2                                                            GETC0081
      CALL GETARG(n1, chain, status)                                    GETC0082
c --- if missing, get the chain id                                      GETC0083
      if (status.lt.1) then                                             GETC0084
C----   Accept chain-ID                                                 GETC0085
        write(*,'(a$)')' Enter chain-ID letter or leave blank for all: 'GETC0086
        READ(*,'(a)',ERR=906) CHAIN                                     GETC0087
WINNT - new subroutine UPSTRG      from my library                      GETC0088
        call upstrg (chain,1)                                           GETC0089
C----   Accept resolution                                               GETC0090
 9015   write(*,'(a$)')' Enter resolution : '                           GETC0091
        READ(*,*,ERR=9015) RESOL                                        GETC0092
      else                                                              GETC0093
c ---   there is something but what                                     GETC0094
WINNT - new function ISNUM from my library                              GETC0095
        call upstrg (chain,1)                                           GETC0096
c ---   if it's a number it must be the resolution so use blank for all GETC0097
        if (isnum(chain)) then                                          GETC0098
           chain=' '                                                    GETC0099
           write(*,*)'All chains included '                             GETC0100
c ---      must be the resolution then                                  GETC0101
           CALL GETARG(n1, cres, status)                                GETC0102
           read(cres,'(f5.0)') resol                                    GETC0103
           write (*,'(a,f5.2)')' Resolution is ',resol                  GETC0104
        else                                                            GETC0105
           write(*,*)'Chain processed : ',chain                         GETC0106
c ---      get third parameter from command line                        GETC0107
           n1 = 3                                                       GETC0108
           CALL GETARG(n1, cres, status)                                GETC0109
           read(cres,'(f8.0)') resol                                    GETC0110
           write (*,'(a,f5.2)')' Resolution is ',resol                  GETC0111
c ---      if missing, get the resolution                               GETC0112
           if (status.lt.1) then                                        GETC0113
C----         Accept resolution                                         GETC0114
 9014         write(*,'(a$)')' Enter resolution : '                     GETC0115
              READ(*,*,ERR=9014) RESOL                                  GETC0116
           end if                                                       GETC0117
        end if                                                          GETC0118
      end if                                                            GETC0119
                                                                        GETC0120
                                                                        GETC0121
C---- Add chain identifier to plot headings                             GETC0122
      IF (CHAIN.NE.' ') THEN                                            GETC0123
          BRCODE = BRCODE(1:ILEN) // ' - Chain ' // CHAIN               GETC0124
          BLEN = BLEN + 10                                              GETC0125
          IF (BLEN.GT.78) BLEN = 78                                     GETC0126
      ENDIF                                                             GETC0127
                                                                        GETC0128
C---- Accept protein's resolution                                       GETC0129
C      PRINT*, 'Enter resolution'                                       GETC0130
C      READ(*,*,ERR=904) RESOL                                          GETC0131
      IF (RESOL.LT.1.0) RESOL = 1.0                                     GETC0132
      IF (RESOL.GT.4.0) RESOL = 4.0                                     GETC0133
WINNT -end                                                              GETC0134
      GO TO 999                                                         GETC0135
                                                                        GETC0136
C---- Fatal errors                                                      GETC0137
 900  CONTINUE                                                          GETC0138
      PRINT*, '*** ERROR. Data error in entered filename'               GETC0139
      GO TO 990                                                         GETC0140
                                                                        GETC0141
 904  CONTINUE                                                          GETC0142
      PRINT*, '*** ERROR. Data error in entered resolution'             GETC0143
      GO TO 990                                                         GETC0144
                                                                        GETC0145
 906  CONTINUE                                                          GETC0146
      PRINT*, '*** ERROR. Data error in entered chain-ID'               GETC0147
      GO TO 990                                                         GETC0148
                                                                        GETC0149
990   CONTINUE                                                          GETC0150
      IFAIL = .TRUE.                                                    GETC0151
                                                                        GETC0152
999   CONTINUE                                                          GETC0153
      RETURN                                                            GETC0154
      END                                                               GETC0155
                                                                        GETC0156
                                                                        GETC0157
      SUBROUTINE MEANS                                                  MEAN0001
C-----------------------------------------------------------------------MEAN0002
C                                                                       MEAN0003
C  SUBROUTINE MEANS  -  First pass through the data file(s) calculating MEAN0004
C                       the means of the appropriate quantities and,    MEAN0005
C                       those standard deviations that are calculated   MEAN0006
C                       aroun a global mean                             MEAN0007
C                                                                       MEAN0008
C----------------------------------------------------------------------+MEAN0009
                                                                        MEAN0010
      INCLUDE 'pplot.inc'                                               MEAN0011
                                                                        MEAN0012
      CHARACTER*1   INCHN, SECSTR                                       MEAN0013
      CHARACTER*2   REGION                                              MEAN0014
      CHARACTER*3   RESDUE                                              MEAN0015
      CHARACTER*5   SEQNO                                               MEAN0016
      INTEGER       I, IRESID, LINE, OOI1, OOI2, REGNO, REGTYP, SERNO   MEAN0017
      LOGICAL       DISALL                                              MEAN0018
      REAL          CGAMB, CHI1, CHI2, CHI3, CHI4, DIHANG, DISULF,      MEAN0019
CHECK v.3.2-->                                                          MEAN0020
C     -              ENHB, MCBVAL, OMEGA, PHI, PSI, SCBVAL              MEAN0021
     &              ENHB, MCBSTD, MCBVAL, OMEGA, PHI, PSI, SCBSTD,      MEAN0022
     &              SCBVAL                                              MEAN0023
CHECK v.3.2<--                                                          MEAN0024
                                                                        MEAN0025
                                                                        MEAN0026
C---- Initialise variables                                              MEAN0027
      ACDEV = 0.0                                                       MEAN0028
      ACMEAN = 0.0                                                      MEAN0029
      ACSTD = 0.0                                                       MEAN0030
      CH2DEV = 0.0                                                      MEAN0031
      CH2MEA = 0.0                                                      MEAN0032
      CH2STD = 0.0                                                      MEAN0033
      C3LMEA = 0.0                                                      MEAN0034
      C3LSTD = 0.0                                                      MEAN0035
      C3RMEA = 0.0                                                      MEAN0036
      C3RSTD = 0.0                                                      MEAN0037
      GMIDEV = 0.0                                                      MEAN0038
      GMIMEA = 0.0                                                      MEAN0039
      GMISTD = 0.0                                                      MEAN0040
      GPLDEV = 0.0                                                      MEAN0041
      GPLMEA = 0.0                                                      MEAN0042
      GPLSTD = 0.0                                                      MEAN0043
      GTRDEV = 0.0                                                      MEAN0044
      GTRMEA = 0.0                                                      MEAN0045
      GTRSTD = 0.0                                                      MEAN0046
      HBDEV = 0.0                                                       MEAN0047
      HBMEAN = 0.0                                                      MEAN0048
      HBSTD = 0.0                                                       MEAN0049
      HPMEAN = 0.0                                                      MEAN0050
      HPSTD = 0.0                                                       MEAN0051
      IRESID = 0                                                        MEAN0052
      LINE = 0                                                          MEAN0053
      NALPHC = 0                                                        MEAN0054
      NALLOW = 0                                                        MEAN0055
      NAROMA = 0                                                        MEAN0056
      NASN = 0                                                          MEAN0057
      NCORE = 0                                                         MEAN0058
      NCPOOL = 0                                                        MEAN0059
CHECK v.3.2-->                                                          MEAN0060
      NCHI2 = 0                                                         MEAN0061
CHECK v.3.2<--                                                          MEAN0062
      NCHI3L = 0                                                        MEAN0063
      NCHI3R = 0                                                        MEAN0064
      NCIS = 0                                                          MEAN0065
      NDAM = 0                                                          MEAN0066
      NDISUL = 0                                                        MEAN0067
      NENDCH = 0                                                        MEAN0068
      NGENER = 0                                                        MEAN0069
      NGLY = 0                                                          MEAN0070
      NGMINU = 0                                                        MEAN0071
      NGPLUS = 0                                                        MEAN0072
      NGTRAN = 0                                                        MEAN0073
      NHBOND = 0                                                        MEAN0074
      NHXPSI = 0                                                        MEAN0075
      NOMEGA = 0                                                        MEAN0076
      NONPG = 0                                                         MEAN0077
      NOUTSI = 0                                                        MEAN0078
      NPHIHX = 0                                                        MEAN0079
      NPRO = 0                                                          MEAN0080
      NPROPH = 0                                                        MEAN0081
      NRAMPL = 0                                                        MEAN0082
      OMDEV = 0.0                                                       MEAN0083
      OMSTD = 0.0                                                       MEAN0084
      OMMEAN = 0.0                                                      MEAN0085
      OOIMAX = 0                                                        MEAN0086
      OOIMIN = 999                                                      MEAN0087
      PHMEAN = 0.0                                                      MEAN0088
      PHSTD = 0.0                                                       MEAN0089
      DO 50, I = 1, MXPLOT                                              MEAN0090
          PINMAX(I) = 0.0                                               MEAN0091
 50   CONTINUE                                                          MEAN0092
      PLTSTD(PLTCH1) = LIMRES * (SDEVGM + SDEVGT + SDEVGP) / 3.0        MEAN0093
      PLTSTD(PLTOME) = LIMRES * SDEVOM                                  MEAN0094
      PLTSTD(PLTCAL) = LIMRES * SDEVDH                                  MEAN0095
      PLTSTD(PLTHB) = LIMRES * SDEVHB                                   MEAN0096
      PLTSTD(PLTCGB) = 999.9                                            MEAN0097
      PLTSTD(PLTMCB) = 999.9                                            MEAN0098
      PLTSTD(PLTSCB) = 999.9                                            MEAN0099
      PLTSTD(PLTLAV) = 6.0                                              MEAN0100
      PLTSTD(PLTLCC) = 6.0                                              MEAN0101
      PLTSTD(PLTLPP) = 6.0                                              MEAN0102
      PLTSTD(PLTOOI) = 100.0                                            MEAN0103
      PINMAX(PLTOOI) =  99.0                                            MEAN0104
CHECK v.3.1-->                                                          MEAN0105
      PLTSTD(PLTACC) = 100.0                                            MEAN0106
      PINMAX(PLTACC) =  99.0                                            MEAN0107
CHECK v.3.1<--                                                          MEAN0108
CHECK v.3.2-->                                                          MEAN0109
      PLTSTD(PLTSDM) = 999.9                                            MEAN0110
      PLTSTD(PLTSDS) = 999.9                                            MEAN0111
CHECK v.3.2<--                                                          MEAN0112
      POOMEA = 0.0                                                      MEAN0113
      POOSTD = 0.0                                                      MEAN0114
      PPMEAN = 0.0                                                      MEAN0115
      PPSTD = 0.0                                                       MEAN0116
      SSMEAN = 0.0                                                      MEAN0117
      SSSTD = 0.0                                                       MEAN0118
                                                                        MEAN0119
C---- Open the data file holding the residue information, <filename>.rinMEAN0120
      OPEN(UNIT=1, FILE=FILRIN, STATUS='OLD', FORM='FORMATTED',         MEAN0121
     &    ACCESS='SEQUENTIAL',                                          MEAN0122
CVAX     -    READONLY,                                                 MEAN0123
     &    ERR=900)                                                      MEAN0124
                                                                        MEAN0125
C---- Read through the residues file                                    MEAN0126
 100  CONTINUE                                                          MEAN0127
          READ(1,110,END=500,ERR=902) SERNO, RESDUE, INCHN, SEQNO,      MEAN0128
     &        SECSTR, PHI, PSI, OMEGA, CHI1, CHI2, CHI3, CHI4, ENHB,    MEAN0129
CHECK v.3.2-->                                                          MEAN0130
C     -        DISULF, DIHANG, CGAMB, MCBVAL, SCBVAL, OOI1, OOI2        MEAN0131
C 110      FORMAT(I4,A3,1X,A1,A5,A1,11F7.2,2F7.3,2I3)                   MEAN0132
     &        DISULF, DIHANG, CGAMB, MCBVAL, SCBVAL, OOI1, OOI2,        MEAN0133
     &        MCBSTD, SCBSTD                                            MEAN0134
 110      FORMAT(I4,A3,1X,A1,A5,A1,11F7.2,2F7.3,2I3,2F7.3)              MEAN0135
CHECK v.3.2<--                                                          MEAN0136
          LINE = LINE + 1                                               MEAN0137
                                                                        MEAN0138
C----     Only process this residue if it belongs to the required chain MEAN0139
          IF (CHAIN.EQ.' ' .OR. INCHN.EQ.CHAIN) THEN                    MEAN0140
                                                                        MEAN0141
C----         Increment residue-count                                   MEAN0142
              IRESID = IRESID + 1                                       MEAN0143
                                                                        MEAN0144
C----         Accumulate values for calculation of means                MEAN0145
                                                                        MEAN0146
C----         Chi-1 torsion angle                                       MEAN0147
              IF (RESDUE.EQ.'PRO') CHI1 = 999.9                         MEAN0148
              IF (CHI1.LT.0.0) CHI1 = CHI1 + 360.0                      MEAN0149
              IF (CHI1.EQ.360.0) CHI1 = 0.0                             MEAN0150
              IF (CHI1.GE.0.0 .AND. CHI1.LT.360.0) THEN                 MEAN0151
                  POOMEA = POOMEA + CHI1                                MEAN0152
                  NCPOOL = NCPOOL + 1                                   MEAN0153
                                                                        MEAN0154
C----             Chi-1 gauche minus                                    MEAN0155
                  IF (CHI1.GE.0.0 .AND. CHI1.LT.120.0) THEN             MEAN0156
                      GMIMEA = GMIMEA + CHI1                            MEAN0157
                      GMIDEV = GMIDEV + (CHI1 - GLOBGM)                 MEAN0158
     &                    * (CHI1 - GLOBGM)                             MEAN0159
                      NGMINU = NGMINU + 1                               MEAN0160
                      PINMAX(PLTCH1) = MAX(ABS(CHI1 - GLOBGM),          MEAN0161
     &                    PINMAX(PLTCH1))                               MEAN0162
                                                                        MEAN0163
C----             Chi-1 trans                                           MEAN0164
                  ELSE IF (CHI1.GE.120.0 .AND. CHI1.LT.240.0) THEN      MEAN0165
                      GTRMEA = GTRMEA + CHI1                            MEAN0166
                      GTRDEV = GTRDEV + (CHI1 - GLOBGT)                 MEAN0167
     &                    * (CHI1 - GLOBGT)                             MEAN0168
                      NGTRAN = NGTRAN + 1                               MEAN0169
                      PINMAX(PLTCH1) = MAX(ABS(CHI1 - GLOBGT),          MEAN0170
     &                    PINMAX(PLTCH1))                               MEAN0171
                                                                        MEAN0172
C----             Chi-1 gauche plus                                     MEAN0173
                  ELSE IF (CHI1.GE.240.0 .AND. CHI1.LT.360.0) THEN      MEAN0174
                      GPLMEA = GPLMEA + CHI1                            MEAN0175
                      GPLDEV = GPLDEV + (CHI1 - GLOBGP)                 MEAN0176
     &                    * (CHI1 - GLOBGP)                             MEAN0177
                      NGPLUS = NGPLUS + 1                               MEAN0178
                      PINMAX(PLTCH1) = MAX(ABS(CHI1 - GLOBGP),          MEAN0179
     &                    PINMAX(PLTCH1))                               MEAN0180
                  ENDIF                                                 MEAN0181
              ENDIF                                                     MEAN0182
                                                                        MEAN0183
C----         Chi-2 trans torsion angle                                 MEAN0184
              IF (RESDUE.NE.'PHE' .AND. RESDUE.NE.'TYR' .AND.           MEAN0185
     &            RESDUE.NE.'TRP' .AND. RESDUE.NE.'HIS' .AND.           MEAN0186
     &            RESDUE.NE.'ASP' .AND. RESDUE.NE.'ASN') THEN           MEAN0187
                  IF (CHI2.LE.0.0) CHI2 = CHI2 + 360.0                  MEAN0188
                  IF (CHI2.GT.120.0 .AND. CHI2.LE.240.0) THEN           MEAN0189
                      CH2MEA = CH2MEA + CHI2                            MEAN0190
                      CH2DEV = CH2DEV + (CHI2 - GLOBC2)                 MEAN0191
     &                    * (CHI2 - GLOBC2)                             MEAN0192
                      NCHI2 = NCHI2 + 1                                 MEAN0193
                  ENDIF                                                 MEAN0194
              ENDIF                                                     MEAN0195
                                                                        MEAN0196
C----         Proline phi                                               MEAN0197
              IF (RESDUE.EQ.'PRO' .AND. PHI.NE.999.9) THEN              MEAN0198
                  PPMEAN = PPMEAN + PHI                                 MEAN0199
                  NPROPH = NPROPH + 1                                   MEAN0200
              ENDIF                                                     MEAN0201
                                                                        MEAN0202
C----         Phi helix                                                 MEAN0203
              IF (SECSTR.EQ.'H' .AND. PHI.NE.999.9) THEN                MEAN0204
                  PHMEAN = PHMEAN + PHI                                 MEAN0205
                  NPHIHX = NPHIHX + 1                                   MEAN0206
              ENDIF                                                     MEAN0207
                                                                        MEAN0208
C----         Helix psi                                                 MEAN0209
              IF (SECSTR.EQ.'H' .AND. PSI.NE.999.9) THEN                MEAN0210
                  HPMEAN = HPMEAN + PSI                                 MEAN0211
                  NHXPSI = NHXPSI + 1                                   MEAN0212
              ENDIF                                                     MEAN0213
                                                                        MEAN0214
C----         Chi-3 right-hand                                          MEAN0215
              IF (RESDUE.EQ.'CYS' .AND. CHI3.GT.0.0 .AND.               MEAN0216
     &            CHI3.LE.180.0) THEN                                   MEAN0217
                  C3RMEA = C3RMEA + CHI3                                MEAN0218
                  NCHI3R = NCHI3R + 1                                   MEAN0219
              ENDIF                                                     MEAN0220
                                                                        MEAN0221
C----         Chi-3 left-hand                                           MEAN0222
              IF (RESDUE.EQ.'CYS' .AND. CHI3.LE.0.0 .AND.               MEAN0223
     &            CHI3.GE.-180.0) THEN                                  MEAN0224
                  C3LMEA = C3LMEA + CHI3                                MEAN0225
                  NCHI3L = NCHI3L + 1                                   MEAN0226
              ENDIF                                                     MEAN0227
                                                                        MEAN0228
C----         Disulphide bond                                           MEAN0229
              IF (RESDUE.EQ.'CYS') THEN                                 MEAN0230
                  IF (DISULF.NE.0.0) THEN                               MEAN0231
                      SSMEAN = SSMEAN + DISULF                          MEAN0232
                      NDISUL = NDISUL + 1                               MEAN0233
                  ENDIF                                                 MEAN0234
              ENDIF                                                     MEAN0235
                                                                        MEAN0236
C----         Case of trans peptide (ie abs(omega) > 45)                MEAN0237
              IF (ABS(OMEGA).GE.45.0 .AND. OMEGA.NE.999.9) THEN         MEAN0238
                  IF (OMEGA.LE.0.0) OMEGA = OMEGA + 360.0               MEAN0239
                  OMMEAN = OMMEAN + OMEGA                               MEAN0240
                  NOMEGA = NOMEGA + 1                                   MEAN0241
                  PINMAX(PLTOME) = MAX(ABS(OMEGA - GLOBOM),             MEAN0242
     &                PINMAX(PLTOME))                                   MEAN0243
                                                                        MEAN0244
C----         Case of cis peptide (ie abs(omega) < 45)                  MEAN0245
              ELSE IF (ABS(OMEGA).LT.45.0 .AND. OMEGA.NE.999.9) THEN    MEAN0246
                  PINMAX(PLTOME) = MAX(ABS(OMEGA),PINMAX(PLTOME))       MEAN0247
              ENDIF                                                     MEAN0248
                                                                        MEAN0249
C----         Hydrogen bond energy mean and standard deviation          MEAN0250
              IF (ENHB.LT.0.0) THEN                                     MEAN0251
                  HBMEAN = HBMEAN + ENHB                                MEAN0252
                  HBDEV = HBDEV + (ENHB - GLOBHB) * (ENHB - GLOBHB)     MEAN0253
                  NHBOND = NHBOND + 1                                   MEAN0254
                  PINMAX(PLTHB) = MAX(ABS(ENHB - GLOBHB),PINMAX(PLTHB)) MEAN0255
              ENDIF                                                     MEAN0256
                                                                        MEAN0257
C----         Alpha-carbon tetrahedral chirality                        MEAN0258
              IF (DIHANG.LE.360.0) THEN                                 MEAN0259
                  ACMEAN = ACMEAN + DIHANG                              MEAN0260
                  ACDEV = ACDEV + (DIHANG - GLOBDH) * (DIHANG - GLOBDH) MEAN0261
                  NALPHC = NALPHC + 1                                   MEAN0262
                  PINMAX(PLTCAL) = MAX(ABS(DIHANG - GLOBDH),            MEAN0263
     &                PINMAX(PLTCAL))                                   MEAN0264
              ENDIF                                                     MEAN0265
                                                                        MEAN0266
C----         Ooi number                                                MEAN0267
              OOIMIN = MIN(OOI2,OOIMIN)                                 MEAN0268
              OOIMAX = MAX(OOI2,OOIMAX)                                 MEAN0269
                                                                        MEAN0270
C----         Set maximum values for B-value measures for pins plot     MEAN0271
              PINMAX(PLTCGB) = MAX(CGAMB,PINMAX(PLTCGB))                MEAN0272
              PINMAX(PLTMCB) = MAX(MCBVAL,PINMAX(PLTMCB))               MEAN0273
              PINMAX(PLTSCB) = MAX(SCBVAL,PINMAX(PLTSCB))               MEAN0274
CHECK v.3.2-->                                                          MEAN0275
              PINMAX(PLTSDM) = MAX(MCBSTD,PINMAX(PLTSDM))               MEAN0276
              PINMAX(PLTSDS) = MAX(SCBSTD,PINMAX(PLTSDS))               MEAN0277
CHECK v.3.2<--                                                          MEAN0278
                                                                        MEAN0279
C----         Increment count of different types of residues            MEAN0280
              IF (RESDUE.EQ.'ASN') NASN = NASN + 1                      MEAN0281
              IF (RESDUE.EQ.'GLY') NGLY = NGLY + 1                      MEAN0282
              IF (RESDUE.EQ.'PRO') NPRO = NPRO + 1                      MEAN0283
              IF (RESDUE.EQ.'PHE' .OR. RESDUE.EQ.'TYR' .OR.             MEAN0284
     &            RESDUE.EQ.'TRP' .OR. RESDUE.EQ.'HIS' .OR.             MEAN0285
     &            RESDUE.EQ.'ASP') NAROMA = NAROMA + 1                  MEAN0286
              DISALL = .FALSE.                                          MEAN0287
                                                                        MEAN0288
C----         Determine which region of Ramachandran plot residue lies  MEAN0289
C             in                                                        MEAN0290
              CALL RAMREG(PHI,PSI,REGION,REGNO,REGTYP)                  MEAN0291
                                                                        MEAN0292
C----         If residue is neither a glycine nor a proline, then       MEAN0293
C             determine in which region of the Ramachandran plot its    MEAN0294
C             phi-psi values fall                                       MEAN0295
              IF (RESDUE.NE.'GLY' .AND. RESDUE.NE.'PRO') THEN           MEAN0296
                                                                        MEAN0297
C----             Check whether this is an end-residue at a chain break MEAN0298
                  IF (PHI.EQ.999.9 .OR. PSI.EQ.999.9) THEN              MEAN0299
                      NENDCH = NENDCH + 1                               MEAN0300
                                                                        MEAN0301
C----             If valid phi-psi, then determine region type          MEAN0302
                  ELSE                                                  MEAN0303
                      NONPG = NONPG + 1                                 MEAN0304
                                                                        MEAN0305
C----                 Increment counts of residues in each region type  MEAN0306
                      IF (REGION.EQ.'XX') THEN                          MEAN0307
                          NOUTSI = NOUTSI + 1                           MEAN0308
                          DISALL = .TRUE.                               MEAN0309
                      ELSE IF (REGION.EQ.'B ' .OR. REGION.EQ.'A '       MEAN0310
     &                    .OR. REGION.EQ.'L ') THEN                     MEAN0311
                          NCORE = NCORE + 1                             MEAN0312
                      ELSE IF (REGION.EQ.'b ' .OR. REGION.EQ.'a '       MEAN0313
     &                    .OR. REGION.EQ.'l ' .OR. REGION.EQ.'p ') THEN MEAN0314
                          NALLOW = NALLOW + 1                           MEAN0315
                      ELSE IF (REGION.EQ.'~b' .OR. REGION.EQ.'~a'       MEAN0316
     &                    .OR. REGION.EQ.'~l' .OR. REGION.EQ.'~p') THEN MEAN0317
                          NGENER = NGENER + 1                           MEAN0318
                      ENDIF                                             MEAN0319
                  ENDIF                                                 MEAN0320
              ENDIF                                                     MEAN0321
          ENDIF                                                         MEAN0322
                                                                        MEAN0323
C---- Loop back for next record in file                                 MEAN0324
      GO TO 100                                                         MEAN0325
                                                                        MEAN0326
C---- End of file reached                                               MEAN0327
 500  CONTINUE                                                          MEAN0328
      NRESID = IRESID                                                   MEAN0329
                                                                        MEAN0330
C---- Check that file wasn't empty                                      MEAN0331
      IF (NRESID.EQ.0) GO TO 908                                        MEAN0332
                                                                        MEAN0333
C---- Calculate percentages for residues in the different regions of theMEAN0334
C     Ramachandran plot                                                 MEAN0335
      IF (NONPG.GT.0) THEN                                              MEAN0336
          ALLOWP = 100.0 * REAL(NALLOW) / REAL(NONPG)                   MEAN0337
          COREPC = 100.0 * REAL(NCORE) / REAL(NONPG)                    MEAN0338
          GENERP = 100.0 * REAL(NGENER) / REAL(NONPG)                   MEAN0339
          OUTSIP = 100.0 * REAL(NOUTSI) / REAL(NONPG)                   MEAN0340
      ELSE                                                              MEAN0341
          ALLOWP = 0.0                                                  MEAN0342
          COREPC = 0.0                                                  MEAN0343
          GENERP = 0.0                                                  MEAN0344
          OUTSIP = 0.0                                                  MEAN0345
      ENDIF                                                             MEAN0346
                                                                        MEAN0347
C---- Adjust Ooi-number maximum and minimum if equal                    MEAN0348
      IF (OOIMAX.LE.OOIMIN) OOIMAX = OOIMIN + 1.0                       MEAN0349
                                                                        MEAN0350
      GO TO 999                                                         MEAN0351
                                                                        MEAN0352
C---- Fatal errors                                                      MEAN0353
900   CONTINUE                                                          MEAN0354
      PRINT*, '*** ERROR. Unable to open .rin data file '               MEAN0355
      PRINT*, FILRIN, '*'                                               MEAN0356
      PRINT*, '           Run program CLEAN to create it'               MEAN0357
      GO TO 990                                                         MEAN0358
                                                                        MEAN0359
902   CONTINUE                                                          MEAN0360
      PRINT*, '*** ERROR. Data error in .rin file at line:', LINE + 1   MEAN0361
      GO TO 990                                                         MEAN0362
                                                                        MEAN0363
 908  CONTINUE                                                          MEAN0364
      PRINT*, '*** ERROR. Data file .rin empty. Nothing to plot !'      MEAN0365
      GO TO 990                                                         MEAN0366
                                                                        MEAN0367
990   CONTINUE                                                          MEAN0368
      IFAIL = .TRUE.                                                    MEAN0369
                                                                        MEAN0370
999   CONTINUE                                                          MEAN0371
      RETURN                                                            MEAN0372
      END                                                               MEAN0373
                                                                        MEAN0374
      SUBROUTINE CALCS                                                  CALC0001
C-----------------------------------------------------------------------CALC0002
C                                                                       CALC0003
C  SUBROUTINE CALCS  -  Calculate means and the deviations from ideal   CALC0004
C                       values                                          CALC0005
C                                                                       CALC0006
C----------------------------------------------------------------------+CALC0007
                                                                        CALC0008
      INCLUDE 'pplot.inc'                                               CALC0009
                                                                        CALC0010
      INTEGER       I                                                   CALC0011
                                                                        CALC0012
C---- Calculate means and standard deviations                           CALC0013
                                                                        CALC0014
C---- Chi-1 torsion angle (gauche minus)                                CALC0015
      IF (NGMINU.NE.0) THEN                                             CALC0016
          GMIMEA = GMIMEA / NGMINU                                      CALC0017
          IF (NGMINU.GT.1) THEN                                         CALC0018
              GMIDEV = SQRT(GMIDEV / (NGMINU - 1))                      CALC0019
          ELSE                                                          CALC0020
              GMIDEV =0.0                                               CALC0021
          ENDIF                                                         CALC0022
      ENDIF                                                             CALC0023
                                                                        CALC0024
C---- Chi-1 torsion angle (trans)                                       CALC0025
      IF (NGTRAN.NE.0) THEN                                             CALC0026
          GTRMEA = GTRMEA / NGTRAN                                      CALC0027
          IF (NGTRAN.GT.1) THEN                                         CALC0028
              GTRDEV = SQRT(GTRDEV / (NGTRAN - 1))                      CALC0029
          ELSE                                                          CALC0030
              GTRDEV =0.0                                               CALC0031
          ENDIF                                                         CALC0032
      ENDIF                                                             CALC0033
                                                                        CALC0034
C---- Chi-1 torsion angle (gauche plus)                                 CALC0035
      IF (NGPLUS.NE.0) THEN                                             CALC0036
          GPLMEA = GPLMEA / NGPLUS                                      CALC0037
          IF (NGPLUS.GT.1) THEN                                         CALC0038
              GPLDEV = SQRT(GPLDEV / (NGPLUS - 1))                      CALC0039
          ELSE                                                          CALC0040
              GPLDEV =0.0                                               CALC0041
          ENDIF                                                         CALC0042
      ENDIF                                                             CALC0043
                                                                        CALC0044
C---- Chi-1 torsion angle (pooled standard deviation)                   CALC0045
      IF (NCPOOL.NE.0) THEN                                             CALC0046
          POOSTD = NGMINU * GMIDEV + NGTRAN * GTRDEV + NGPLUS * GPLDEV  CALC0047
          POOSTD = POOSTD / (NGMINU + NGTRAN + NGPLUS)                  CALC0048
      ELSE                                                              CALC0049
          POOSTD =0.0                                                   CALC0050
      ENDIF                                                             CALC0051
                                                                        CALC0052
C---- Chi-2 trans torsion angle                                         CALC0053
      IF (NCHI2.NE.0) THEN                                              CALC0054
          CH2MEA = CH2MEA / NCHI2                                       CALC0055
          IF (NCHI2.GT.1) THEN                                          CALC0056
              CH2DEV = SQRT(CH2DEV / (NCHI2 - 1))                       CALC0057
          ELSE                                                          CALC0058
              CH2DEV =0.0                                               CALC0059
          ENDIF                                                         CALC0060
      ENDIF                                                             CALC0061
                                                                        CALC0062
C---- Proline phi torsion angle                                         CALC0063
      IF (NPROPH.NE.0) THEN                                             CALC0064
          PPMEAN = PPMEAN / NPROPH                                      CALC0065
      ENDIF                                                             CALC0066
                                                                        CALC0067
C---- Phi torsion angle in helices                                      CALC0068
      IF (NPHIHX.NE.0) THEN                                             CALC0069
          PHMEAN = PHMEAN / NPHIHX                                      CALC0070
      ENDIF                                                             CALC0071
                                                                        CALC0072
C---- Helix psi torsion angle                                           CALC0073
      IF (NHXPSI.NE.0) THEN                                             CALC0074
          HPMEAN = HPMEAN / NHXPSI                                      CALC0075
      ENDIF                                                             CALC0076
                                                                        CALC0077
C---- Chi-3 torsion angle, right-handed                                 CALC0078
      IF (NCHI3R.NE.0) THEN                                             CALC0079
          C3RMEA = C3RMEA / NCHI3R                                      CALC0080
      ENDIF                                                             CALC0081
                                                                        CALC0082
C---- Chi-3 torsion angle, left-handed                                  CALC0083
      IF (NCHI3L.NE.0) THEN                                             CALC0084
          C3LMEA = C3LMEA / NCHI3L                                      CALC0085
      ENDIF                                                             CALC0086
                                                                        CALC0087
C---- Disulphide bond                                                   CALC0088
      IF (NDISUL.NE.0) THEN                                             CALC0089
          SSMEAN = SSMEAN / NDISUL                                      CALC0090
      ENDIF                                                             CALC0091
                                                                        CALC0092
C---- Omega torsion angle                                               CALC0093
      IF (NOMEGA.NE.0) THEN                                             CALC0094
          OMMEAN = OMMEAN / NOMEGA                                      CALC0095
      ENDIF                                                             CALC0096
                                                                        CALC0097
C---- Hydrogen bond energy                                              CALC0098
      IF (NHBOND.NE.0) THEN                                             CALC0099
          HBMEAN = HBMEAN / NHBOND                                      CALC0100
          IF (NHBOND.GT.1) THEN                                         CALC0101
              HBDEV = SQRT(HBDEV / (NHBOND - 1))                        CALC0102
          ELSE                                                          CALC0103
              HBDEV =0.0                                                CALC0104
          ENDIF                                                         CALC0105
      ENDIF                                                             CALC0106
                                                                        CALC0107
C---- Alpha carbon tetrahedral distortion                               CALC0108
      IF (NALPHC.NE.0) THEN                                             CALC0109
          ACMEAN = ACMEAN / NALPHC                                      CALC0110
          IF (NALPHC.GT.1) THEN                                         CALC0111
              ACDEV = SQRT(ACDEV / (NALPHC - 1))                        CALC0112
          ELSE                                                          CALC0113
              ACDEV =0.0                                                CALC0114
          ENDIF                                                         CALC0115
      ENDIF                                                             CALC0116
                                                                        CALC0117
C---- Adjust maximum values, if necessary                               CALC0118
      DO 100, I = 1, MXPLOT                                             CALC0119
          IF (PINMAX(I).LT.1.0) THEN                                    CALC0120
              PINMAX(I) = 1.0                                           CALC0121
          ELSE IF (PINMAX(I).LT.2.0) THEN                               CALC0122
              PINMAX(I) = 2.0                                           CALC0123
          ELSE IF (PINMAX(I).LT.5.0) THEN                               CALC0124
              PINMAX(I) = 5.0                                           CALC0125
          ELSE IF (PINMAX(I).LT.10.0) THEN                              CALC0126
              PINMAX(I) = 10.0                                          CALC0127
          ELSE IF (PINMAX(I).LT.15.0) THEN                              CALC0128
              PINMAX(I) = 15.0                                          CALC0129
          ELSE IF (PINMAX(I).LT.20.0) THEN                              CALC0130
              PINMAX(I) = 20.0                                          CALC0131
          ELSE IF (PINMAX(I).LT.30.0) THEN                              CALC0132
              PINMAX(I) = 30.0                                          CALC0133
          ELSE IF (PINMAX(I).LT.40.0) THEN                              CALC0134
              PINMAX(I) = 40.0                                          CALC0135
          ELSE IF (PINMAX(I).LT.50.0) THEN                              CALC0136
              PINMAX(I) = 50.0                                          CALC0137
          ELSE IF (PINMAX(I).LT.100.0) THEN                             CALC0138
              PINMAX(I) = 100.0                                         CALC0139
          ELSE IF (PINMAX(I).LT.125.0) THEN                             CALC0140
              PINMAX(I) = 125.0                                         CALC0141
          ELSE IF (PINMAX(I).LT.150.0) THEN                             CALC0142
              PINMAX(I) = 120.0                                         CALC0143
          ELSE IF (PINMAX(I).LT.200.0) THEN                             CALC0144
              PINMAX(I) = 200.0                                         CALC0145
          ELSE IF (PINMAX(I).LT.500.0) THEN                             CALC0146
              PINMAX(I) = 500.0                                         CALC0147
          ENDIF                                                         CALC0148
 100  CONTINUE                                                          CALC0149
                                                                        CALC0150
      RETURN                                                            CALC0151
      END                                                               CALC0152
                                                                        CALC0153
      SUBROUTINE GETNB(FILNB,NBAD,BADCOP,VWDIST,NONBON,NRESID,IFAIL)    GETN0001
C-----------------------------------------------------------------------GETN0002
C                                                                       GETN0003
C  SUBROUTINE GETNB  -  Read through the non-bonded interactions file   GETN0004
C                       to calculate no. of bad contacts per 100 resi's GETN0005
C                       figure                                          GETN0006
C                                                                       GETN0007
C----------------------------------------------------------------------+GETN0008
                                                                        GETN0009
      CHARACTER*1   MS1, MS2                                            GETN0010
      CHARACTER*3   ATYPE1, ATYPE2                                      GETN0011
      CHARACTER*3   RESDU1, RESDU2                                      GETN0012
      CHARACTER*(*) FILNB                                               GETN0013
      INTEGER       LINE, NBAD, NRESID                                  GETN0014
      LOGICAL       BADYES, IFAIL, NONBON                               GETN0015
      REAL          BADCOP, DIST, VWDIST                                GETN0016
                                                                        GETN0017
                                                                        GETN0018
C---- Initialise variables                                              GETN0019
      LINE = 0                                                          GETN0020
      NBAD = 0                                                          GETN0021
                                                                        GETN0022
C---- Open the data file holding non-bonded contacts, <filename>.nb     GETN0023
      OPEN(UNIT=2, FILE=FILNB, STATUS='OLD', FORM='FORMATTED',          GETN0024
     &    ACCESS='SEQUENTIAL',                                          GETN0025
CVAX     -    READONLY,                                                 GETN0026
     &    ERR=50)                                                       GETN0027
      NONBON = .TRUE.                                                   GETN0028
      GO TO 100                                                         GETN0029
                                                                        GETN0030
C---- Non-bonded interactions file is missing. So, plot without this datGETN0031
 50   CONTINUE                                                          GETN0032
      PRINT*                                                            GETN0033
      PRINT*, '***** Non-bonded interactions file is missing:', FILNB   GETN0034
      PRINT*, '      Plots will be produced without this data'          GETN0035
      PRINT*                                                            GETN0036
      NONBON = .FALSE.                                                  GETN0037
      GO TO 999                                                         GETN0038
                                                                        GETN0039
C---- If the file exists, then read through it                          GETN0040
                                                                        GETN0041
C---- Read in next record                                               GETN0042
 100  CONTINUE                                                          GETN0043
          READ(2,150,END=500,ERR=900) RESDU1, ATYPE1, RESDU2, ATYPE2,   GETN0044
     &        DIST, MS1, MS2                                            GETN0045
 150      FORMAT(16X,A3,1X,A3,13X,A3,1X,A3,1X,F4.0,1X,2A1)              GETN0046
          LINE = LINE + 1                                               GETN0047
                                                                        GETN0048
C----     Check distance                                                GETN0049
          CALL ISBAD(RESDU1,ATYPE1,RESDU2,ATYPE2,DIST,VWDIST,BADYES)    GETN0050
          IF (BADYES) NBAD = NBAD + 1                                   GETN0051
                                                                        GETN0052
C---- Loop back for next record in file                                 GETN0053
      GO TO 100                                                         GETN0054
                                                                        GETN0055
C---- End of file reached                                               GETN0056
 500  CONTINUE                                                          GETN0057
                                                                        GETN0058
C---- If non-bonded interactions file is empty, then set flag accordinglGETN0059
      IF (LINE.EQ.0) NONBON = .FALSE.                                   GETN0060
      BADCOP = 100.0 * REAL(NBAD) / REAL(NRESID)                        GETN0061
                                                                        GETN0062
      GO TO 999                                                         GETN0063
                                                                        GETN0064
C---- Fatal errors                                                      GETN0065
 900  CONTINUE                                                          GETN0066
      PRINT*, '*** ERROR. Error reading .nb file at line:', LINE + 1    GETN0067
      GO TO 990                                                         GETN0068
                                                                        GETN0069
990   CONTINUE                                                          GETN0070
      IFAIL = .TRUE.                                                    GETN0071
                                                                        GETN0072
999   CONTINUE                                                          GETN0073
      RETURN                                                            GETN0074
      END                                                               GETN0075
                                                                        GETN0076
      SUBROUTINE ISBAD(RESDU1,ATYPE1,RESDU2,ATYPE2,DIST,VWDIST,BADYES)  ISBA0001
C-----------------------------------------------------------------------ISBA0002
C                                                                       ISBA0003
C  SUBROUTINE ISBAD  -  Check whether supplied non-bonded distance bad  ISBA0004
C                                                                       ISBA0005
C----------------------------------------------------------------------+ISBA0006
                                                                        ISBA0007
      CHARACTER*3   ATYPE1, ATYPE2, RESDU1, RESDU2                      ISBA0008
      LOGICAL       BADYES                                              ISBA0009
      REAL          DIST, VWDIST                                        ISBA0010
                                                                        ISBA0011
      INTEGER       MXACC, MXDON                                        ISBA0012
      PARAMETER    (MXACC = 39, MXDON = 33)                             ISBA0013
                                                                        ISBA0014
      CHARACTER*7   ACCEPT(MXACC), ATOM1, ATOM2, DONOR(MXDON)           ISBA0015
      INTEGER       ITYPE                                               ISBA0016
      LOGICAL       ACCEP1, ACCEP2, DONOR1, DONOR2                      ISBA0017
                                                                        ISBA0018
      DATA DONOR  / 'ALA N  ','CYS N  ','ASP N  ','GLU N  ','PHE N  ',  ISBA0019
     &              'GLY N  ','HIS N  ','ILE N  ','LYS N  ','LEU N  ',  ISBA0020
     &              'MET N  ','ASN N  ','GLN N  ','ARG N  ','SER N  ',  ISBA0021
     &              'THR N  ','VAL N  ','TRP N  ','TYR N  ','CYS SG ',  ISBA0022
     &              'HIS ND1','HIS NE2','LYS NZ ','ASN ND2','GLN NE2',  ISBA0023
     &              'ARG NE ','ARG NH1','ARG NH2','SER OG ','THR OG1',  ISBA0024
     &              'TRP NE1','TYR OH ','CYH SG ' /                     ISBA0025
                                                                        ISBA0026
      DATA ACCEPT / 'ALA O  ','CYS O  ','ASP O  ','GLU O  ','PHE O  ',  ISBA0027
     &              'GLY O  ','HIS O  ','ILE O  ','LYS O  ','LEU O  ',  ISBA0028
     &              'MET O  ','ASN O  ','PRO O  ','GLN O  ','ARG O  ',  ISBA0029
     &              'SER O  ','THR O  ','VAL O  ','TRP O  ','TYR O  ',  ISBA0030
     &              'CYS SG ','ASP OD1','ASP OD2','GLU OE1','GLU OE2',  ISBA0031
     &              'HIS ND1','HIS NE2','MET SD ','ASN OD1','GLN OE1',  ISBA0032
     &              'SER OG ','THR OG1','TYR OH ','CYH SG ','CSS SG ',  ISBA0033
     &              'HOH O  ','WAT O  ','H2O O  ','DOD O  ' /           ISBA0034
                                                                        ISBA0035
                                                                        ISBA0036
C---- Check the distance                                                ISBA0037
      BADYES = .FALSE.                                                  ISBA0038
                                                                        ISBA0039
C---- Initialise variables                                              ISBA0040
      ACCEP1 = .FALSE.                                                  ISBA0041
      ACCEP2 = .FALSE.                                                  ISBA0042
      ATOM1 = RESDU1 // ' ' // ATYPE1                                   ISBA0043
      ATOM2 = RESDU2 // ' ' // ATYPE2                                   ISBA0044
      DONOR1 = .FALSE.                                                  ISBA0045
      DONOR2 = .FALSE.                                                  ISBA0046
                                                                        ISBA0047
C---- If distance is greater than van der Waals distance, then not a    ISBA0048
C     bad contact and don't need to worry about the atom types          ISBA0049
      IF (DIST.GT.VWDIST) GO TO 999                                     ISBA0050
                                                                        ISBA0051
C---- Exclude water-hydrogens                                           ISBA0052
      IF (ATOM1(1:5).EQ.'DOD D' .OR. ATOM2(1:5).EQ.'DOD D') GO TO 999   ISBA0053
                                                                        ISBA0054
C---- Exclude likely H-bonded atoms                                     ISBA0055
                                                                        ISBA0056
C---- Check whether either atom 1 is an acceptor and atom 2 is a donor  ISBA0057
      DO 100, ITYPE = 1, MXACC                                          ISBA0058
          IF (ATOM1.EQ.ACCEPT(ITYPE)) ACCEP1 = .TRUE.                   ISBA0059
 100  CONTINUE                                                          ISBA0060
      DO 200, ITYPE = 1, MXDON                                          ISBA0061
          IF (ATOM2.EQ.DONOR(ITYPE)) DONOR2 = .TRUE.                    ISBA0062
 200  CONTINUE                                                          ISBA0063
      IF (ACCEP1 .AND. DONOR2) GO TO 999                                ISBA0064
                                                                        ISBA0065
C---- Check whether either atom 2 is an acceptor and atom 1 is a donor  ISBA0066
      DO 300, ITYPE = 1, MXACC                                          ISBA0067
          IF (ATOM2.EQ.ACCEPT(ITYPE)) ACCEP2 = .TRUE.                   ISBA0068
 300  CONTINUE                                                          ISBA0069
      DO 400, ITYPE = 1, MXDON                                          ISBA0070
          IF (ATOM1.EQ.DONOR(ITYPE)) DONOR1 = .TRUE.                    ISBA0071
 400  CONTINUE                                                          ISBA0072
      IF (ACCEP2 .AND. DONOR1) GO TO 999                                ISBA0073
                                                                        ISBA0074
C---- Check whether both atoms are water molecule oxygens               ISBA0075
      IF (ATOM1.EQ.ATOM2) THEN                                          ISBA0076
          IF (ATOM1.EQ.'HOH O') GO TO 999                               ISBA0077
          IF (ATOM1.EQ.'WAT O') GO TO 999                               ISBA0078
          IF (ATOM1.EQ.'H2O O') GO TO 999                               ISBA0079
          IF (ATOM1.EQ.'DOD O') GO TO 999                               ISBA0080
      ENDIF                                                             ISBA0081
                                                                        ISBA0082
C---- If have reached here then this is a bad contact                   ISBA0083
      BADYES = .TRUE.                                                   ISBA0084
                                                                        ISBA0085
 999  CONTINUE                                                          ISBA0086
                                                                        ISBA0087
      RETURN                                                            ISBA0088
      END                                                               ISBA0089
                                                                        ISBA0090
      SUBROUTINE GETLAN                                                 GETL0001
C-----------------------------------------------------------------------GETL0002
C                                                                       GETL0003
C  SUBROUTINE GETLAN  -  Read through the bond lengths and angles file  GETL0004
C                        to calculate mean values and find minimum and  GETL0005
C                        maximum values                                 GETL0006
C                                                                       GETL0007
C----------------------------------------------------------------------+GETL0008
                                                                        GETL0009
      INCLUDE 'pplot.inc'                                               GETL0010
                                                                        GETL0011
      CHARACTER*1   INCHN                                               GETL0012
      CHARACTER*3   RESNAM                                              GETL0013
      CHARACTER*80  IREC                                                GETL0014
      INTEGER       IMAIN, IRESID, LINEA                                GETL0015
      REAL          VALUE                                               GETL0016
                                                                        GETL0017
C---- Initialise variables                                              GETL0018
      LINEA = 0                                                         GETL0019
      DO 20, IMAIN = 1, NMAIN                                           GETL0020
          MCHMEA(IMAIN) = 0.0                                           GETL0021
          MCHSTD(IMAIN) = 0.0                                           GETL0022
          MCHNUM(IMAIN) = 0                                             GETL0023
          MCHMAX(IMAIN) = 0.0                                           GETL0024
          MCHMIN(IMAIN) = 999.9                                         GETL0025
 20   CONTINUE                                                          GETL0026
                                                                        GETL0027
C---- Open lengths and angles file, <filename>.lan                      GETL0028
      OPEN(UNIT=4, FILE=FILLAN, STATUS='OLD', FORM='FORMATTED',         GETL0029
     &    ACCESS='SEQUENTIAL',                                          GETL0030
CVAX     -    READONLY,                                                 GETL0031
     &    ERR=900)                                                      GETL0032
                                                                        GETL0033
C---- Read through the header records                                   GETL0034
      DO 50, IMAIN = 1, NALP                                            GETL0035
          READ(4,*)                                                     GETL0036
 50   CONTINUE                                                          GETL0037
                                                                        GETL0038
C---- Loop while reading in records                                     GETL0039
 100  CONTINUE                                                          GETL0040
          READ(4,200,END=500,ERR=904) IREC                              GETL0041
 200      FORMAT(A)                                                     GETL0042
          LINEA = LINEA + 1                                             GETL0043
                                                                        GETL0044
C----     Only process this record if it is not a planar group          GETL0045
          IF (IREC(29:33).NE.'PLANE') THEN                              GETL0046
              READ(IREC,210,ERR=906) IRESID, INCHN, RESNAM, IMAIN, VALUEGETL0047
 210          FORMAT(I6,A1,5X,A3,I2,F9.4)                               GETL0048
                                                                        GETL0049
C----         Only process this residue if it belongs to the required   GETL0050
C             chain                                                     GETL0051
              IF (CHAIN.EQ.' ' .OR. INCHN.EQ.CHAIN) THEN                GETL0052
                                                                        GETL0053
C----             Accumulate mean values                                GETL0054
                  MCHMEA(IMAIN) = MCHMEA(IMAIN) + VALUE                 GETL0055
                  MCHNUM(IMAIN) = MCHNUM(IMAIN) + 1                     GETL0056
                  MCHMAX(IMAIN) = MAX(VALUE,MCHMAX(IMAIN))              GETL0057
                  MCHMIN(IMAIN) = MIN(VALUE,MCHMIN(IMAIN))              GETL0058
              ENDIF                                                     GETL0059
          ENDIF                                                         GETL0060
                                                                        GETL0061
C---- Loop back for next record in file                                 GETL0062
      GO TO 100                                                         GETL0063
                                                                        GETL0064
C---- End of file reached                                               GETL0065
 500  CONTINUE                                                          GETL0066
                                                                        GETL0067
C---- Calculate mean values                                             GETL0068
      DO 800, IMAIN = 1, NMAIN                                          GETL0069
          IF (MCHNUM(IMAIN).GT.0) THEN                                  GETL0070
              MCHMEA(IMAIN) = MCHMEA(IMAIN) / REAL(MCHNUM(IMAIN))       GETL0071
          ENDIF                                                         GETL0072
 800  CONTINUE                                                          GETL0073
                                                                        GETL0074
      GO TO 999                                                         GETL0075
                                                                        GETL0076
C---- Fatal errors                                                      GETL0077
 900  CONTINUE                                                          GETL0078
      PRINT*, '*** ERROR. Unable to open .lan file'                     GETL0079
      GO TO 990                                                         GETL0080
                                                                        GETL0081
 904  CONTINUE                                                          GETL0082
      PRINT*, '*** ERROR. Error reading .lan file at line:', LINEA + 1  GETL0083
      GO TO 990                                                         GETL0084
                                                                        GETL0085
 906  CONTINUE                                                          GETL0086
      PRINT*, '*** ERROR. Data error in .lan file at line:', LINEA + 1  GETL0087
      PRINT*, IREC                                                      GETL0088
      GO TO 990                                                         GETL0089
                                                                        GETL0090
990   CONTINUE                                                          GETL0091
      IFAIL = .TRUE.                                                    GETL0092
                                                                        GETL0093
999   CONTINUE                                                          GETL0094
      RETURN                                                            GETL0095
      END                                                               GETL0096
                                                                        GETL0097
      SUBROUTINE GETSDH                                                 GETS0001
C-----------------------------------------------------------------------GETS0002
C                                                                       GETS0003
C  SUBROUTINE GETSDH  -  Read through the log-odds scores file          GETS0004
C                                                                       GETS0005
C----------------------------------------------------------------------+GETS0006
                                                                        GETS0007
      INCLUDE 'pplot.inc'                                               GETS0008
                                                                        GETS0009
      CHARACTER*1   INCHN                                               GETS0010
      CHARACTER*120 IREC                                                GETS0011
      INTEGER       IDISTR, IVALUE, LINE                                GETS0012
      REAL          VALUE(NDISTR)                                       GETS0013
                                                                        GETS0014
C---- Initialise variables                                              GETS0015
      LINE = 0                                                          GETS0016
                                                                        GETS0017
C---- Open the file, <filename>.sdh                                     GETS0018
      OPEN(UNIT=3, FILE=FILSDH, STATUS='OLD', FORM='FORMATTED',         GETS0019
     &    ACCESS='SEQUENTIAL',                                          GETS0020
CVAX     -    READONLY,                                                 GETS0021
     &    ERR=900)                                                      GETS0022
                                                                        GETS0023
C---- Read through the records until the final line with mean-values    GETS0024
 100  CONTINUE                                                          GETS0025
          READ(3,120,END=500,ERR=904) IREC                              GETS0026
 120      FORMAT(A)                                                     GETS0027
          LINE = LINE + 1                                               GETS0028
                                                                        GETS0029
C----     If it is the "Means" record, store the overall stereochemical GETS0030
C         R-factor                                                      GETS0031
          IF (IREC(1:5).EQ.'Means') THEN                                GETS0032
                                                                        GETS0033
C----         Extract the G-factors                                     GETS0034
              READ(IREC,140,ERR=904) (GFACTR(IDISTR),                   GETS0035
     &            IDISTR = 1, NDISTR)                                   GETS0036
 140          FORMAT(17X,10F9.4)                                        GETS0037
              SFACT = GFACTR(NDISTR)                                    GETS0038
                                                                        GETS0039
C----     Otherwise read in log-odds values to determine the maximum    GETS0040
          ELSE                                                          GETS0041
              READ(IREC,180,ERR=904) INCHN, (VALUE(IVALUE), IVALUE = 1, GETS0042
     &            NDISTR)                                               GETS0043
 180          FORMAT(6X,1X,A1,9X,10F9.4)                                GETS0044
                                                                        GETS0045
C----         Only process this residue if it belongs to the required   GETS0046
C             chain                                                     GETS0047
              IF (CHAIN.EQ.' ' .OR. INCHN.EQ.CHAIN) THEN                GETS0048
                  IF (VALUE(1).LT.0.0) THEN                             GETS0049
                      PINMAX(PLTLPP) = MAX(ABS(VALUE(1)),PINMAX(PLTLPP))GETS0050
                  ENDIF                                                 GETS0051
                  IF (VALUE(2).LT.0.0) THEN                             GETS0052
                      PINMAX(PLTLCC) = MAX(ABS(VALUE(2)),PINMAX(PLTLCC))GETS0053
                  ENDIF                                                 GETS0054
                  IF (VALUE(NDISTR).LT.0.0) THEN                        GETS0055
                      PINMAX(PLTLAV)                                    GETS0056
     &                    = MAX(ABS(VALUE(NDISTR)),PINMAX(PLTLAV))      GETS0057
                  ENDIF                                                 GETS0058
              ENDIF                                                     GETS0059
          ENDIF                                                         GETS0060
                                                                        GETS0061
C---- Loop back for next record in file                                 GETS0062
      GO TO 100                                                         GETS0063
                                                                        GETS0064
C---- End of file reached                                               GETS0065
 500  CONTINUE                                                          GETS0066
                                                                        GETS0067
      GO TO 999                                                         GETS0068
                                                                        GETS0069
C---- Fatal errors                                                      GETS0070
 900  CONTINUE                                                          GETS0071
      PRINT*, '*** ERROR. Unable to open .sdh file'                     GETS0072
      GO TO 990                                                         GETS0073
                                                                        GETS0074
 904  CONTINUE                                                          GETS0075
      PRINT*, '*** ERROR. Error reading .sdh file at line:', LINE + 1   GETS0076
      GO TO 990                                                         GETS0077
                                                                        GETS0078
CHECK v.3.0.1-->                                                        GETS0079
C 906  CONTINUE                                                         GETS0080
C      PRINT*, '*** ERROR. Data error in .sdh file at line:', LINE + 1  GETS0081
C      PRINT*, IREC                                                     GETS0082
C      GO TO 990                                                        GETS0083
CHECK v.3.0.1<--                                                        GETS0084
                                                                        GETS0085
990   CONTINUE                                                          GETS0086
      IFAIL = .TRUE.                                                    GETS0087
                                                                        GETS0088
999   CONTINUE                                                          GETS0089
      RETURN                                                            GETS0090
      END                                                               GETS0091
                                                                        GETS0092
      SUBROUTINE GETRSA                                                 GETR0001
C-----------------------------------------------------------------------GETR0002
CHECK v.3.1-->                                                          GETR0003
C                                                                       GETR0004
C  SUBROUTINE GETRSA  -  Check whether .rsa file exists and, if so, readGETR0005
C                        through the residue accessibilities            GETR0006
C                                                                       GETR0007
C----------------------------------------------------------------------+GETR0008
                                                                        GETR0009
      INCLUDE 'pplot.inc'                                               GETR0010
                                                                        GETR0011
      CHARACTER*1   INCHN                                               GETR0012
      CHARACTER*120 IREC                                                GETR0013
      INTEGER       LINE, NVAL                                          GETR0014
      REAL          VALUE                                               GETR0015
                                                                        GETR0016
C---- Initialise variables                                              GETR0017
      ACCESS = .FALSE.                                                  GETR0018
      LINE = 0                                                          GETR0019
      NVAL = 0                                                          GETR0020
                                                                        GETR0021
C---- Open the file, <filename>.rsa                                     GETR0022
      OPEN(UNIT=13, FILE=FILRSA, STATUS='OLD', FORM='FORMATTED',        GETR0023
     &    ACCESS='SEQUENTIAL',                                          GETR0024
CVAX     -    READONLY,                                                 GETR0025
     &    ERR=999)                                                      GETR0026
                                                                        GETR0027
C---- Read through the file                                             GETR0028
 100  CONTINUE                                                          GETR0029
          READ(13,120,END=500,ERR=900) IREC                             GETR0030
 120      FORMAT(A)                                                     GETR0031
          LINE = LINE + 1                                               GETR0032
                                                                        GETR0033
C----     Process only if it is an ATOM record                          GETR0034
CHECK v.3.3.2-->                                                        GETR0035
C          IF (IREC(1:4).EQ.'ATOM') THEN                                GETR0036
          IF (IREC(1:3).EQ.'RES') THEN                                  GETR0037
CHECK v.3.3.2<--                                                        GETR0038
                                                                        GETR0039
C----         Read in the percentage residue accessibility              GETR0040
              READ(IREC,180,ERR=900) INCHN, VALUE                       GETR0041
CHECK v.3.3.2-->                                                        GETR0042
C 180          FORMAT(5X,A1,18X,F5.0)                                   GETR0043
 180          FORMAT(8X,A1,14X,F5.0)                                    GETR0044
CHECK v.3.3.2<--                                                        GETR0045
                                                                        GETR0046
C----         Only process this residue if it belongs to the required   GETR0047
C             chain                                                     GETR0048
              IF (CHAIN.EQ.' ' .OR. INCHN.EQ.CHAIN) THEN                GETR0049
                  NVAL = NVAL + 1                                       GETR0050
              ENDIF                                                     GETR0051
          ENDIF                                                         GETR0052
                                                                        GETR0053
C---- Loop back for next record in file                                 GETR0054
      GO TO 100                                                         GETR0055
                                                                        GETR0056
C---- End of file reached                                               GETR0057
 500  CONTINUE                                                          GETR0058
                                                                        GETR0059
C---- If have come across any valid residue-accessibility records, then GETR0060
C     set the accessibility-flag to TRUE                                GETR0061
      IF (NVAL.GT.0) ACCESS = .TRUE.                                    GETR0062
                                                                        GETR0063
      GO TO 999                                                         GETR0064
                                                                        GETR0065
C---- Errors                                                            GETR0066
 900  CONTINUE                                                          GETR0067
      PRINT*, '*** WARNING. Error reading .rsa file at line:', LINE + 1 GETR0068
      PRINT*, '***          Estimated accessibilities will be used'     GETR0069
      GO TO 999                                                         GETR0070
                                                                        GETR0071
999   CONTINUE                                                          GETR0072
      RETURN                                                            GETR0073
      END                                                               GETR0074
                                                                        GETR0075
      SUBROUTINE STDEVS                                                 STDE0001
C-----------------------------------------------------------------------STDE0002
CHECK v.3.1<--                                                          STDE0003
C                                                                       STDE0004
C  SUBROUTINE STDEVS  -   Second pass through data file(s), calculating STDE0005
C                         standard deviations                           STDE0006
C                                                                       STDE0007
C----------------------------------------------------------------------+STDE0008
                                                                        STDE0009
      INCLUDE 'pplot.inc'                                               STDE0010
                                                                        STDE0011
      CHARACTER*1   INCHN, SECSTR                                       STDE0012
      CHARACTER*3   RESDUE                                              STDE0013
      CHARACTER*5   SEQNO                                               STDE0014
      INTEGER       LINE, SERNO                                         STDE0015
      REAL          CGAMB, CHI1, CHI2, CHI3, CHI4, DIHANG, DISULF, ENHB,STDE0016
     &              OMEGA, PHI, PSI                                     STDE0017
                                                                        STDE0018
                                                                        STDE0019
C---- Rewind the residue-information file                               STDE0020
      REWIND(1)                                                         STDE0021
                                                                        STDE0022
C---- Initialise variables                                              STDE0023
      LINE = 0                                                          STDE0024
      NCHICH = 0                                                        STDE0025
                                                                        STDE0026
C---- Read through the residues file                                    STDE0027
 100  CONTINUE                                                          STDE0028
          READ(1,110,END=500,ERR=902) SERNO, RESDUE, INCHN, SEQNO,      STDE0029
     &        SECSTR, PHI, PSI, OMEGA, CHI1, CHI2, CHI3, CHI4, ENHB,    STDE0030
     &        DISULF, DIHANG, CGAMB                                     STDE0031
 110      FORMAT(I4,A3,1X,A1,A5,A1,11F7.2)                              STDE0032
          LINE = LINE + 1                                               STDE0033
                                                                        STDE0034
C----     Only process this residue if it belongs to the required chain STDE0035
          IF (CHAIN.EQ.' ' .OR. INCHN.EQ.CHAIN) THEN                    STDE0036
                                                                        STDE0037
C----         Accumulate figures for calculation of standard deviations STDE0038
                                                                        STDE0039
C----         Chi-1 torsion angle                                       STDE0040
              IF (RESDUE.EQ.'PRO') CHI1 = 999.9                         STDE0041
              IF (CHI1.LT.0.0) CHI1 = CHI1 + 360.0                      STDE0042
              IF (CHI1.EQ.360.0) CHI1 = 0.0                             STDE0043
              IF (CHI1.GE.0.0 .AND. CHI1.LT.360.0) THEN                 STDE0044
                                                                        STDE0045
C----             Chi-1 gauche minus                                    STDE0046
                  IF (CHI1.GE.0.0 .AND. CHI1.LT.120.0) THEN             STDE0047
                      GMISTD = GMISTD + (CHI1 - GMIMEA)                 STDE0048
     &                    * (CHI1 - GMIMEA)                             STDE0049
                                                                        STDE0050
C----             Chi-1 trans                                           STDE0051
                  ELSE IF (CHI1.GE.120.0 .AND. CHI1.LT.240.0) THEN      STDE0052
                      GTRSTD = GTRSTD + (CHI1 - GTRMEA)                 STDE0053
     &                    * (CHI1 - GTRMEA)                             STDE0054
                                                                        STDE0055
C----             Chi-1 gauche plus                                     STDE0056
                  ELSE IF (CHI1.GE.240.0 .AND. CHI1.LT.360.0) THEN      STDE0057
                      GPLSTD = GPLSTD + (CHI1 - GPLMEA)                 STDE0058
     &                    * (CHI1 - GPLMEA)                             STDE0059
                  ENDIF                                                 STDE0060
              ENDIF                                                     STDE0061
                                                                        STDE0062
C----         Chi-2 trans torsion angle                                 STDE0063
              IF (CHI2.LE.0.0) CHI2 = CHI2 + 360.0                      STDE0064
              IF (RESDUE.NE.'PHE' .AND. RESDUE.NE.'TYR' .AND.           STDE0065
     &            RESDUE.NE.'TRP' .AND. RESDUE.NE.'HIS' .AND.           STDE0066
     &            RESDUE.NE.'ASP' .AND. RESDUE.NE.'ASN') THEN           STDE0067
                  IF (CHI2.GT.120.0 .AND. CHI2.LE.240.0) THEN           STDE0068
                      CH2STD = CH2STD + (CHI2 - CH2MEA)                 STDE0069
     &                    * (CHI2 - CH2MEA)                             STDE0070
                  ENDIF                                                 STDE0071
              ENDIF                                                     STDE0072
                                                                        STDE0073
C----         Proline phi                                               STDE0074
              IF (RESDUE.EQ.'PRO' .AND. PHI.NE.999.9) THEN              STDE0075
                  PPSTD = PPSTD + (PHI - PPMEAN) * (PHI - PPMEAN)       STDE0076
              ENDIF                                                     STDE0077
                                                                        STDE0078
C----         Phi helix                                                 STDE0079
              IF (SECSTR.EQ.'H' .AND. PHI.NE.999.9) THEN                STDE0080
                  PHSTD = PHSTD + (PHI - PHMEAN) * (PHI - PHMEAN)       STDE0081
              ENDIF                                                     STDE0082
                                                                        STDE0083
C----         Helix psi                                                 STDE0084
              IF (SECSTR.EQ.'H' .AND. PSI.NE.999.9) THEN                STDE0085
                  HPSTD = HPSTD + (PSI - HPMEAN) * (PSI - HPMEAN)       STDE0086
              ENDIF                                                     STDE0087
                                                                        STDE0088
C----         Chi-3 right-hand                                          STDE0089
              IF (RESDUE.EQ.'CYS' .AND. CHI3.GT.0.0 .AND.               STDE0090
     &            CHI3.LE.180.0) THEN                                   STDE0091
                  C3RSTD = C3RSTD + (CHI3 - C3RMEA) * (CHI3 - C3RMEA)   STDE0092
              ENDIF                                                     STDE0093
                                                                        STDE0094
C----         Chi-3 left-hand                                           STDE0095
              IF (RESDUE.EQ.'CYS' .AND. CHI3.LE.0.0 .AND.               STDE0096
     &            CHI3.GE.-180.0) THEN                                  STDE0097
                  C3LSTD = C3LSTD + (CHI3 - C3LMEA) * (CHI3 - C3LMEA)   STDE0098
              ENDIF                                                     STDE0099
                                                                        STDE0100
C----         Disulphide bond                                           STDE0101
              IF (RESDUE.EQ.'CYS') THEN                                 STDE0102
                  IF (DISULF.NE.0.0) THEN                               STDE0103
                     SSSTD = SSSTD + (DISULF - SSMEAN)                  STDE0104
     &                   * (DISULF - SSMEAN)                            STDE0105
                  ENDIF                                                 STDE0106
              ENDIF                                                     STDE0107
                                                                        STDE0108
C----         Omega torsion angle                                       STDE0109
              IF (ABS(OMEGA).GE.45.0 .AND. OMEGA.NE.999.9) THEN         STDE0110
                  IF (OMEGA.LE.0.0) OMEGA = OMEGA + 360.0               STDE0111
                  OMSTD = OMSTD + (OMEGA - OMMEAN) * (OMEGA - OMMEAN)   STDE0112
              ENDIF                                                     STDE0113
                                                                        STDE0114
C----         Hydrogen bond energy                                      STDE0115
              IF (ENHB.LT.0.0) THEN                                     STDE0116
                  HBSTD = HBSTD + (ENHB - HBMEAN) * (ENHB - HBMEAN)     STDE0117
              ENDIF                                                     STDE0118
                                                                        STDE0119
C----         Alpha-carbon tetrahedral chirality                        STDE0120
              IF (DIHANG.LE.360.0) THEN                                 STDE0121
                  ACSTD = ACSTD + (DIHANG - ACMEAN) * (DIHANG - ACMEAN) STDE0122
              ENDIF                                                     STDE0123
                                                                        STDE0124
C----         Plot this point on the Chi-1 vs Chi-2 plot                STDE0125
              IF (CHI1.NE.999.9 .AND. CHI2.NE.999.9) THEN               STDE0126
                  NCHICH = NCHICH + 1                                   STDE0127
              ENDIF                                                     STDE0128
          ENDIF                                                         STDE0129
                                                                        STDE0130
C---- Loop back for next record in file                                 STDE0131
      GO TO 100                                                         STDE0132
                                                                        STDE0133
C---- End of file reached                                               STDE0134
 500  CONTINUE                                                          STDE0135
                                                                        STDE0136
      GO TO 999                                                         STDE0137
                                                                        STDE0138
C---- Fatal errors                                                      STDE0139
902   CONTINUE                                                          STDE0140
      PRINT*, '*** ERROR. Data error in .rin file at line:', LINE + 1   STDE0141
      GO TO 990                                                         STDE0142
                                                                        STDE0143
990   CONTINUE                                                          STDE0144
      IFAIL = .TRUE.                                                    STDE0145
                                                                        STDE0146
 999  CONTINUE                                                          STDE0147
      RETURN                                                            STDE0148
      END                                                               STDE0149
                                                                        STDE0150
      SUBROUTINE SCALCS                                                 SCAL0001
C-----------------------------------------------------------------------SCAL0002
C                                                                       SCAL0003
C  SUBROUTINE SCALCS  -  Calculate standard deviations                  SCAL0004
C                                                                       SCAL0005
C----------------------------------------------------------------------+SCAL0006
                                                                        SCAL0007
      INCLUDE 'pplot.inc'                                               SCAL0008
                                                                        SCAL0009
C---- Calculate means and standard deviations                           SCAL0010
                                                                        SCAL0011
C---- Chi-1 torsion angle (gauche minus)                                SCAL0012
      IF (NGMINU.GT.1) THEN                                             SCAL0013
          GMISTD = SQRT(GMISTD / (NGMINU - 1))                          SCAL0014
      ELSE                                                              SCAL0015
          GMISTD =0.0                                                   SCAL0016
      ENDIF                                                             SCAL0017
                                                                        SCAL0018
C---- Chi-1 torsion angle (trans)                                       SCAL0019
      IF (NGTRAN.GT.1) THEN                                             SCAL0020
          GTRSTD = SQRT(GTRSTD / (NGTRAN - 1))                          SCAL0021
      ELSE                                                              SCAL0022
          GTRSTD =0.0                                                   SCAL0023
      ENDIF                                                             SCAL0024
                                                                        SCAL0025
C---- Chi-1 torsion angle (gauche plus)                                 SCAL0026
      IF (NGPLUS.GT.1) THEN                                             SCAL0027
          GPLSTD = SQRT(GPLSTD / (NGPLUS - 1))                          SCAL0028
      ELSE                                                              SCAL0029
          GPLSTD =0.0                                                   SCAL0030
      ENDIF                                                             SCAL0031
                                                                        SCAL0032
C---- Chi-2 trans torsion angle                                         SCAL0033
      IF (NCHI2.GT.1) THEN                                              SCAL0034
          CH2STD = SQRT(CH2STD / (NCHI2 - 1))                           SCAL0035
      ELSE                                                              SCAL0036
          CH2STD =0.0                                                   SCAL0037
      ENDIF                                                             SCAL0038
                                                                        SCAL0039
C---- Proline phi torsion angle                                         SCAL0040
      IF (NPROPH.GT.1) THEN                                             SCAL0041
          PPSTD = SQRT(PPSTD / (NPROPH - 1))                            SCAL0042
      ENDIF                                                             SCAL0043
                                                                        SCAL0044
C---- Phi torsion angle in helices                                      SCAL0045
      IF (NPHIHX.GT.1) THEN                                             SCAL0046
          PHSTD = SQRT(PHSTD / (NPHIHX - 1))                            SCAL0047
      ENDIF                                                             SCAL0048
                                                                        SCAL0049
C---- Helix psi torsion angle                                           SCAL0050
      IF (NHXPSI.GT.1) THEN                                             SCAL0051
          HPSTD = SQRT(HPSTD / (NHXPSI - 1))                            SCAL0052
      ENDIF                                                             SCAL0053
                                                                        SCAL0054
C---- Chi-3 torsion angle, right-handed                                 SCAL0055
      IF (NCHI3R.GT.1) THEN                                             SCAL0056
          C3RSTD = SQRT(C3RSTD / (NCHI3R - 1))                          SCAL0057
      ENDIF                                                             SCAL0058
                                                                        SCAL0059
C---- Chi-3 torsion angle, left-handed                                  SCAL0060
      IF (NCHI3L.GT.1) THEN                                             SCAL0061
          C3LSTD = SQRT(C3LSTD / (NCHI3L - 1))                          SCAL0062
      ENDIF                                                             SCAL0063
                                                                        SCAL0064
C---- Disulphide bond                                                   SCAL0065
      IF (NDISUL.GT.1) THEN                                             SCAL0066
          SSSTD = SQRT(SSSTD / (NDISUL - 1))                            SCAL0067
      ENDIF                                                             SCAL0068
                                                                        SCAL0069
C---- Omega torsion angle                                               SCAL0070
      IF (NOMEGA.GT.1) THEN                                             SCAL0071
          OMSTD = SQRT(OMSTD / (NOMEGA - 1))                            SCAL0072
      ENDIF                                                             SCAL0073
                                                                        SCAL0074
C---- Hydrogen bond energy                                              SCAL0075
      IF (NHBOND.GT.1) THEN                                             SCAL0076
          HBSTD = SQRT(HBSTD / (NHBOND - 1))                            SCAL0077
      ELSE                                                              SCAL0078
          HBSTD =0.0                                                    SCAL0079
      ENDIF                                                             SCAL0080
                                                                        SCAL0081
C---- Alpha carbon chirality                                            SCAL0082
      IF (NALPHC.GT.1) THEN                                             SCAL0083
          ACSTD = SQRT(ACSTD / (NALPHC - 1))                            SCAL0084
      ENDIF                                                             SCAL0085
                                                                        SCAL0086
C---- Store the values used in the stereochemical quality plots         SCAL0087
      SVALUE(1) = COREPC                                                SCAL0088
      SVALUE(2) = OMSTD                                                 SCAL0089
      SVALUE(3) = BADCOP                                                SCAL0090
      SVALUE(4) = ACSTD                                                 SCAL0091
      SVALUE(5) = HBSTD                                                 SCAL0092
      SVALUE(6) = SFACT                                                 SCAL0093
      SVALUE(7) = GMISTD                                                SCAL0094
      SVALUE(8) = GTRSTD                                                SCAL0095
      SVALUE(9) = GPLSTD                                                SCAL0096
      SVALUE(10) = POOSTD                                               SCAL0097
      SVALUE(11) = CH2STD                                               SCAL0098
      NVALUE(1) = NONPG                                                 SCAL0099
      NVALUE(2) = NOMEGA                                                SCAL0100
      NVALUE(3) = NBAD                                                  SCAL0101
      NVALUE(4) = NALPHC                                                SCAL0102
      NVALUE(5) = NHBOND                                                SCAL0103
      NVALUE(6) = NRESID                                                SCAL0104
      NVALUE(7) = NGMINU                                                SCAL0105
      NVALUE(8) = NGTRAN                                                SCAL0106
      NVALUE(9) = NGPLUS                                                SCAL0107
      NVALUE(10) = NGMINU + NGTRAN + NGPLUS                             SCAL0108
      NVALUE(11) = NCHI2                                                SCAL0109
                                                                        SCAL0110
                                                                        SCAL0111
      RETURN                                                            SCAL0112
      END                                                               SCAL0113
                                                                        SCAL0114
      SUBROUTINE QUALIT                                                 QUAL0001
C-----------------------------------------------------------------------QUAL0002
C                                                                       QUAL0003
C  SUBROUTINE QUALIT  -  Perform all the quality-assessment plots       QUAL0004
C                                                                       QUAL0005
C----------------------------------------------------------------------+QUAL0006
                                                                        QUAL0007
      INCLUDE 'pplot.inc'                                               QUAL0008
                                                                        QUAL0009
CHECK v.3.2-->                                                          QUAL0010
      CHARACTER*1   CNUMB                                               QUAL0011
      CHARACTER*9   PLHAND                                              QUAL0012
CHECK v.3.2<--                                                          QUAL0013
      CHARACTER*21  GTITLE(2)                                           QUAL0014
      CHARACTER*30  DE(NQUALP)                                          QUAL0015
CHECK v.3.1-->                                                          QUAL0016
      CHARACTER*30  PLDESC                                              QUAL0017
CHECK v.3.1<--                                                          QUAL0018
      CHARACTER*50  GSTIT(NQUALP), YAXIS(NQUALP)                        QUAL0019
CHECK v.3.2-->                                                          QUAL0020
      CHARACTER*60  PTITLE                                              QUAL0021
      CHARACTER*79   BLNKLN, SUMLIN                                     QUAL0022
CHECK v.3.2<--                                                          QUAL0023
CHECK v.3.2-->                                                          QUAL0024
C      INTEGER       IGRAPH, INTRLY(NQUALP), IQUALP, ISET, NGRAPH,      QUAL0025
C     -              JGRAPH, NGAPY(NQUALP), TITLEN(NQUALP), YLEN(NQUALP)QUAL0026
      INTEGER       IGRAPH, INTRLY(NQUALP), IQUALP, ISET, JGRAPH,       QUAL0027
     &              NBETTE, NGRAPH, NINSID, NGAPY(NQUALP), NWORSE,      QUAL0028
     &              TITLEN(NQUALP), YLEN(NQUALP)                        QUAL0029
CHECK v.3.2<--                                                          QUAL0030
      REAL          CO(3,NQUALP), SCALEX, TSIZE, X, XCENTR, XL, XR, Y,  QUAL0031
     &              YB(NQUALP), YL, YLOWER(NQUALP), YR, YUPPER(NQUALP)  QUAL0032
                                                                        QUAL0033
CHECK v.3.2-->                                                          QUAL0034
      DATA BLNKLN( 1:40) / ' |                                      ' / QUAL0035
      DATA BLNKLN(41:79) / '                                      |'  / QUAL0036
CHECK v.3.2<--                                                          QUAL0037
                                                                        QUAL0038
      DATA  CO     / 84.2, 11.2, -5.7,                                  QUAL0039
     &                6.0,  0.0,  0.0,                                  QUAL0040
     &               10.4,-15.7,  6.3,                                  QUAL0041
     &               3.12,  0.0,  0.0,                                  QUAL0042
     &               0.35,  0.23, 0.0,                                  QUAL0043
     &               0.43, -0.41, 0.0,                                  QUAL0044
     &              -0.14,  9.13, 0.0,                                  QUAL0045
     &               4.23,  7.39, 0.0,                                  QUAL0046
     &               2.49,  7.52, 0.0,                                  QUAL0047
     &               2.85,  7.66, 0.0,                                  QUAL0048
     &                9.6,  5.4,  0.0 /                                 QUAL0049
                                                                        QUAL0050
      DATA DE     / 'a. %-tage residues in A, B, L ',                   QUAL0051
     &              'b. Omega angle st dev         ',                   QUAL0052
     &              'c. Bad contacts / 100 residues',                   QUAL0053
     &              'd. Zeta angle st dev          ',                   QUAL0054
     &              'e. H-bond energy st dev       ',                   QUAL0055
     &              'f. Overall G-factor           ',                   QUAL0056
     &              'a. Chi-1 gauche minus st dev  ',                   QUAL0057
     &              'b. Chi-1 trans st dev         ',                   QUAL0058
     &              'c. Chi-1 gauche plus st dev   ',                   QUAL0059
     &              'd. Chi-1 pooled st dev        ',                   QUAL0060
     &              'e. Chi-2 trans st dev         ' /                  QUAL0061
                                                                        QUAL0062
      DATA GSTIT  / 'a. Ramachandran plot quality assessment         ', QUAL0063
     &              'b. Peptide bond planarity - omega angle sd      ', QUAL0064
     &              'c. Measure of bad non-bonded interactions       ', QUAL0065
     &              'd. Alpha carbon tetrahedral distortion          ', QUAL0066
     &              'e. Hydrogen bond energies                       ', QUAL0067
     &              'f. Overall G-factor                             ', QUAL0068
     &              'a. Chi-1 gauche minus                           ', QUAL0069
     &              'b. Chi-1 trans                                  ', QUAL0070
     &              'c. Chi-1 gauche plus                            ', QUAL0071
     &              'd. Chi-1 pooled standard deviations             ', QUAL0072
     &              'e. Standard deviation of Chi-2 trans angle      '/ QUAL0073
                                                                        QUAL0074
      DATA GTITLE / 'Main-chain parameters', 'Side-chain parameters' /  QUAL0075
                                                                        QUAL0076
      DATA NGAPY  /     5,    5,    7,    8,   4,    7,    5,    5,     QUAL0077
     &                  5,    5,    5 /                                 QUAL0078
                                                                        QUAL0079
      DATA INTRLY /     0,    0,    0,    1,   1,    1,    0,    0,     QUAL0080
     &                  0,    0,    0 /                                 QUAL0081
                                                                        QUAL0082
      DATA TITLEN /    39,   42,   41,   38,  25,   19,   21,   14,     QUAL0083
     &                 20,   34,   42 /                                 QUAL0084
                                                                        QUAL0085
      DATA  YAXIS / '%-tage of residues in most favoured regions     ', QUAL0086
     &              'Standard deviation (degrees)                    ', QUAL0087
     &              'Bad contacts per 100 residues                   ', QUAL0088
     &              'Zeta angle standard dev. (degrees)              ', QUAL0089
     &              'Standard deviation (kcal/mol)                   ', QUAL0090
     &              'G-factor                                        ', QUAL0091
     &              'Standard deviation (degrees)                    ', QUAL0092
     &              'Standard deviation (degrees)                    ', QUAL0093
     &              'Standard deviation (degrees)                    ', QUAL0094
     &              'Standard deviation (degrees)                    ', QUAL0095
     &              'Standard deviation (degrees)                    '/ QUAL0096
                                                                        QUAL0097
      DATA YB     /  10.0,  3.0, 10.0,  1.6, 0.2,  0.3,  6.5,  5.3,     QUAL0098
     &                4.9,  4.85, 5.0 /                                 QUAL0099
                                                                        QUAL0100
      DATA YLEN   /    43,   28,   29,   34,  29,    8,   28,   28,     QUAL0101
     &                 28,   28,   28 /                                 QUAL0102
                                                                        QUAL0103
      DATA YLOWER /   0.0,  0.0,  0.0,  0.0, 0.0, -2.5,  0.0,  0.0,     QUAL0104
     &                0.0,  0.0,  0.0 /                                 QUAL0105
                                                                        QUAL0106
      DATA YUPPER / 100.0, 25.0, 70.0, 20.0, 2.0,  1.0, 50.0, 50.0,     QUAL0107
     &               50.0, 50.0, 50.0 /                                 QUAL0108
                                                                        QUAL0109
                                                                        QUAL0110
C---- Initialise variables                                              QUAL0111
      DO 20, IQUALP = 1, NQUALP                                         QUAL0112
          COEFF(1,IQUALP) = CO(1,IQUALP)                                QUAL0113
          COEFF(2,IQUALP) = CO(2,IQUALP)                                QUAL0114
          COEFF(3,IQUALP) = CO(3,IQUALP)                                QUAL0115
          DESC(IQUALP) = DE(IQUALP)                                     QUAL0116
          YBAND(IQUALP) = YB(IQUALP)                                    QUAL0117
 20   CONTINUE                                                          QUAL0118
                                                                        QUAL0119
C---- Loop through the two graphs: Main-chain and Side-chain properties QUAL0120
      DO 1000, ISET = 1, 2                                              QUAL0121
          PLTYPE = ISET                                                 QUAL0122
                                                                        QUAL0123
CHECK v.3.2-->                                                          QUAL0124
C----     Initialise counts of points in the different regions          QUAL0125
          NBETTE = 0                                                    QUAL0126
          NINSID = 0                                                    QUAL0127
          NWORSE = 0                                                    QUAL0128
CHECK v.3.2<--                                                          QUAL0129
          IF ((ISET.EQ.1 .AND. PLOTQ1) .OR.                             QUAL0130
     &        (ISET.EQ.2 .AND. PLOTQ2)) THEN                            QUAL0131
                                                                        QUAL0132
C----         Open new PostScript file                                  QUAL0133
CHECK v.3.1-->                                                          QUAL0134
C              CALL PSNAME(FILPS,ILEN,IPLOT)                            QUAL0135
              IF (ISET.EQ.1) THEN                                       QUAL0136
                  PLDESC = 'Main-chain parameters'                      QUAL0137
CHECK v.3.2-->                                                          QUAL0138
                  PLHAND = 'mainchpar'                                  QUAL0139
CHECK v.3.2<--                                                          QUAL0140
              ELSE                                                      QUAL0141
                  PLDESC = 'Side-chain parameters'                      QUAL0142
CHECK v.3.2-->                                                          QUAL0143
                  PLHAND = 'sidechpar'                                  QUAL0144
CHECK v.3.2<--                                                          QUAL0145
              ENDIF                                                     QUAL0146
CHECK v.3.2-->                                                          QUAL0147
C              CALL PSNAME(FILPS,ILEN,IPLOT,PLDESC)                     QUAL0148
              PTITLE = PLDESC                                           QUAL0149
              CALL PSNAME(FILPS,ILEN,IPLOT,PLDESC,PLHAND,WITHAN)        QUAL0150
CHECK v.3.2<--                                                          QUAL0151
CHECK v.3.1<--                                                          QUAL0152
CHECK v.3.2-->                                                          QUAL0153
C              CALL PSOPEN(FILPS,BBOXX1,BBOXX2,BBOXY1,BBOXY2,MXCOLR,    QUAL0154
C     -            RGB,INCOLR(PLTYPE),COLPLT(PLTYPE,1))                 QUAL0155
CHECK v.3.4-->                                                          QUAL0156
C              CALL PSOPEN(FILPS,MXCOLR,RGB,INCOLR(PLTYPE),PTITLE,1)    QUAL0157
              CALL PSOPEN(FILPS,MXCOLR,RGB,NCOLOR,INCOLR(PLTYPE),PTITLE,QUAL0158
     &            1)                                                    QUAL0159
CHECK v.3.4<--                                                          QUAL0160
              CALL PSPAGE(FILPS,BBOXX1,BBOXX2,BBOXY1,BBOXY2,MXCOLR,     QUAL0161
CHECK v.3.4-->                                                          QUAL0162
C     -            RGB,INCOLR(PLTYPE),COLPLT(PLTYPE,1),1,PLABEL)        QUAL0163
     &            RGB,INCOLR(PLTYPE),COLPLT(PLTYPE,1),1,PLABEL,.FALSE.) QUAL0164
CHECK v.3.4<--                                                          QUAL0165
CHECK v.3.2<--                                                          QUAL0166
                                                                        QUAL0167
C----         Initialise variables                                      QUAL0168
              NGRAPH = (ISET - 1) * 6                                   QUAL0169
              XCENTR = XORIGN + XMWID + XSEP / 2.0                      QUAL0170
              YL = YORIGN + 3.0 * YMWID + 2.0 * YSEP                    QUAL0171
              SCALEX = XMWID / (REND - RSTART)                          QUAL0172
              CALL PSLWID(0.1)                                          QUAL0173
                                                                        QUAL0174
CHECK v.3.2-->                                                          QUAL0175
C----         Print program name in top left-hand corner                QUAL0176
              CALL PSTEXT(BBOXX1 + 15.0,BBOXY2 - 10.0,10.0,             QUAL0177
     &            'PROCHECK')                                           QUAL0178
CHECK v.3.2<--                                                          QUAL0179
                                                                        QUAL0180
C----         Main graph heading                                        QUAL0181
              CALL PSCTXT(XCENTR,YL + 56.0,30.0,GTITLE(ISET))           QUAL0182
              CALL PSCTXT(XCENTR,YL + 26.0,25.0,BRCODE(1:BLEN))         QUAL0183
                                                                        QUAL0184
C----         Plot the axes                                             QUAL0185
              DO 200, IGRAPH = 1, 3                                     QUAL0186
                  YL = YORIGN + (3 - IGRAPH) * (YMWID + YSEP)           QUAL0187
                  YR = YL + YMWID                                       QUAL0188
                  DO 100, JGRAPH = 1, 2                                 QUAL0189
                      NGRAPH = NGRAPH + 1                               QUAL0190
                      XL = XORIGN + (JGRAPH - 1) * (XMWID + XSEP)       QUAL0191
                      XR = XL + XMWID                                   QUAL0192
                                                                        QUAL0193
C----                 If one of the graphs, then do the plot            QUAL0194
                      IF (NGRAPH.LE.NQUALP) THEN                        QUAL0195
                                                                        QUAL0196
C----                     Write out background shade for the plot       QUAL0197
                          CALL PSLWID(0.1)                              QUAL0198
                          IF (BSHADE(PLTYPE)) THEN                      QUAL0199
                              CALL PSHADE(0.95,COLPLT(PLTYPE,2),RGB,    QUAL0200
     &                            MXCOLR,INCOLR(PLTYPE))                QUAL0201
                              CALL PSUBOX(XL,YL,XL,YR,XR,YR,XR,YL)      QUAL0202
                          ENDIF                                         QUAL0203
                                                                        QUAL0204
C----                     Adjust upper y-bound if point off end of scaleQUAL0205
 50                       CONTINUE                                      QUAL0206
                          IF (SVALUE(NGRAPH).GT.YUPPER(NGRAPH)) THEN    QUAL0207
                              YUPPER(NGRAPH) = 2.0 * YUPPER(NGRAPH)     QUAL0208
                              GO TO 50                                  QUAL0209
                          ENDIF                                         QUAL0210
                                                                        QUAL0211
C----                     Draw axes                                     QUAL0212
                          CALL AXES(XL,XR,YL,YR,NGAPX,NGAPY(NGRAPH),    QUAL0213
     &                        RSTART,REND,YLOWER(NGRAPH),YUPPER(NGRAPH),QUAL0214
     &                        10.0,1,INTRLY(NGRAPH),15.0,.TRUE.,.TRUE., QUAL0215
     &                        .FALSE.,.FALSE.,.FALSE.)                  QUAL0216
C----                     Graph heading and x-axis title                QUAL0217
                          CALL PSCTXT((XL + XR) / 2.0,YL + YMWID + 8.0, QUAL0218
     &                        10.0,GSTIT(NGRAPH)(1:TITLEN(NGRAPH)))     QUAL0219
                          CALL PSCTXT((XL + XR) / 2.0,YL - 16.0,10.0,   QUAL0220
     &                        'Resolution (Angstroms)')                 QUAL0221
                                                                        QUAL0222
C----                     y-axis title                                  QUAL0223
                          CALL PSRCTX(XL - 30.0,(YL + YR) / 2.0,10.0,   QUAL0224
     &                        YAXIS(NGRAPH)(1:YLEN(NGRAPH)))            QUAL0225
                                                                        QUAL0226
C----                     Draw the shaded band representing acceptable  QUAL0227
C                         values                                        QUAL0228
                          CALL CURSHD(0.0,COEFF(3,NGRAPH),              QUAL0229
     &                        COEFF(2,NGRAPH),COEFF(1,NGRAPH),          QUAL0230
     &                        YLOWER(NGRAPH),YUPPER(NGRAPH),            QUAL0231
     &                        YBAND(NGRAPH),XL,XR,YL,YR,RSTART,         QUAL0232
     &                        REND,RGAP,INCOLR(PLTYPE),                 QUAL0233
     &                        MXCOLR,RGB,COLPLT(PLTYPE,3))              QUAL0234
                                                                        QUAL0235
C----                     Redraw the box around the graph               QUAL0236
                          CALL PSLINE(XL,YL,XL,YR)                      QUAL0237
                          CALL PSLINE(XL,YR,XR,YR)                      QUAL0238
                          CALL PSLINE(XR,YR,XR,YL)                      QUAL0239
                          CALL PSLINE(XR,YL,XL,YL)                      QUAL0240
                                                                        QUAL0241
C----                     Plot the point corresponding to the current   QUAL0242
C                         structure                                     QUAL0243
                          X = XL + SCALEX * (RESOL - RSTART)            QUAL0244
                          Y = YL + (YR - YL)                            QUAL0245
     &                        * (SVALUE(NGRAPH) - YLOWER(NGRAPH))       QUAL0246
     &                        / (YUPPER(NGRAPH) - YLOWER(NGRAPH))       QUAL0247
                          CALL PSMARK(X,Y,1,HWIDX,HWIDY)                QUAL0248
                                                                        QUAL0249
C----                 Otherwise, if box on bottom right, draw it        QUAL0250
                      ELSE                                              QUAL0251
                          CALL PSLWID(0.6)                              QUAL0252
                          CALL PSHADE(1.0,1,RGB,MXCOLR,.FALSE.)         QUAL0253
                          CALL PSBBOX(XL,YL,XL,YR,XR,YR,XR,YL)          QUAL0254
                          TSIZE = 25.0                                  QUAL0255
                          IF (ILEN.GT.10) TSIZE = TSIZE * 10.0 / ILEN   QUAL0256
                          CALL PSCTXT((XL + XR) / 2.0,(YL + YR) / 2.0,  QUAL0257
     &                        TSIZE,BRCODE(1:BLEN))                     QUAL0258
                      ENDIF                                             QUAL0259
 100              CONTINUE                                              QUAL0260
 200          CONTINUE                                                  QUAL0261
                                                                        QUAL0262
C----         Print the statistics at the bottom of the page            QUAL0263
CHECK v.3.2-->                                                          QUAL0264
C              CALL QSTAT(ISET)                                         QUAL0265
              CALL QSTAT(ISET,NBETTE,NWORSE)                            QUAL0266
CHECK v.3.2<--                                                          QUAL0267
                                                                        QUAL0268
C----         Close the PostScript file                                 QUAL0269
CHECK v.3.2-->                                                          QUAL0270
              CALL PSENDP                                               QUAL0271
CHECK v.3.2<--                                                          QUAL0272
              CALL PSCLOS(BBOXX1,BBOXX2,BBOXY1,BBOXY2)                  QUAL0273
          ENDIF                                                         QUAL0274
                                                                        QUAL0275
CHECK v.3.2-->                                                          QUAL0276
C----     Write out the quality statistics to the .sum summary file     QUAL0277
                                                                        QUAL0278
C----     Blank out the output line                                     QUAL0279
          SUMLIN = BLNKLN                                               QUAL0280
                                                                        QUAL0281
C----     Set up line label according to which quality plots have just  QUAL0282
C         been done                                                     QUAL0283
          IF (ISET.EQ.1) THEN                                           QUAL0284
              SUMLIN(4:21) = 'Main-chain params:'                       QUAL0285
          ELSE                                                          QUAL0286
              SUMLIN(4:21) = 'Side-chain params:'                       QUAL0287
          ENDIF                                                         QUAL0288
                                                                        QUAL0289
C----     Show the number of properties that score better than expected QUAL0290
          WRITE(CNUMB,620) NBETTE                                       QUAL0291
 620      FORMAT(I1)                                                    QUAL0292
          SUMLIN(26:26) = CNUMB                                         QUAL0293
          SUMLIN(28:33) = 'better'                                      QUAL0294
                                                                        QUAL0295
C----     Show the number of properties that score as expected          QUAL0296
          WRITE(CNUMB,620) NINSID                                       QUAL0297
          SUMLIN(39:39) = CNUMB                                         QUAL0298
          SUMLIN(41:46) = 'inside'                                      QUAL0299
                                                                        QUAL0300
C----     Show the number of properties that score worse than expected  QUAL0301
          WRITE(CNUMB,620) NWORSE                                       QUAL0302
          SUMLIN(53:53) = CNUMB                                         QUAL0303
          SUMLIN(55:59) = 'worse'                                       QUAL0304
                                                                        QUAL0305
C----     Determine whether to highlight the line with a + or a *       QUAL0306
          IF (NWORSE.GT.0) THEN                                         QUAL0307
              SUMLIN(1:1) = '+'                                         QUAL0308
          ENDIF                                                         QUAL0309
          IF (NWORSE.GT.3) THEN                                         QUAL0310
              SUMLIN(1:1) = '*'                                         QUAL0311
          ENDIF                                                         QUAL0312
                                                                        QUAL0313
C----     Write the line out to the summary file                        QUAL0314
          WRITE(14,660) SUMLIN                                          QUAL0315
 660      FORMAT(A)                                                     QUAL0316
CHECK v.3.2<--                                                          QUAL0317
                                                                        QUAL0318
 1000 CONTINUE                                                          QUAL0319
                                                                        QUAL0320
CHECK v.3.2-->                                                          QUAL0321
C---- Write out blank line to summary file after chi1-ch2 line          QUAL0322
      WRITE(14,660) BLNKLN                                              QUAL0323
CHECK v.3.2<--                                                          QUAL0324
                                                                        QUAL0325
      RETURN                                                            QUAL0326
      END                                                               QUAL0327
                                                                        QUAL0328
      SUBROUTINE CURSHD(A3,A2,A1,C,VMIN,VMAX,VDIFF,XPOS1,XPOS2,YPOS1,   CURS0001
     &    YPOS2,RSTART,REND,RGAP,INCOLR,MXCOLR,RGB,COLOUR)              CURS0002
C-----------------------------------------------------------------------CURS0003
C                                                                       CURS0004
C  SUBROUTINE CURSHD  -  Shade in the 'expected' regions with resolutionCURS0005
C                        for the main-chain and side-chain plots        CURS0006
C                                                                       CURS0007
C----------------------------------------------------------------------+CURS0008
                                                                        CURS0009
      INTEGER       COLOUR, CURRNT, IRESOL, LAST, MXCOLR, NRESOL        CURS0010
      LOGICAL       INCOLR                                              CURS0011
      REAL          A1, A2, A3, C, REND, RESOL, RGAP, RGB(3,MXCOLR),    CURS0012
     &              RSTART, VBOT, VDIFF, VMAX, VMID, VMIN, VTOP, X(2),  CURS0013
     &              XPOS1, XPOS2, XSCALE, YBOT(2), YMID(2), YPOS1,      CURS0014
     &              YPOS2, YTOP(2), YSCALE                              CURS0015
                                                                        CURS0016
C---- Determine the number of resolution steps required, and initialise CURS0017
      NRESOL = (REND - RSTART) / RGAP + 1                               CURS0018
      RESOL = RSTART                                                    CURS0019
      CURRNT = 1                                                        CURS0020
      LAST = 2                                                          CURS0021
      XSCALE = (XPOS2 - XPOS1) / (REND - RSTART)                        CURS0022
      YSCALE = (YPOS2 - YPOS1) / (VMAX - VMIN)                          CURS0023
                                                                        CURS0024
C---- Loop through the resolution steps                                 CURS0025
      DO 200, IRESOL = 1, NRESOL                                        CURS0026
                                                                        CURS0027
C----     Calculate current x-value in PostScript coordinates           CURS0028
          X(CURRNT) = XPOS1 + XSCALE * (RESOL - RSTART)                 CURS0029
                                                                        CURS0030
C----     Calculate the three y-values                                  CURS0031
          VMID = A3 * RESOL * RESOL * RESOL                             CURS0032
     &        + A2 * RESOL * RESOL                                      CURS0033
     &        + A1 * RESOL + C                                          CURS0034
          VBOT = VMID - VDIFF                                           CURS0035
          VTOP = VMID + VDIFF                                           CURS0036
                                                                        CURS0037
C----     Make sure no line is off graph                                CURS0038
          VBOT = MAX(VMIN,VBOT)                                         CURS0039
          VMID = MAX(VMIN,VMID)                                         CURS0040
          VTOP = MAX(VMIN,VTOP)                                         CURS0041
          VBOT = MIN(VMAX,VBOT)                                         CURS0042
          VMID = MIN(VMAX,VMID)                                         CURS0043
          VTOP = MIN(VMAX,VTOP)                                         CURS0044
                                                                        CURS0045
C----     Convert into PostScript coordinates                           CURS0046
          YBOT(CURRNT) = YPOS1 + YSCALE * (VBOT - VMIN)                 CURS0047
          YMID(CURRNT) = YPOS1 + YSCALE * (VMID - VMIN)                 CURS0048
          YTOP(CURRNT) = YPOS1 + YSCALE * (VTOP - VMIN)                 CURS0049
                                                                        CURS0050
C----     If this is not the first point, draw shaded region and line seCURS0051
          IF (IRESOL.GT.1) THEN                                         CURS0052
                                                                        CURS0053
C----         Draw the shaded region                                    CURS0054
              CALL PSHADE(0.5,COLOUR,RGB,MXCOLR,INCOLR)                 CURS0055
              CALL PSUBOX(X(LAST),YBOT(LAST),X(LAST),YTOP(LAST),        CURS0056
     &            X(CURRNT),YTOP(CURRNT),X(CURRNT),YBOT(CURRNT))        CURS0057
                                                                        CURS0058
C----         Draw the three line segments                              CURS0059
              CALL PSLINE(X(LAST),YBOT(LAST),X(CURRNT),YBOT(CURRNT))    CURS0060
              CALL PSLINE(X(LAST),YMID(LAST),X(CURRNT),YMID(CURRNT))    CURS0061
              CALL PSLINE(X(LAST),YTOP(LAST),X(CURRNT),YTOP(CURRNT))    CURS0062
          ENDIF                                                         CURS0063
                                                                        CURS0064
C----     Increment resolution value and swap storage pointers          CURS0065
          RESOL = RESOL + RGAP                                          CURS0066
          CURRNT = 3 - CURRNT                                           CURS0067
          LAST = 3 - LAST                                               CURS0068
200   CONTINUE                                                          CURS0069
                                                                        CURS0070
      RETURN                                                            CURS0071
      END                                                               CURS0072
                                                                        CURS0073
      SUBROUTINE QSTAT(ISET,NBETTE,NWORSE)                              QSTA0001
C-----------------------------------------------------------------------QSTA0002
C                                                                       QSTA0003
C  SUBROUTINE QSTAT  -  Print the overall statistics on the main-chain  QSTA0004
C                       and side-chain parameters plots                 QSTA0005
C                                                                       QSTA0006
C----------------------------------------------------------------------+QSTA0007
                                                                        QSTA0008
CHECK v.3.2-->                                                          QSTA0009
C      SUBROUTINE QSTAT(ISET)                                           QSTA0010
CHECK v.3.2<--                                                          QSTA0011
                                                                        QSTA0012
      SAVE                                                              QSTA0013
                                                                        QSTA0014
      INCLUDE 'pplot.inc'                                               QSTA0015
                                                                        QSTA0016
      CHARACTER*7   INOUT                                               QSTA0017
      CHARACTER*100 IREC                                                QSTA0018
CHECK v.3.2-->                                                          QSTA0019
C      INTEGER       IGRAPH, ISET, NGRAPH, TGRAPH                       QSTA0020
      INTEGER       IGRAPH, ISET, NBETTE, NGRAPH, NWORSE, TGRAPH        QSTA0021
CHECK v.3.2<--                                                          QSTA0022
      LOGICAL       FIRST, REVERS                                       QSTA0023
      REAL          BANDS, CMPVAL, XCENTR, XPOS1, XPOS2, XPOS3, XPOS4,  QSTA0024
     &              XPOS5, XPOS6, XSTART, Y, YGAP                       QSTA0025
                                                                        QSTA0026
      DATA  FIRST / .TRUE. /                                            QSTA0027
      DATA  XSTART, YGAP / -20.0, 9.0 /                                 QSTA0028
      DATA  XPOS1, XPOS2, XPOS3, XPOS4, XPOS5, XPOS6                    QSTA0029
     &    / 135.0, 177.0, 220.0, 256.0, 301.0, 323.0 /                  QSTA0030
                                                                        QSTA0031
C---- Initialise variables                                              QSTA0032
      XCENTR = XORIGN + XMWID + XSEP / 2.0                              QSTA0033
      IF (FIRST) THEN                                                   QSTA0034
          XSTART = XORIGN + XSTART                                      QSTA0035
          XPOS1 = XORIGN + XPOS1                                        QSTA0036
          XPOS2 = XORIGN + XPOS2                                        QSTA0037
          XPOS3 = XORIGN + XPOS3                                        QSTA0038
          XPOS4 = XORIGN + XPOS4                                        QSTA0039
          XPOS5 = XORIGN + XPOS5                                        QSTA0040
          XPOS6 = XORIGN + XPOS6                                        QSTA0041
          FIRST = .FALSE.                                               QSTA0042
      ENDIF                                                             QSTA0043
      Y = YORIGN - 32.0                                                 QSTA0044
                                                                        QSTA0045
C---- Print statistics                                                  QSTA0046
      CALL PSCTXT(XCENTR,Y,12.0,'Plot statistics')                      QSTA0047
      Y = Y - 1.5 * YGAP                                                QSTA0048
                                                                        QSTA0049
C---- Column headings                                                   QSTA0050
      CALL PSCTXT((XPOS3 + XPOS4) / 2.0,Y,9.0,'Comparison values')      QSTA0051
      CALL PSCTXT(XPOS5,Y,9.0,'No. of')                                 QSTA0052
      Y = Y - YGAP                                                      QSTA0053
      WRITE(IREC,100)                                                   QSTA0054
 100  FORMAT(                                                           QSTA0055
     &    '                                No. of   Parameter  Typic',  QSTA0056
     &    'al   Band    band widths          ')                         QSTA0057
      CALL QPUT(XSTART,XPOS1,XPOS2,XPOS3,XPOS4,XPOS5,XPOS6,Y,YGAP,      QSTA0058
     &    IREC)                                                         QSTA0059
      WRITE(IREC,120)                                                   QSTA0060
 120  FORMAT(                                                           QSTA0061
     &    'Stereochemical parameter       data pts    value     valu',  QSTA0062
     &    'e    width    from mean           ')                         QSTA0063
      CALL QPUT(XSTART,XPOS1,XPOS2,XPOS3,XPOS4,XPOS5,XPOS6,Y,YGAP,      QSTA0064
     &    IREC)                                                         QSTA0065
      Y = Y - YGAP / 2.0                                                QSTA0066
      CALL PSLWID(0.2)                                                  QSTA0067
      CALL PSLINE(XSTART,Y + 0.5 * YGAP,XPOS6,Y + 0.5 * YGAP)           QSTA0068
      Y = Y - YGAP / 2.0                                                QSTA0069
                                                                        QSTA0070
C---- Initialise graph start                                            QSTA0071
      NGRAPH = (ISET - 1) * 6                                           QSTA0072
      IF (ISET.EQ.1) THEN                                               QSTA0073
          TGRAPH = 6                                                    QSTA0074
      ELSE                                                              QSTA0075
          TGRAPH = 5                                                    QSTA0076
      ENDIF                                                             QSTA0077
                                                                        QSTA0078
C---- Loop through the graphs on this plot                              QSTA0079
      DO 500, IGRAPH = 1, TGRAPH                                        QSTA0080
          NGRAPH = NGRAPH + 1                                           QSTA0081
          IF (NGRAPH.EQ.1 .OR. NGRAPH.EQ.6) THEN                        QSTA0082
              REVERS = .TRUE.                                           QSTA0083
          ELSE                                                          QSTA0084
              REVERS = .FALSE.                                          QSTA0085
          ENDIF                                                         QSTA0086
          CALL BANDIS(0.0,COEFF(3,NGRAPH),COEFF(2,NGRAPH),              QSTA0087
     &        COEFF(1,NGRAPH),RESOL,SVALUE(NGRAPH),CMPVAL,              QSTA0088
     &        YBAND(NGRAPH),BANDS,INOUT,REVERS)                         QSTA0089
          WRITE(IREC,220) DESC(NGRAPH), NVALUE(NGRAPH), SVALUE(NGRAPH), QSTA0090
     &        CMPVAL, YBAND(NGRAPH), BANDS, INOUT                       QSTA0091
 220      FORMAT(A30,I6,4X,F8.1,2X,F8.1,F8.1,3X,F8.1,4X,A)              QSTA0092
          CALL QPUT(XSTART,XPOS1,XPOS2,XPOS3,XPOS4,XPOS5,XPOS6,Y,YGAP,  QSTA0093
     &        IREC)                                                     QSTA0094
                                                                        QSTA0095
CHECK v.3.2-->                                                          QSTA0096
C----     Increment the appropriate count                               QSTA0097
          IF (INOUT.EQ.'BETTER') THEN                                   QSTA0098
              NBETTE = NBETTE + 1                                       QSTA0099
          ELSE IF (INOUT.EQ.'WORSE') THEN                               QSTA0100
              NWORSE = NWORSE + 1                                       QSTA0101
          ELSE                                                          QSTA0102
              NBETTE = NBETTE + 1                                       QSTA0103
          ENDIF                                                         QSTA0104
CHECK v.3.2<--                                                          QSTA0105
 500  CONTINUE                                                          QSTA0106
                                                                        QSTA0107
      RETURN                                                            QSTA0108
      END                                                               QSTA0109
                                                                        QSTA0110
      SUBROUTINE QPUT(XSTART,X1,X2,X3,X4,X5,X6,Y,YGAP,IREC)             QPUT0001
C-----------------------------------------------------------------------QPUT0002
C                                                                       QPUT0003
C  SUBROUTINE QPUT  -  Print statistics line for stereochemical quality QPUT0004
C                      plot                                             QPUT0005
C                                                                       QPUT0006
C----------------------------------------------------------------------+QPUT0007
                                                                        QPUT0008
      CHARACTER*(*) IREC                                                QPUT0009
      REAL          XSTART, X1, X2, X3, X4, X5, X6, Y, YGAP             QPUT0010
                                                                        QPUT0011
C---- Print the text and numbers                                        QPUT0012
      CALL PSTEXT(XSTART,Y,9.0,IREC(1:30))                              QPUT0013
      CALL PSCTXT(X1,Y,9.0,IREC(31:40))                                 QPUT0014
      CALL PSCTXT(X2,Y,9.0,IREC(41:51))                                 QPUT0015
      CALL PSCTXT(X3,Y,9.0,IREC(52:60))                                 QPUT0016
      CALL PSCTXT(X4,Y,9.0,IREC(61:68))                                 QPUT0017
      CALL PSCTXT(X5,Y,9.0,IREC(69:81))                                 QPUT0018
      CALL PSTEXT(X6,Y,9.0,IREC(82:88))                                 QPUT0019
                                                                        QPUT0020
C---- Increment y-value                                                 QPUT0021
      Y = Y - YGAP                                                      QPUT0022
                                                                        QPUT0023
      RETURN                                                            QPUT0024
      END                                                               QPUT0025
                                                                        QPUT0026
      SUBROUTINE PINS                                                   PINS0001
C-----------------------------------------------------------------------PINS0002
C                                                                       PINS0003
C  SUBROUTINE PINS  -   Third pass through files to produce pins plot   PINS0004
C                                                                       PINS0005
C----------------------------------------------------------------------+PINS0006
                                                                        PINS0007
      INCLUDE 'pplot.inc'                                               PINS0008
                                                                        PINS0009
      CHARACTER*1   BRKCH, INCHN, CHNEND, CIS, DAMINO, LSTBRK, LSTCHN,  PINS0010
CHECK v.3.2-->                                                          PINS0011
C     -              NXTCHN, NXTSTR, OLDCHN, PINCIS(MXPINS), SECSTR     PINS0012
     &              NXTCHN, NXTCIS, NXTSTR, OLDCHN, PINCIS(MXPINS),     PINS0013
     &              SECSTR                                              PINS0014
CHECK v.3.2<--                                                          PINS0015
      CHARACTER*2   PINCHN(MXPINS), PINSST(MXPINS)                      PINS0016
CHECK v.3.2-->                                                          PINS0017
C      CHARACTER*3   PINRES(MXPINS), RESDUE                             PINS0018
      CHARACTER*3   CISPEP, PINRES(MXPINS), RESDUE                      PINS0019
CHECK v.3.2<--                                                          PINS0020
      CHARACTER*5   PINSNO(MXPINS), SEQNO                               PINS0021
CHECK v.3.0.1-->                                                        PINS0022
C      CHARACTER*80  IREC                                               PINS0023
CHECK v.3.0.1<--                                                        PINS0024
      INTEGER       BGAP, COLPOS(MXCOLS), FGAP, FPIN, IDIST, IGAP, LINE,PINS0025
     &              LINEA, NGAP, NPIN, OOI1, OOI2, PINREG(MXPINS),      PINS0026
     &              REGTYP, SERNO, THEPIN                               PINS0027
      LOGICAL       BRKPOS(MXPINS), PAGEND, PINOPE                      PINS0028
      REAL          CALVAL, CGAMB, CH1VAL, CHI1, CHI2, CHI3, CHI4,      PINS0029
     &              DIHANG, DISULF, ENHB, HBVAL, LAVVAL, LCCVAL,        PINS0030
CHECK v.3.2-->                                                          PINS0031
C     -              LPPVAL, LSTCHX, LSTCHY, MCBVAL, MXDEVR, OMEGA,     PINS0032
C     -              OMEVAL, PHI, PINACC(MXPINS), PINDAT(MXPINS,3),     PINS0033
C     -              PINDEV(MXPINS), PINSCO(NDISTR,MXPINS), PSI, SCBVAL,PINS0034
CCHECK v.3.1-->                                                         PINS0035
CC     -              SCORE(NDISTR), VALUE(MXPLOT)                      PINS0036
C     -              SCORE(NDISTR), VALACC, VALUE(MXPLOT)               PINS0037
CCHECK v.3.1<--                                                         PINS0038
     &              LPPVAL, LSTCHX, LSTCHY, MCBSTD, MCBVAL, MXDEVR,     PINS0039
     &              OMEGA, OMEVAL, PHI, PINACC(MXPINS),                 PINS0040
     &              PINDAT(MXPINS,3), PINDEV(MXPINS),                   PINS0041
     &              PINSCO(NDISTR,MXPINS), PSI, SCBSTD, SCBVAL,         PINS0042
     &              SCORE(NDISTR), VALACC, VALUE(MXPLOT)                PINS0043
CHECK v.3.2<--                                                          PINS0044
                                                                        PINS0045
      DATA COLPOS /  18,  27,  33,  39,  45,  51,  57,  63,  70,  78,   PINS0046
     &               85,  93, 100, 109, 116 /                           PINS0047
                                                                        PINS0048
      DATA BGAP, FGAP / 2, 10 /                                         PINS0049
                                                                        PINS0050
C---- Initialise variables                                              PINS0051
      NBADPR = 0                                                        PINS0052
CHECK v.3.2-->                                                          PINS0053
      NXTCIS = ' '                                                      PINS0054
CHECK v.3.2<--                                                          PINS0055
      DO 50, NPIN = 1, MXPINS                                           PINS0056
          PINACC(NPIN) = 0.0                                            PINS0057
          PINCIS(NPIN) = ' '                                            PINS0058
          PINDAT(NPIN,1) = 0.0                                          PINS0059
          PINDAT(NPIN,2) = 0.0                                          PINS0060
          PINDAT(NPIN,3) = 0.0                                          PINS0061
          PINDEV(NPIN) = 0.0                                            PINS0062
          PINRES(NPIN) = ' '                                            PINS0063
          PINSST(NPIN) = '='                                            PINS0064
          PINREG(NPIN) = 0                                              PINS0065
          PINCHN(NPIN) = ' '                                            PINS0066
          DO 10, IDIST = 1, NDISTR                                      PINS0067
              PINSCO(IDIST,NPIN) = 999.99                               PINS0068
 10       CONTINUE                                                      PINS0069
          PINSNO(NPIN) = ' '                                            PINS0070
 50   CONTINUE                                                          PINS0071
      PINOPE = .FALSE.                                                  PINS0072
      PLTYPE = 3                                                        PINS0073
                                                                        PINS0074
C---- Open asterisks print file, and write headers                      PINS0075
      CALL ASTOPE                                                       PINS0076
      IF (IFAIL) GO TO 999                                              PINS0077
                                                                        PINS0078
C---- Rewind the residue-information file (.rin), the .sdh file and,    PINS0079
C     if it exists, the .rsa file                                       PINS0080
      REWIND(1)                                                         PINS0081
      REWIND(3)                                                         PINS0082
CHECK v.3.1-->                                                          PINS0083
      IF (ACCESS) REWIND(13)                                            PINS0084
CHECK v.3.1<--                                                          PINS0085
                                                                        PINS0086
C---- Initialise variables                                              PINS0087
      FPIN = 0                                                          PINS0088
      LINE = 0                                                          PINS0089
      LINEA = 0                                                         PINS0090
      NPIN = 0                                                          PINS0091
      THEPIN = MXPINS                                                   PINS0092
      IF (NRESID.LT.MXPINS .AND. NRESID.GT.2) THEPIN = NRESID           PINS0093
      THEPIN = MXPINS                                                   PINS0094
      NPLOTS = NPLOTS + NRESID / MXPINS                                 PINS0095
                                                                        PINS0096
C---- Read in the first record from the residue-information file        PINS0097
      READ(1,80,END=500,ERR=902) SERNO, RESDUE, BRKCH, INCHN, SEQNO,    PINS0098
     &    SECSTR, PHI, PSI, OMEGA, CHI1, CHI2, CHI3, CHI4, ENHB,        PINS0099
CHECK v.3.2-->                                                          PINS0100
C     -    DISULF, DIHANG, CGAMB, MCBVAL, SCBVAL, OOI1, OOI2            PINS0101
C 80   FORMAT(I4,A3,A1,A1,A5,A1,11F7.2,2F7.3,2I3)                       PINS0102
     &    DISULF, DIHANG, CGAMB, MCBVAL, SCBVAL, OOI1, OOI2, MCBSTD,    PINS0103
     &    SCBSTD                                                        PINS0104
 80   FORMAT(I4,A3,A1,A1,A5,A1,11F7.2,2F7.3,2I3,2F7.3)                  PINS0105
CHECK v.3.2<--                                                          PINS0106
      LINE = LINE + 1                                                   PINS0107
      CHNEND = '>'                                                      PINS0108
      LSTBRK = BRKCH                                                    PINS0109
      LSTCHN = ' '                                                      PINS0110
      NXTCHN = INCHN                                                    PINS0111
      NXTSTR = SECSTR                                                   PINS0112
      OLDCHN = ' '                                                      PINS0113
                                                                        PINS0114
C---- Read in the corresponding record from the .sdh file               PINS0115
      CALL REASDH(SERNO,LAVVAL,LCCVAL,LPPVAL,SCORE)                     PINS0116
                                                                        PINS0117
CHECK v.3.1-->                                                          PINS0118
C---- If using the calculated accessibilities, read in the correspondingPINS0119
C     record from the .rsa file                                         PINS0120
      IF (ACCESS) THEN                                                  PINS0121
          CALL REARSA(INCHN,SEQNO,RESDUE,VALACC)                        PINS0122
      ENDIF                                                             PINS0123
CHECK v.3.1<--                                                          PINS0124
                                                                        PINS0125
C---- Read through the residues file (.rin)                             PINS0126
 100  CONTINUE                                                          PINS0127
                                                                        PINS0128
C----     Only process this residue if it belongs to the required chain PINS0129
          IF (CHAIN.EQ.' ' .OR. INCHN.EQ.CHAIN) THEN                    PINS0130
                                                                        PINS0131
C----         Calculate absolute deviations of values that might be requPINS0132
C             for Residues plot                                         PINS0133
                                                                        PINS0134
C----         Chi-1 (excl. PRO)                                         PINS0135
              IF (CHI1.LT.0.0) CHI1 = CHI1 + 360.0                      PINS0136
              IF (RESDUE.EQ.'PRO') CHI1 = 999.9                         PINS0137
              IF (CHI1.GE.0.0 .AND. CHI1.LE.120.0) THEN                 PINS0138
                  CH1VAL = ABS(CHI1 - GLOBGM)                           PINS0139
              ELSE IF (CHI1.GT.120.0 .AND. CHI1.LE.240.0) THEN          PINS0140
                  CH1VAL = ABS(CHI1 - GLOBGT)                           PINS0141
              ELSE IF (CHI1.GT.240.0 .AND. CHI1.LE.360.0) THEN          PINS0142
                  CH1VAL = ABS(CHI1 - GLOBGP)                           PINS0143
              ELSE                                                      PINS0144
                  CH1VAL = 999.9                                        PINS0145
              ENDIF                                                     PINS0146
                                                                        PINS0147
C----         Case of trans peptide (ie abs(omega) > 45)                PINS0148
CHECK v.3.2-->                                                          PINS0149
C              CIS = ' '                                                PINS0150
              CIS = NXTCIS                                              PINS0151
              CISPEP = ' '                                              PINS0152
              IF (CIS.EQ.'c') CISPEP = 'cis'                            PINS0153
              NXTCIS = ' '                                              PINS0154
CHECK v.3.2<--                                                          PINS0155
              IF (ABS(OMEGA).GE.45.0 .AND. OMEGA.LE.180.0) THEN         PINS0156
                  IF (OMEGA.LT.0.0) OMEGA = OMEGA + 360.0               PINS0157
                  OMEVAL = ABS(OMEGA - GLOBOM)                          PINS0158
                                                                        PINS0159
C----         Case of cis peptide (ie abs(omega) < 45)                  PINS0160
              ELSE IF (ABS(OMEGA).LT.45.0) THEN                         PINS0161
                  OMEVAL = ABS(OMEGA)                                   PINS0162
CHECK v.3.2-->                                                          PINS0163
C                  CIS = 'c'                                            PINS0164
                  NXTCIS = 'c'                                          PINS0165
CHECK v.3.2<--                                                          PINS0166
              ELSE                                                      PINS0167
                  OMEVAL = 0.0                                          PINS0168
              ENDIF                                                     PINS0169
                                                                        PINS0170
C----         Hydrogen bond energy mean and standard deviation          PINS0171
              IF (ENHB.LT.0.0) THEN                                     PINS0172
                  HBVAL = ABS(ENHB - GLOBHB)                            PINS0173
              ELSE                                                      PINS0174
                  HBVAL = 0.0                                           PINS0175
              ENDIF                                                     PINS0176
                                                                        PINS0177
C----         Alpha carbon chirality                                    PINS0178
              DAMINO = ' '                                              PINS0179
              IF (DIHANG.NE.999.9) THEN                                 PINS0180
                  CALVAL = ABS(DIHANG - GLOBDH)                         PINS0181
                  IF (DIHANG.LT.0) DAMINO = 'D'                         PINS0182
              ELSE                                                      PINS0183
                  CALVAL = 0.0                                          PINS0184
              ENDIF                                                     PINS0185
                                                                        PINS0186
C----         Store the values required for the Residues plot           PINS0187
              VALUE(PLTCH1) = CH1VAL                                    PINS0188
              VALUE(PLTOME) = OMEVAL                                    PINS0189
              VALUE(PLTHB) = HBVAL                                      PINS0190
              VALUE(PLTCAL) = CALVAL                                    PINS0191
              VALUE(PLTCGB) = CGAMB                                     PINS0192
              VALUE(PLTMCB) = MCBVAL                                    PINS0193
              VALUE(PLTSCB) = SCBVAL                                    PINS0194
              VALUE(PLTLPP) = LPPVAL                                    PINS0195
              VALUE(PLTLCC) = LCCVAL                                    PINS0196
              VALUE(PLTLAV) = LAVVAL                                    PINS0197
              VALUE(PLTOOI) = 100.0 * (OOIMAX - OOI2)                   PINS0198
     &            / (OOIMAX - OOIMIN)                                   PINS0199
CHECK v.3.1-->                                                          PINS0200
              VALUE(PLTACC) = VALACC                                    PINS0201
CHECK v.3.1<--                                                          PINS0202
CHECK v.3.2-->                                                          PINS0203
              VALUE(PLTSDM) = MCBSTD                                    PINS0204
              VALUE(PLTSDS) = SCBSTD                                    PINS0205
CHECK v.3.2<--                                                          PINS0206
                                                                        PINS0207
C----         Print current residue's data on asterisks print           PINS0208
              CALL ASTPRN(SERNO,RESDUE,INCHN,SEQNO,                     PINS0209
     &            SECSTR,PHI,PSI,OMEGA,CHI1,CHI2,CHI3,ENHB,DISULF,      PINS0210
CHECK v.3.2-->                                                          PINS0211
C     -            DIHANG,CGAMB,MXDEVR,REGTYP)                          PINS0212
     &            DIHANG,MXDEVR,REGTYP,CISPEP)                          PINS0213
CHECK v.3.2<--                                                          PINS0214
                                                                        PINS0215
C----         Move required values across into plot-arrays              PINS0216
              NPIN = NPIN + 1                                           PINS0217
              IF (PLTNUM(1).GT.0) PINDAT(NPIN,1) = VALUE(PLTNUM(1))     PINS0218
              IF (PLTNUM(2).GT.0) PINDAT(NPIN,2) = VALUE(PLTNUM(2))     PINS0219
              IF (PLTNUM(3).GT.0) PINDAT(NPIN,3) = VALUE(PLTNUM(3))     PINS0220
              BRKPOS(NPIN) = .FALSE.                                    PINS0221
              PINRES(NPIN) = RESDUE                                     PINS0222
CHECK v.3.1-->                                                          PINS0223
C              PINACC(NPIN) = VALUE(PLTOOI)                             PINS0224
              IF (ACCESS) THEN                                          PINS0225
                  PINACC(NPIN) = VALACC                                 PINS0226
              ELSE                                                      PINS0227
                  PINACC(NPIN) = VALUE(PLTOOI)                          PINS0228
              ENDIF                                                     PINS0229
CHECK v.3.1<--                                                          PINS0230
              IF (CIS.EQ.'c' .AND. DAMINO.EQ.'D') THEN                  PINS0231
                  PINCIS(NPIN) = 'X'                                    PINS0232
              ELSE IF (CIS.EQ.'c') THEN                                 PINS0233
                  PINCIS(NPIN) = CIS                                    PINS0234
              ELSE IF (DAMINO.EQ.'D') THEN                              PINS0235
                  PINCIS(NPIN) = DAMINO                                 PINS0236
              ENDIF                                                     PINS0237
              PINSST(NPIN) = SECSTR // '='                              PINS0238
              CHNEND = ' '                                              PINS0239
              IF (LINE.EQ.1) CHNEND = '>'                               PINS0240
              IF (LINE.EQ.NRESID) CHNEND = '<'                          PINS0241
              PINCHN(NPIN) = INCHN // CHNEND                            PINS0242
              DO 200, IDIST = 1, NDISTR                                 PINS0243
                  PINSCO(IDIST,NPIN) = SCORE(IDIST)                     PINS0244
 200          CONTINUE                                                  PINS0245
              PINSNO(NPIN) = SEQNO                                      PINS0246
                                                                        PINS0247
C----         Store maximum deviation score                             PINS0248
              PINDEV(NPIN) = MXDEVR                                     PINS0249
              IF (RESDUE.NE.'GLY') THEN                                 PINS0250
                  PINREG(NPIN) = REGTYP                                 PINS0251
              ELSE                                                      PINS0252
                  PINREG(NPIN) = 0                                      PINS0253
              ENDIF                                                     PINS0254
          ENDIF                                                         PINS0255
                                                                        PINS0256
C----     Read in the next record from the residue-information file to pPINS0257
C         up chain ID and secondary structure of next residue           PINS0258
          OLDCHN = INCHN                                                PINS0259
          READ(1,80,END=500,ERR=902) SERNO, RESDUE, BRKCH, INCHN, SEQNO,PINS0260
     &        SECSTR, PHI, PSI, OMEGA, CHI1, CHI2, CHI3, CHI4, ENHB,    PINS0261
CHECK v.3.2-->                                                          PINS0262
C     -        DISULF, DIHANG, CGAMB, MCBVAL, SCBVAL, OOI1, OOI2        PINS0263
     &        DISULF, DIHANG, CGAMB, MCBVAL, SCBVAL, OOI1, OOI2, MCBSTD,PINS0264
     &        SCBSTD                                                    PINS0265
CHECK v.3.2<--                                                          PINS0266
          LINE = LINE + 1                                               PINS0267
          NXTCHN = INCHN                                                PINS0268
          NXTSTR = SECSTR                                               PINS0269
          IF (NPIN.GT.0) PINSST(NPIN)(2:2) = NXTSTR                     PINS0270
                                                                        PINS0271
C----     Read in the corresponding record from .sdh                    PINS0272
          CALL REASDH(SERNO,LAVVAL,LCCVAL,LPPVAL,SCORE)                 PINS0273
                                                                        PINS0274
CHECK v.3.1-->                                                          PINS0275
C----     Read in the corresponding record from .rsa, if present        PINS0276
          IF (ACCESS) THEN                                              PINS0277
              CALL REARSA(INCHN,SEQNO,RESDUE,VALACC)                    PINS0278
          ENDIF                                                         PINS0279
CHECK v.3.1<--                                                          PINS0280
                                                                        PINS0281
C----     Determine whether at a chain-end or chain-start               PINS0282
          IF (NPIN.GT.0) THEN                                           PINS0283
              IF (OLDCHN.NE.NXTCHN) THEN                                PINS0284
                  CHNEND = '<'                                          PINS0285
                  PINCHN(NPIN)(2:2) = CHNEND                            PINS0286
              ELSE IF (OLDCHN.NE.LSTCHN) THEN                           PINS0287
                  CHNEND = '>'                                          PINS0288
                  PINCHN(NPIN)(2:2) = CHNEND                            PINS0289
              ELSE IF (LSTBRK.EQ.'!' .AND. BRKCH.EQ.'!') THEN           PINS0290
                  CHNEND = '<'                                          PINS0291
                  PINCHN(NPIN)(2:2) = CHNEND                            PINS0292
                  CHNEND = '!'                                          PINS0293
              ELSE IF (LSTBRK.EQ.'!' .AND. BRKCH.EQ.' ') THEN           PINS0294
                  CHNEND = '>'                                          PINS0295
                  PINCHN(NPIN)(2:2) = CHNEND                            PINS0296
              ENDIF                                                     PINS0297
              LSTBRK = BRKCH                                            PINS0298
              LSTCHN = OLDCHN                                           PINS0299
          ENDIF                                                         PINS0300
                                                                        PINS0301
C----     If have a pageful of data, then produce the pinplot           PINS0302
          IF (NPIN.EQ.THEPIN) THEN                                      PINS0303
              IF (PLOTPN) THEN                                          PINS0304
                                                                        PINS0305
C----             If current PostScript file is open, close it          PINS0306
                  IF (PINOPE) THEN                                      PINS0307
CHECK v.3.2-->                                                          PINS0308
C                      CALL PSCLOS(BBOXX1,BBOXX2,BBOXY1,BBOXY2)         PINS0309
                      CALL PSENDP                                       PINS0310
                      IF (.NOT.COMBPS) THEN                             PINS0311
                          CALL PSCLOS(BBOXX1,BBOXX2,BBOXY1,BBOXY2)      PINS0312
                      ENDIF                                             PINS0313
CHECK v.3.2<--                                                          PINS0314
                  ENDIF                                                 PINS0315
                                                                        PINS0316
C----             Produce current page                                  PINS0317
                  CALL PINPLT(THEPIN,NPIN,FPIN,PINDAT,PINDEV,PINRES,    PINS0318
     &                PINSST,PINREG,PINCHN,PINSNO,BRKPOS,PINACC,        PINS0319
     &                PINSCO,PINCIS,LSTCHX,LSTCHY)                      PINS0320
                  PINOPE = .TRUE.                                       PINS0321
              ENDIF                                                     PINS0322
              FPIN = FPIN + THEPIN                                      PINS0323
              NPIN = 0                                                  PINS0324
              CHNEND = ' '                                              PINS0325
          ENDIF                                                         PINS0326
                                                                        PINS0327
C----     Check whether this residue is the end of a chain              PINS0328
          IF (CHNEND.EQ.'<' .OR. CHNEND.EQ.'!') THEN                    PINS0329
                                                                        PINS0330
C----         Leave the appropriate number of blanks between the chains PINS0331
              PAGEND = .FALSE.                                          PINS0332
              IF (CHNEND.EQ.'<') THEN                                   PINS0333
                  NGAP = FGAP                                           PINS0334
              ELSE                                                      PINS0335
                  NGAP = BGAP                                           PINS0336
              ENDIF                                                     PINS0337
              DO 300, IGAP = 1, NGAP                                    PINS0338
                                                                        PINS0339
C----             Add blanks providing that haven't reached end of page PINS0340
                  IF (.NOT.PAGEND) THEN                                 PINS0341
                      NPIN = NPIN + 1                                   PINS0342
                      BRKPOS(NPIN) = .TRUE.                             PINS0343
                                                                        PINS0344
C----                 If have a pageful of data, then produce the pinploPINS0345
                      IF (NPIN.EQ.THEPIN) THEN                          PINS0346
                          IF (PLOTPN) THEN                              PINS0347
                                                                        PINS0348
C----                         If current PostScript file is open, close PINS0349
                              IF (PINOPE) THEN                          PINS0350
CHECK v.3.2-->                                                          PINS0351
C                                  CALL PSCLOS(BBOXX1,BBOXX2,BBOXY1,    PINS0352
C     -                                BBOXY2)                          PINS0353
                                  CALL PSENDP                           PINS0354
                                  IF (.NOT.COMBPS) THEN                 PINS0355
                                      CALL PSCLOS(BBOXX1,BBOXX2,BBOXY1, PINS0356
     &                                    BBOXY2)                       PINS0357
                                  ENDIF                                 PINS0358
CHECK v.3.2<--                                                          PINS0359
                              ENDIF                                     PINS0360
                                                                        PINS0361
C----                         Produce current page                      PINS0362
                              CALL PINPLT(THEPIN,NPIN,FPIN,PINDAT,      PINS0363
     &                            PINDEV,PINRES,PINSST,PINREG,PINCHN,   PINS0364
     &                            PINSNO,BRKPOS,PINACC,PINSCO,PINCIS,   PINS0365
     &                            LSTCHX,LSTCHY)                        PINS0366
                              PINOPE = .TRUE.                           PINS0367
                          ENDIF                                         PINS0368
                          FPIN = FPIN + THEPIN                          PINS0369
                          NPIN = 0                                      PINS0370
                          CHNEND = ' '                                  PINS0371
                          PAGEND = .TRUE.                               PINS0372
                      ENDIF                                             PINS0373
                  ENDIF                                                 PINS0374
 300          CONTINUE                                                  PINS0375
          ENDIF                                                         PINS0376
                                                                        PINS0377
C---- Loop back for next record in file                                 PINS0378
      GO TO 100                                                         PINS0379
                                                                        PINS0380
C---- End of file reached                                               PINS0381
 500  CONTINUE                                                          PINS0382
                                                                        PINS0383
C---- If any more data left to be printed, then produce the pinplot     PINS0384
      IF (PLOTPN .AND. NPIN.GT.0) THEN                                  PINS0385
                                                                        PINS0386
C----      If current PostScript file is open, close it                 PINS0387
           IF (PINOPE) THEN                                             PINS0388
CHECK v.3.2-->                                                          PINS0389
C               CALL PSCLOS(BBOXX1,BBOXX2,BBOXY1,BBOXY2)                PINS0390
               CALL PSENDP                                              PINS0391
               IF (.NOT.COMBPS) THEN                                    PINS0392
                   CALL PSCLOS(BBOXX1,BBOXX2,BBOXY1,BBOXY2)             PINS0393
               ENDIF                                                    PINS0394
CHECK v.3.2<--                                                          PINS0395
           ENDIF                                                        PINS0396
                                                                        PINS0397
C----     Produce current page                                          PINS0398
          CALL PINPLT(THEPIN,NPIN,FPIN,PINDAT,PINDEV,PINRES,            PINS0399
     &        PINSST,PINREG,PINCHN,PINSNO,BRKPOS,PINACC,PINSCO,PINCIS,  PINS0400
     &        LSTCHX,LSTCHY)                                            PINS0401
          PINOPE = .TRUE.                                               PINS0402
      ENDIF                                                             PINS0403
                                                                        PINS0404
C---- Plot the overall G-factors for the protein as a whole on the      PINS0405
C     PROCHECKer board                                                  PINS0406
      IF (PLOTPN) THEN                                                  PINS0407
CHECK v.3.2-->                                                          PINS0408
C          CALL PINGFS(LSTCHX,XGAP,LSTCHY,YHT,GFACTR,NDISTR,INCOLR,     PINS0409
          CALL PINGFS(LSTCHX,XGAP,LSTCHY,YHT,GFACTR,NDISTR,             PINS0410
     &        INCOLR(PLTYPE),                                           PINS0411
CHECK v.3.2<--                                                          PINS0412
     &        MXCOLR,RGB,COLPLT(PLTYPE,11),COLPLT(PLTYPE,12),           PINS0413
     &        NCOVAL,NDIHED)                                            PINS0414
CHECK v.3.2-->                                                          PINS0415
          CALL PSENDP                                                   PINS0416
CHECK v.3.2<--                                                          PINS0417
          CALL PSCLOS(BBOXX1,BBOXX2,BBOXY1,BBOXY2)                      PINS0418
      ENDIF                                                             PINS0419
                                                                        PINS0420
C---- Print totals for asterisks print                                  PINS0421
CHECK v.3.2-->                                                          PINS0422
C      CALL ASTEND(MXCOLS,COLPOS)                                       PINS0423
      CALL ASTEND(MXCOLS,COLPOS,1)                                      PINS0424
CHECK v.3.2<--                                                          PINS0425
                                                                        PINS0426
C---- Print mean values for each parameter on asterisks print           PINS0427
      CALL ASTMEA                                                       PINS0428
                                                                        PINS0429
C---- Print the key and statistical data                                PINS0430
      CALL ASTKEY                                                       PINS0431
                                                                        PINS0432
C---- List the bond lengths and angles                                  PINS0433
      CALL ASTLAN                                                       PINS0434
                                                                        PINS0435
C---- List the bad contacts, if required                                PINS0436
      IF (BCLIST .AND. NONBON) THEN                                     PINS0437
          CALL ASTBAD                                                   PINS0438
      ENDIF                                                             PINS0439
                                                                        PINS0440
C---- Print statistics from the plots                                   PINS0441
      CALL ASTATS                                                       PINS0442
                                                                        PINS0443
CHECK v.3.3.2-->                                                        PINS0444
C---- Print statistics to the html file                                 PINS0445
      CALL HSTATS                                                       PINS0446
CHECK v.3.3.2<--                                                        PINS0447
                                                                        PINS0448
C---- Print the Morris et al. classification of the structure           PINS0449
      CALL MCLASS                                                       PINS0450
                                                                        PINS0451
C---- Print the G-factors for the protein                               PINS0452
      CALL GFACTS                                                       PINS0453
                                                                        PINS0454
CHECK v.3.3.2-->                                                        PINS0455
C---- Write the G-factors out to the html file                          PINS0456
      CALL GHTML                                                        PINS0457
CHECK v.3.3.2<--                                                        PINS0458
                                                                        PINS0459
      GO TO 999                                                         PINS0460
                                                                        PINS0461
C---- Fatal errors                                                      PINS0462
902   CONTINUE                                                          PINS0463
      PRINT*, '*** ERROR. Data error in .rin file at line:', LINE + 1   PINS0464
      GO TO 990                                                         PINS0465
                                                                        PINS0466
CHECK v.3.0.1-->                                                        PINS0467
C 904  CONTINUE                                                         PINS0468
C      PRINT*, '*** ERROR. Error reading .rsa file at line:', LINEA + 1 PINS0469
C      GO TO 990                                                        PINS0470
                                                                        PINS0471
C 906  CONTINUE                                                         PINS0472
C      PRINT*, '*** ERROR. Data error in .rsa file at line:', LINEA + 1 PINS0473
C      PRINT*, IREC                                                     PINS0474
C      GO TO 990                                                        PINS0475
CHECK v.3.0.1<--                                                        PINS0476
                                                                        PINS0477
990   CONTINUE                                                          PINS0478
      IFAIL = .TRUE.                                                    PINS0479
                                                                        PINS0480
 999  CONTINUE                                                          PINS0481
      RETURN                                                            PINS0482
      END                                                               PINS0483
                                                                        PINS0484
      SUBROUTINE PINPLT(THEPIN,NPIN,FPIN,PINDAT,PINDEV,PINRES,PINSST,   PINP0001
     &    PINREG,PINCHN,PINSNO,BRKPOS,PINACC,PINSCO,PINCIS,LSTCHX,      PINP0002
     &    LSTCHY)                                                       PINP0003
C-----------------------------------------------------------------------PINP0004
C                                                                       PINP0005
C  SUBROUTINE PINPLT  -  Print current page for pin plot                PINP0006
C                                                                       PINP0007
C----------------------------------------------------------------------+PINP0008
                                                                        PINP0009
      SAVE                                                              PINP0010
                                                                        PINP0011
      INCLUDE 'pplot.inc'                                               PINP0012
                                                                        PINP0013
      REAL          DASCOY, MAXDVY, NOTEX1, NOTEX2, NOTEY1, NOTEY2,     PINP0014
     &              SECSTY, SEQRMY                                      PINP0015
      PARAMETER    (                                                    PINP0016
     &              DASCOY = 189.0,                                     PINP0017
     &              MAXDVY = 144.0,                                     PINP0018
     &              NOTEX1 = 112.0,                                     PINP0019
CHECK v.3.1-->                                                          PINP0020
C     -              NOTEX2 = 157.0,                                    PINP0021
     &              NOTEX2 = 143.0,                                     PINP0022
CHECK v.3.1<--                                                          PINP0023
     &              NOTEY1 =  22.0,                                     PINP0024
     &              NOTEY2 =  30.0,                                     PINP0025
     &              SECSTY =  44.0,                                     PINP0026
     &              SEQRMY =  99.0                                      PINP0027
     &             )                                                    PINP0028
                                                                        PINP0029
      REAL          SIZLAB, TSIZE                                       PINP0030
      PARAMETER    (                                                    PINP0031
     &              SIZLAB =  10.0,                                     PINP0032
     &              TSIZE  =  15.0                                      PINP0033
     &             )                                                    PINP0034
                                                                        PINP0035
      INTEGER       THEPIN                                              PINP0036
                                                                        PINP0037
      CHARACTER*1   A, PINCIS(THEPIN), RCHAR                            PINP0038
      CHARACTER*2   PAGENO, PINCHN(THEPIN), PINSST(THEPIN)              PINP0039
      CHARACTER*3   CODE(20), PINRES(THEPIN)                            PINP0040
      CHARACTER*5   PINSNO(THEPIN), TICLAB(MXPINS)                      PINP0041
      CHARACTER*6   ASTER                                               PINP0042
      CHARACTER*7   PAGE                                                PINP0043
CHECK v.3.2-->                                                          PINP0044
      CHARACTER*9    PLHAND                                             PINP0045
CHECK v.3.2<--                                                          PINP0046
      CHARACTER*11  CLABEL(NDISTR)                                      PINP0047
      CHARACTER*20  AMINO, CDUMMY                                       PINP0048
      CHARACTER*26  LOWER                                               PINP0049
CHECK v.3.2-->                                                          PINP0050
C      CHARACTER*27  PLTYHD(MXPLOT)                                     PINP0051
      CHARACTER*32  PLTYHD(MXPLOT)                                      PINP0052
CHECK v.3.2<--                                                          PINP0053
CHECK v.3.1-->                                                          PINP0054
      CHARACTER*30  PLDESC                                              PINP0055
CHECK v.3.1<--                                                          PINP0056
      CHARACTER*55  PLTHED(MXPLOT)                                      PINP0057
CHECK v.3.2-->                                                          PINP0058
      CHARACTER*60   PTITLE                                             PINP0059
CHECK v.3.2<--                                                          PINP0060
      CHARACTER*100 IREC                                                PINP0061
      INTEGER       FPIN, ICODE, IDIST, IGRAPH, IPIN, IRGRAF, N, NPAGE, PINP0062
     &              NPIN, NSTD, PINREG(THEPIN), PLOTNO, PLTHLN(MXPLOT), PINP0063
     &              PLTYLN(MXPLOT), TICLEN(MXPINS)                      PINP0064
CHECK v.3.2-->                                                          PINP0065
C      LOGICAL       BRKPOS(MXPINS), TICPOS(MXPINS)                     PINP0066
      LOGICAL       BRKPOS(MXPINS), FIRST, TICPOS(MXPINS)               PINP0067
CHECK v.3.2<--                                                          PINP0068
      REAL          LSTCHX, LSTCHY, PINACC(THEPIN), PINDAT(THEPIN,3),   PINP0069
     &              PINDEV(THEPIN), PINSCO(NDISTR,THEPIN), RDUM1, RDUM2,PINP0070
     &              SCALEX, X, XCENTR, Y, YBOT, YDIFF, YP               PINP0071
                                                                        PINP0072
                                                                        PINP0073
      DATA  A      / 'A' /                                              PINP0074
      DATA  AMINO  / 'ACDEFGHIKLMNPQRSTVWY'/                            PINP0075
                                                                        PINP0076
      DATA  CLABEL /                                                    PINP0077
     &               'Phi-psi',                                         PINP0078
     &               'Chi1-chi2',                                       PINP0079
     &               'Chi1 only',                                       PINP0080
     &               'Chi3 & chi4',                                     PINP0081
     &               'Omega',                                           PINP0082
     &               'Dihedrals',                                       PINP0083
     &               'MC bonds',                                        PINP0084
     &               'MC angles',                                       PINP0085
     &               'Mainchain',                                       PINP0086
     &               'Overall' /                                        PINP0087
                                                                        PINP0088
      DATA  CODE   / 'ALA','CYS','ASP','GLU','PHE','GLY','HIS',         PINP0089
     &               'ILE','LYS','LEU','MET','ASN','PRO','GLN','ARG',   PINP0090
     &               'SER','THR','VAL','TRP','TYR' /                    PINP0091
      DATA  LOWER  / 'abcdefghijklmnopqrstuvwxyz' /                     PINP0092
      DATA  NPAGE  / 0 /                                                PINP0093
      DATA  PLTHED /                                                    PINP0094
     &    'x. Absolute deviation from mean Chi-1 value (excl. Pro)',    PINP0095
     &    'x. Absolute deviation from mean of omega torsion',           PINP0096
     &    'x. C-alpha chirality: abs. deviation of zeta torsion',       PINP0097
     &    'x. Absolute deviation from mean of H-bond energy',           PINP0098
     &    'x. Gamma atom B-value',                                      PINP0099
     &    'x. Average B-value of main-chain atoms',                     PINP0100
     &    'x. Average B-value of side-chain atoms',                     PINP0101
     &    'x. G-factor for phi-psi distribution',                       PINP0102
     &    'x. G-factor for chi1-chi2 distribution',                     PINP0103
     &    'x. Average residue G-factor',                                PINP0104
CHECK v.3.1-->                                                          PINP0105
C     -    'x. Approx. accessibility (based on Ooi numbers)'            PINP0106
     &    'x. Approx. accessibility (based on Ooi numbers)',            PINP0107
CHECK v.3.2-->                                                          PINP0108
C     -    'x. Percentage residue accessibility'                        PINP0109
     &    'x. Percentage residue accessibility',                        PINP0110
     &    'x. Standard deviation of main-chain atom B-values',          PINP0111
     &    'x. Standard deviation of side-chain atom B-values'           PINP0112
CHECK v.3.2<--                                                          PINP0113
CHECK v.3.1<--                                                          PINP0114
     &            /                                                     PINP0115
                                                                        PINP0116
CHECK v.3.1-->                                                          PINP0117
C      DATA  PLTHLN /  55, 48, 52, 48, 21, 38, 38, 36, 38, 27, 47 /     PINP0118
CHECK v.3.2-->                                                          PINP0119
C      DATA  PLTHLN /  55, 48, 52, 48, 21, 38, 38, 36, 38, 27, 47, 35 / PINP0120
      DATA  PLTHLN /  55, 48, 52, 48, 21, 38, 38, 36, 38, 27, 47, 35,   PINP0121
     &                49, 49 /                                          PINP0122
CHECK v.3.2<--                                                          PINP0123
CHECK v.3.1<--                                                          PINP0124
                                                                        PINP0125
      DATA  PLTYHD /                                                    PINP0126
     &    'Chi-1 abs. mean dev.',                                       PINP0127
     &    'Omega abs. mean dev.',                                       PINP0128
     &    'Zeta abs. mean dev.',                                        PINP0129
     &    'H-bond en. abs. mean dev.',                                  PINP0130
     &    'Gamma atom B-value',                                         PINP0131
     &    'Ave. main-chain B-value',                                    PINP0132
     &    'Ave. side-chain B-value',                                    PINP0133
     &    'G-factor',                                                   PINP0134
     &    'G-factor',                                                   PINP0135
     &    'G-factor',                                                   PINP0136
CHECK v.3.1-->                                                          PINP0137
C     -    'Estimated accessibility'                                    PINP0138
     &    'Estimated accessibility',                                    PINP0139
CHECK v.3.2-->                                                          PINP0140
C     -    '%-tage residue accessibility'                               PINP0141
     &    '%-tage residue accessibility',                               PINP0142
     &    'B-value st. dev.',                                           PINP0143
     &    'B-value st. dev.'                                            PINP0144
CHECK v.3.2<--                                                          PINP0145
CHECK v.3.1<--                                                          PINP0146
     &            /                                                     PINP0147
                                                                        PINP0148
CHECK v.3.1-->                                                          PINP0149
C      DATA  PLTYLN / 20, 20, 19, 25, 18, 23, 23, 8, 8, 8, 23 /         PINP0150
CHECK v.3.2-->                                                          PINP0151
C      DATA  PLTYLN / 20, 20, 19, 25, 18, 23, 23, 8, 8, 8, 23, 28 /     PINP0152
      DATA  PLTYLN / 20, 20, 19, 25, 18, 23, 23, 8, 8, 8, 23, 28,       PINP0153
     &               16, 16 /                                           PINP0154
CHECK v.3.2<--                                                          PINP0155
CHECK v.3.1<--                                                          PINP0156
                                                                        PINP0157
CHECK v.3.1-->                                                          PINP0158
      DATA  PLDESC / 'Residue properties plot' /                        PINP0159
CHECK v.3.1<--                                                          PINP0160
CHECK v.3.2-->                                                          PINP0161
      DATA  PLHAND / 'residprop' /                                      PINP0162
      DATA  PTITLE / 'Residue properties plot' /                        PINP0163
CHECK v.3.2<--                                                          PINP0164
                                                                        PINP0165
      DATA  RDUM1, RDUM2 / 999999.9, 999999.9 /                         PINP0166
                                                                        PINP0167
CHECK v.3.2-->                                                          PINP0168
      DATA  FIRST  / .TRUE. /                                           PINP0169
CHECK v.3.2<--                                                          PINP0170
                                                                        PINP0171
C---- Initialise variables                                              PINP0172
      XCENTR = XPORIG + XPWID / 2.0                                     PINP0173
      YP = YPORIG + 3.0 * YPWID + 2.0 * YPSEP                           PINP0174
      SCALEX = XPWID / THEPIN                                           PINP0175
                                                                        PINP0176
C---- Open new PostScript file                                          PINP0177
CHECK v.3.1-->                                                          PINP0178
C      CALL PSNAME(FILPS,ILEN,IPLOT)                                    PINP0179
CHECK v.3.2-->                                                          PINP0180
C      CALL PSNAME(FILPS,ILEN,IPLOT,PLDESC)                             PINP0181
C      PLDESC = ' '                                                     PINP0182
CHECK v.3.2<--                                                          PINP0183
CHECK v.3.1<--                                                          PINP0184
CHECK v.3.2-->                                                          PINP0185
C      CALL PSOPEN(FILPS,BBOXX1,BBOXX2,BBOXY1,BBOXY2,MXCOLR,            PINP0186
C     -    RGB,INCOLR(PLTYPE),COLPLT(PLTYPE,1))                         PINP0187
      IF (.NOT.COMBPS .OR. FIRST) THEN                                  PINP0188
          CALL PSNAME(FILPS,ILEN,IPLOT,PLDESC,PLHAND,WITHAN)            PINP0189
CHECK v.3.4-->                                                          PINP0190
C          CALL PSOPEN(FILPS,MXCOLR,RGB,INCOLR(PLTYPE),PTITLE,          PINP0191
C     -        NPAGE + 1)                                               PINP0192
          CALL PSOPEN(FILPS,MXCOLR,RGB,NCOLOR,INCOLR(PLTYPE),PTITLE,    PINP0193
     &        NPAGE + 1)                                                PINP0194
CHECK v.3.4<--                                                          PINP0195
          FIRST = .FALSE.                                               PINP0196
          PLDESC = ' '                                                  PINP0197
      ENDIF                                                             PINP0198
      CALL PSPAGE(FILPS,BBOXX1,BBOXX2,BBOXY1,BBOXY2,MXCOLR,             PINP0199
CHECK v.3.4-->                                                          PINP0200
C     -    RGB,INCOLR(PLTYPE),COLPLT(PLTYPE,1),NPAGE + 1,PLABEL)        PINP0201
     &    RGB,INCOLR(PLTYPE),COLPLT(PLTYPE,1),NPAGE + 1,PLABEL,.FALSE.) PINP0202
CHECK v.3.4<--                                                          PINP0203
CHECK v.3.2<--                                                          PINP0204
      CALL PSLWID(0.1)                                                  PINP0205
                                                                        PINP0206
C---- Main graph heading                                                PINP0207
      CALL PSCTXT(XCENTR,YP + 65.0,30.0,'Residue properties')           PINP0208
      CALL PSCTXT(XCENTR,YP + 36.0,25.0,BRCODE(1:BLEN))                 PINP0209
                                                                        PINP0210
CHECK v.3.2-->                                                          PINP0211
C---- Print program name in top left-hand corner                        PINP0212
      CALL PSTEXT(BBOXX1 + 15.0,BBOXY2 - 10.0,10.0,                     PINP0213
     &    'PROCHECK')                                                   PINP0214
CHECK v.3.2<--                                                          PINP0215
                                                                        PINP0216
C---- Loop through the three graphs to be plotted                       PINP0217
      IRGRAF = 0                                                        PINP0218
      NSTD = 0                                                          PINP0219
      DO 100, IGRAPH = 1, 3                                             PINP0220
                                                                        PINP0221
C----     Determine position on page                                    PINP0222
          YP = YPORIG + (3 - IGRAPH) * (YPWID + YPSEP)                  PINP0223
          PLOTNO = PLTNUM(IGRAPH)                                       PINP0224
          IF (PLOTNO.GT.0) THEN                                         PINP0225
                                                                        PINP0226
CHECK v.3.2-->                                                          PINP0227
C----         If this is a B-value plot and all values are very small (iPINP0228
C             < 2.0), the change heading to read U-values, rather than  PINP0229
C             B-values                                                  PINP0230
              IF (PLOTNO.EQ.PLTCGB .OR. PLOTNO.EQ.PLTMCB .OR.           PINP0231
     &            PLOTNO.EQ.PLTSCB .OR. PLOTNO.EQ.PLTSDM .OR.           PINP0232
     &            PLOTNO.EQ.PLTSDS) THEN                                PINP0233
                  IF (PINMAX(PLTMCB).LT.2.0) THEN                       PINP0234
                      DO 40, N = 1, PLTHLN(PLOTNO)                      PINP0235
                          IF (PLTHED(PLOTNO)(N:N).EQ.'B') THEN          PINP0236
                              PLTHED(PLOTNO)(N:N) = 'U'                 PINP0237
                          ENDIF                                         PINP0238
 40                   CONTINUE                                          PINP0239
                      DO 80, N = 1, PLTYLN(PLOTNO)                      PINP0240
                          IF (PLTYHD(PLOTNO)(N:N).EQ.'B') THEN          PINP0241
                              PLTYHD(PLOTNO)(N:N) = 'U'                 PINP0242
                          ENDIF                                         PINP0243
 80                   CONTINUE                                          PINP0244
                  ENDIF                                                 PINP0245
              ENDIF                                                     PINP0246
CHECK v.3.2<--                                                          PINP0247
                                                                        PINP0248
C----         Plot the graph box and axes                               PINP0249
              IRGRAF = IRGRAF + 1                                       PINP0250
              PLTHED(PLOTNO)(1:1) = LOWER(IRGRAF:IRGRAF)                PINP0251
              CALL PINGRF(XPORIG,YP,XPWID,YPWID,BSHADE(PLTYPE),         PINP0252
     &            PINMAX(PLOTNO),FPIN,FPIN + THEPIN,PLTHED(PLOTNO),     PINP0253
     &            PLTHLN(PLOTNO),PLTYHD(PLOTNO),PLTYLN(PLOTNO),         PINP0254
     &            INCOLR(PLTYPE),MXCOLR,RGB,COLPLT(PLTYPE,2))           PINP0255
                                                                        PINP0256
C----         Print the residue numbers along the x-axis                PINP0257
              CALL PINRNO(XPORIG,XPORIG + XPWID,YP,PINSNO,              PINP0258
     &            MXPINS,NPIN,FPIN,TICPOS,TICLAB,TICLEN,SIZLAB,TSIZE)   PINP0259
                                                                        PINP0260
C----         Plot the graph bars for the residues on this page         PINP0261
              CALL PINBOX(THEPIN,NPIN,PINDAT(1,IGRAPH),XPORIG,YP,       PINP0262
     &            YPWID,SCALEX,YPWID / PINMAX(PLOTNO),PLTSTD(PLOTNO),   PINP0263
     &            INCOLR(PLTYPE),MXCOLR,RGB,COLPLT(PLTYPE,4),           PINP0264
     &            COLPLT(PLTYPE,3))                                     PINP0265
              IF (PLTSTD(PLOTNO).NE.999.9) NSTD = NSTD + 1              PINP0266
          ENDIF                                                         PINP0267
                                                                        PINP0268
 100  CONTINUE                                                          PINP0269
                                                                        PINP0270
C---- Print number of deviations residues are highlighted by            PINP0271
      IF (NSTD.GT.0) THEN                                               PINP0272
          X = XPORIG + XPWID - NOTEX1                                   PINP0273
          YP = YPORIG - NOTEY1                                          PINP0274
          CALL PSTEXT(X,YP,8.0,                                         PINP0275
CHECK v.3.1-->                                                          PINP0276
C     -            'Highlighted residues than are those')               PINP0277
     &            'Highlighted residues are those that')                PINP0278
CHECK v.3.1<--                                                          PINP0279
          X = XPORIG + XPWID - NOTEX2                                   PINP0280
          YP = YPORIG - NOTEY2                                          PINP0281
          WRITE(IREC,120) LIMRES                                        PINP0282
CHECK v.3.1-->                                                          PINP0283
C 120      FORMAT('that deviate by more than',F4.1,                     PINP0284
C     -        ' st. devs. from ideal')                                 PINP0285
 120      FORMAT('deviate by more than',F4.1,' st. devs. from ideal')   PINP0286
CHECK v.3.1<--                                                          PINP0287
          CALL PSTEXT(X,YP,8.0,IREC(1:50))                              PINP0288
      ENDIF                                                             PINP0289
                                                                        PINP0290
C---- Print the "wiring diagram" showing the secondary structure, with  PINP0291
C     background shading giving a measure of the accessibility          PINP0292
      IRGRAF = IRGRAF + 1                                               PINP0293
      Y = YPORIG - SECSTY                                               PINP0294
CHECK v.3.3.2-->                                                        PINP0295
C      CALL PSTEXT(XPORIG,Y,12.0,LOWER(IRGRAF:IRGRAF) //                PINP0296
C     -    '. Secondary structure & estimated accessibility')           PINP0297
      IF (ACCESS) THEN                                                  PINP0298
          CALL PSTEXT(XPORIG,Y,12.0,LOWER(IRGRAF:IRGRAF) //             PINP0299
     &        '. Secondary structure & percentage accessibility')       PINP0300
      ELSE                                                              PINP0301
          CALL PSTEXT(XPORIG,Y,12.0,LOWER(IRGRAF:IRGRAF) //             PINP0302
     &        '. Secondary structure & estimated accessibility')        PINP0303
      ENDIF                                                             PINP0304
CHECK v.3.3.2<--                                                        PINP0305
      Y = Y - 18.0                                                      PINP0306
      CALL PSLWID(0.0)                                                  PINP0307
      IF (SHOWAC) THEN                                                  PINP0308
          CALL ACCSHD(THEPIN,NPIN,PINACC,PINSST,XPORIG,Y,SCALEX,        PINP0309
CHECK v.3.4-->                                                          PINP0310
C     -        SSSIZE,INCOLR(PLTYPE),MXCOLR,RGB,COLPLT(PLTYPE,5),       PINP0311
C     -        COLPLT(PLTYPE,6))                                        PINP0312
     &        SSSIZE,INCOLR(PLTYPE),MXCOLR,RGB,COLPLT(PLTYPE,6),        PINP0313
     &        COLPLT(PLTYPE,5))                                         PINP0314
CHECK v.3.4<--                                                          PINP0315
      ENDIF                                                             PINP0316
      CALL SSPLOT(THEPIN,NPIN,PINSST,XPORIG,Y,SCALEX,NRESID,PINCHN,     PINP0317
     &    SHOWAC,SSSIZE,INCOLR(PLTYPE),MXCOLR,RGB,COLPLT(PLTYPE,13),    PINP0318
     &    COLPLT(PLTYPE,5),COLPLT(PLTYPE,6))                            PINP0319
                                                                        PINP0320
C---- Print the residue codes                                           PINP0321
      IRGRAF = IRGRAF + 1                                               PINP0322
      Y = YPORIG - SEQRMY                                               PINP0323
      CALL PSTEXT(XPORIG,Y,12.0,LOWER(IRGRAF:IRGRAF) //                 PINP0324
     &    '. Sequence & Ramachandran regions')                          PINP0325
      Y = Y - 21.0                                                      PINP0326
      DO 400, IPIN = 1, NPIN                                            PINP0327
          X = XPORIG + (IPIN - 0.5) * SCALEX                            PINP0328
                                                                        PINP0329
C----     Find single-letter code for this residue                      PINP0330
          ICODE = 0                                                     PINP0331
          DO 300, N = 1, 20                                             PINP0332
              IF (PINRES(IPIN).EQ.CODE(N)) THEN                         PINP0333
                  ICODE = N                                             PINP0334
                  GO TO 350                                             PINP0335
              ENDIF                                                     PINP0336
 300      CONTINUE                                                      PINP0337
                                                                        PINP0338
C----     If not one of the standard 20, then print full 3-letter code  PINP0339
 350      CONTINUE                                                      PINP0340
          IF (ICODE.EQ.0) THEN                                          PINP0341
              CALL PSCTXT(X,Y,6.0,PINRES(IPIN)(1:1))                    PINP0342
              RCHAR = PINRES(IPIN)(2:2)                                 PINP0343
              N = ICHAR(RCHAR) - ICHAR(A) + 1                           PINP0344
              IF (N.GE.1 .AND. N.LE.26) RCHAR = LOWER(N:N)              PINP0345
              CALL PSCTXT(X,Y - 6.0,6.0,RCHAR)                          PINP0346
              RCHAR = PINRES(IPIN)(3:3)                                 PINP0347
              N = ICHAR(RCHAR) - ICHAR(A) + 1                           PINP0348
              IF (N.GE.1 .AND. N.LE.26) RCHAR = LOWER(N:N)              PINP0349
              CALL PSCTXT(X,Y - 12.0,6.0,RCHAR)                         PINP0350
                                                                        PINP0351
C----     Otherwise, print the single-letter code                       PINP0352
          ELSE                                                          PINP0353
              RCHAR = AMINO(ICODE:ICODE)                                PINP0354
              CALL PSCTXT(X,Y,6.0,RCHAR)                                PINP0355
          ENDIF                                                         PINP0356
 400  CONTINUE                                                          PINP0357
                                                                        PINP0358
C---- Add ticks at appropriate positions                                PINP0359
      YDIFF = SEQRMY + 15.0                                             PINP0360
      CALL PINTIC(XPORIG,YPORIG,YDIFF,XPWID,MXPINS,NPIN,-2.0,TICPOS,    PINP0361
CHECK v.3.4-->                                                          PINP0362
C     -    BRKPOS)                                                      PINP0363
     &    BRKPOS,.FALSE.)                                               PINP0364
CHECK v.3.4<--                                                          PINP0365
                                                                        PINP0366
C---- Indicate which Ramachandran plot region all the residues are in   PINP0367
      Y = YPORIG - SEQRMY - 15.0                                        PINP0368
      CALL PINRAM(XPORIG,SCALEX,Y,YHT,PINREG,THEPIN,NPIN,               PINP0369
     &    XPORIG + 192.0,YPORIG - SEQRMY,INCOLR(PLTYPE),MXCOLR,RGB,     PINP0370
     &    COLPLT(PLTYPE,7),COLPLT(PLTYPE,8),COLPLT(PLTYPE,9),           PINP0371
     &    COLPLT(PLTYPE,10))                                            PINP0372
                                                                        PINP0373
C---- Print the maximum deviation scores from the asterisks print       PINP0374
      IRGRAF = IRGRAF + 1                                               PINP0375
      Y = YPORIG - MAXDVY                                               PINP0376
      CALL PSTEXT(XPORIG,Y,12.0,LOWER(IRGRAF:IRGRAF) //                 PINP0377
     &    '. Max. deviation (see listing)')                             PINP0378
      X = XPORIG + SCALEX / 2.0                                         PINP0379
      DO 600, IPIN = 1, NPIN                                            PINP0380
          CALL ASTDEV(PINDEV(IPIN),0.0,1.0,CDUMMY,RDUM1,RDUM2,          PINP0381
     &        ASTER,1,1,0.0,.FALSE.)                                    PINP0382
          IF (ASTER.EQ.'      ' .AND. .NOT.BRKPOS(IPIN)) THEN           PINP0383
              ASTER = '     .'                                          PINP0384
          ENDIF                                                         PINP0385
          Y = YPORIG - MAXDVY - 24.0                                    PINP0386
          DO 500, N = 6, 1, -1                                          PINP0387
              IF (ASTER(N:N).NE.' ') THEN                               PINP0388
                  CALL PSCTXT(X,Y,6.0,ASTER(N:N))                       PINP0389
              ENDIF                                                     PINP0390
              Y = Y + 5.0                                               PINP0391
 500      CONTINUE                                                      PINP0392
      X = X + SCALEX                                                    PINP0393
 600  CONTINUE                                                          PINP0394
                                                                        PINP0395
C---- Add ticks at appropriate positions                                PINP0396
      YDIFF = MAXDVY + 29.0                                             PINP0397
      CALL PINTIC(XPORIG,YPORIG,YDIFF,XPWID,MXPINS,NPIN,2.0,TICPOS,     PINP0398
CHECK v.3.4-->                                                          PINP0399
C     -    BRKPOS)                                                      PINP0400
     &    BRKPOS,.FALSE.)                                               PINP0401
CHECK v.3.4<--                                                          PINP0402
                                                                        PINP0403
C---- Show the chequer-board of log-odds scores                         PINP0404
      IRGRAF = IRGRAF + 1                                               PINP0405
      Y = YPORIG - DASCOY                                               PINP0406
      CALL PSTEXT(XPORIG,Y,12.0,LOWER(IRGRAF:IRGRAF) //                 PINP0407
     &    '. G-factors')                                                PINP0408
      Y = Y - 12.0                                                      PINP0409
      LSTCHY = Y                                                        PINP0410
      CALL PINCHQ(XPORIG,SCALEX,Y,YHT,PINSCO,THEPIN,NPIN,NDISTR,        PINP0411
     &    CLABEL,INCOLR(PLTYPE),MXCOLR,RGB,COLPLT(PLTYPE,11),           PINP0412
     &    COLPLT(PLTYPE,12),YBOT,PINSST,PINCIS,NCOVAL,NDIHED,LSTCHX)    PINP0413
                                                                        PINP0414
C---- Add ticks at appropriate positions                                PINP0415
      CALL PINTIC(XPORIG,YBOT,0.0,XPWID,MXPINS,NPIN,-2.0,TICPOS,        PINP0416
CHECK v.3.4-->                                                          PINP0417
C     -    BRKPOS)                                                      PINP0418
     &    BRKPOS,.FALSE.)                                               PINP0419
CHECK v.3.4<--                                                          PINP0420
                                                                        PINP0421
C---- Print the tick labels                                             PINP0422
      X = XPORIG + XGAP / 2.0                                           PINP0423
      Y = YBOT - TSIZE / 2.0                                            PINP0424
      DO 700, IPIN = 1, NPIN                                            PINP0425
          IF (TICPOS(IPIN)) THEN                                        PINP0426
              CALL PSCTXT(X,Y,SIZLAB,TICLAB(IPIN)(1:TICLEN(IPIN)))      PINP0427
          ENDIF                                                         PINP0428
          X = X + XGAP                                                  PINP0429
 700  CONTINUE                                                          PINP0430
                                                                        PINP0431
C---- Print the page number on the plot                                 PINP0432
      NPAGE = NPAGE + 1                                                 PINP0433
      WRITE(PAGENO,'(I2)') NPAGE                                        PINP0434
      PAGE = 'Page ' // PAGENO                                          PINP0435
      CALL PSCTXT(BBOXX2 - 40.0,BBOXY2 - 20.0,12.0,PAGE)                PINP0436
                                                                        PINP0437
C---- Re-initalise arrays                                               PINP0438
      DO 850, NPIN = 1, MXPINS                                          PINP0439
          PINACC(NPIN) = 0.0                                            PINP0440
          PINCIS(NPIN) = ' '                                            PINP0441
          PINDAT(NPIN,1) = 0.0                                          PINP0442
          PINDAT(NPIN,2) = 0.0                                          PINP0443
          PINDAT(NPIN,3) = 0.0                                          PINP0444
          PINDEV(NPIN) = 0.0                                            PINP0445
          PINRES(NPIN) = ' '                                            PINP0446
          PINSST(NPIN) = '='                                            PINP0447
          PINREG(NPIN) = 0                                              PINP0448
          PINCHN(NPIN) = ' '                                            PINP0449
          DO 840, IDIST = 1, NDISTR                                     PINP0450
              PINSCO(IDIST,NPIN) = 999.99                               PINP0451
 840      CONTINUE                                                      PINP0452
          PINSNO(NPIN) = ' '                                            PINP0453
 850  CONTINUE                                                          PINP0454
                                                                        PINP0455
      RETURN                                                            PINP0456
      END                                                               PINP0457
                                                                        PINP0458
      SUBROUTINE PINRAM(XPORIG,XGAP,YP,YHT,PINREG,THEPIN,NPIN,KEYX,KEYY,PINR0001
     &    INCOLR,MXCOLR,RGB,COL1,COL2,COL3,COL4)                        PINR0002
C-----------------------------------------------------------------------PINR0003
C                                                                       PINR0004
C  SUBROUTINE PINRAM  -  Print Ramachandran plot regions                PINR0005
C                                                                       PINR0006
C----------------------------------------------------------------------+PINR0007
                                                                        PINR0008
      SAVE                                                              PINR0009
                                                                        PINR0010
      INTEGER       MXCOLR, THEPIN                                      PINR0011
                                                                        PINR0012
      INTEGER       COL1, COL2, COL3, COL4, IPIN, NPIN, PINREG(THEPIN)  PINR0013
      LOGICAL       INCOLR                                              PINR0014
      REAL          KEYX, KEYY, RGB(3,MXCOLR), SHADE, X1, X2, XGAP,     PINR0015
     &              XPORIG, Y1, Y2, YHT, YP                             PINR0016
                                                                        PINR0017
      DATA  SHADE / 0.4 /                                               PINR0018
                                                                        PINR0019
C---- Plot the values                                                   PINR0020
      X1 = XPORIG                                                       PINR0021
      DO 100, IPIN = 1, NPIN                                            PINR0022
          X2 = X1 + XGAP                                                PINR0023
          IF (PINREG(IPIN).EQ.4) THEN                                   PINR0024
              Y2 = YP + YHT                                             PINR0025
              CALL PSHADE(0.0,COL4,RGB,MXCOLR,INCOLR)                   PINR0026
              CALL PSTRIA(X1,YP,X2,YP,(X1 + X2) / 2.0,Y2)               PINR0027
          ELSE IF (PINREG(IPIN).EQ.3) THEN                              PINR0028
              Y2 = YP + YHT                                             PINR0029
              CALL PSHADE(SHADE,COL3,RGB,MXCOLR,INCOLR)                 PINR0030
              CALL PSBBOX(X1,YP,X2,YP,X2,Y2,X1,Y2)                      PINR0031
          ELSE IF (PINREG(IPIN).EQ.2) THEN                              PINR0032
              Y2 = YP + 2.0 * YHT                                       PINR0033
              CALL PSHADE(SHADE,COL2,RGB,MXCOLR,INCOLR)                 PINR0034
              CALL PSBBOX(X1,YP,X2,YP,X2,Y2,X1,Y2)                      PINR0035
          ELSE IF (PINREG(IPIN).EQ.1) THEN                              PINR0036
              Y2 = YP + 2.0 * YHT                                       PINR0037
              CALL PSHADE(0.0,COL1,RGB,MXCOLR,INCOLR)                   PINR0038
              CALL PSBBOX(X1,YP,X2,YP,X2,Y2,X1,Y2)                      PINR0039
          ENDIF                                                         PINR0040
          X1 = X2                                                       PINR0041
 100  CONTINUE                                                          PINR0042
                                                                        PINR0043
C---- Print the explanatory key                                         PINR0044
      X1 = KEYX                                                         PINR0045
      X2 = X1 + XGAP                                                    PINR0046
      Y1 = KEYY + YHT / 2.0                                             PINR0047
      Y2 = KEYY - YHT / 2.0                                             PINR0048
      CALL PSHADE(0.0,COL4,RGB,MXCOLR,INCOLR)                           PINR0049
      CALL PSTRIA(X1,Y2,X2,Y2,(X1 + X2) / 2.0,Y1)                       PINR0050
      CALL PSTEXT(X2 + 5.0,KEYY,10.0,'Most favoured')                   PINR0051
      X1 = KEYX + 76.0                                                  PINR0052
      X2 = X1 + XGAP                                                    PINR0053
      CALL PSHADE(SHADE,COL3,RGB,MXCOLR,INCOLR)                         PINR0054
      CALL PSBBOX(X1,Y1,X2,Y1,X2,Y2,X1,Y2)                              PINR0055
      CALL PSTEXT(X2 + 5.0,KEYY,10.0,'Allowed')                         PINR0056
      X1 = KEYX + 127.0                                                 PINR0057
      X2 = X1 + XGAP                                                    PINR0058
      Y1 = Y2                                                           PINR0059
      Y2 = Y1 + 2.0 * YHT                                               PINR0060
      CALL PSHADE(SHADE,COL2,RGB,MXCOLR,INCOLR)                         PINR0061
      CALL PSBBOX(X1,Y1,X2,Y1,X2,Y2,X1,Y2)                              PINR0062
      CALL PSTEXT(X2 + 5.0,KEYY,10.0,'Generous')                        PINR0063
      X1 = KEYX + 178.0                                                 PINR0064
      X2 = X1 + XGAP                                                    PINR0065
      CALL PSHADE(0.0,COL1,RGB,MXCOLR,INCOLR)                           PINR0066
      CALL PSBBOX(X1,Y1,X2,Y1,X2,Y2,X1,Y2)                              PINR0067
      CALL PSTEXT(X2 + 5.0,KEYY,10.0,'Disallowed')                      PINR0068
                                                                        PINR0069
      RETURN                                                            PINR0070
      END                                                               PINR0071
                                                                        PINR0072
      SUBROUTINE ACCSHD(THEPIN,NPIN,PINACC,PINSST,XP,YP,DX,             ACCS0001
     &    SSSIZE,INCOLR,MXCOLR,RGB,MINCOL,MAXCOL)                       ACCS0002
C-----------------------------------------------------------------------ACCS0003
C                                                                       ACCS0004
C  SUBROUTINE ACCSHD  -  Shade in the background of the secondary       ACCS0005
C                        structure "wiring diagram" to give an indicatioACCS0006
C                        of the relative accessibility                  ACCS0007
C                                                                       ACCS0008
C----------------------------------------------------------------------+ACCS0009
                                                                        ACCS0010
      SAVE                                                              ACCS0011
                                                                        ACCS0012
      INTEGER       MXCOLR, NPIN, THEPIN                                ACCS0013
      CHARACTER*1   NXTSTR, SECSTR                                      ACCS0014
      CHARACTER*2   PINSST(THEPIN)                                      ACCS0015
CHECK v.3.2-->                                                          ACCS0016
C      INTEGER       ISTRUC, IPIN, IRES, LSTRUC, MAXCOL, MINCOL, NRESID ACCS0017
      INTEGER       IPIN, MAXCOL, MINCOL                                ACCS0018
CHECK v.3.2<--                                                          ACCS0019
      LOGICAL       BLANK, INCOLR                                       ACCS0020
      REAL          DX, HEIGHT, PINACC(THEPIN), RGB(3,MXCOLR), SHADE,   ACCS0021
     &              SSSIZE, X, XP, X1, X2, Y, YP, Y1, Y2                ACCS0022
                                                                        ACCS0023
CHECK v.3.2-->                                                          ACCS0024
C      DATA IRES,LSTRUC   / 0, 0 /                                      ACCS0025
CHECK v.3.2<--                                                          ACCS0026
                                                                        ACCS0027
C---- Initialise values                                                 ACCS0028
      HEIGHT = SSSIZE * 3.0                                             ACCS0029
      X = XP                                                            ACCS0030
      Y = YP                                                            ACCS0031
                                                                        ACCS0032
C---- Loop through the residues                                         ACCS0033
      DO 400, IPIN = 1, NPIN                                            ACCS0034
                                                                        ACCS0035
C----     Initialise structure type for this residue                    ACCS0036
          SECSTR = PINSST(IPIN)(1:1)                                    ACCS0037
          NXTSTR = PINSST(IPIN)(2:2)                                    ACCS0038
          IF (SECSTR.EQ.'=') THEN                                       ACCS0039
              BLANK = .TRUE.                                            ACCS0040
          ELSE                                                          ACCS0041
              BLANK = .FALSE.                                           ACCS0042
CHECK v.3.2-->                                                          ACCS0043
C              IRES = IRES + 1                                          ACCS0044
CHECK v.3.2<--                                                          ACCS0045
          ENDIF                                                         ACCS0046
                                                                        ACCS0047
C----     If not off the end of a chain, draw a shaded patch according tACCS0048
C         the accessibility                                             ACCS0049
          IF (.NOT.BLANK) THEN                                          ACCS0050
              X1 = X                                                    ACCS0051
              X2 = X + DX                                               ACCS0052
              Y1 = Y - HEIGHT                                           ACCS0053
              Y2 = Y + HEIGHT                                           ACCS0054
              SHADE = PINACC(IPIN) / 100.0                              ACCS0055
              CALL PSCALE(SHADE,INCOLR,MXCOLR,RGB,MINCOL,MAXCOL)        ACCS0056
              CALL PSUBOX(X1,Y1,X1,Y2,X2,Y2,X2,Y1)                      ACCS0057
          ENDIF                                                         ACCS0058
                                                                        ACCS0059
C----     Increment x-position                                          ACCS0060
          X = X + DX                                                    ACCS0061
                                                                        ACCS0062
C----     Save current structure                                        ACCS0063
CHECK v.3.2-->                                                          ACCS0064
C          LSTRUC = ISTRUC                                              ACCS0065
CHECK v.3.2<--                                                          ACCS0066
 400  CONTINUE                                                          ACCS0067
                                                                        ACCS0068
      RETURN                                                            ACCS0069
      END                                                               ACCS0070
                                                                        ACCS0071
      SUBROUTINE PINCHQ(XPORIG,XGAP,YP,YHT,PINSCO,THEPIN,NPIN,NDISTR,   PINC0001
     &    CLABEL,INCOLR,MXCOLR,RGB,MINCOL,MAXCOL,YBOT,PINSST,PINCIS,    PINC0002
     &    NCOVAL,NDIHED,LSTCHX)                                         PINC0003
C-----------------------------------------------------------------------PINC0004
C                                                                       PINC0005
C  SUBROUTINE PINCHQ  -  Print the chequer-board (the PROCHECKer board) PINC0006
C                        of log-odds scores                             PINC0007
C                                                                       PINC0008
C----------------------------------------------------------------------+PINC0009
                                                                        PINC0010
      SAVE                                                              PINC0011
                                                                        PINC0012
      INTEGER       MXCOLR, NDISTR, THEPIN                              PINC0013
      REAL          MINSHD, VALLOW, VALUPP                              PINC0014
      PARAMETER    (                                                    PINC0015
     &              MINSHD =  0.97,                                     PINC0016
     &              VALLOW =  0.00,                                     PINC0017
     &              VALUPP = -4.00                                      PINC0018
     &             )                                                    PINC0019
                                                                        PINC0020
      CHARACTER*1   PINCIS(THEPIN), SECSTR                              PINC0021
      CHARACTER*2   PINSST(THEPIN)                                      PINC0022
      CHARACTER*11  CLABEL(NDISTR)                                      PINC0023
      CHARACTER*100 STRING                                              PINC0024
      INTEGER       IDISTR, IPIN, MAXCOL, MINCOL, NBOTH, NCIS, NDAM,    PINC0025
     &              NCOVAL, NDIHED, NPIN, SLEN                          PINC0026
      LOGICAL       INCOLR                                              PINC0027
      REAL          LSTCHX, PINSCO(NDISTR,THEPIN), RGB(3,MXCOLR),       PINC0028
     &              SHADE, VALUE, X1, X2, XGAP, XPORIG, Y1, Y2, YBOT,   PINC0029
     &              YHT, YP                                             PINC0030
                                                                        PINC0031
C---- Initialise values                                                 PINC0032
      NBOTH = 0                                                         PINC0033
      NCIS = 0                                                          PINC0034
      NDAM = 0                                                          PINC0035
      X1 = XPORIG - 35.0                                                PINC0036
      Y1 = YP - YHT / 2.0                                               PINC0037
                                                                        PINC0038
C---- Print the row headings                                            PINC0039
      DO 100, IDISTR = 1, NDISTR                                        PINC0040
          CALL PSTEXT(X1,Y1,6.0,CLABEL(IDISTR))                         PINC0041
          Y1 = Y1 - YHT                                                 PINC0042
          IF (IDISTR.EQ.NDIHED) Y1 = Y1 - YHT / 2.0                     PINC0043
          IF (IDISTR.EQ.NDIHED + 1) Y1 = Y1 - YHT                       PINC0044
          IF (IDISTR.EQ.NDIHED + NCOVAL + 1) Y1 = Y1 - YHT / 2.0        PINC0045
          IF (IDISTR.EQ.NDISTR - 1) Y1 = Y1 - YHT * 1.5                 PINC0046
 100  CONTINUE                                                          PINC0047
                                                                        PINC0048
C---- Reinitialise                                                      PINC0049
      X1 = XPORIG                                                       PINC0050
                                                                        PINC0051
C---- Lop through the residues to be processed                          PINC0052
      DO 800, IPIN = 1, NPIN                                            PINC0053
          X2 = X1 + XGAP                                                PINC0054
          Y1 = YP                                                       PINC0055
                                                                        PINC0056
C----     Process if not within a chain-break                           PINC0057
          SECSTR = PINSST(IPIN)(1:1)                                    PINC0058
          IF (SECSTR.NE.'=') THEN                                       PINC0059
                                                                        PINC0060
C----         If this is a cis-peptide or a D-amino acid, plot a marker PINC0061
C             accordingly                                               PINC0062
              IF (PINCIS(IPIN).NE.' ') THEN                             PINC0063
                  CALL PSCTXT((X1 + X2) / 2.0,Y1 + YHT * 0.75,6.0,      PINC0064
     &                PINCIS(IPIN))                                     PINC0065
                  IF (PINCIS(IPIN).EQ.'c') NCIS = NCIS + 1              PINC0066
                  IF (PINCIS(IPIN).EQ.'D') NDAM = NDAM + 1              PINC0067
                  IF (PINCIS(IPIN).EQ.'X') NBOTH = NBOTH + 1            PINC0068
              ENDIF                                                     PINC0069
                                                                        PINC0070
C----         Loop through the different distribution types             PINC0071
              DO 300, IDISTR = 1, NDISTR                                PINC0072
                                                                        PINC0073
C----             Calculate y-extent of current box and its shade       PINC0074
                  Y2 = Y1 - YHT                                         PINC0075
                  VALUE = PINSCO(IDISTR,IPIN)                           PINC0076
                  IF (VALUE.GT.999.0) THEN                              PINC0077
                      SHADE = 1.0                                       PINC0078
                  ELSE                                                  PINC0079
                      IF (VALUE.GT.VALLOW) THEN                         PINC0080
                          SHADE = MINSHD                                PINC0081
                      ELSE IF (VALUE.LE.VALUPP) THEN                    PINC0082
                          SHADE = 0.0                                   PINC0083
                      ELSE                                              PINC0084
                          SHADE = MINSHD                                PINC0085
     &                        - MINSHD * (VALUE - VALLOW)               PINC0086
     &                        / (VALUPP - VALLOW)                       PINC0087
                      ENDIF                                             PINC0088
                  ENDIF                                                 PINC0089
                                                                        PINC0090
C----             Plot the box                                          PINC0091
                  IF (VALUE.GT.999.0) THEN                              PINC0092
                      CALL PSHADE(SHADE,1,RGB,MXCOLR,.FALSE.)           PINC0093
                  ELSE                                                  PINC0094
                      CALL PSCALE(SHADE,INCOLR,MXCOLR,RGB,MINCOL,       PINC0095
     &                    MAXCOL)                                       PINC0096
                  ENDIF                                                 PINC0097
                  CALL PSBBOX(X1,Y1,X2,Y1,X2,Y2,X1,Y2)                  PINC0098
                                                                        PINC0099
C----             Increment y-value for next block                      PINC0100
                  Y1 = Y2                                               PINC0101
                  IF (IDISTR.EQ.NDIHED) Y1 = Y1 - YHT / 2.0             PINC0102
                  IF (IDISTR.EQ.NDIHED + 1) Y1 = Y1 - YHT               PINC0103
                  IF (IDISTR.EQ.NDIHED + NCOVAL + 1)                    PINC0104
     &                Y1 = Y1 - YHT / 2.0                               PINC0105
                  IF (IDISTR.EQ.NDISTR - 1) Y1 = Y1 - YHT * 1.5         PINC0106
 300          CONTINUE                                                  PINC0107
                                                                        PINC0108
                                                                        PINC0109
C----         If this is a cis-peptide or a D-amino acid, plot a marker PINC0110
C             accordingly                                               PINC0111
              IF (PINCIS(IPIN).NE.' ') THEN                             PINC0112
                  CALL PSCTXT((X1 + X2) / 2.0,Y1 + YHT * 1.75,6.0,      PINC0113
     &                PINCIS(IPIN))                                     PINC0114
              ENDIF                                                     PINC0115
          ENDIF                                                         PINC0116
                                                                        PINC0117
C----     Increment x-value for next residue                            PINC0118
          X1 = X2                                                       PINC0119
 800  CONTINUE                                                          PINC0120
                                                                        PINC0121
C---- Return the last x- and y-value                                    PINC0122
      LSTCHX = X2                                                       PINC0123
      YBOT = Y2                                                         PINC0124
                                                                        PINC0125
C---- If any cis-peptides or D-amino acids, print key at bottom of page PINC0126
      STRING = ' '                                                      PINC0127
      SLEN = 0                                                          PINC0128
      IF (NCIS.GT.0) THEN                                               PINC0129
          STRING = 'c = cis-peptide'                                    PINC0130
          SLEN = 15                                                     PINC0131
      ENDIF                                                             PINC0132
      IF (NDAM.GT.0) THEN                                               PINC0133
          STRING = STRING(1:SLEN) // '    ' // 'D = D-amino acid'       PINC0134
          SLEN = SLEN + 20                                              PINC0135
      ENDIF                                                             PINC0136
      IF (NBOTH.GT.0) THEN                                              PINC0137
          STRING = STRING(1:SLEN) // '    ' //                          PINC0138
     &        'X = cis-peptide & D-amino acid'                          PINC0139
          SLEN = SLEN + 34                                              PINC0140
      ENDIF                                                             PINC0141
      IF (SLEN.GT.0) THEN                                               PINC0142
          CALL PSTEXT(XPORIG,YBOT - 22.0,8.0,STRING(1:SLEN))            PINC0143
      ENDIF                                                             PINC0144
                                                                        PINC0145
      RETURN                                                            PINC0146
      END                                                               PINC0147
                                                                        PINC0148
      SUBROUTINE SSPLOT(THEPIN,NPIN,PINSST,XP,YP,DX,NRESID,PINCHN,      SSPL0001
     &    SHOWAC,SSSIZE,INCOLR,MXCOLR,RGB,COLOUR,MINACC,MAXACC)         SSPL0002
C-----------------------------------------------------------------------SSPL0003
C                                                                       SSPL0004
C  SUBROUTINE SSPLOT  -  Draw the secondary structure "wiring diagram"  SSPL0005
C                                                                       SSPL0006
C----------------------------------------------------------------------+SSPL0007
                                                                        SSPL0008
      SAVE                                                              SSPL0009
                                                                        SSPL0010
      INTEGER       BLANK, COIL, HELIX, STRAND                          SSPL0011
      PARAMETER    (                                                    SSPL0012
     &              BLANK  =   0,                                       SSPL0013
     &              COIL   =   3,                                       SSPL0014
     &              HELIX  =   1,                                       SSPL0015
     &              STRAND =   2                                        SSPL0016
     &             )                                                    SSPL0017
                                                                        SSPL0018
      REAL          ARRWID, COIWID, THICK, THIN                         SSPL0019
      PARAMETER    (                                                    SSPL0020
     &              ARRWID = 1.8,                                       SSPL0021
     &              COIWID = 0.25,                                      SSPL0022
     &              THICK  = 0.4,                                       SSPL0023
     &              THIN   = 0.2                                        SSPL0024
     &             )                                                    SSPL0025
                                                                        SSPL0026
      INTEGER       MXCOLR, NPIN, THEPIN                                SSPL0027
      CHARACTER*1   NXTSTR, SECSTR                                      SSPL0028
      CHARACTER*2   PINCHN(THEPIN), PINSST(THEPIN)                      SSPL0029
      INTEGER       COLOUR, FIRSTH, ISTRUC, IPIN, IRES, LENRUN, LSTRUC, SSPL0030
     &              MAXACC, MINACC, NRESID                              SSPL0031
      LOGICAL       INCOLR, SHOWAC                                      SSPL0032
      REAL          DX, HEIGHT, HWIDTH, RGB(3,MXCOLR), SSSIZE, X, XP,   SSPL0033
     &              X1, X2, Y, YP, Y1, Y2                               SSPL0034
                                                                        SSPL0035
      DATA IRES,LSTRUC   / 0, 0 /                                       SSPL0036
                                                                        SSPL0037
C---- Initialise values                                                 SSPL0038
      HEIGHT = SSSIZE * 1.5                                             SSPL0039
      HWIDTH = SSSIZE * 1.2                                             SSPL0040
      X = XP                                                            SSPL0041
      Y = YP                                                            SSPL0042
      LENRUN = 0                                                        SSPL0043
      CALL PSLWID(THIN)                                                 SSPL0044
                                                                        SSPL0045
C---- Loop through the residues                                         SSPL0046
      DO 400, IPIN = 1, NPIN                                            SSPL0047
                                                                        SSPL0048
C----     If this is the start of a chain, draw chain-start             SSPL0049
          IF (PINCHN(IPIN)(2:2).EQ.'>' .AND.                            SSPL0050
     &        PINCHN(IPIN)(1:1).NE.' ') THEN                            SSPL0051
              CALL PSLINE(X,Y - SSSIZE * 0.6,X,Y + SSSIZE * 0.6)        SSPL0052
                                                                        SSPL0053
C----         Print the chain identifier                                SSPL0054
              CALL PSTEXT(X - 10.0,Y,10.0,PINCHN(IPIN)(1:1))            SSPL0055
          ENDIF                                                         SSPL0056
                                                                        SSPL0057
C----     If this is the end of a chain, draw chain-end                 SSPL0058
          IF (PINCHN(IPIN)(2:2).EQ.'<') THEN                            SSPL0059
              CALL PSLINE(X + DX,Y - SSSIZE * 0.6,X + DX,               SSPL0060
     &            Y + SSSIZE * 0.6)                                     SSPL0061
          ENDIF                                                         SSPL0062
                                                                        SSPL0063
C----     Initialise structure type for this residue                    SSPL0064
          SECSTR = PINSST(IPIN)(1:1)                                    SSPL0065
          NXTSTR = PINSST(IPIN)(2:2)                                    SSPL0066
          IF (SECSTR.NE.'=') IRES = IRES + 1                            SSPL0067
          IF (SECSTR.EQ.'H' .OR. SECSTR.EQ.'G') THEN                    SSPL0068
              ISTRUC = HELIX                                            SSPL0069
          ELSE IF (SECSTR.EQ.'E') THEN                                  SSPL0070
              ISTRUC = STRAND                                           SSPL0071
          ELSE IF (SECSTR.EQ.'=') THEN                                  SSPL0072
              ISTRUC = BLANK                                            SSPL0073
          ELSE                                                          SSPL0074
              ISTRUC = COIL                                             SSPL0075
          ENDIF                                                         SSPL0076
                                                                        SSPL0077
C----     If coil, then draw a horizontal bar                           SSPL0078
          IF (ISTRUC.EQ.COIL) THEN                                      SSPL0079
                                                                        SSPL0080
C----         Draw the current fragment of the coil                     SSPL0081
              X1 = X                                                    SSPL0082
              X2 = X + DX                                               SSPL0083
              Y1 = Y - SSSIZE * COIWID                                  SSPL0084
              Y2 = Y + SSSIZE * COIWID                                  SSPL0085
              CALL PSHADE(1.0,COLOUR,RGB,MXCOLR,INCOLR)                 SSPL0086
              CALL PSUBOX(X1,Y1,X1,Y2,X2,Y2,X2,Y1)                      SSPL0087
              CALL PSLINE(X1,Y1,X2,Y1)                                  SSPL0088
              CALL PSLINE(X1,Y2,X2,Y2)                                  SSPL0089
                                                                        SSPL0090
C----         If this is the start of the coil, then start box          SSPL0091
              IF (LSTRUC.NE.COIL) THEN                                  SSPL0092
                  CALL PSLINE(X,Y1,X,Y2)                                SSPL0093
              ENDIF                                                     SSPL0094
                                                                        SSPL0095
C----         If this is the last residue of the coil, draw its end     SSPL0096
              IF (NXTSTR.EQ.'E' .OR. NXTSTR.EQ.'H' .OR.                 SSPL0097
     &            NXTSTR.EQ.'G' .OR. IRES.EQ.NRESID) THEN               SSPL0098
                  CALL PSLINE(X2,Y1,X2,Y2)                              SSPL0099
              ENDIF                                                     SSPL0100
              X = X + DX                                                SSPL0101
                                                                        SSPL0102
C----     Else if it's a strand, draw a horizontal box                  SSPL0103
          ELSE IF (ISTRUC.EQ.STRAND) THEN                               SSPL0104
                                                                        SSPL0105
C----         If this is the last residue of the strand, draw the arrow-SSPL0106
              IF (NXTSTR.NE.'E' .OR. IRES.EQ.NRESID) THEN               SSPL0107
                  X1 = X                                                SSPL0108
                  X2 = X + DX                                           SSPL0109
                  Y1 = Y - ARRWID * SSSIZE                              SSPL0110
                  Y2 = Y + ARRWID * SSSIZE                              SSPL0111
                  CALL PSHADE(1.0,COLOUR,RGB,MXCOLR,INCOLR)             SSPL0112
                  CALL PSUTRI(X1,Y1,X1,Y2,X2,Y)                         SSPL0113
                  CALL PSLINE(X,Y2,X,Y + SSSIZE)                        SSPL0114
                  CALL PSLINE(X,Y1,X,Y - SSSIZE)                        SSPL0115
                  CALL PSLINE(X,Y2,X + DX,Y)                            SSPL0116
                  CALL PSLINE(X,Y1,X + DX,Y)                            SSPL0117
                  X = X + DX                                            SSPL0118
                                                                        SSPL0119
C----         Otherwise, draw the current fragment of the strand        SSPL0120
              ELSE                                                      SSPL0121
                  X1 = X                                                SSPL0122
                  X2 = X + DX                                           SSPL0123
                  Y1 = Y - SSSIZE                                       SSPL0124
                  Y2 = Y + SSSIZE                                       SSPL0125
                  CALL PSHADE(1.0,COLOUR,RGB,MXCOLR,INCOLR)             SSPL0126
                  CALL PSUBOX(X1,Y1,X1,Y2,X2,Y2,X2,Y1)                  SSPL0127
                  IF (.NOT.SHOWAC) CALL PSLWID(THICK)                   SSPL0128
                  CALL PSLINE(X,Y - SSSIZE,X + DX,Y - SSSIZE)           SSPL0129
                  IF (.NOT.SHOWAC) CALL PSLWID(THIN)                    SSPL0130
                  CALL PSLINE(X,Y + SSSIZE,X + DX,Y + SSSIZE)           SSPL0131
                  X = X + DX                                            SSPL0132
              ENDIF                                                     SSPL0133
                                                                        SSPL0134
C----         If this is the start of the strand, then start box        SSPL0135
              IF (LSTRUC.NE.STRAND) THEN                                SSPL0136
                  IF (.NOT.SHOWAC) CALL PSLWID(THICK)                   SSPL0137
                  CALL PSLINE(X1,Y - SSSIZE,X1,Y + SSSIZE)              SSPL0138
                  IF (.NOT.SHOWAC) CALL PSLWID(THIN)                    SSPL0139
              ENDIF                                                     SSPL0140
                                                                        SSPL0141
C----     Else if it's a helix, draw a sawtooth                         SSPL0142
          ELSE IF (ISTRUC.EQ.HELIX) THEN                                SSPL0143
                                                                        SSPL0144
C----         Increment count of helix residues in current helix        SSPL0145
              LENRUN = LENRUN + 1                                       SSPL0146
              IF (LENRUN.EQ.1) FIRSTH = IRES                            SSPL0147
                                                                        SSPL0148
C----         If at end of the helix, draw it                           SSPL0149
              IF (IRES.EQ.NRESID .OR. IPIN.EQ.NPIN .OR.                 SSPL0150
     &            (NXTSTR.NE.'H' .AND. NXTSTR.NE.'G')) THEN             SSPL0151
                  CALL DHELIX(LENRUN,X,Y,FIRSTH,DX,HWIDTH,HEIGHT,       SSPL0152
     &                SHOWAC,INCOLR,MXCOLR,RGB,COLOUR)                  SSPL0153
                  LENRUN = 0                                            SSPL0154
              ENDIF                                                     SSPL0155
          ELSE                                                          SSPL0156
              X = X + DX                                                SSPL0157
          ENDIF                                                         SSPL0158
                                                                        SSPL0159
C----     Save current structure                                        SSPL0160
          LSTRUC = ISTRUC                                               SSPL0161
 400  CONTINUE                                                          SSPL0162
                                                                        SSPL0163
C---- Show key to wiring diagram                                        SSPL0164
      X = XP                                                            SSPL0165
      Y = YP - 17.0                                                     SSPL0166
      CALL PSTEXT(X,Y,10.0,'Key:-')                                     SSPL0167
                                                                        SSPL0168
C---- Helix                                                             SSPL0169
      X = XP + 32.0                                                     SSPL0170
      CALL DHELIX(4,X,Y,1,DX,HWIDTH,HEIGHT,SHOWAC,INCOLR,MXCOLR,        SSPL0171
     &    RGB,COLOUR)                                                   SSPL0172
CHECK v.3.0.1-->                                                        SSPL0173
C 500  CONTINUE                                                         SSPL0174
CHECK v.3.0.1<--                                                        SSPL0175
      X = X + 4.0                                                       SSPL0176
      CALL PSTEXT(X,Y,10.0,'Helix')                                     SSPL0177
                                                                        SSPL0178
C---- Strand                                                            SSPL0179
      X = XP + 88.0                                                     SSPL0180
      X1 = X                                                            SSPL0181
      X2 = X + 3 * DX                                                   SSPL0182
      Y1 = Y - SSSIZE                                                   SSPL0183
      Y2 = Y + SSSIZE                                                   SSPL0184
      CALL PSHADE(1.0,COLOUR,RGB,MXCOLR,INCOLR)                         SSPL0185
      CALL PSUBOX(X1,Y1,X1,Y2,X2,Y2,X2,Y1)                              SSPL0186
      IF (.NOT.SHOWAC) CALL PSLWID(THICK)                               SSPL0187
      CALL PSLINE(X1,Y1,X1,Y2)                                          SSPL0188
      CALL PSLINE(X,Y - SSSIZE,X + 3 * DX,Y - SSSIZE)                   SSPL0189
      IF (.NOT.SHOWAC) CALL PSLWID(THIN)                                SSPL0190
      CALL PSLINE(X,Y + SSSIZE,X + 3 * DX,Y + SSSIZE)                   SSPL0191
      X = X + 3 * DX                                                    SSPL0192
      X1 = X                                                            SSPL0193
      X2 = X + DX                                                       SSPL0194
      Y1 = Y - ARRWID * SSSIZE                                          SSPL0195
      Y2 = Y + ARRWID * SSSIZE                                          SSPL0196
      CALL PSHADE(1.0,COLOUR,RGB,MXCOLR,INCOLR)                         SSPL0197
      CALL PSUTRI(X1,Y1,X1,Y2,X2,Y)                                     SSPL0198
      CALL PSLINE(X,Y2,X,Y + SSSIZE)                                    SSPL0199
      CALL PSLINE(X,Y1,X,Y - SSSIZE)                                    SSPL0200
      CALL PSLINE(X,Y2,X + DX,Y)                                        SSPL0201
      CALL PSLINE(X,Y1,X + DX,Y)                                        SSPL0202
      X = X + DX + 4.0                                                  SSPL0203
      CALL PSTEXT(X,Y,10.0,'Beta strand')                               SSPL0204
                                                                        SSPL0205
C---- Coil                                                              SSPL0206
      X = XP + 166.0                                                    SSPL0207
      X1 = X                                                            SSPL0208
      X2 = X1 + 4 * DX                                                  SSPL0209
      Y1 = Y - SSSIZE * COIWID                                          SSPL0210
      Y2 = Y + SSSIZE * COIWID                                          SSPL0211
      CALL PSHADE(1.0,COLOUR,RGB,MXCOLR,INCOLR)                         SSPL0212
      CALL PSUBOX(X1,Y1,X1,Y2,X2,Y2,X2,Y1)                              SSPL0213
      CALL PSLINE(X1,Y1,X2,Y1)                                          SSPL0214
      CALL PSLINE(X1,Y2,X2,Y2)                                          SSPL0215
      CALL PSLINE(X1,Y1,X1,Y2)                                          SSPL0216
      CALL PSLINE(X2,Y1,X2,Y2)                                          SSPL0217
      X = X + 4 * DX + 4.0                                              SSPL0218
      CALL PSTEXT(X,Y,10.0,'Random coil')                               SSPL0219
                                                                        SSPL0220
C---- Accessibility shading                                             SSPL0221
      IF (SHOWAC) THEN                                                  SSPL0222
          X = XP + 248.0                                                SSPL0223
          Y1 = Y + 2.5                                                  SSPL0224
          Y2 = Y - 2.5                                                  SSPL0225
          IF (INCOLR) THEN                                              SSPL0226
              CALL PSTEXT(X,Y,8.0,'Accessibility shading:')             SSPL0227
              X1 = X + 80.0                                             SSPL0228
              X2 = X1 + 5.0                                             SSPL0229
              CALL PSHADE(0.0,MINACC,RGB,MXCOLR,INCOLR)                 SSPL0230
              CALL PSBBOX(X1,Y1,X2,Y1,X2,Y2,X1,Y2)                      SSPL0231
              X = X2 + 7.0                                              SSPL0232
              CALL PSTEXT(X,Y,8.0,'Buried')                             SSPL0233
              X1 = X + 34.0                                             SSPL0234
              X2 = X1 + 5.0                                             SSPL0235
              CALL PSHADE(0.0,MAXACC,RGB,MXCOLR,INCOLR)                 SSPL0236
              CALL PSBBOX(X1,Y1,X2,Y1,X2,Y2,X1,Y2)                      SSPL0237
              X = X2 + 7.0                                              SSPL0238
              CALL PSTEXT(X,Y,8.0,'Accessible')                         SSPL0239
          ELSE                                                          SSPL0240
              CALL PSTEXT(X,Y,8.0,'Accessibility shading: Black=' //    SSPL0241
     &            'buried, White=accessible')                           SSPL0242
          ENDIF                                                         SSPL0243
      ENDIF                                                             SSPL0244
                                                                        SSPL0245
      RETURN                                                            SSPL0246
      END                                                               SSPL0247
                                                                        SSPL0248
      SUBROUTINE PINGRF(XPORIG,YP,XPWID,YPWID,BSHADE,YMAX,FPIN,         PING0001
     &    LPIN,IREC,LIREC,JREC,LJREC,INCOLR,MXCOLR,RGB,COLOUR)          PING0002
C-----------------------------------------------------------------------PING0003
CHECK v.3.4-->                                                          PING0004
C Routines PINTIC, PINRNO, DHELIX transferred to ps.f                   PING0005
CHECK v.3.4<--                                                          PING0006
C                                                                       PING0007
C  SUBROUTINE PINGRF  -  Print current graph for pins plot              PING0008
C                                                                       PING0009
C----------------------------------------------------------------------+PING0010
                                                                        PING0011
CHECK v.3.2-->                                                          PING0012
C      CHARACTER*110 IREC, JREC                                         PING0013
      CHARACTER*(*) IREC, JREC                                          PING0014
CHECK v.3.2<--                                                          PING0015
      INTEGER       COLOUR, FPIN, INTRL, LPIN, LIREC, LJREC, MXCOLR     PING0016
      LOGICAL       BSHADE, INCOLR                                      PING0017
      REAL          RGB(3,MXCOLR), SCALEY, XCENTR, XP, XPORIG, XPWID,   PING0018
     &              YCENTR, YMAX, YP, YPWID                             PING0019
                                                                        PING0020
C---- Draw box and axis labels                                          PING0021
      XP = XPORIG                                                       PING0022
      IF (BSHADE) THEN                                                  PING0023
          CALL PSHADE(0.9,COLOUR,RGB,MXCOLR,INCOLR)                     PING0024
          CALL PSUBOX(XP,YP,XP,YP + YPWID,XP + XPWID,YP + YPWID,        PING0025
     &        XP + XPWID,YP)                                            PING0026
      ENDIF                                                             PING0027
      XCENTR = XPORIG + XPWID / 2.0                                     PING0028
      YCENTR = YP + YPWID / 2.0                                         PING0029
      SCALEY = YPWID / YMAX                                             PING0030
      INTRL = 0                                                         PING0031
      IF (YMAX.LE.2.0) INTRL = 1                                        PING0032
      CALL AXES(XP,XP + XPWID,YP,YP + YPWID,0,5,REAL(FPIN),             PING0033
     &    REAL(LPIN),0.0,YMAX,10.0,0,INTRL,15.0,.TRUE.,.TRUE.,          PING0034
     &    .FALSE.,.FALSE.,.FALSE.)                                      PING0035
                                                                        PING0036
C---- Sub-heading and x-axis title                                      PING0037
      CALL PSCTXT(XCENTR,YP + YPWID + 10.0,15.0,IREC(1:LIREC))          PING0038
      CALL PSCTXT(XCENTR,YP - 20.0,10.0,'Residue number')               PING0039
                                                                        PING0040
C---- y-axis headings                                                   PING0041
      CALL PSRCTX(XPORIG - 28.0,YP + YPWID / 2.0,10.0,JREC(1:LJREC))    PING0042
                                                                        PING0043
      RETURN                                                            PING0044
      END                                                               PING0045
                                                                        PING0046
      SUBROUTINE PINBOX(THEPIN,NPIN,PINDAT,XP,YP,YPWID,SCALEX,SCALEY,   PINB0001
     &    STDNUM,INCOLR,MXCOLR,RGB,COLBAD,COLGD)                        PINB0002
C-----------------------------------------------------------------------PINB0003
C                                                                       PINB0004
C  SUBROUTINE PINBOX  -  Print histogram bars for pins plot             PINB0005
C                                                                       PINB0006
C----------------------------------------------------------------------+PINB0007
                                                                        PINB0008
      INTEGER       COLBAD, COLGD, IPIN, MXCOLR, NPIN, THEPIN           PINB0009
      LOGICAL       INCOLR                                              PINB0010
      REAL          PINDAT(THEPIN), RGB(3,MXCOLR), SCALEX, SCALEY,      PINB0011
     &              STDNUM, XP, X1, X2, YP, YPWID, Y1, Y2               PINB0012
                                                                        PINB0013
C---- Plot the values                                                   PINB0014
      X1 = XP                                                           PINB0015
      Y1 = YP                                                           PINB0016
      DO 100, IPIN = 1, NPIN                                            PINB0017
          X2 = X1 + SCALEX                                              PINB0018
CHECK v.3.2-->                                                          PINB0019
C          IF (PINDAT(IPIN).GT.0.0) THEN                                PINB0020
          IF (PINDAT(IPIN).LT.990.0) THEN                               PINB0021
CHECK v.3.2<--                                                          PINB0022
              Y2 = SCALEY * PINDAT(IPIN)                                PINB0023
              IF (Y2.GT.YPWID) Y2 = YPWID                               PINB0024
              Y2 = Y1 + Y2                                              PINB0025
              IF (PINDAT(IPIN).GT.STDNUM) THEN                          PINB0026
                  CALL PSHADE(0.0,COLBAD,RGB,MXCOLR,INCOLR)             PINB0027
              ELSE                                                      PINB0028
                  CALL PSHADE(0.4,COLGD,RGB,MXCOLR,INCOLR)              PINB0029
              ENDIF                                                     PINB0030
              CALL PSBBOX(X1,Y1,X2,Y1,X2,Y2,X1,Y2)                      PINB0031
          ENDIF                                                         PINB0032
          X1 = X2                                                       PINB0033
 100  CONTINUE                                                          PINB0034
                                                                        PINB0035
      RETURN                                                            PINB0036
      END                                                               PINB0037
                                                                        PINB0038
      SUBROUTINE PINGFS(XSTART,XGAP,YSTART,YHT,GFACTR,NDISTR,INCOLR,    PING0001
     &    MXCOLR,RGB,MINCOL,MAXCOL,NCOVAL,NDIHED)                       PING0002
C-----------------------------------------------------------------------PING0003
C                                                                       PING0004
C  SUBROUTINE PINGFS  -  Print the overall G-factors on the chequer-boarPING0005
C                        for the protein as a whole                     PING0006
C                                                                       PING0007
C----------------------------------------------------------------------+PING0008
                                                                        PING0009
      SAVE                                                              PING0010
                                                                        PING0011
CHECK v.3.2-->                                                          PING0012
      CHARACTER*7   CNUMB                                               PING0013
CHECK v.3.2<--                                                          PING0014
      INTEGER       MXCOLR                                              PING0015
      REAL          MINSHD, VALLOW, VALUPP                              PING0016
      PARAMETER    (                                                    PING0017
     &              MINSHD =  0.97,                                     PING0018
     &              VALLOW =  0.00,                                     PING0019
     &              VALUPP = -2.50                                      PING0020
     &             )                                                    PING0021
                                                                        PING0022
      INTEGER       IDISTR, MAXCOL, MINCOL, NCOVAL, NDIHED, NDISTR      PING0023
      LOGICAL       INCOLR                                              PING0024
      REAL          GFACTR(NDISTR), RGB(3,MXCOLR), SHADE,               PING0025
     &              VALUE, X1, X2, XGAP, XSTART, Y1, Y2, YHT, YSTART    PING0026
                                                                        PING0027
C---- Initialise values                                                 PING0028
      X1 = XSTART + XGAP                                                PING0029
      X2 = X1 + XGAP                                                    PING0030
      Y1 = YSTART                                                       PING0031
                                                                        PING0032
C---- Print column heading                                              PING0033
      CALL PSCTXT((X1 + X2) / 2.0,Y1 + YHT * 0.75,6.0,'Ave')            PING0034
                                                                        PING0035
C---- Loop through the different distribution types                     PING0036
      DO 300, IDISTR = 1, NDISTR                                        PING0037
                                                                        PING0038
C----     Calculate y-extent of current box and its shade               PING0039
          Y2 = Y1 - YHT                                                 PING0040
          VALUE = GFACTR(IDISTR)                                        PING0041
          IF (VALUE.GT.999.0) THEN                                      PING0042
              SHADE = 1.0                                               PING0043
          ELSE                                                          PING0044
              IF (VALUE.GT.VALLOW) THEN                                 PING0045
                  SHADE = MINSHD                                        PING0046
              ELSE IF (VALUE.LE.VALUPP) THEN                            PING0047
                  SHADE = 0.0                                           PING0048
              ELSE                                                      PING0049
                  SHADE = MINSHD                                        PING0050
     &                - MINSHD * (VALUE - VALLOW)                       PING0051
     &                / (VALUPP - VALLOW)                               PING0052
              ENDIF                                                     PING0053
          ENDIF                                                         PING0054
                                                                        PING0055
C----     Plot the box                                                  PING0056
          IF (VALUE.GT.999.0) THEN                                      PING0057
              CALL PSHADE(SHADE,1,RGB,MXCOLR,.FALSE.)                   PING0058
          ELSE                                                          PING0059
              CALL PSCALE(SHADE,INCOLR,MXCOLR,RGB,MINCOL,               PING0060
     &            MAXCOL)                                               PING0061
          ENDIF                                                         PING0062
          CALL PSBBOX(X1,Y1,X2,Y1,X2,Y2,X1,Y2)                          PING0063
                                                                        PING0064
CHECK v.3.2-->                                                          PING0065
C----     Print the G-factor value to the right of the box              PING0066
          IF (VALUE.LT.990.0) THEN                                      PING0067
              WRITE(CNUMB,200) VALUE                                    PING0068
 200          FORMAT(F7.2)                                              PING0069
              CALL PSTEXT(X2,(Y1 + Y2) / 2.0,6.0,CNUMB)                 PING0070
          ENDIF                                                         PING0071
CHECK v.3.2<--                                                          PING0072
                                                                        PING0073
C----     Increment y-value for next block                              PING0074
          Y1 = Y2                                                       PING0075
          IF (IDISTR.EQ.NDIHED) Y1 = Y1 - YHT / 2.0                     PING0076
          IF (IDISTR.EQ.NDIHED + 1) Y1 = Y1 - YHT                       PING0077
          IF (IDISTR.EQ.NDIHED + NCOVAL + 1)                            PING0078
     &        Y1 = Y1 - YHT / 2.0                                       PING0079
          IF (IDISTR.EQ.NDISTR - 1) Y1 = Y1 - YHT * 1.5                 PING0080
 300  CONTINUE                                                          PING0081
                                                                        PING0082
      RETURN                                                            PING0083
      END                                                               PING0084
                                                                        PING0085
      SUBROUTINE REASDH(IRESID,LAVVAL,LCCVAL,LPPVAL,SCORE)              REAS0001
C-----------------------------------------------------------------------REAS0002
C                                                                       REAS0003
C  SUBROUTINE REASDH  -  Get the next record from the .sdh file         REAS0004
C                                                                       REAS0005
C----------------------------------------------------------------------+REAS0006
                                                                        REAS0007
      SAVE                                                              REAS0008
                                                                        REAS0009
      INCLUDE 'pplot.inc'                                               REAS0010
                                                                        REAS0011
      CHARACTER*120 IREC                                                REAS0012
      INTEGER       IDIST, INRES, IRESID, LINE                          REAS0013
      REAL          LAVVAL, LCCVAL, LPPVAL, SCORE(NDISTR)               REAS0014
                                                                        REAS0015
      DATA INRES, LINE   / 2*0 /                                        REAS0016
                                                                        REAS0017
C---- Initialise variables                                              REAS0018
      LAVVAL = 0.0                                                      REAS0019
      LCCVAL = 0.0                                                      REAS0020
      LPPVAL = 0.0                                                      REAS0021
      DO 50, IDIST = 1, NDISTR                                          REAS0022
          SCORE(IDIST) = 0.0                                            REAS0023
 50   CONTINUE                                                          REAS0024
                                                                        REAS0025
C---- If the required residue is of a greater number than that required,REAS0026
C     read through the file until come to it                            REAS0027
      IF (IRESID.GT.INRES) THEN                                         REAS0028
                                                                        REAS0029
C----     Read through the records                                      REAS0030
 100      CONTINUE                                                      REAS0031
              READ(3,120,END=500,ERR=900) IREC                          REAS0032
 120          FORMAT(A)                                                 REAS0033
              LINE = LINE + 1                                           REAS0034
                                                                        REAS0035
C----         If it is not the "Means" record, then check the residue noREAS0036
              IF (IREC(1:5).NE.'Means') THEN                            REAS0037
                                                                        REAS0038
C----             Get the residue number                                REAS0039
                  READ(IREC,180,ERR=902) INRES                          REAS0040
 180              FORMAT(I6)                                            REAS0041
              ENDIF                                                     REAS0042
                                                                        REAS0043
C----     Loop back for next record in file                             REAS0044
          IF (IRESID.GT.INRES) GO TO 100                                REAS0045
      ENDIF                                                             REAS0046
                                                                        REAS0047
C---- If it is the one required, save the details                       REAS0048
      IF (IRESID.EQ.INRES) THEN                                         REAS0049
          READ(IREC,210,ERR=900,END=999) (SCORE(IDIST),                 REAS0050
     &        IDIST = 1, NDISTR)                                        REAS0051
 210      FORMAT(17X,10F9.4)                                            REAS0052
          IF (SCORE(1).LT.0.0) LPPVAL = -SCORE(1)                       REAS0053
          IF (SCORE(2).LT.0.0) LCCVAL = -SCORE(2)                       REAS0054
          IF (SCORE(NDIHED + 1).LT.0.0) LAVVAL = -SCORE(NDIHED + 1)     REAS0055
      ENDIF                                                             REAS0056
                                                                        REAS0057
C---- End of file reached                                               REAS0058
 500  CONTINUE                                                          REAS0059
                                                                        REAS0060
      GO TO 999                                                         REAS0061
                                                                        REAS0062
C---- Fatal errors                                                      REAS0063
 900  CONTINUE                                                          REAS0064
      PRINT*, '*** ERROR. Error reading .sdh file at line:', LINE + 1   REAS0065
      GO TO 999                                                         REAS0066
                                                                        REAS0067
 902  CONTINUE                                                          REAS0068
      PRINT*, '*** ERROR. Data error in .sdh file at line:', LINE + 1   REAS0069
      PRINT*, IREC                                                      REAS0070
      GO TO 999                                                         REAS0071
                                                                        REAS0072
999   CONTINUE                                                          REAS0073
      RETURN                                                            REAS0074
      END                                                               REAS0075
                                                                        REAS0076
      SUBROUTINE REARSA(INCHN,SEQNO,RESDUE,VALACC)                      REAR0001
C-----------------------------------------------------------------------REAR0002
CHECK v.3.1-->                                                          REAR0003
C                                                                       REAR0004
C  SUBROUTINE REARSA  -  Get the next record from the .rsa file         REAR0005
C                                                                       REAR0006
C----------------------------------------------------------------------+REAR0007
                                                                        REAR0008
      SAVE                                                              REAR0009
                                                                        REAR0010
      INCLUDE 'pplot.inc'                                               REAR0011
                                                                        REAR0012
      CHARACTER*1   CHN, INCHN                                          REAR0013
      CHARACTER*3   RES, RESDUE                                         REAR0014
      CHARACTER*5   SEQ, SEQNO                                          REAR0015
      CHARACTER*6   CMPARE                                              REAR0016
      CHARACTER*120 IREC                                                REAR0017
      INTEGER       LINE, NREWIN                                        REAR0018
      LOGICAL       ATEND                                               REAR0019
      REAL          VAL, VALACC                                         REAR0020
                                                                        REAR0021
      DATA ATEND  / .FALSE. /                                           REAR0022
      DATA LINE   / 0 /                                                 REAR0023
                                                                        REAR0024
C---- Initialise variables                                              REAR0025
      NREWIN = 0                                                        REAR0026
      VALACC = 0.0                                                      REAR0027
                                                                        REAR0028
C---- If a previous read has hit the end of the file, rewind it         REAR0029
      IF (ATEND) THEN                                                   REAR0030
          ATEND = .FALSE.                                               REAR0031
          REWIND(13)                                                    REAR0032
      ENDIF                                                             REAR0033
                                                                        REAR0034
C---- Read through the file until have the next ATOM record             REAR0035
 100  CONTINUE                                                          REAR0036
          READ(13,120,END=500,ERR=900) IREC                             REAR0037
 120      FORMAT(A)                                                     REAR0038
          LINE = LINE + 1                                               REAR0039
CHECK v.3.3.2-->                                                        REAR0040
C          IF (IREC(1:4).NE.'ATOM') GO TO 100                           REAR0041
          IF (IREC(1:3).NE.'RES') GO TO 100                             REAR0042
CHECK v.3.3.2<--                                                        REAR0043
                                                                        REAR0044
C----     Check if this is the correct residue record                   REAR0045
CHECK v.3.3.2-->                                                        REAR0046
C          READ(IREC,140,ERR=902) CHN, SEQ, RES, VAL                    REAR0047
C 140      FORMAT(5X,A1,A5,1X,A3,8X,F6.0)                               REAR0048
          READ(IREC,140,ERR=902) RES, CHN, SEQ, VAL                     REAR0049
 140      FORMAT(4X,A3,1X,A1,A5,8X,F6.0)                                REAR0050
CHECK v.3.3.2<--                                                        REAR0051
                                                                        REAR0052
C----     If this is the right record, then save the accessibility %-tagREAR0053
          IF (CHN.EQ.INCHN .AND. SEQ.EQ.SEQNO) THEN                     REAR0054
              VALACC = MIN(VAL,100.0)                                   REAR0055
                                                                        REAR0056
C----         If the residue-type is wrong, print a warning             REAR0057
              IF (RES.NE.RESDUE) THEN                                   REAR0058
                  PRINT*, '*** WARNING. Residue-type in .rsa file ',    REAR0059
     &                'disagrees with that in the PDB file:'            REAR0060
                  PRINT*, '***          [', INCHN, SEQNO, RESDUE,       REAR0061
     &                ']  [', CHN, SEQ, RES, ']', VALACC                REAR0062
              ENDIF                                                     REAR0063
                                                                        REAR0064
C----     Otherwise, check whether need to keep reading the file or to  REAR0065
C         rewind it                                                     REAR0066
          ELSE                                                          REAR0067
              CMPARE = INCHN // SEQNO                                   REAR0068
                                                                        REAR0069
C----         If have overshot the record we're after, then rewind the  REAR0070
C             file and have another search for it                       REAR0071
              IF (CMPARE.LT.IREC(6:11)) THEN                            REAR0072
                  NREWIN = NREWIN + 1                                   REAR0073
                  IF (NREWIN.LT.2) THEN                                 REAR0074
                      REWIND(13)                                        REAR0075
                      GO TO 100                                         REAR0076
                  ENDIF                                                 REAR0077
                                                                        REAR0078
C----         Otherwise, search for the next record                     REAR0079
              ELSE                                                      REAR0080
                  GO TO 100                                             REAR0081
              ENDIF                                                     REAR0082
          ENDIF                                                         REAR0083
                                                                        REAR0084
      GO TO 999                                                         REAR0085
                                                                        REAR0086
C---- End of file reached                                               REAR0087
 500  CONTINUE                                                          REAR0088
      ATEND = .TRUE.                                                    REAR0089
                                                                        REAR0090
      GO TO 999                                                         REAR0091
                                                                        REAR0092
C---- Fatal errors                                                      REAR0093
 900  CONTINUE                                                          REAR0094
      PRINT*, '*** ERROR. Error reading .rsa file at line:', LINE + 1   REAR0095
      GO TO 999                                                         REAR0096
                                                                        REAR0097
 902  CONTINUE                                                          REAR0098
      PRINT*, '*** ERROR. Data error in .rsa file at line:', LINE + 1   REAR0099
      PRINT*, IREC                                                      REAR0100
      GO TO 999                                                         REAR0101
                                                                        REAR0102
999   CONTINUE                                                          REAR0103
      RETURN                                                            REAR0104
      END                                                               REAR0105
                                                                        REAR0106
      SUBROUTINE ASTOPE                                                 ASTO0001
C-----------------------------------------------------------------------ASTO0002
CHECK v.3.1<--                                                          ASTO0003
C                                                                       ASTO0004
C  SUBROUTINE ASTOPE  -  Open output listing file (.out) asterisks file ASTO0005
C                        (.ast)                                         ASTO0006
C                                                                       ASTO0007
C----------------------------------------------------------------------+ASTO0008
                                                                        ASTO0009
      INCLUDE 'pplot.inc'                                               ASTO0010
                                                                        ASTO0011
      INTEGER       I                                                   ASTO0012
                                                                        ASTO0013
C---- Initialise variables                                              ASTO0014
      DO 10, I = 1, MXCOLS                                              ASTO0015
          MXDEVC(I) = 0.0                                               ASTO0016
 10   CONTINUE                                                          ASTO0017
      NPRINT = 1                                                        ASTO0018
                                                                        ASTO0019
C---- Rewind non-bonded interactions file                               ASTO0020
      IF (NONBON) REWIND(2)                                             ASTO0021
                                                                        ASTO0022
C---- Open output print file, <filename>.out                            ASTO0023
      OPEN(UNIT=7, FILE=FILOUT, STATUS='UNKNOWN', FORM='FORMATTED',     ASTO0024
     &    ACCESS='SEQUENTIAL',                                          ASTO0025
CVAX     -    CARRIAGECONTROL='LIST',RECL=132,                          ASTO0026
     &    ERR=900)                                                      ASTO0027
                                                                        ASTO0028
C---- Open output asterisks file, <filename>.ast                        ASTO0029
      IF (IDITIS) THEN                                                  ASTO0030
          OPEN(UNIT=9, FILE=FILAST, STATUS='UNKNOWN', FORM='FORMATTED', ASTO0031
     &        ACCESS='SEQUENTIAL',                                      ASTO0032
CVAX     -        CARRIAGECONTROL='LIST',RECL=132,                      ASTO0033
     &        ERR=902)                                                  ASTO0034
      ENDIF                                                             ASTO0035
                                                                        ASTO0036
      GO TO 999                                                         ASTO0037
                                                                        ASTO0038
C---- Fatal errors                                                      ASTO0039
 900  CONTINUE                                                          ASTO0040
      PRINT*, '*** ERROR. Unable to open output file [', FILOUT, ']',   ASTO0041
     &    ' Program aborted'                                            ASTO0042
      GO TO 990                                                         ASTO0043
                                                                        ASTO0044
 902  CONTINUE                                                          ASTO0045
      PRINT*, '*** ERROR. Unable to open output file [', FILAST, ']',   ASTO0046
     &    ' Program aborted'                                            ASTO0047
      GO TO 990                                                         ASTO0048
                                                                        ASTO0049
990   CONTINUE                                                          ASTO0050
      IFAIL = .TRUE.                                                    ASTO0051
                                                                        ASTO0052
999   CONTINUE                                                          ASTO0053
      RETURN                                                            ASTO0054
      END                                                               ASTO0055
                                                                        ASTO0056
      SUBROUTINE ASTPRN(SERNO, RESDUE, INCHN, SEQNO,                    ASTP0001
     &        SECSTR, PHI, PSI, OMEGA, CHI1, CHI2, CHI3, ENHB, DISULF,  ASTP0002
     &        DIHANG, MXDEVR,REGTYP,CISPEP)                             ASTP0003
C-----------------------------------------------------------------------ASTP0004
C                                                                       ASTP0005
C  SUBROUTINE ASTPRN  -  Print current line of asterisks print          ASTP0006
C                                                                       ASTP0007
C----------------------------------------------------------------------+ASTP0008
                                                                        ASTP0009
CHECK v.3.2-->                                                          ASTP0010
C     -        DIHANG, CGAMB,MXDEVR,REGTYP)                             ASTP0011
CHECK v.3.2<--                                                          ASTP0012
                                                                        ASTP0013
      INCLUDE 'pplot.inc'                                               ASTP0014
                                                                        ASTP0015
      CHARACTER*1   INCHN, SECSTR                                       ASTP0016
      CHARACTER*2   DAMINO, REGION                                      ASTP0017
      CHARACTER*3   CISPEP, RESDUE                                      ASTP0018
      CHARACTER*5   SEQNO                                               ASTP0019
      CHARACTER*6   CHAVAL(MXCOLS)                                      ASTP0020
      CHARACTER*132 AREC, IREC                                          ASTP0021
      INTEGER       I, NBADR, REGNO, REGTYP, SERNO                      ASTP0022
CHECK v.3.2-->                                                          ASTP0023
C      REAL          BADCON, CGAMB, CHI1, CHI2, CHI3, DIHANG, DISULF,   ASTP0024
      REAL          BADCON, CHI1, CHI2, CHI3, DIHANG, DISULF,           ASTP0025
CHECK v.3.2<--                                                          ASTP0026
     &              ENHB, MXDEVR, OMEGA, PHI, PSI                       ASTP0027
                                                                        ASTP0028
                                                                        ASTP0029
C---- Initialise variables                                              ASTP0030
      AREC = ' '                                                        ASTP0031
      DO 10, I = 1, MXCOLS - 1                                          ASTP0032
          CHAVAL(I) = '    - '                                          ASTP0033
 10   CONTINUE                                                          ASTP0034
      CHAVAL(MXCOLS) = '     -'                                         ASTP0035
      IREC = ' '                                                        ASTP0036
      MXDEVR = 0.0                                                      ASTP0037
      REGION = '-'                                                      ASTP0038
                                                                        ASTP0039
C---- Find which Ramachandran-plot region this residue is in            ASTP0040
      CALL RAMREG(PHI,PSI,REGION,REGNO,REGTYP)                          ASTP0041
                                                                        ASTP0042
C---- Asterisks required if disallowed or generous                      ASTP0043
      IF (RESDUE.NE.'GLY' .AND. RESDUE.NE.'PRO') THEN                   ASTP0044
                                                                        ASTP0045
C----     Check whether this is an end-residue at a chain break         ASTP0046
          IF (PHI.NE.999.9 .AND. PSI.NE.999.9) THEN                     ASTP0047
                                                                        ASTP0048
C----         Determine number of asterisks required                    ASTP0049
              IF (REGION.EQ.'XX') THEN                                  ASTP0050
                  CALL ASTDEV(4.0,0.0,1.0,CHAVAL(1),MXDEVC(1),          ASTP0051
     &                MXDEVR,AREC,19,1,STDLIM,ASTONL)                   ASTP0052
              ELSE IF (REGION(1:1).EQ.'~') THEN                         ASTP0053
                  CALL ASTDEV(2.0,0.0,1.0,CHAVAL(1),MXDEVC(1),          ASTP0054
     &                MXDEVR,AREC,19,1,STDLIM,ASTONL)                   ASTP0055
              ENDIF                                                     ASTP0056
          ELSE                                                          ASTP0057
              REGION = '-'                                              ASTP0058
          ENDIF                                                         ASTP0059
      ELSE                                                              ASTP0060
          REGION = '-'                                                  ASTP0061
      ENDIF                                                             ASTP0062
                                                                        ASTP0063
C---- Chi-1 torsion angle                                               ASTP0064
      IF (RESDUE.EQ.'PRO') CHI1 = 999.9                                 ASTP0065
      IF (CHI1.LT.0.0) CHI1 = CHI1 + 360.0                              ASTP0066
      IF (CHI1.EQ.360.0) CHI1 = 0.0                                     ASTP0067
      IF (CHI1.GE.0.0 .AND. CHI1.LT.360.0) THEN                         ASTP0068
                                                                        ASTP0069
C----     Chi-1 gauche minus                                            ASTP0070
          IF (CHI1.GE.0.0 .AND. CHI1.LT.120.0) THEN                     ASTP0071
              CALL ASTDEV(CHI1,GLOBGM,SDEVGM,CHAVAL(2),MXDEVC(2),       ASTP0072
     &            MXDEVR,AREC,27,1,STDLIM,ASTONL)                       ASTP0073
                                                                        ASTP0074
C----     Chi-1 trans                                                   ASTP0075
          ELSE IF (CHI1.GE.120.0 .AND. CHI1.LT.240.0) THEN              ASTP0076
              CALL ASTDEV(CHI1,GLOBGT,SDEVGT,CHAVAL(3),MXDEVC(3),       ASTP0077
     &            MXDEVR,AREC,33,1,STDLIM,ASTONL)                       ASTP0078
                                                                        ASTP0079
C----     Chi-1 gauche plus                                             ASTP0080
          ELSE IF (CHI1.GE.240.0 .AND. CHI1.LT.360.0) THEN              ASTP0081
              CALL ASTDEV(CHI1-360.0,GLOBGP-360.0,SDEVGP,CHAVAL(4),     ASTP0082
     &            MXDEVC(4), MXDEVR,AREC,39,1,STDLIM,ASTONL)            ASTP0083
          ENDIF                                                         ASTP0084
      ENDIF                                                             ASTP0085
                                                                        ASTP0086
C---- Chi-2 trans torsion angle                                         ASTP0087
      IF (RESDUE.NE.'PHE' .AND. RESDUE.NE.'TYR' .AND.                   ASTP0088
     &    RESDUE.NE.'TRP' .AND. RESDUE.NE.'HIS' .AND.                   ASTP0089
     &    RESDUE.NE.'ASP' .AND. RESDUE.NE.'ASN') THEN                   ASTP0090
          IF (CHI2.LE.0.0) CHI2 = CHI2 + 360.0                          ASTP0091
          IF (CHI2.GT.120.0 .AND. CHI2.LE.240.0) THEN                   ASTP0092
              CALL ASTDEV(CHI2,GLOBC2,SDEVC2,CHAVAL(5),MXDEVC(5),       ASTP0093
     &            MXDEVR,AREC,45,1,STDLIM,ASTONL)                       ASTP0094
          ENDIF                                                         ASTP0095
      ENDIF                                                             ASTP0096
                                                                        ASTP0097
C---- Proline phi                                                       ASTP0098
      IF (RESDUE.EQ.'PRO' .AND. PHI.NE.999.9) THEN                      ASTP0099
          CALL ASTDEV(PHI,GLOBPP,SDEVPP,CHAVAL(6),MXDEVC(6),            ASTP0100
     &        MXDEVR,AREC,51,1,STDLIM,ASTONL)                           ASTP0101
      ENDIF                                                             ASTP0102
                                                                        ASTP0103
C---- Phi helix                                                         ASTP0104
      IF (SECSTR.EQ.'H' .AND. PHI.NE.999.9) THEN                        ASTP0105
          CALL ASTDEV(PHI,GLOBPH,SDEVPH,CHAVAL(7),MXDEVC(7),            ASTP0106
     &        MXDEVR,AREC,57,1,STDLIM,ASTONL)                           ASTP0107
      ENDIF                                                             ASTP0108
                                                                        ASTP0109
C---- Helix psi                                                         ASTP0110
      IF (SECSTR.EQ.'H' .AND. PSI.NE.999.9) THEN                        ASTP0111
          CALL ASTDEV(PSI,GLOBHP,SDEVHP,CHAVAL(8),MXDEVC(8),            ASTP0112
     &        MXDEVR,AREC,63,1,STDLIM,ASTONL)                           ASTP0113
      ENDIF                                                             ASTP0114
                                                                        ASTP0115
C---- Chi-3 right-hand                                                  ASTP0116
      IF (RESDUE.EQ.'CYS' .AND. CHI3.GT.0.0 .AND. CHI3.LE.180.0) THEN   ASTP0117
          CALL ASTDEV(CHI3,GLOB3R,SDEV3R,CHAVAL(9),MXDEVC(9),           ASTP0118
     &        MXDEVR,AREC,70,1,STDLIM,ASTONL)                           ASTP0119
      ENDIF                                                             ASTP0120
                                                                        ASTP0121
C---- Chi-3 left-hand                                                   ASTP0122
      IF (RESDUE.EQ.'CYS' .AND. CHI3.LE.0.0 .AND. CHI3.GE.-180.0) THEN  ASTP0123
          CALL ASTDEV(CHI3,GLOB3L,SDEV3L,CHAVAL(10),MXDEVC(10),         ASTP0124
     &        MXDEVR,AREC,78,1,STDLIM,ASTONL)                           ASTP0125
      ENDIF                                                             ASTP0126
                                                                        ASTP0127
C---- Disulphide bond                                                   ASTP0128
      IF (RESDUE.EQ.'CYS') THEN                                         ASTP0129
          IF (DISULF.NE.0.0) THEN                                       ASTP0130
              CALL ASTDEV(DISULF,GLOBSS,SDEVSS,CHAVAL(11),MXDEVC(11),   ASTP0131
     &            MXDEVR,AREC,85,1,STDLIM,ASTONL)                       ASTP0132
          ENDIF                                                         ASTP0133
      ENDIF                                                             ASTP0134
                                                                        ASTP0135
C---- Case of trans peptide (ie abs(omega) > 45)                        ASTP0136
      IF (ABS(OMEGA).GE.45.0 .AND. OMEGA.LE.360.0) THEN                 ASTP0137
          IF (OMEGA.LT.0.0) OMEGA = OMEGA + 360.0                       ASTP0138
          CALL ASTDEV(OMEGA,GLOBOM,SDEVOM,CHAVAL(12),MXDEVC(12),        ASTP0139
     &        MXDEVR,AREC,93,1,STDLIM,ASTONL)                           ASTP0140
CHECK v.3.2-->                                                          ASTP0141
C          CISPEP = ' '                                                 ASTP0142
CHECK v.3.2<--                                                          ASTP0143
                                                                        ASTP0144
C---- Case of cis peptide (ie abs(omega) < 45)                          ASTP0145
      ELSE IF (ABS(OMEGA).LT.45.0) THEN                                 ASTP0146
          CALL ASTDEV(OMEGA,0.0,SDEVCS,CHAVAL(12),MXDEVC(12),           ASTP0147
     &        MXDEVR,AREC,93,1,STDLIM,ASTONL)                           ASTP0148
CHECK v.3.2-->                                                          ASTP0149
C          CISPEP = 'cis'                                               ASTP0150
C          NCIS = NCIS + 1                                              ASTP0151
C          PRINT*, '    * cis-peptide:  ', RESDUE, ' ', INCHN, ' ',     ASTP0152
C     -        SEQNO                                                    ASTP0153
CHECK v.3.2<--                                                          ASTP0154
      ENDIF                                                             ASTP0155
                                                                        ASTP0156
CHECK v.3.2-->                                                          ASTP0157
C---- If this ia a cis peptide, then display message                    ASTP0158
      IF (CISPEP.EQ.'cis') THEN                                         ASTP0159
          NCIS = NCIS + 1                                               ASTP0160
          PRINT*, '    * cis-peptide:  ', RESDUE, ' ', INCHN, ' ',      ASTP0161
     &        SEQNO                                                     ASTP0162
      ENDIF                                                             ASTP0163
CHECK v.3.2<--                                                          ASTP0164
                                                                        ASTP0165
C---- Hydrogen bond energy mean and standard deviation                  ASTP0166
      IF (ENHB.LT.0.0) THEN                                             ASTP0167
          CALL ASTDEV(ENHB,GLOBHB,SDEVHB,CHAVAL(13),MXDEVC(13),         ASTP0168
     &        MXDEVR,AREC,100,1,STDLIM,ASTONL)                          ASTP0169
      ENDIF                                                             ASTP0170
                                                                        ASTP0171
C---- Alpha carbon chirality (zeta torsion angle)                       ASTP0172
      IF (DIHANG.NE.999.9) THEN                                         ASTP0173
          CALL ASTDEV(DIHANG,GLOBDH,SDEVDH,CHAVAL(14),MXDEVC(14),       ASTP0174
     &        MXDEVR,AREC,109,1,STDLIM,ASTONL)                          ASTP0175
      ENDIF                                                             ASTP0176
                                                                        ASTP0177
C---- If the zeta torsion angle is negative, then have a D-amino acid   ASTP0178
      DAMINO = '  '                                                     ASTP0179
      IF (DIHANG.LT.0.0) THEN                                           ASTP0180
          DAMINO = 'D>'                                                 ASTP0181
          NDAM = NDAM + 1                                               ASTP0182
          PRINT*, '    * D-amino acid: ', RESDUE, ' ', INCHN, ' ',      ASTP0183
     &        SEQNO                                                     ASTP0184
      ENDIF                                                             ASTP0185
                                                                        ASTP0186
C---- Find the number of non-bonded contacts for this residue           ASTP0187
      IF (NONBON) THEN                                                  ASTP0188
          CALL READNB(CHAIN,INCHN,SEQNO,NBADR,VWDIST)                   ASTP0189
          BADCON = REAL(NBADR)                                          ASTP0190
          IF (NBADR.GT.0) THEN                                          ASTP0191
              NBADPR = NBADPR + NBADR                                   ASTP0192
              CALL ASTDEV(BADCON,0.0,1.0,CHAVAL(15),MXDEVC(15),         ASTP0193
     &            MXDEVR,AREC,116,0,STDLIM,ASTONL)                      ASTP0194
          ENDIF                                                         ASTP0195
      ENDIF                                                             ASTP0196
                                                                        ASTP0197
C---- Print the lines                                                   ASTP0198
                                                                        ASTP0199
C---- Write out residue information to IDITIS asterisk file             ASTP0200
      IF (IDITIS) THEN                                                  ASTP0201
          WRITE(9,240) SERNO, INCHN, RESDUE, SEQNO, MXDEVR              ASTP0202
 240      FORMAT(I4,A1,1X,A3,A5,F10.3)                                  ASTP0203
      ENDIF                                                             ASTP0204
                                                                        ASTP0205
C---- If printing all residues, or only the highlighted ones and the devASTP0206
C     is above the minimum required, then print                         ASTP0207
      IF (.NOT.ONLYHI .OR. MXDEVR.GT.0.0) THEN                          ASTP0208
                                                                        ASTP0209
C----     If only printing the asterisks line, transfer residue info to ASTP0210
C         start of the line                                             ASTP0211
          IF (ASTONL) THEN                                              ASTP0212
              WRITE(AREC(1:21),610) SERNO, INCHN, RESDUE, SEQNO,        ASTP0213
     &            SECSTR, CISPEP                                        ASTP0214
              AREC(25:26) = REGION                                      ASTP0215
                                                                        ASTP0216
C----     Otherwise, print the line holding the information             ASTP0217
          ELSE                                                          ASTP0218
              ILINE = ILINE + 1                                         ASTP0219
              IF (AREC.NE.' ') THEN                                     ASTP0220
                  IF (ILINE.GE.NLINES - 1) THEN                         ASTP0221
                      CALL ASTHED                                       ASTP0222
                  ENDIF                                                 ASTP0223
              ELSE                                                      ASTP0224
                  IF (ILINE.GE.NLINES) THEN                             ASTP0225
                      CALL ASTHED                                       ASTP0226
                  ENDIF                                                 ASTP0227
              ENDIF                                                     ASTP0228
              WRITE(7,610) SERNO, INCHN, RESDUE, SEQNO,                 ASTP0229
     &             SECSTR, CISPEP, REGION, (CHAVAL(I), I = 2, 13),      ASTP0230
     &             DAMINO, CHAVAL(14), CHAVAL(15)                       ASTP0231
 610          FORMAT(I4,A1,1X,A3,A5,2X,A1,1X,A3,1X,A2,2X,7A6,1X,A6,2X,  ASTP0232
     &            A6,1X,A6,2X,A6,1X,A6,1X,A2,A6,1X,A6)                  ASTP0233
          ENDIF                                                         ASTP0234
                                                                        ASTP0235
C----     Print asterisks line if not blank                             ASTP0236
          IF (AREC.NE.' ') THEN                                         ASTP0237
              ILINE = ILINE + 1                                         ASTP0238
              IF (ILINE.GE.NLINES) CALL ASTHED                          ASTP0239
              WRITE(7,620) AREC                                         ASTP0240
 620          FORMAT(A131)                                              ASTP0241
          ENDIF                                                         ASTP0242
      ENDIF                                                             ASTP0243
                                                                        ASTP0244
      RETURN                                                            ASTP0245
      END                                                               ASTP0246
                                                                        ASTP0247
      SUBROUTINE ASTHED                                                 ASTH0001
C-----------------------------------------------------------------------ASTH0002
C                                                                       ASTH0003
C  SUBROUTINE ASTHED  -  Print headings for asterisks print-out         ASTH0004
C                                                                       ASTH0005
C----------------------------------------------------------------------+ASTH0006
                                                                        ASTH0007
      INCLUDE 'pplot.inc'                                               ASTH0008
                                                                        ASTH0009
                                                                        ASTH0010
C---- Initialise values                                                 ASTH0011
      ILINE = 0                                                         ASTH0012
      IPAGE = IPAGE + 1                                                 ASTH0013
                                                                        ASTH0014
C---- Throw a page if not the first one                                 ASTH0015
      IF (IPAGE.GT.1) WRITE(7,*) CHAR(12)                               ASTH0016
                                                                        ASTH0017
C---- Print headings                                                    ASTH0018
      WRITE(7,100) BRCODE, IPAGE                                        ASTH0019
 100  FORMAT(                                                           ASTH0020
     &    'Residue-by-residue listing for ',A78,14X,'Page',I3,/,        ASTH0021
     &    '----------------------------------------',/)                 ASTH0022
      ILINE = ILINE + 3                                                 ASTH0023
                                                                        ASTH0024
C---- Print explanatory text, if required                               ASTH0025
      IF (IPAGE.EQ.1 .AND. HEADIN) THEN                                 ASTH0026
          CALL ASTABL                                                   ASTH0027
      ENDIF                                                             ASTH0028
                                                                        ASTH0029
C---- Print user-defined options, if required                           ASTH0030
      IF (IPAGE.EQ.1) THEN                                              ASTH0031
          CALL ASTOPT                                                   ASTH0032
      ENDIF                                                             ASTH0033
                                                                        ASTH0034
C---- Print the appropriate column headings                             ASTH0035
      IF (NPRINT.EQ.1) CALL COLHD1                                      ASTH0036
      IF (NPRINT.EQ.2) CALL COLHD2                                      ASTH0037
      IF (NPRINT.EQ.3) CALL COLHD3                                      ASTH0038
                                                                        ASTH0039
      RETURN                                                            ASTH0040
      END                                                               ASTH0041
                                                                        ASTH0042
C-----------------------------------------------------------------------ASTH0043
C***********************************************************************ASTH0044
C                                                                       ASTH0045
C  SUBROUTINE COLHD1  -  Column headings headings for asterisks print-ouASTH0046
C                                                                       ASTH0047
C----------------------------------------------------------------------+ASTH0048
                                                                        ASTH0049
      SUBROUTINE COLHD1                                                 COLH0001
                                                                        COLH0002
      INCLUDE 'pplot.inc'                                               COLH0003
                                                                        COLH0004
                                                                        COLH0005
C---- Print column headings                                             COLH0006
      WRITE(7,260)                                                      COLH0007
 260  FORMAT(                                                           COLH0008
     &    '...........................................................',COLH0009
     &    '...........................................................',COLH0010
     &    '.............')                                              COLH0011
      ILINE = ILINE + 1                                                 COLH0012
      WRITE(7,280)                                                      COLH0013
 280  FORMAT(                                                           COLH0014
     &    ' Residue     Kabsch Region',/,                               COLH0015
     &    '---------    Sander   of',/,                                 COLH0016
     &    'No.  Type Seq  sec  Ramch.  Chi-1 dihedral   Chi-2 Proline ',COLH0017
     &    'Phi  Helix  Chi-3   Chi-3 Disulph Omega  H-bond Chirality  ',COLH0018
     &    ' Bad      Max',/,                                            COLH0019
     &    '  Chain   no. struc  plot   g(-) trans g(+)  trans   phi  h',COLH0020
     &    'elix  psi  rt-hand lf-hand  bond dihedral  en.   C-alpha  c',COLH0021
     &    'ontacts   dev',/,                                            COLH0022
     &    '-----------------------------------------------------------',COLH0023
     &    '-----------------------------------------------------------',COLH0024
     &    '-------------')                                              COLH0025
      ILINE = ILINE + 5                                                 COLH0026
                                                                        COLH0027
      RETURN                                                            COLH0028
      END                                                               COLH0029
                                                                        COLH0030
                                                                        COLH0031
      SUBROUTINE COLHD2                                                 COLH0001
C-----------------------------------------------------------------------COLH0002
C                                                                       COLH0003
C  SUBROUTINE COLHD2  -  Column headings headings for bond length and   COLH0004
C                        angles                                         COLH0005
C                                                                       COLH0006
C----------------------------------------------------------------------+COLH0007
                                                                        COLH0008
      INCLUDE 'pplot.inc'                                               COLH0009
                                                                        COLH0010
C---- Print column headings                                             COLH0011
      WRITE(7,420)                                                      COLH0012
 420  FORMAT(//,                                                        COLH0013
     &    '...........................................................',COLH0014
     &    '...........................................................',COLH0015
     &    '.............',/,                                            COLH0016
     &    '   Residue ',/,                                              COLH0017
     &    '-------------     <---------- Bond lengths ---------->    <',COLH0018
     &    '---------------------- Bond angles ---------------------->') COLH0019
      ILINE = ILINE + 5                                                 COLH0020
                                                                        COLH0021
      WRITE(7,440)                                                      COLH0022
 440  FORMAT(                                                           COLH0023
     &    ' No.  Type Seq                                             ',COLH0024
     &    '                                                           ',COLH0025
     &    '          Max',/,                                            COLH0026
     &    '  Chain    no.    C-N     C-O     CA-C    CA-CB   N-CA    C',COLH0027
     &    '-N-CA   CA-C-N   CA-C-O  CB-CA-C   N-CA-C  N-CA-CB   O-C-N ',COLH0028
     &    '          dev',/,                                            COLH0029
     &    '-----------------------------------------------------------',COLH0030
     &    '-----------------------------------------------------------',COLH0031
     &    '-------------')                                              COLH0032
      ILINE = ILINE + 3                                                 COLH0033
                                                                        COLH0034
      RETURN                                                            COLH0035
      END                                                               COLH0036
                                                                        COLH0037
      SUBROUTINE COLHD3                                                 COLH0001
C-----------------------------------------------------------------------COLH0002
C                                                                       COLH0003
C  SUBROUTINE COLHD3  -  Column headings headings for bad contacts listiCOLH0004
C                                                                       COLH0005
C----------------------------------------------------------------------+COLH0006
                                                                        COLH0007
      INCLUDE 'pplot.inc'                                               COLH0008
                                                                        COLH0009
                                                                        COLH0010
C---- Print column headings                                             COLH0011
      WRITE(7,100)                                                      COLH0012
 100  FORMAT(//,36X,                                                    COLH0013
     &    'B  A  D     C  O  N  T  A  C  T  S     L  I  S  T  I  N  G', COLH0014
     &    //)                                                           COLH0015
      ILINE = ILINE + 5                                                 COLH0016
      WRITE(7,200)                                                      COLH0017
 200  FORMAT(                                                           COLH0018
     &    30X,'........................................',               COLH0019
     &    '...............................',/,                          COLH0020
     &    30X,'  Residue                 Residue       ',/,             COLH0021
     &    30X,'-----------             -----------     ',/,             COLH0022
     &    30X,' No.   Type              No.   Type     ',               COLH0023
     &    '         Contact     Distance',/,                            COLH0024
     &    30X,'    Chain      Atom          Chain     At',              COLH0025
     &    'om       type      (Angstroms)',/,                           COLH0026
     &    30X,'----------------------------------------',               COLH0027
     &    '-------------------------------')                            COLH0028
      ILINE = ILINE + 6                                                 COLH0029
                                                                        COLH0030
      RETURN                                                            COLH0031
      END                                                               COLH0032
                                                                        COLH0033
      SUBROUTINE ASTABL                                                 ASTA0001
C-----------------------------------------------------------------------ASTA0002
C                                                                       ASTA0003
C  SUBROUTINE ASTABL  -  Print the table of ideal values and standard   ASTA0004
C                        deviations                                     ASTA0005
C                                                                       ASTA0006
C----------------------------------------------------------------------+ASTA0007
                                                                        ASTA0008
      INCLUDE 'pplot.inc'                                               ASTA0009
                                                                        ASTA0010
                                                                        ASTA0011
      WRITE(7,120)                                                      ASTA0012
 120  FORMAT(                                                           ASTA0013
     &    'This listing highlights the residues in the structure which',ASTA0014
     &    ' may need investigation.',/)                                 ASTA0015
      ILINE = ILINE + 2                                                 ASTA0016
      WRITE(7,140)                                                      ASTA0017
 140  FORMAT(                                                           ASTA0018
     &    'The ideal values and standard deviations against which the ',ASTA0019
     &    'structure has been compared are shown in the following tabl',ASTA0020
     &    'e:',///)                                                     ASTA0021
      ILINE = ILINE + 4                                                 ASTA0022
                                                                        ASTA0023
C---- Table of ideal values                                             ASTA0024
      WRITE(7,160)                                                      ASTA0025
 160  FORMAT(                                                           ASTA0026
     &    '                          <------------------------------- ',ASTA0027
     &    'I D E A L   V A L U E S ------------------------------->',/) ASTA0028
      ILINE = ILINE + 2                                                 ASTA0029
      WRITE(7,180) GLOBGM, GLOBGT, GLOBGP - 360.0, GLOBC2, GLOBPP,      ASTA0030
     &    GLOBPH,                                                       ASTA0031
     &    GLOBHP, GLOB3R, GLOB3L, GLOBSS, GLOBOM, GLOBHB, GLOBDH,       ASTA0032
     &    SDEVGM, SDEVGT, SDEVGP, SDEVC2, SDEVPP, SDEVPH,               ASTA0033
     &    SDEVHP, SDEV3R, SDEV3L, SDEVSS, SDEVOM, SDEVHB, SDEVDH        ASTA0034
 180  FORMAT(                                                           ASTA0035
     &    '                            Chi-1 dihedral         Proline ',ASTA0036
     &    'Phi  Helix  Chi-3   Chi-3 Disulph Omega  H-bond Chirality',/,ASTA0037
     &    '                            g(-) trans g(+)  Chi-2   phi  h',ASTA0038
     &    'elix  psi  rt-hand lf-hand  bond dihedral  en.   C-alpha',/, ASTA0039
     &    '                          ---------------------------------',ASTA0040
     &    '---------------------------------------------------------',/,ASTA0041
     &    '     Ideal value          ',7F6.1,F7.1,F8.1,F7.1,F8.1,F7.1,  ASTA0042
     &    F9.1,/,                                                       ASTA0043
     &    '     Standard deviation   ',7F6.1,F7.1,F8.1,F7.1,F8.1,F7.1,  ASTA0044
     &    F9.1,/,                                                       ASTA0045
     &    '                          ---------------------------------',ASTA0046
     &    '---------------------------------------------------------')  ASTA0047
      ILINE = ILINE + 6                                                 ASTA0048
                                                                        ASTA0049
C---- Explanation of asterisks                                          ASTA0050
      WRITE(7,200)                                                      ASTA0051
 200  FORMAT(//,                                                        ASTA0052
     &    'In the listing below, properties that deviate from these va',ASTA0053
     &    'lues are highlighted by asterisks and plus-signs. Each aste',ASTA0054
     &    'risk',/,                                                     ASTA0055
     &    'represents one standard deviation, and each plus-sign repre',ASTA0056
     &    'sents half a standard deviation. So, a highlight such as +*',ASTA0057
     &    '**, indicates',/,                                            ASTA0058
     &    'that the value of the parameter is between 3.5 and 4.0 stan',ASTA0059
     &    'dard deviations from the ideal value shown above.',/)        ASTA0060
      ILINE = ILINE + 6                                                 ASTA0061
      WRITE(7,220)                                                      ASTA0062
 220  FORMAT(                                                           ASTA0063
     &    'Where the deviation is greater than 4.5 standard deviations',ASTA0064
     &    ' its numerical value is shown; for example, *5.5*.',/)       ASTA0065
      ILINE = ILINE + 2                                                 ASTA0066
      WRITE(7,240)                                                      ASTA0067
 240  FORMAT(                                                           ASTA0068
     &    'The final column gives the maximum deviation in each row, w',ASTA0069
     &    'hile the maximum column deviations are shown at the end of ',ASTA0070
     &    'the listing.',/,                                             ASTA0071
     &    'Also at the end are the keys to the codes used for the seco',ASTA0072
     &    'ndary structure and Ramachandran plot assignments.',//)      ASTA0073
      ILINE = ILINE + 4                                                 ASTA0074
                                                                        ASTA0075
      RETURN                                                            ASTA0076
      END                                                               ASTA0077
                                                                        ASTA0078
                                                                        ASTA0079
      SUBROUTINE ASTOPT                                                 ASTO0001
C-----------------------------------------------------------------------ASTO0002
C                                                                       ASTO0003
C  SUBROUTINE ASTOPT  -  Print the user-defined options for the current ASTO0004
C                        listing                                        ASTO0005
C                                                                       ASTO0006
C----------------------------------------------------------------------+ASTO0007
                                                                        ASTO0008
      INCLUDE 'pplot.inc'                                               ASTO0009
                                                                        ASTO0010
C---- Print options                                                     ASTO0011
      IF (ASTONL) THEN                                                  ASTO0012
          IF (STDLIM.EQ.0.0) THEN                                       ASTO0013
              WRITE(7,100)                                              ASTO0014
 100          FORMAT(                                                   ASTO0015
     &            'Asterisks-only print giving all standard ',          ASTO0016
     &            'deviations. A single dot indicates values that ',    ASTO0017
     &            'are less than one standard deviation from',/,        ASTO0018
     &            'the ideal.',/)                                       ASTO0019
          ELSE                                                          ASTO0020
              WRITE(7,200) STDLIM                                       ASTO0021
 200          FORMAT(                                                   ASTO0022
     &            'Asterisks printed only for parameters which ',       ASTO0023
     &            'differ from the ideal by more than ',F4.1,' ',       ASTO0024
     &            'standard deviations. Other parameters are',/,        ASTO0025
     &            'indicated by a single dot.',/)                       ASTO0026
          ENDIF                                                         ASTO0027
      ELSE                                                              ASTO0028
          IF (STDLIM.EQ.0.0) THEN                                       ASTO0029
              WRITE(7,300)                                              ASTO0030
 300          FORMAT(                                                   ASTO0031
     &            'Full print-out.',//)                                 ASTO0032
          ELSE                                                          ASTO0033
              WRITE(7,400) STDLIM, STDLIM                               ASTO0034
 400          FORMAT(                                                   ASTO0035
     &            'The listing includes only parameters which ',        ASTO0036
     &            'differ from the ideal by more than ',F4.1,' ',       ASTO0037
     &            'standard deviations. Three dots appear ',/,          ASTO0038
     &            'in place of all acceptable values (ie those ',       ASTO0039
CHECK v.3.2-->                                                          ASTO0040
C     -            'not more than ', F4.1,' standard deviations '       ASTO0041
     &            'not more than ', F4.1,' standard deviations ',       ASTO0042
CHECK v.3.2<--                                                          ASTO0043
     &            'from the ideal',/)                                   ASTO0044
          ENDIF                                                         ASTO0045
      ENDIF                                                             ASTO0046
      ILINE = ILINE + 3                                                 ASTO0047
                                                                        ASTO0048
      RETURN                                                            ASTO0049
      END                                                               ASTO0050
                                                                        ASTO0051
      SUBROUTINE ASTDEV(VALUE,GLOBAL,STDEV,CHAVAL,MXDEVC,MXDEVR,        ASTD0001
     &    AREC,APOS,NTYPE,STDLIM,ASTONL)                                ASTD0002
C-----------------------------------------------------------------------ASTD0003
C                                                                       ASTD0004
C  SUBROUTINE ASTDEV  -  Calculate number of standard deviations value iASTD0005
C                        away from an ideal mean                        ASTD0006
C                                                                       ASTD0007
C----------------------------------------------------------------------+ASTD0008
                                                                        ASTD0009
      CHARACTER*6   ASTER                                               ASTD0010
      CHARACTER*(*) CHAVAL                                              ASTD0011
      CHARACTER*(*) AREC                                                ASTD0012
      INTEGER       APOS, IDEV, IVALUE, NTYPE                           ASTD0013
      LOGICAL       ASTONL                                              ASTD0014
      REAL          DEV, GLOBAL, MXDEVC, MXDEVR, STDEV, STDLIM, VALUE   ASTD0015
                                                                        ASTD0016
                                                                        ASTD0017
C---- Initialise values                                                 ASTD0018
      IF (ASTONL) THEN                                                  ASTD0019
          ASTER = '     .'                                              ASTD0020
      ELSE                                                              ASTD0021
          ASTER = ' '                                                   ASTD0022
      ENDIF                                                             ASTD0023
      DEV = 0.0                                                         ASTD0024
                                                                        ASTD0025
C---- Write the given value into the character field                    ASTD0026
      IF (NTYPE.EQ.0) THEN                                              ASTD0027
          IVALUE = VALUE + 0.5                                          ASTD0028
          WRITE(CHAVAL,100) IVALUE                                      ASTD0029
 100      FORMAT(I6)                                                    ASTD0030
      ELSE IF (NTYPE.EQ.1) THEN                                         ASTD0031
          WRITE(CHAVAL,110) VALUE                                       ASTD0032
 110      FORMAT(F6.1)                                                  ASTD0033
      ELSE IF (NTYPE.EQ.2) THEN                                         ASTD0034
          WRITE(CHAVAL,120) VALUE                                       ASTD0035
 120      FORMAT(F6.2)                                                  ASTD0036
      ELSE IF (NTYPE.EQ.3) THEN                                         ASTD0037
          WRITE(CHAVAL,130) VALUE                                       ASTD0038
 130      FORMAT(F6.3)                                                  ASTD0039
      ENDIF                                                             ASTD0040
                                                                        ASTD0041
C---- Calculate deviation from the ideal                                ASTD0042
      IF (STDEV.NE.0.0) THEN                                            ASTD0043
          DEV = ABS((VALUE - GLOBAL) / STDEV)                           ASTD0044
                                                                        ASTD0045
C----     If the deviation is less than the user-defined minimum, treat ASTD0046
C         as though it's zero                                           ASTD0047
          IF (DEV.LT.STDLIM) THEN                                       ASTD0048
              DEV = 0.0                                                 ASTD0049
              IF (NTYPE.EQ.0) THEN                                      ASTD0050
                  CHAVAL = '     .'                                     ASTD0051
              ELSE                                                      ASTD0052
                  CHAVAL = '   ...'                                     ASTD0053
              ENDIF                                                     ASTD0054
          ENDIF                                                         ASTD0055
                                                                        ASTD0056
C----     Determine the number of asterisks to print                    ASTD0057
          IDEV = DEV + 0.5                                              ASTD0058
          IF (DEV.GE.1.0) ASTER = '     *'                              ASTD0059
          IF (DEV.GE.1.5) ASTER = '    +*'                              ASTD0060
          IF (DEV.GE.2.0) ASTER = '    **'                              ASTD0061
          IF (DEV.GE.2.5) ASTER = '   +**'                              ASTD0062
          IF (DEV.GE.3.0) ASTER = '   ***'                              ASTD0063
          IF (DEV.GE.3.5) ASTER = '  +***'                              ASTD0064
          IF (DEV.GE.4.0) ASTER = '  ****'                              ASTD0065
          IF (DEV.GE.4.5) THEN                                          ASTD0066
              IF (IDEV.GT.99999) THEN                                   ASTD0067
                  ASTER = 'XXXXXX'                                      ASTD0068
              ELSE IF (IDEV.GT.9999) THEN                               ASTD0069
                  WRITE(ASTER,140) IDEV                                 ASTD0070
 140              FORMAT(I5,'*')                                        ASTD0071
              ELSE IF (IDEV.GT.999) THEN                                ASTD0072
                  WRITE(ASTER,150) IDEV                                 ASTD0073
 150              FORMAT('*',I4,'*')                                    ASTD0074
              ELSE IF (IDEV.GT.99) THEN                                 ASTD0075
                  WRITE(ASTER,160) IDEV                                 ASTD0076
 160              FORMAT(' *',I3,'*')                                   ASTD0077
              ELSE IF (DEV.GT.9.0) THEN                                 ASTD0078
                  WRITE(ASTER,180) DEV                                  ASTD0079
 180              FORMAT('*',F4.1,'*')                                  ASTD0080
              ELSE                                                      ASTD0081
                  WRITE(ASTER,200) DEV                                  ASTD0082
 200              FORMAT(' *',F3.1,'*')                                 ASTD0083
              ENDIF                                                     ASTD0084
          ENDIF                                                         ASTD0085
                                                                        ASTD0086
C----     Check whether this is the maximum deviation so far            ASTD0087
          IF (DEV.GT.MXDEVR .AND. MXDEVR.LT.99999.0) THEN               ASTD0088
              MXDEVR = DEV                                              ASTD0089
              AREC(126:131) = ASTER                                     ASTD0090
          ENDIF                                                         ASTD0091
                                                                        ASTD0092
C----     Repeat for current column value                               ASTD0093
          IF (DEV.GT.MXDEVC) THEN                                       ASTD0094
              MXDEVC = DEV                                              ASTD0095
          ENDIF                                                         ASTD0096
                                                                        ASTD0097
C----     Update the asterisks line                                     ASTD0098
          AREC(APOS:APOS+5) = ASTER                                     ASTD0099
      ENDIF                                                             ASTD0100
                                                                        ASTD0101
      RETURN                                                            ASTD0102
      END                                                               ASTD0103
                                                                        ASTD0104
                                                                        ASTD0105
      SUBROUTINE READNB(CHAIN,INCHN,SEQNO,NBAD,VWDIST)                  READ0001
C-----------------------------------------------------------------------READ0002
C                                                                       READ0003
C  SUBROUTINE READNB  -  Read in records from the non-bonded interactionREAD0004
C                        file for this residue and accumulate a count ofREAD0005
C                        the number of bad contacts                     READ0006
C                                                                       READ0007
C----------------------------------------------------------------------+READ0008
                                                                        READ0009
      SAVE                                                              READ0010
                                                                        READ0011
      CHARACTER*1   CHAIN, INCHN, INCHN1                                READ0012
      CHARACTER*3   ATYPE1, ATYPE2                                      READ0013
      CHARACTER*3   RESDU1, RESDU2                                      READ0014
      CHARACTER*5   SEQNO, SEQNO1, SEQNO2                               READ0015
      INTEGER       IPOS, LINE, NBAD                                    READ0016
      LOGICAL       BADYES, ENDFIL, NUMFND, READIN                      READ0017
      REAL          DIST, VWDIST                                        READ0018
                                                                        READ0019
      DATA INCHN1 / ' ' /                                               READ0020
      DATA ENDFIL / .FALSE. /                                           READ0021
      DATA READIN / .TRUE. /                                            READ0022
      DATA LINE   / 0 /                                                 READ0023
      DATA SEQNO1, SEQNO2 / 2*'     ' /                                 READ0024
                                                                        READ0025
C---- Initialise variables                                              READ0026
      IF (INCHN.EQ.'-') INCHN = ' '                                     READ0027
      IF (SEQNO(5:5).EQ.'-') SEQNO(5:5) = ' '                           READ0028
      NBAD = 0                                                          READ0029
                                                                        READ0030
C---- Check that haven't previously encountered the end of file         READ0031
      IF (ENDFIL) GO TO 999                                             READ0032
                                                                        READ0033
C---- Loop until all records for this residue have been processed       READ0034
 100  CONTINUE                                                          READ0035
                                                                        READ0036
C----     Read in the next record, if required                          READ0037
          IF (READIN) THEN                                              READ0038
               READ(2,150,END=500,ERR=900) INCHN1, SEQNO1, RESDU1,      READ0039
     &            ATYPE1, SEQNO2, RESDU2, ATYPE2, DIST                  READ0040
 150          FORMAT(4X,A1,6X,A5,A3,1X,A3,8X,A5,A3,1X,A3,1X,F4.0)       READ0041
              IF (INCHN1.EQ.'-') INCHN1 = ' '                           READ0042
              IF (SEQNO1(5:5).EQ.'-') SEQNO1(5:5) = ' '                 READ0043
                                                                        READ0044
C----         Only consider this record if it belongs to the required   READ0045
C             chain                                                     READ0046
              IF (CHAIN.NE.' ' .AND. INCHN1.NE.CHAIN) GO TO 100         READ0047
                                                                        READ0048
C----         Strip off any leading zeros from sequence number          READ0049
              NUMFND = .FALSE.                                          READ0050
              DO 200, IPOS = 1, 4                                       READ0051
                  IF (.NOT.NUMFND) THEN                                 READ0052
                      IF (SEQNO1(IPOS:IPOS).EQ.'0') THEN                READ0053
                          SEQNO1(IPOS:IPOS) = ' '                       READ0054
                      ELSE                                              READ0055
                          NUMFND = .TRUE.                               READ0056
                      ENDIF                                             READ0057
                  ENDIF                                                 READ0058
 200          CONTINUE                                                  READ0059
              LINE = LINE + 1                                           READ0060
              READIN = .FALSE.                                          READ0061
          ENDIF                                                         READ0062
                                                                        READ0063
C----     If this is the correct residue, process it and read in the    READ0064
C         next one                                                      READ0065
          IF (INCHN1.EQ.INCHN .AND. SEQNO1.EQ.SEQNO) THEN               READ0066
              CALL ISBAD(RESDU1,ATYPE1,RESDU2,ATYPE2,DIST,VWDIST,       READ0067
     &            BADYES)                                               READ0068
              IF (BADYES) NBAD = NBAD + 1                               READ0069
              READIN = .TRUE.                                           READ0070
                                                                        READ0071
C----     Otherwise, drop out, keeping this record until the correct resREAD0072
C         comes along                                                   READ0073
          ELSE                                                          READ0074
              GO TO 999                                                 READ0075
          ENDIF                                                         READ0076
      GO TO 100                                                         READ0077
                                                                        READ0078
C---- End of file reached. Set flag                                     READ0079
 500  CONTINUE                                                          READ0080
      ENDFIL = .TRUE.                                                   READ0081
      GO TO 999                                                         READ0082
                                                                        READ0083
C---- File error                                                        READ0084
 900  CONTINUE                                                          READ0085
      PRINT*, '*** ERROR. Error reading .nb file at line: ', LINE       READ0086
      ENDFIL = .TRUE.                                                   READ0087
                                                                        READ0088
 999  CONTINUE                                                          READ0089
      RETURN                                                            READ0090
      END                                                               READ0091
                                                                        READ0092
      SUBROUTINE ASTEND(NCOLS,IPOS,ITIME)                               ASTE0001
C-----------------------------------------------------------------------ASTE0002
C                                                                       ASTE0003
C  SUBROUTINE ASTEND  -  Print final totals on asterisks print          ASTE0004
C                                                                       ASTE0005
C----------------------------------------------------------------------+ASTE0006
                                                                        ASTE0007
CHECK v.3.2-->                                                          ASTE0008
C      SUBROUTINE ASTEND(NCOLS,IPOS)                                    ASTE0009
CHECK v.3.2<--                                                          ASTE0010
                                                                        ASTE0011
      INCLUDE 'pplot.inc'                                               ASTE0012
                                                                        ASTE0013
      INTEGER       NCOLS                                               ASTE0014
                                                                        ASTE0015
      CHARACTER*6   CHAVAL(MXCOLS)                                      ASTE0016
      CHARACTER*132 AREC                                                ASTE0017
CHECK v.3.2-->                                                          ASTE0018
C      INTEGER       ICOL, IPOS(NCOLS)                                  ASTE0019
      INTEGER       ICOL, IPOS(NCOLS), ITIME                            ASTE0020
CHECK v.3.2<--                                                          ASTE0021
      REAL          DUMMY, MXDEVR                                       ASTE0022
                                                                        ASTE0023
      DATA  DUMMY / 0.0 /                                               ASTE0024
                                                                        ASTE0025
C---- Initialise variables                                              ASTE0026
      MXDEVR = 0.0                                                      ASTE0027
                                                                        ASTE0028
C---- Convert maximum column deviations to asterisks                    ASTE0029
      AREC = 'Max deviations:'                                          ASTE0030
      DO 50, ICOL = 1, NCOLS                                            ASTE0031
          CHAVAL(ICOL) = ' '                                            ASTE0032
          CALL ASTDEV(MXDEVC(ICOL),0.0,1.0,CHAVAL(ICOL),DUMMY,          ASTE0033
     &        MXDEVR,AREC,IPOS(ICOL),1,STDLIM,ASTONL)                   ASTE0034
 50   CONTINUE                                                          ASTE0035
                                                                        ASTE0036
CHECK v.3.2-->                                                          ASTE0037
C---- Store the overall maximum deviation                               ASTE0038
      OMAXDV(ITIME) = MXDEVR                                            ASTE0039
CHECK v.3.2<--                                                          ASTE0040
                                                                        ASTE0041
C---- Print the maximum deviation values in each column                 ASTE0042
      ILINE = ILINE + 1                                                 ASTE0043
      IF (ILINE.GE.NLINES) THEN                                         ASTE0044
          CALL ASTHED                                                   ASTE0045
          WRITE(7,*)                                                    ASTE0046
      ELSE                                                              ASTE0047
          WRITE(7,100)                                                  ASTE0048
 100      FORMAT(131('-'))                                              ASTE0049
      ENDIF                                                             ASTE0050
      ILINE = ILINE + 1                                                 ASTE0051
      IF (ILINE.GE.NLINES - 1) CALL ASTHED                              ASTE0052
      WRITE(7,110) AREC                                                 ASTE0053
 110  FORMAT(A,/,131('-'))                                              ASTE0054
      ILINE = ILINE + 1                                                 ASTE0055
                                                                        ASTE0056
      RETURN                                                            ASTE0057
      END                                                               ASTE0058
                                                                        ASTE0059
      SUBROUTINE ASTMEA                                                 ASTM0001
C-----------------------------------------------------------------------ASTM0002
C                                                                       ASTM0003
C  SUBROUTINE ASTMEA  -  Print mean values for each parameter           ASTM0004
C                                                                       ASTM0005
C----------------------------------------------------------------------+ASTM0006
                                                                        ASTM0007
      INCLUDE 'pplot.inc'                                               ASTM0008
                                                                        ASTM0009
      CHARACTER*6   CHAVAL(MXCOLS), STDVAL(MXCOLS)                      ASTM0010
      CHARACTER*132 ADUMMY, AREC, IREC                                  ASTM0011
      INTEGER       I, NBOTT                                            ASTM0012
      REAL          DUMMY, MXDEVR                                       ASTM0013
                                                                        ASTM0014
C---- Initialise variables                                              ASTM0015
      AREC = ' '                                                        ASTM0016
      DO 10, I = 1, MXCOLS - 1                                          ASTM0017
          CHAVAL(I) = '    - '                                          ASTM0018
          STDVAL(I) = '    - '                                          ASTM0019
 10   CONTINUE                                                          ASTM0020
      IREC = ' '                                                        ASTM0021
      DUMMY = 0.0                                                       ASTM0022
      MXDEVR = 0.0                                                      ASTM0023
                                                                        ASTM0024
C---- Chi-1 gauche minus torsion angle                                  ASTM0025
      IF (NGMINU.GT.0) THEN                                             ASTM0026
          CALL ASTDEV(GMIMEA,GLOBGM,SDEVGM,CHAVAL(2),MXDEVC(2),         ASTM0027
     &        MXDEVR,AREC,27,1,0.0,.FALSE.)                             ASTM0028
          CALL ASTDEV(GMISTD,GLOBGM,0.0,STDVAL(2),MXDEVC(2),            ASTM0029
     &        DUMMY,ADUMMY,27,1,0.0,.FALSE.)                            ASTM0030
      ENDIF                                                             ASTM0031
                                                                        ASTM0032
C---- Chi-1 trans torsion angle                                         ASTM0033
      IF (NGTRAN.GT.0) THEN                                             ASTM0034
          CALL ASTDEV(GTRMEA,GLOBGT,SDEVGT,CHAVAL(3),MXDEVC(3),         ASTM0035
     &        MXDEVR,AREC,33,1,0.0,.FALSE.)                             ASTM0036
          CALL ASTDEV(GTRSTD,GLOBGT,0.0,STDVAL(3),MXDEVC(3),            ASTM0037
     &        DUMMY,ADUMMY,33,1,0.0,.FALSE.)                            ASTM0038
      ENDIF                                                             ASTM0039
                                                                        ASTM0040
C---- Chi-1 gauche plus torsion angle                                   ASTM0041
      IF (NGPLUS.GT.0) THEN                                             ASTM0042
          CALL ASTDEV(GPLMEA-360.0,GLOBGP-360.0,SDEVGP,CHAVAL(4),       ASTM0043
     &        MXDEVC(4), MXDEVR,AREC,39,1,0.0,.FALSE.)                  ASTM0044
          CALL ASTDEV(GPLSTD,GLOBGP,0.0,STDVAL(4),                      ASTM0045
     &        MXDEVC(4),DUMMY,ADUMMY,39,1,0.0,.FALSE.)                  ASTM0046
      ENDIF                                                             ASTM0047
                                                                        ASTM0048
C---- Chi-2 trans torsion angle                                         ASTM0049
      IF (NCHI2.GT.0) THEN                                              ASTM0050
          CALL ASTDEV(CH2MEA,GLOBC2,SDEVC2,CHAVAL(5),MXDEVC(5),         ASTM0051
     &        MXDEVR,AREC,45,1,0.0,.FALSE.)                             ASTM0052
          CALL ASTDEV(CH2STD,GLOBC2,0.0,STDVAL(5),MXDEVC(5),            ASTM0053
     &        DUMMY,ADUMMY,45,1,0.0,.FALSE.)                            ASTM0054
      ENDIF                                                             ASTM0055
                                                                        ASTM0056
C---- Proline phi                                                       ASTM0057
      IF (NPROPH.GT.0) THEN                                             ASTM0058
          CALL ASTDEV(PPMEAN,GLOBPP,SDEVPP,CHAVAL(6),MXDEVC(6),         ASTM0059
     &        MXDEVR,AREC,51,1,0.0,.FALSE.)                             ASTM0060
          CALL ASTDEV(PPSTD,GLOBPP,0.0,STDVAL(6),MXDEVC(6),             ASTM0061
     &        DUMMY,ADUMMY,51,1,0.0,.FALSE.)                            ASTM0062
      ENDIF                                                             ASTM0063
                                                                        ASTM0064
C---- Phi helix                                                         ASTM0065
      IF (NPHIHX.GT.0) THEN                                             ASTM0066
          CALL ASTDEV(PHMEAN,GLOBPH,SDEVPH,CHAVAL(7),MXDEVC(7),         ASTM0067
     &        MXDEVR,AREC,57,1,0.0,.FALSE.)                             ASTM0068
          CALL ASTDEV(PHSTD,GLOBPH,0.0,STDVAL(7),MXDEVC(7),             ASTM0069
     &        DUMMY,ADUMMY,57,1,0.0,.FALSE.)                            ASTM0070
      ENDIF                                                             ASTM0071
                                                                        ASTM0072
C---- Helix psi                                                         ASTM0073
      IF (NHXPSI.GT.0) THEN                                             ASTM0074
          CALL ASTDEV(HPMEAN,GLOBHP,SDEVHP,CHAVAL(8),MXDEVC(8),         ASTM0075
     &        MXDEVR,AREC,63,1,0.0,.FALSE.)                             ASTM0076
          CALL ASTDEV(HPSTD,GLOBHP,0.0,STDVAL(8),MXDEVC(8),             ASTM0077
     &        DUMMY,ADUMMY,63,1,0.0,.FALSE.)                            ASTM0078
      ENDIF                                                             ASTM0079
                                                                        ASTM0080
C---- Chi-3 right-hand                                                  ASTM0081
      IF (NCHI3R.GT.0) THEN                                             ASTM0082
          CALL ASTDEV(C3RMEA,GLOB3R,SDEV3R,CHAVAL(9),MXDEVC(9),         ASTM0083
     &        MXDEVR,AREC,70,1,0.0,.FALSE.)                             ASTM0084
          CALL ASTDEV(C3RSTD,GLOB3R,0.0,STDVAL(9),MXDEVC(9),            ASTM0085
     &        DUMMY,ADUMMY,70,1,0.0,.FALSE.)                            ASTM0086
      ENDIF                                                             ASTM0087
                                                                        ASTM0088
C---- Chi-3 left-hand                                                   ASTM0089
      IF (NCHI3L.GT.0) THEN                                             ASTM0090
          CALL ASTDEV(C3LMEA,GLOB3L,SDEV3L,CHAVAL(10),MXDEVC(10),       ASTM0091
     &        MXDEVR,AREC,78,1,0.0,.FALSE.)                             ASTM0092
          CALL ASTDEV(C3LSTD,GLOB3L,0.0,STDVAL(10),MXDEVC(10),          ASTM0093
     &        DUMMY,ADUMMY,78,1,0.0,.FALSE.)                            ASTM0094
      ENDIF                                                             ASTM0095
                                                                        ASTM0096
C---- Disulphide bond                                                   ASTM0097
      IF (NDISUL.GT.0) THEN                                             ASTM0098
          CALL ASTDEV(SSMEAN,GLOBSS,SDEVSS,CHAVAL(11),MXDEVC(11),       ASTM0099
     &        MXDEVR,AREC,85,1,0.0,.FALSE.)                             ASTM0100
          CALL ASTDEV(SSSTD,GLOBSS,0.0,STDVAL(11),MXDEVC(11),           ASTM0101
     &        DUMMY,ADUMMY,85,1,0.0,.FALSE.)                            ASTM0102
      ENDIF                                                             ASTM0103
                                                                        ASTM0104
C---- Omega dihedral angle                                              ASTM0105
      IF (NOMEGA.GT.0) THEN                                             ASTM0106
          CALL ASTDEV(OMMEAN,GLOBOM,SDEVOM,CHAVAL(12),MXDEVC(12),       ASTM0107
     &        MXDEVR,AREC,93,1,0.0,.FALSE.)                             ASTM0108
          CALL ASTDEV(OMSTD,GLOBOM,0.0,STDVAL(12),MXDEVC(12),           ASTM0109
     &        DUMMY,ADUMMY,93,1,0.0,.FALSE.)                            ASTM0110
      ENDIF                                                             ASTM0111
                                                                        ASTM0112
C---- Hydrogen bond energy mean and standard deviation                  ASTM0113
      IF (NHBOND.GT.0) THEN                                             ASTM0114
          CALL ASTDEV(HBMEAN,GLOBHB,SDEVHB,CHAVAL(13),MXDEVC(13),       ASTM0115
     &        MXDEVR,AREC,100,1,0.0,.FALSE.)                            ASTM0116
          CALL ASTDEV(HBSTD,GLOBHB,0.0,STDVAL(13),MXDEVC(13),           ASTM0117
     &        DUMMY,ADUMMY,100,1,0.0,.FALSE.)                           ASTM0118
      ENDIF                                                             ASTM0119
                                                                        ASTM0120
C---- Alpha carbon chirality                                            ASTM0121
      IF (NALPHC.GT.0) THEN                                             ASTM0122
          CALL ASTDEV(ACMEAN,GLOBDH,SDEVDH,CHAVAL(14),MXDEVC(14),       ASTM0123
     &        MXDEVR,AREC,109,1,0.0,.FALSE.)                            ASTM0124
          CALL ASTDEV(ACSTD,GLOBDH,0.0,STDVAL(14),MXDEVC(14),           ASTM0125
     &        DUMMY,ADUMMY,109,1,0.0,.FALSE.)                           ASTM0126
      ENDIF                                                             ASTM0127
                                                                        ASTM0128
C---- See whether any cis-peptides or D-amino acids found               ASTM0129
      NBOTT = 4                                                         ASTM0130
      IF (NCIS.GT.0) NBOTT = NBOTT + 2                                  ASTM0131
      IF (NDAM.GT.0) NBOTT = NBOTT + 2                                  ASTM0132
                                                                        ASTM0133
C---- Print the lines                                                   ASTM0134
      ILINE = ILINE + 1                                                 ASTM0135
      IF (ILINE.GE.NLINES - NBOTT) CALL ASTHED                          ASTM0136
      WRITE(7,610) (CHAVAL(I), I = 2, MXCOLS - 1)                       ASTM0137
 610  FORMAT('Mean values:              ',7A6,1X,A6,2X,A6,1X,           ASTM0138
     &    A6,2X,A6,1X,A6,3X,A6)                                         ASTM0139
                                                                        ASTM0140
C---- Print asterisks line if not blank                                 ASTM0141
      IF (AREC.NE.' ') THEN                                             ASTM0142
          ILINE = ILINE + 1                                             ASTM0143
          WRITE(7,620) AREC                                             ASTM0144
 620      FORMAT(A131)                                                  ASTM0145
      ENDIF                                                             ASTM0146
                                                                        ASTM0147
C---- Print the standard deviations                                     ASTM0148
      ILINE = ILINE + 2                                                 ASTM0149
      WRITE(7,650) (STDVAL(I), I = 2, MXCOLS - 1)                       ASTM0150
 650  FORMAT('Standard deviations:      ',7A6,1X,A6,2X,A6,1X,           ASTM0151
     &    A6,2X,A6,1X,A6,3X,A6,/)                                       ASTM0152
                                                                        ASTM0153
C---- Print numbers of values                                           ASTM0154
      WRITE(7,700) NGMINU, NGTRAN, NGPLUS, NCHI2, NPROPH, NPHIHX,       ASTM0155
     &    NHXPSI, NCHI3R, NCHI3L, NDISUL, NOMEGA, NHBOND, NALPHC,       ASTM0156
     &    NBADPR                                                        ASTM0157
 700  FORMAT('Numbers of values:        ',7I6,1X,I6,2X,I6,1X,           ASTM0158
     &    I6,2X,I6,1X,I6,3X,I6,1X,I6)                                   ASTM0159
                                                                        ASTM0160
C---- Print the numbers of cis-peptides and D-amino acids found, if any ASTM0161
      IF (NCIS.GT.0 .OR. NDAM.GT.0) WRITE(7,*)                          ASTM0162
      IF (NCIS.GT.0) THEN                                               ASTM0163
          WRITE(7,720) NCIS                                             ASTM0164
 720      FORMAT(/,40X,'Number of cis-peptides (labelled cis):  ',I6)   ASTM0165
      ENDIF                                                             ASTM0166
      IF (NDAM.GT.0) THEN                                               ASTM0167
          WRITE(7,740) NDAM                                             ASTM0168
 740      FORMAT(/,40X,'Number of D-amino acids (labelled D>):  ',I6)   ASTM0169
      ENDIF                                                             ASTM0170
                                                                        ASTM0171
      RETURN                                                            ASTM0172
      END                                                               ASTM0173
                                                                        ASTM0174
      SUBROUTINE ASTKEY                                                 ASTK0001
C-----------------------------------------------------------------------ASTK0002
C                                                                       ASTK0003
C  SUBROUTINE ASTKEY  -  Print Key to asterisks print-out and a summary ASTK0004
C                        the statistics                                 ASTK0005
C                                                                       ASTK0006
C----------------------------------------------------------------------+ASTK0007
                                                                        ASTK0008
      INCLUDE 'pplot.inc'                                               ASTK0009
                                                                        ASTK0010
C---- Print the key to the codes used in the listing                    ASTK0011
      NPRINT = 0                                                        ASTK0012
      IF (ILINE.GE.NLINES - 20) CALL ASTHED                             ASTK0013
      WRITE(7,120)                                                      ASTK0014
 120  FORMAT(//,                                                        ASTK0015
     &    '   KEY TO CODES:',/,                                         ASTK0016
     &    '   ------------',//,                                         ASTK0017
     &    '         Regions of the Ramachandran plot                  ',ASTK0018
     &    '         Secondary structure (extended Kabsch/Sander)   ',/, ASTK0019
     &    '         --------------------------------                  ',ASTK0020
     &    '         --------------------------------------------   ',/) ASTK0021
      WRITE(7,140)                                                      ASTK0022
 140  FORMAT(                                                           ASTK0023
     &    '         A  - Core alpha                                   ',ASTK0024
     &    '         B - residue in isolated beta-bridge             ',/,ASTK0025
     &    '         a  - Allowed alpha                                ',ASTK0026
     &    '         E - extended strand, participates in beta-ladder',/,ASTK0027
     &    '         ~a - Generous alpha              ** Generous      ',ASTK0028
     &    '         G - 3-helix (3/10 helix)                        ',/,ASTK0029
     &    '         B  - Core beta                                    ',ASTK0030
     &    '         H - 4-helix (alpha-helix)                       ',/,ASTK0031
     &    '         b  - Allowed beta                                 ',ASTK0032
     &    '         I - 5-helix (pi-helix)                          ',/,ASTK0033
     &    '         ~b - Generous beta               ** Generous      ',ASTK0034
     &    '         S - bend                                        ')  ASTK0035
      WRITE(7,160)                                                      ASTK0036
 160  FORMAT(                                                           ASTK0037
     &    '         L  - Core left-handed alpha                       ',ASTK0038
     &    '         T - hydrogen-bonded turn                        ',/,ASTK0039
     &    '         l  - Allowed left-handed alpha                    ',ASTK0040
     &    '                                                         ',/,ASTK0041
     &    '         ~l - Generous left-handed alpha  ** Generous      ',ASTK0042
     &    '         e - extension of beta-strand                    ',/,ASTK0043
     &    '         p  - Allowed epsilon                              ',ASTK0044
     &    '         g - extension of 3/10 helix                     ',/,ASTK0045
     &    '         ~p - Generous epsilon            ** Generous      ',ASTK0046
     &    '         h - extension of alpha-helix                    ',/,ASTK0047
     &    '         XX - Outside major areas       **** Disallowed    ',ASTK0048
     &    ///)                                                          ASTK0049
      ILINE = ILINE + 20                                                ASTK0050
                                                                        ASTK0051
      RETURN                                                            ASTK0052
      END                                                               ASTK0053
                                                                        ASTK0054
      SUBROUTINE ASTLAN                                                 ASTL0001
C-----------------------------------------------------------------------ASTL0002
C                                                                       ASTL0003
C  SUBROUTINE ASTLAN  -  List the main-chain bond lengths and bond angleASTL0004
C                                                                       ASTL0005
C----------------------------------------------------------------------+ASTL0006
                                                                        ASTL0007
      INCLUDE 'pplot.inc'                                               ASTL0008
                                                                        ASTL0009
      INTEGER       NCOLS, NROWS                                        ASTL0010
      PARAMETER    (NCOLS=12, NROWS=9)                                  ASTL0011
                                                                        ASTL0012
      CHARACTER*1   AL(NMAIN), INCHN, CLOBRA(NCOLS,NROWS), OLDCHN,      ASTL0013
     &              OPNBRA(NCOLS,NROWS)                                 ASTL0014
      CHARACTER*3   OLDRES, RESNAM                                      ASTL0015
      CHARACTER*5   OLDSEQ, SEQNO                                       ASTL0016
      CHARACTER*6   CHAVAL(NCOLS), CHBVAL(NCOLS)                        ASTL0017
      CHARACTER*8   INLANG, LASTLA, LENANG(NMAIN)                       ASTL0018
      CHARACTER*13  ENCODE(NMAIN)                                       ASTL0019
      CHARACTER*16  ADESC(NROWS), ENDESC(NMAIN), EXDESC(NROWS), INDESC  ASTL0020
      CHARACTER*132 AREC, IREC                                          ASTL0021
      INTEGER       COLPOS(NCOLS), I, ICOL, IFMT, IMAIN, IRESID, IROW,  ASTL0022
     &              LINE, MAPPOS(NMAIN), SRESID                         ASTL0023
      REAL          DIFF, ENGMEA(NMAIN), ENGSTD(NMAIN),                 ASTL0024
     &              ENGTAB(2,NCOLS,NROWS), MXDEVR, SVAL(NMAIN),         ASTL0025
     &              VALUE                                               ASTL0026
                                                                        ASTL0027
      DATA COLPOS / 18, 26, 34, 42, 50, 59, 68, 77, 86, 95, 104, 113 /  ASTL0028
                                                                        ASTL0029
      DATA ADESC  / 'Any             ',                                 ASTL0030
     &              'Pro             ',                                 ASTL0031
     &              'Except Pro      ',                                 ASTL0032
     &              'Gly             ',                                 ASTL0033
     &              'Except Gly      ',                                 ASTL0034
     &              'Ala             ',                                 ASTL0035
     &              'Ile,Thr,Val     ',                                 ASTL0036
     &              'Except Gly,Pro  ',                                 ASTL0037
     &              'The rest        ' /                                ASTL0038
                                                                        ASTL0039
      DATA EXDESC / '                ',                                 ASTL0040
     &              '(Pro)           ',                                 ASTL0041
     &              '(except Pro)    ',                                 ASTL0042
     &              '(Gly)           ',                                 ASTL0043
     &              '(except Gly)    ',                                 ASTL0044
     &              '(Ala)           ',                                 ASTL0045
     &              '(Ile,Thr,Val)   ',                                 ASTL0046
     &              '(except Gly,Pro)',                                 ASTL0047
     &              '(the rest)      ' /                                ASTL0048
                                                                        ASTL0049
      DATA MAPPOS /  7,  7,  7,                                         ASTL0050
     &              12, 12,                                             ASTL0051
     &               1,  1,                                             ASTL0052
     &               2,                                                 ASTL0053
     &               3,  3,                                             ASTL0054
     &               4,  4,  4,                                         ASTL0055
     &               5,  5,  5,                                         ASTL0056
     &               6,  6,  6,                                         ASTL0057
     &               8,  8,                                             ASTL0058
     &               9,  9,  9,                                         ASTL0059
     &              10, 10, 10,                                         ASTL0060
     &              11, 11, 11, 11 /                                    ASTL0061
                                                                        ASTL0062
C---- Initialise variables                                              ASTL0063
      AREC = ' '                                                        ASTL0064
      LASTLA = ' '                                                      ASTL0065
      LINE = 0                                                          ASTL0066
CHECK v.3.2-->                                                          ASTL0067
      MXDEVR = 0.0                                                      ASTL0068
CHECK v.3.2<--                                                          ASTL0069
      NPRINT = 0                                                        ASTL0070
      OLDCHN = ' '                                                      ASTL0071
      OLDRES = ' '                                                      ASTL0072
      OLDSEQ = ' '                                                      ASTL0073
      SRESID = 0                                                        ASTL0074
      IREC = ' '                                                        ASTL0075
      DO 20, IMAIN = 1, NMAIN                                           ASTL0076
          SVAL(IMAIN) = 0.0                                             ASTL0077
 20   CONTINUE                                                          ASTL0078
      DO 50, ICOL = 1, NCOLS                                            ASTL0079
          MXDEVC(ICOL) = 0.0                                            ASTL0080
          DO 40, IROW = 1, NROWS                                        ASTL0081
              CLOBRA(ICOL,IROW) = ' '                                   ASTL0082
              OPNBRA(ICOL,IROW) = ' '                                   ASTL0083
              ENGTAB(1,ICOL,IROW) = 0.0                                 ASTL0084
              ENGTAB(2,ICOL,IROW) = 0.0                                 ASTL0085
 40       CONTINUE                                                      ASTL0086
 50   CONTINUE                                                          ASTL0087
      CALL ASTHED                                                       ASTL0088
      NPRINT = 2                                                        ASTL0089
                                                                        ASTL0090
C---- Print headings for ideal values table, if required                ASTL0091
      IF (HEADIN) THEN                                                  ASTL0092
          WRITE(7,100)                                                  ASTL0093
 100      FORMAT(//,                                                    ASTL0094
     &        '                          M A I N   C H A I N   B O N D',ASTL0095
     &        '   L E N G T H S   A N D   B O N D   A N G L E S')       ASTL0096
          ILINE = ILINE + 3                                             ASTL0097
                                                                        ASTL0098
          WRITE(7,110)                                                  ASTL0099
 110      FORMAT(//,                                                    ASTL0100
     &        18X,'..................................... Small molecu', ASTL0101
     &            'le data .........................................',  ASTL0102
     &        //,                                                       ASTL0103
     &        18X,'<---------- Bond lengths ---------->    <---------', ASTL0104
     &            '------------- Bond angles ---------------------->',  ASTL0105
     &        //,                                                       ASTL0106
     &        18X,'C-N     C-O     CA-C    CA-CB   N-CA    C-N-CA   C', ASTL0107
     &            'A-C-N   CA-C-O  CB-CA-C   N-CA-C  N-CA-CB   O-C-N',  ASTL0108
     &        /,                                                        ASTL0109
     &        18X,'--------------------------------------------------', ASTL0110
     &            '-------------------------------------------------')  ASTL0111
          ILINE = ILINE + 8                                             ASTL0112
      ENDIF                                                             ASTL0113
                                                                        ASTL0114
C---- Rewind the main-chain bond-lengths and angles file                ASTL0115
      REWIND(4)                                                         ASTL0116
                                                                        ASTL0117
C---- Read through the header records and pick up the small-molecule    ASTL0118
C     data                                                              ASTL0119
      DO 300, IMAIN = 1, NMAIN                                          ASTL0120
          READ(4,130,ERR=904) AL(IMAIN), INLANG, ENCODE(IMAIN),         ASTL0121
     &        INDESC, ENGMEA(IMAIN), ENGSTD(IMAIN)                      ASTL0122
 130      FORMAT(A1,1X,A8,6X,A13,4X,A16,2F8.3)                          ASTL0123
          ENDESC(IMAIN) = INDESC                                        ASTL0124
                                                                        ASTL0125
C----     Work out where to put these values in the table               ASTL0126
          ICOL = MAPPOS(IMAIN)                                          ASTL0127
          DO 200, I = 1, NROWS                                          ASTL0128
              IF (INDESC.EQ.EXDESC(I)) IROW = I                         ASTL0129
 200      CONTINUE                                                      ASTL0130
          ENGTAB(1,ICOL,IROW) = ENGMEA(IMAIN)                           ASTL0131
          ENGTAB(2,ICOL,IROW) = ENGSTD(IMAIN)                           ASTL0132
          CLOBRA(ICOL,IROW) = ')'                                       ASTL0133
          OPNBRA(ICOL,IROW) = '('                                       ASTL0134
          IF (INLANG.EQ.LASTLA) THEN                                    ASTL0135
              LENANG(IMAIN) = ' '                                       ASTL0136
          ELSE                                                          ASTL0137
              LENANG(IMAIN) = INLANG                                    ASTL0138
          ENDIF                                                         ASTL0139
          LASTLA = INLANG                                               ASTL0140
 300  CONTINUE                                                          ASTL0141
                                                                        ASTL0142
C---- Skip all the records giving data on the planar groups             ASTL0143
      DO 305, IMAIN = 1, NPLANE                                         ASTL0144
          READ(4,*)                                                     ASTL0145
 305   CONTINUE                                                         ASTL0146
                                                                        ASTL0147
C---- Print the small-molecule means and standard deviations            ASTL0148
                                                                        ASTL0149
C---- Loop through the rows and columns                                 ASTL0150
      DO 400, IROW = 1, NROWS                                           ASTL0151
          DO 310, I = 1, NCOLS                                          ASTL0152
              CHAVAL(I) = '   -  '                                      ASTL0153
              CHBVAL(I) = '      '                                      ASTL0154
 310      CONTINUE                                                      ASTL0155
          DO 350, ICOL = 1, NCOLS                                       ASTL0156
              IF (ICOL.LE.5) THEN                                       ASTL0157
                  IFMT = 3                                              ASTL0158
              ELSE                                                      ASTL0159
                  IFMT = 2                                              ASTL0160
              ENDIF                                                     ASTL0161
              IF (ENGTAB(1,ICOL,IROW).NE.0.0) THEN                      ASTL0162
                  CALL ASTDEV(ENGTAB(1,ICOL,IROW),0.0,1.0,              ASTL0163
     &                CHAVAL(ICOL),MXDEVC(ICOL),MXDEVR,AREC,            ASTL0164
     &                COLPOS(ICOL),IFMT,0.0,.FALSE.)                    ASTL0165
                  CALL ASTDEV(ENGTAB(2,ICOL,IROW),0.0,1.0,              ASTL0166
     &                CHBVAL(ICOL),MXDEVC(ICOL),MXDEVR,AREC,            ASTL0167
     &                COLPOS(ICOL),IFMT,0.0,.FALSE.)                    ASTL0168
              ENDIF                                                     ASTL0169
 350      CONTINUE                                                      ASTL0170
                                                                        ASTL0171
C----     Print the row of means and standard deviations                ASTL0172
          IF (HEADIN) THEN                                              ASTL0173
              WRITE(7,370) ADESC(IROW), (CHAVAL(ICOL), ICOL = 1, NCOLS) ASTL0174
 370          FORMAT(A16,5(1X,A6,1X),7(2X,A6,1X))                       ASTL0175
              WRITE(7,380) '   ', (OPNBRA(ICOL,IROW), CHBVAL(ICOL),     ASTL0176
     &            CLOBRA(ICOL,IROW), ICOL = 1, NCOLS)                   ASTL0177
 380          FORMAT(A16,5(A1,A6,A1),7(1X,A1,A6,A1))                    ASTL0178
              ILINE = ILINE + 2                                         ASTL0179
          ENDIF                                                         ASTL0180
 400  CONTINUE                                                          ASTL0181
                                                                        ASTL0182
C---- Print explanatory note                                            ASTL0183
      IF (HEADIN) THEN                                                  ASTL0184
          WRITE(7,410)                                                  ASTL0185
 410      FORMAT(/,                                                     ASTL0186
     &        'Note. The table above shows the mean values obtained ',  ASTL0187
     &        'from small molecule data by Engh & Huber (1991). Th',    ASTL0188
     &        'e values shown in brackets',/,                           ASTL0189
     &        '      are standard deviations')                          ASTL0190
          ILINE = ILINE + 3                                             ASTL0191
      ENDIF                                                             ASTL0192
                                                                        ASTL0193
C---- Print column headings                                             ASTL0194
      CALL COLHD2                                                       ASTL0195
                                                                        ASTL0196
C---- Re-initialise values                                              ASTL0197
      DO 450, ICOL = 1, NCOLS                                           ASTL0198
          MXDEVC(ICOL) = 0.0                                            ASTL0199
 450  CONTINUE                                                          ASTL0200
                                                                        ASTL0201
C---- Loop while reading in records                                     ASTL0202
 500  CONTINUE                                                          ASTL0203
          READ(4,520,END=800,ERR=904) IREC                              ASTL0204
 520      FORMAT(A)                                                     ASTL0205
          LINE = LINE + 1                                               ASTL0206
                                                                        ASTL0207
C----     Only process this record if it is not a planar group          ASTL0208
          IF (IREC(29:33).NE.'PLANE') THEN                              ASTL0209
                                                                        ASTL0210
C----         Read in the required data                                 ASTL0211
              READ(IREC,540,ERR=906) IRESID, INCHN, SEQNO, RESNAM,      ASTL0212
     &            IMAIN, VALUE                                          ASTL0213
 540          FORMAT(I6,A1,A5,A3,I2,F9.4)                               ASTL0214
                                                                        ASTL0215
C----         Only process this record if it belongs to the required chaASTL0216
              IF (CHAIN.EQ.' ' .OR. INCHN.EQ.CHAIN) THEN                ASTL0217
                                                                        ASTL0218
C----             Accumulate data for calc of standard deviations       ASTL0219
                  DIFF = MCHMEA(IMAIN) - VALUE                          ASTL0220
                  MCHSTD(IMAIN) = MCHSTD(IMAIN) + DIFF * DIFF           ASTL0221
                                                                        ASTL0222
C----             If residue has changed, then print line for last residASTL0223
                  IF (SRESID.GT.0 .AND. IRESID.NE.SRESID) THEN          ASTL0224
                      CALL LANPRN(SRESID,OLDRES,OLDCHN,OLDSEQ,SVAL,     ASTL0225
     &                    ENGMEA,ENGSTD,NCOLS,COLPOS,MAPPOS)            ASTL0226
                                                                        ASTL0227
C----                 Reinitialise stored values                        ASTL0228
                      DO 600, I = 1, NMAIN                              ASTL0229
                          SVAL(I) = 0.0                                 ASTL0230
 600                  CONTINUE                                          ASTL0231
                  ENDIF                                                 ASTL0232
                                                                        ASTL0233
C----             Store current value                                   ASTL0234
                  OLDCHN = INCHN                                        ASTL0235
                  OLDRES = RESNAM                                       ASTL0236
                  OLDSEQ = SEQNO                                        ASTL0237
                  SVAL(IMAIN) = VALUE                                   ASTL0238
                  SRESID = IRESID                                       ASTL0239
              ENDIF                                                     ASTL0240
          ENDIF                                                         ASTL0241
                                                                        ASTL0242
C---- Loop back for next record in file                                 ASTL0243
      GO TO 500                                                         ASTL0244
                                                                        ASTL0245
C---- End of file reached                                               ASTL0246
 800  CONTINUE                                                          ASTL0247
                                                                        ASTL0248
C---- Print final residue                                               ASTL0249
      IF (SRESID.GT.0) THEN                                             ASTL0250
          CALL LANPRN(SRESID,OLDRES,OLDCHN,OLDSEQ,SVAL,ENGMEA,ENGSTD,   ASTL0251
     &            NCOLS,COLPOS,MAPPOS)                                  ASTL0252
      ENDIF                                                             ASTL0253
                                                                        ASTL0254
C---- Print column deviations                                           ASTL0255
CHECK v.3.2-->                                                          ASTL0256
C      CALL ASTEND(NCOLS,COLPOS)                                        ASTL0257
      CALL ASTEND(NCOLS,COLPOS,2)                                       ASTL0258
CHECK v.3.2<--                                                          ASTL0259
                                                                        ASTL0260
C---- Calculate standard deviations                                     ASTL0261
      DO 850, IMAIN = 1, NMAIN                                          ASTL0262
          IF (MCHNUM(IMAIN).GT.0) THEN                                  ASTL0263
              MCHSTD(IMAIN) = MCHSTD(IMAIN) / REAL(MCHNUM(IMAIN))       ASTL0264
              MCHSTD(IMAIN) = SQRT(MCHSTD(IMAIN))                       ASTL0265
          ENDIF                                                         ASTL0266
 850  CONTINUE                                                          ASTL0267
                                                                        ASTL0268
C---- Print analysis of main-chain bond lengths and bond angles         ASTL0269
      CALL ASTBLA(AL,LENANG,ENCODE,ENDESC,ENGMEA,ENGSTD)                ASTL0270
                                                                        ASTL0271
      GO TO 999                                                         ASTL0272
                                                                        ASTL0273
C---- Fatal errors                                                      ASTL0274
 904  CONTINUE                                                          ASTL0275
      PRINT*, '*** ERROR. Error reading .lan file at line:', LINE + 1   ASTL0276
      GO TO 990                                                         ASTL0277
                                                                        ASTL0278
 906  CONTINUE                                                          ASTL0279
      PRINT*, '*** ERROR. Data error in .lan file at line:', LINE + 1   ASTL0280
      PRINT*, IREC                                                      ASTL0281
                                                                        ASTL0282
 990  CONTINUE                                                          ASTL0283
      IFAIL = .TRUE.                                                    ASTL0284
                                                                        ASTL0285
 999  CONTINUE                                                          ASTL0286
      RETURN                                                            ASTL0287
      END                                                               ASTL0288
                                                                        ASTL0289
      SUBROUTINE LANPRN(SRESID,RESDUE,INCHN,SEQNO,SVAL,ENGMEA,ENGSTD,   LANP0001
     &            NCOLS,COLPOS,MAPPOS)                                  LANP0002
C-----------------------------------------------------------------------LANP0003
C                                                                       LANP0004
C  SUBROUTINE LANPRN  -  Print current line of bond lengths and angles  LANP0005
C                        listing                                        LANP0006
C                                                                       LANP0007
C----------------------------------------------------------------------+LANP0008
                                                                        LANP0009
      INCLUDE 'pplot.inc'                                               LANP0010
                                                                        LANP0011
      INTEGER       NCOLS                                               LANP0012
                                                                        LANP0013
      CHARACTER*1   INCHN, REGION                                       LANP0014
      CHARACTER*3   RESDUE                                              LANP0015
      CHARACTER*5   SEQNO                                               LANP0016
      CHARACTER*6   CHAVAL(MXCOLS)                                      LANP0017
      CHARACTER*132 AREC, IREC                                          LANP0018
      INTEGER       COLPOS(NCOLS), I, ICOL, IFMT, IMAIN, MAPPOS(NMAIN), LANP0019
     &              SRESID                                              LANP0020
      REAL          ENGMEA(NMAIN), ENGSTD(NMAIN), MXDEVR, SVAL(NMAIN)   LANP0021
                                                                        LANP0022
C---- Initialise variables                                              LANP0023
      AREC = ' '                                                        LANP0024
      DO 10, I = 1, NCOLS                                               LANP0025
          CHAVAL(I) = '   -  '                                          LANP0026
 10   CONTINUE                                                          LANP0027
      CHAVAL(NCOLS + 1) = '     -'                                      LANP0028
      IREC = ' '                                                        LANP0029
      MXDEVR = 0.0                                                      LANP0030
      REGION = '-'                                                      LANP0031
                                                                        LANP0032
C---- Loop through all the stored values                                LANP0033
      DO 500, IMAIN = 1, NMAIN                                          LANP0034
          ICOL = MAPPOS(IMAIN)                                          LANP0035
          IF (ICOL.LE.5) THEN                                           LANP0036
              IFMT = 3                                                  LANP0037
          ELSE                                                          LANP0038
              IFMT = 2                                                  LANP0039
          ENDIF                                                         LANP0040
          IF (SVAL(IMAIN).NE.0.0) THEN                                  LANP0041
              CALL ASTDEV(SVAL(IMAIN),ENGMEA(IMAIN),ENGSTD(IMAIN),      LANP0042
     &            CHAVAL(ICOL),MXDEVC(ICOL),MXDEVR,AREC,                LANP0043
     &            COLPOS(ICOL),IFMT,STDLIM,ASTONL)                      LANP0044
          ENDIF                                                         LANP0045
 500  CONTINUE                                                          LANP0046
                                                                        LANP0047
C---- Print the lines                                                   LANP0048
                                                                        LANP0049
C---- If printing all residues, or only the highlighted ones and the devLANP0050
C     is above the minimum required, then print                         LANP0051
      IF (.NOT.ONLYHI .OR. MXDEVR.GT.0.0) THEN                          LANP0052
                                                                        LANP0053
C----     If only printing the asterisks line, transfer residue info to LANP0054
C         start of the line                                             LANP0055
          IF (ASTONL) THEN                                              LANP0056
              WRITE(AREC(1:14),320) SRESID, INCHN, RESDUE, SEQNO        LANP0057
 320          FORMAT(I4,A1,1X,A3,A5,1X,5(2X,A6),7(3X,A6))               LANP0058
                                                                        LANP0059
C----     Otherwise, print the line holding the information             LANP0060
          ELSE                                                          LANP0061
              ILINE = ILINE + 1                                         LANP0062
              IF (AREC.NE.' ') THEN                                     LANP0063
                  IF (ILINE.GE.NLINES - 1) THEN                         LANP0064
                      CALL ASTHED                                       LANP0065
                  ENDIF                                                 LANP0066
              ELSE                                                      LANP0067
                  IF (ILINE.GE.NLINES) THEN                             LANP0068
                      CALL ASTHED                                       LANP0069
                  ENDIF                                                 LANP0070
              ENDIF                                                     LANP0071
              WRITE(7,320) SRESID, INCHN, RESDUE, SEQNO,                LANP0072
     &            (CHAVAL(I), I = 1, NCOLS)                             LANP0073
          ENDIF                                                         LANP0074
                                                                        LANP0075
C----     Print asterisks line if not blank                             LANP0076
          IF (AREC.NE.' ') THEN                                         LANP0077
              ILINE = ILINE + 1                                         LANP0078
              IF (ILINE.GE.NLINES) CALL ASTHED                          LANP0079
              WRITE(7,620) AREC                                         LANP0080
 620          FORMAT(A131)                                              LANP0081
          ENDIF                                                         LANP0082
      ENDIF                                                             LANP0083
                                                                        LANP0084
      RETURN                                                            LANP0085
      END                                                               LANP0086
                                                                        LANP0087
      SUBROUTINE ASTBLA(AL,LENANG,ENCODE,EXDESC,ENGMEA,ENGSTD)          ASTB0001
C-----------------------------------------------------------------------ASTB0002
C                                                                       ASTB0003
C  SUBROUTINE ASTBLA  -  Print analysis of main-chain bond length and   ASTB0004
C                        bond angles                                    ASTB0005
C                                                                       ASTB0006
C----------------------------------------------------------------------+ASTB0007
                                                                        ASTB0008
      INCLUDE 'pplot.inc'                                               ASTB0009
                                                                        ASTB0010
      CHARACTER*1   AL(NMAIN)                                           ASTB0011
      CHARACTER*6   ANGLEN, CHAVAL(3)                                   ASTB0012
      CHARACTER*8   BREC, LENANG(NMAIN)                                 ASTB0013
      CHARACTER*13  ENCODE(NMAIN)                                       ASTB0014
      CHARACTER*16  EXDESC(NMAIN)                                       ASTB0015
      CHARACTER*132 AREC                                                ASTB0016
      INTEGER       I, IMAIN                                            ASTB0017
      REAL          ENGMEA(NMAIN), ENGSTD(NMAIN), MXDEVR                ASTB0018
                                                                        ASTB0019
C---- Print main heading for the analysis print                         ASTB0020
      MXDEVR = 999999.99                                                ASTB0021
      NPRINT = 0                                                        ASTB0022
      CALL ASTHED                                                       ASTB0023
      WRITE(7,100)                                                      ASTB0024
 100  FORMAT(//,                                                        ASTB0025
     &    10X,'    A N A L Y S I S   O F   M A I N   C H A I N   B O ', ASTB0026
     &        'N D   L E N G T H S   A N D   B O N D   A N G L E S')    ASTB0027
      ILINE = ILINE + 3                                                 ASTB0028
                                                                        ASTB0029
C---- Print subheading for bond-lengths analysis                        ASTB0030
      WRITE(7,200)                                                      ASTB0031
 200  FORMAT(//,                                                        ASTB0032
     &    10X,'                                             +--------', ASTB0033
     &    '----------+',/,                                              ASTB0034
     &    10X,'                                             |   BOND ', ASTB0035
     &    'LENGTHS   |',/,                                              ASTB0036
     &    10X,'                                             +--------', ASTB0037
     &    '----------+')                                                ASTB0038
      ILINE = ILINE + 5                                                 ASTB0039
                                                                        ASTB0040
C---- Print column headings                                             ASTB0041
      ANGLEN = 'Bond  '                                                 ASTB0042
      WRITE(7,300) ANGLEN                                               ASTB0043
 300  FORMAT(/,                                                         ASTB0044
     &    10X,'------------------------------------------------------', ASTB0045
     &    '-------------------------------------------------------',/,  ASTB0046
     &    10X,'                                       (Small molecule', ASTB0047
     &    ' data)   Number of  Min     Max       Mean    Standard ',/,  ASTB0048
     &    10X,A6,'    X-PLOR labelling                  Mean  St. ',    ASTB0049
     &    'dev       values   value   value      value   deviation',/,  ASTB0050
     &    10X,'------------------------------------------------------', ASTB0051
     &    '-------------------------------------------------------')    ASTB0052
      ILINE = ILINE + 5                                                 ASTB0053
                                                                        ASTB0054
C---- Loop through the main-chain bond lengths                          ASTB0055
      DO 500, IMAIN = 1, NMAIN                                          ASTB0056
          IF (AL(IMAIN).EQ.'L') THEN                                    ASTB0057
                                                                        ASTB0058
C----         Calculate asterisks on min, max, and mean                 ASTB0059
              AREC = ' '                                                ASTB0060
              CHAVAL(1) = '  -   '                                      ASTB0061
              CHAVAL(2) = '  -   '                                      ASTB0062
              CHAVAL(3) = '  -   '                                      ASTB0063
              IF (MCHNUM(IMAIN).NE.0) THEN                              ASTB0064
                  CALL ASTDEV(MCHMIN(IMAIN),ENGMEA(IMAIN),              ASTB0065
     &                ENGSTD(IMAIN),CHAVAL(1),MXDEVC(1),MXDEVR,         ASTB0066
     &                AREC,83,3,0.0,.FALSE.)                            ASTB0067
                  CALL ASTDEV(MCHMAX(IMAIN),ENGMEA(IMAIN),              ASTB0068
     &                ENGSTD(IMAIN),CHAVAL(2),MXDEVC(2),MXDEVR,         ASTB0069
     &                AREC,91,3,0.0,.FALSE.)                            ASTB0070
                  CALL ASTDEV(MCHMEA(IMAIN),ENGMEA(IMAIN),              ASTB0071
     &                ENGSTD(IMAIN),CHAVAL(3),MXDEVC(3),MXDEVR,         ASTB0072
     &                AREC,102,3,0.0,.FALSE.)                           ASTB0073
                  WRITE(BREC,310) MCHSTD(IMAIN)                         ASTB0074
 310              FORMAT(F8.3)                                          ASTB0075
              ELSE                                                      ASTB0076
                  BREC = '    -   '                                     ASTB0077
              ENDIF                                                     ASTB0078
              IF (ILINE.GT.NLINES - 2) THEN                             ASTB0079
                  CALL ASTHED                                           ASTB0080
                  WRITE(7,300) ANGLEN                                   ASTB0081
                  ILINE = ILINE + 5                                     ASTB0082
              ENDIF                                                     ASTB0083
              WRITE(7,320) LENANG(IMAIN), ENCODE(IMAIN), EXDESC(IMAIN), ASTB0084
     &            ENGMEA(IMAIN), ENGSTD(IMAIN),                         ASTB0085
     &            MCHNUM(IMAIN), (CHAVAL(I), I = 1, 3), BREC            ASTB0086
 320          FORMAT(10X,A8,2X,A13,4X,A16,F5.3,F8.3,7X,I6,3X,A6,2X,     ASTB0087
     &            A6,6X,A6,2X,A8)                                       ASTB0088
              ILINE = ILINE + 1                                         ASTB0089
              IF (AREC.NE.' ') THEN                                     ASTB0090
                  WRITE(7,330) AREC                                     ASTB0091
 330              FORMAT(A131)                                          ASTB0092
                  ILINE = ILINE + 1                                     ASTB0093
              ENDIF                                                     ASTB0094
          ENDIF                                                         ASTB0095
 500  CONTINUE                                                          ASTB0096
                                                                        ASTB0097
C---- Print bottom line                                                 ASTB0098
      WRITE(7,520)                                                      ASTB0099
 520  FORMAT(                                                           ASTB0100
     &    10X,'------------------------------------------------------', ASTB0101
     &    '-------------------------------------------------------')    ASTB0102
      ILINE = ILINE + 1                                                 ASTB0103
                                                                        ASTB0104
C---- Print subheading for bond-angles analysis                         ASTB0105
      IF (ILINE.GT.NLINES - 14 - MCHANG) CALL ASTHED                    ASTB0106
      WRITE(7,600)                                                      ASTB0107
 600  FORMAT(//,                                                        ASTB0108
     &    10X,'                                             +--------', ASTB0109
     &    '---------+',/,                                               ASTB0110
     &    10X,'                                             |   BOND ', ASTB0111
     &    'ANGLES   |',/,                                               ASTB0112
     &    10X,'                                             +--------', ASTB0113
     &    '---------+')                                                 ASTB0114
      ILINE = ILINE + 5                                                 ASTB0115
      ANGLEN = 'Angle '                                                 ASTB0116
      WRITE(7,300) ANGLEN                                               ASTB0117
      ILINE = ILINE + 5                                                 ASTB0118
                                                                        ASTB0119
C---- Loop through the main-chain bond angless                          ASTB0120
      DO 800, IMAIN = 1, NMAIN                                          ASTB0121
          IF (AL(IMAIN).EQ.'A') THEN                                    ASTB0122
                                                                        ASTB0123
C----         Calculate asterisks on min, max, and mean                 ASTB0124
              AREC = ' '                                                ASTB0125
              CHAVAL(1) = '  -   '                                      ASTB0126
              CHAVAL(2) = '  -   '                                      ASTB0127
              CHAVAL(3) = '  -   '                                      ASTB0128
              IF (MCHNUM(IMAIN).NE.0) THEN                              ASTB0129
                  CALL ASTDEV(MCHMIN(IMAIN),ENGMEA(IMAIN),              ASTB0130
     &                ENGSTD(IMAIN),CHAVAL(1),MXDEVC(1),MXDEVR,         ASTB0131
     &                AREC,83,2,0.0,.FALSE.)                            ASTB0132
                  CALL ASTDEV(MCHMAX(IMAIN),ENGMEA(IMAIN),              ASTB0133
     &                ENGSTD(IMAIN),CHAVAL(2),MXDEVC(2),MXDEVR,         ASTB0134
     &                AREC,91,2,0.0,.FALSE.)                            ASTB0135
                  CALL ASTDEV(MCHMEA(IMAIN),ENGMEA(IMAIN),              ASTB0136
     &                ENGSTD(IMAIN),CHAVAL(3),MXDEVC(3),MXDEVR,         ASTB0137
     &                AREC,102,2,0.0,.FALSE.)                           ASTB0138
                  WRITE(BREC,610) MCHSTD(IMAIN)                         ASTB0139
 610              FORMAT(F8.2)                                          ASTB0140
              ELSE                                                      ASTB0141
                  BREC = '    -   '                                     ASTB0142
              ENDIF                                                     ASTB0143
              IF (ILINE.GT.NLINES - 2) THEN                             ASTB0144
                  CALL ASTHED                                           ASTB0145
                  WRITE(7,300) ANGLEN                                   ASTB0146
                  ILINE = ILINE + 5                                     ASTB0147
              ENDIF                                                     ASTB0148
              WRITE(7,620) LENANG(IMAIN), ENCODE(IMAIN), EXDESC(IMAIN), ASTB0149
     &            ENGMEA(IMAIN), ENGSTD(IMAIN),                         ASTB0150
     &            MCHNUM(IMAIN), (CHAVAL(I), I = 1, 3), BREC            ASTB0151
 620          FORMAT(10X,A8,2X,A13,4X,A16,F5.1,F8.1,7X,I6,3X,A6,2X,     ASTB0152
     &            A6,6X,A6,2X,A8)                                       ASTB0153
              ILINE = ILINE + 1                                         ASTB0154
              IF (AREC.NE.' ') THEN                                     ASTB0155
                  WRITE(7,330) AREC                                     ASTB0156
                  ILINE = ILINE + 1                                     ASTB0157
              ENDIF                                                     ASTB0158
          ENDIF                                                         ASTB0159
 800  CONTINUE                                                          ASTB0160
                                                                        ASTB0161
C---- Print bottom line                                                 ASTB0162
      WRITE(7,520)                                                      ASTB0163
                                                                        ASTB0164
C---- Print explanatory text at end                                     ASTB0165
      WRITE(7,900)                                                      ASTB0166
 900  FORMAT(/,                                                         ASTB0167
     &    'The small molecule data used in the above analysis is from', ASTB0168
     &    ' Engh & Huber (1991). The atom labelling follows that used', ASTB0169
     &    ' in the',/,                                                  ASTB0170
     &    'X-PLOR dictionary, with some additional atoms (marked with', ASTB0171
     &    ' an asterisk) as defined by Engh & Huber.')                  ASTB0172
      ILINE = ILINE + 3                                                 ASTB0173
                                                                        ASTB0174
      RETURN                                                            ASTB0175
      END                                                               ASTB0176
                                                                        ASTB0177
      SUBROUTINE ASTBAD                                                 ASTB0001
C-----------------------------------------------------------------------ASTB0002
C                                                                       ASTB0003
C  SUBROUTINE ASTBAD  -  List the bad contacts                          ASTB0004
C                                                                       ASTB0005
C----------------------------------------------------------------------+ASTB0006
                                                                        ASTB0007
      INCLUDE 'pplot.inc'                                               ASTB0008
                                                                        ASTB0009
      CHARACTER*1   INCHN1, INCHN2, KABS1, KABS2, MS1, MS2              ASTB0010
      CHARACTER*3   RESDU1, RESDU2                                      ASTB0011
      CHARACTER*4   ATYPE1, ATYPE2                                      ASTB0012
      CHARACTER*5   SEQNO1, SEQNO2                                      ASTB0013
      CHARACTER*9   CTYPE                                               ASTB0014
      INTEGER       IPOS, LINE, NBADC                                   ASTB0015
      LOGICAL       BADYES, NUMFND                                      ASTB0016
      REAL          DIST                                                ASTB0017
                                                                        ASTB0018
                                                                        ASTB0019
C---- Initialise variables                                              ASTB0020
      ILINE = NLINES                                                    ASTB0021
      LINE = 0                                                          ASTB0022
      NBADC = 0                                                         ASTB0023
      NPRINT = 3                                                        ASTB0024
                                                                        ASTB0025
C---- Rewind the non-bonded contacts file                               ASTB0026
      REWIND(2)                                                         ASTB0027
                                                                        ASTB0028
C---- Read in next record                                               ASTB0029
 100  CONTINUE                                                          ASTB0030
          READ(2,150,END=500,ERR=900) INCHN1, SEQNO1, RESDU1,           ASTB0031
     &        ATYPE1, KABS1, INCHN2, SEQNO2, RESDU2, ATYPE2,            ASTB0032
     &        KABS2, DIST, MS1, MS2                                     ASTB0033
 150      FORMAT(10X,A1,A5,A3,A4,A1,6X,A1,A5,A3,A4,A1,F4.0,1X,2A1)      ASTB0034
          LINE = LINE + 1                                               ASTB0035
                                                                        ASTB0036
C----     Only process this residue if it belongs to the required chain ASTB0037
          IF (CHAIN.EQ.' ' .OR. INCHN1.EQ.CHAIN .OR.                    ASTB0038
     &        INCHN2.EQ.CHAIN) THEN                                     ASTB0039
                                                                        ASTB0040
C----         Check distance                                            ASTB0041
              CALL ISBAD(RESDU1,ATYPE1(2:4),RESDU2,ATYPE2(2:4),DIST,    ASTB0042
     &            VWDIST,BADYES)                                        ASTB0043
              IF (BADYES) THEN                                          ASTB0044
                  NBADC = NBADC + 1                                     ASTB0045
                                                                        ASTB0046
C----             Print this contact                                    ASTB0047
                  CTYPE = ' Het-Het '                                   ASTB0048
                  IF (INCHN1.EQ.'-') INCHN1 = ' '                       ASTB0049
                  IF (INCHN2.EQ.'-') INCHN2 = ' '                       ASTB0050
                  IF (SEQNO1(5:5).EQ.'-') SEQNO1(5:5) = ' '             ASTB0051
                  IF (SEQNO2(5:5).EQ.'-') SEQNO2(5:5) = ' '             ASTB0052
                  IF (MS1.EQ.'M') CTYPE(1:4) = 'Main'                   ASTB0053
                  IF (MS1.EQ.'S') CTYPE(1:4) = 'Side'                   ASTB0054
                  IF (MS2.EQ.'M') CTYPE(6:9) = 'Main'                   ASTB0055
                  IF (MS2.EQ.'S') CTYPE(6:9) = 'Side'                   ASTB0056
                  ILINE = ILINE + 1                                     ASTB0057
                  IF (ILINE.GE.NLINES) CALL ASTHED                      ASTB0058
                                                                        ASTB0059
C----             Strip off any leading zeros from sequence numbers     ASTB0060
                  NUMFND = .FALSE.                                      ASTB0061
                  DO 160, IPOS = 1, 4                                   ASTB0062
                      IF (.NOT.NUMFND) THEN                             ASTB0063
                          IF (SEQNO1(IPOS:IPOS).EQ.'0') THEN            ASTB0064
                              SEQNO1(IPOS:IPOS) = ' '                   ASTB0065
                          ELSE                                          ASTB0066
                              NUMFND = .TRUE.                           ASTB0067
                          ENDIF                                         ASTB0068
                      ENDIF                                             ASTB0069
 160              CONTINUE                                              ASTB0070
                  NUMFND = .FALSE.                                      ASTB0071
                  DO 180, IPOS = 1, 4                                   ASTB0072
                      IF (.NOT.NUMFND) THEN                             ASTB0073
                          IF (SEQNO2(IPOS:IPOS).EQ.'0') THEN            ASTB0074
                              SEQNO2(IPOS:IPOS) = ' '                   ASTB0075
                          ELSE                                          ASTB0076
                              NUMFND = .TRUE.                           ASTB0077
                          ENDIF                                         ASTB0078
                      ENDIF                                             ASTB0079
 180              CONTINUE                                              ASTB0080
                  WRITE(7,200) NBADC, SEQNO1, INCHN1, RESDU1, ATYPE1,   ASTB0081
     &                SEQNO2, INCHN2, RESDU2, ATYPE2, CTYPE, DIST       ASTB0082
 200              FORMAT(20X,I6,'.',3X,A5,1X,A1,1X,A3,3X,A4,'  --> ',   ASTB0083
     &                A5,1X,A1,1X,A3,3X,A4,6X,A9,4X,F6.1)               ASTB0084
              ENDIF                                                     ASTB0085
          ENDIF                                                         ASTB0086
                                                                        ASTB0087
C---- Loop back for next record in file                                 ASTB0088
      GO TO 100                                                         ASTB0089
                                                                        ASTB0090
C---- End of file reached                                               ASTB0091
 500  CONTINUE                                                          ASTB0092
                                                                        ASTB0093
      GO TO 999                                                         ASTB0094
                                                                        ASTB0095
C---- Fatal errors                                                      ASTB0096
 900  CONTINUE                                                          ASTB0097
      PRINT*, '*** ERROR. Error reading .nb file at line:', LINE + 1    ASTB0098
                                                                        ASTB0099
 999  CONTINUE                                                          ASTB0100
      RETURN                                                            ASTB0101
      END                                                               ASTB0102
                                                                        ASTB0103
      SUBROUTINE ASTATS                                                 ASTA0001
C-----------------------------------------------------------------------ASTA0002
C                                                                       ASTA0003
C  SUBROUTINE ASTATS  -  Print summary of statistics given on plots     ASTA0004
C                                                                       ASTA0005
C----------------------------------------------------------------------+ASTA0006
                                                                        ASTA0007
      INCLUDE 'pplot.inc'                                               ASTA0008
                                                                        ASTA0009
      CHARACTER*7   INOUT                                               ASTA0010
      INTEGER       NGRAPH, NTOTAL                                      ASTA0011
      LOGICAL       REVERS                                              ASTA0012
      REAL          BANDS, CMPVAL, ENDSPC, GLYPC, NONPGP, PROPC, TOTALP ASTA0013
                                                                        ASTA0014
C---- Initialise values                                                 ASTA0015
      NTOTAL = NCORE + NALLOW + NGENER + NOUTSI + NGLY + NPRO + NENDCH  ASTA0016
      ENDSPC = 100.0 * REAL(NENDCH) / REAL(NRESID)                      ASTA0017
      GLYPC = 100.0 * REAL(NGLY) / REAL(NRESID)                         ASTA0018
      NONPGP = 100.0 * REAL(NONPG) / REAL(NRESID)                       ASTA0019
      PROPC = 100.0 * REAL(NPRO) / REAL(NRESID)                         ASTA0020
      TOTALP = 100.0 * REAL(NTOTAL) / REAL(NRESID)                      ASTA0021
                                                                        ASTA0022
C---- Start a new page                                                  ASTA0023
      NPRINT = 0                                                        ASTA0024
      CALL ASTHED                                                       ASTA0025
                                                                        ASTA0026
C---- Ramachandran plot statistics                                      ASTA0027
      WRITE(7,100)                                                      ASTA0028
 100  FORMAT(//,                                                        ASTA0029
     &    37X,'R A M A C H A N D R A N   P L O T   S T A T I S ',       ASTA0030
     &    'T I C S',/)                                                  ASTA0031
      ILINE = ILINE + 4                                                 ASTA0032
      WRITE(7,120) NCORE, COREPC, NALLOW, ALLOWP, NGENER, GENERP,       ASTA0033
     &    NOUTSI, OUTSIP                                                ASTA0034
 120  FORMAT(                                                           ASTA0035
     &    29X,'Residues in most favoured regions      [A,B,L]       ',  ASTA0036
     &    I6,6X,F5.1,'%',/,                                             ASTA0037
     &    29X,'Residues in additional allowed regions [a,b,l,p]     ',  ASTA0038
     &    I6,6X,F5.1,'%',/,                                             ASTA0039
     &    29X,'Residues in generously allowed regions [~a,~b,~l,~p] ',  ASTA0040
     &    I6,6X,F5.1,'%',/,                                             ASTA0041
     &    29X,'Residues in disallowed regions         [XX]          ',  ASTA0042
     &    I6,6X,F5.1,'%',/,                                             ASTA0043
     &    84X,'----',6X,'------')                                       ASTA0044
      ILINE = ILINE + 5                                                 ASTA0045
      WRITE(7,140) NONPG, 100.0, NENDCH, NGLY, NPRO, NTOTAL             ASTA0046
 140  FORMAT(                                                           ASTA0047
     &    29X,'Number of non-glycine and non-proline residues       ',  ASTA0048
     &    I6,6X,F5.1,'%',//,                                            ASTA0049
     &    29X,'Number of end-residues (excl. Gly and Pro)           ',  ASTA0050
     &    I6,//,                                                        ASTA0051
     &    29X,'Number of glycine residues                           ',  ASTA0052
     &    I6,/,                                                         ASTA0053
     &    29X,'Number of proline residues                           ',  ASTA0054
     &    I6,/,                                                         ASTA0055
     &    84X,'----',/,                                                 ASTA0056
     &    29X,'Total number of residues                             ',  ASTA0057
     &    I6,//)                                                        ASTA0058
      ILINE = ILINE + 10                                                ASTA0059
      WRITE(7,160)                                                      ASTA0060
 160  FORMAT(                                                           ASTA0061
     &    '   Based on the analysis of 118 structures of resolution ',  ASTA0062
     &    'of at least 2.0 Angstroms and R-factor no greater than 20',  ASTA0063
     &    '%, a good',/,                                                ASTA0064
     &    '   quality model would be expected to have over 90% in th',  ASTA0065
     &    'e most favoured regions [E,H,L].')                           ASTA0066
      ILINE = ILINE + 2                                                 ASTA0067
                                                                        ASTA0068
C---- Stereochemistry of main-chain statistics                          ASTA0069
      IF (ILINE.GE.NLINES - 18) CALL ASTHED                             ASTA0070
      WRITE(7,200)                                                      ASTA0071
 200  FORMAT(//,                                                        ASTA0072
     &    32X,'S T E R E O C H E M I S T R Y   O F   M A I N ',         ASTA0073
     &    '- C H A I N',/)                                              ASTA0074
      ILINE = ILINE + 4                                                 ASTA0075
      WRITE(7,220)                                                      ASTA0076
 220  FORMAT(                                                           ASTA0077
     &    22X,'                                                Compar', ASTA0078
     &    'ison values    No. of   ',/,                                 ASTA0079
     &    22X,'                             No. of   Parameter  Typic', ASTA0080
     &    'al   Band    band widths',/,                                 ASTA0081
     &    22X,'Stereochemical parameter    data pts    value     valu', ASTA0082
     &    'e    width    from mean ',/,                                 ASTA0083
     &    22X,'------------------------    --------    -----     ----', ASTA0084
     &    '-    -----    --------- ')                                   ASTA0085
      ILINE = ILINE + 4                                                 ASTA0086
                                                                        ASTA0087
C---- Calculate differences from comparison values                      ASTA0088
      DO 300, NGRAPH = 1, 6                                             ASTA0089
          IF (NGRAPH.EQ.1 .OR. NGRAPH.EQ.6) THEN                        ASTA0090
              REVERS = .TRUE.                                           ASTA0091
          ELSE                                                          ASTA0092
              REVERS = .FALSE.                                          ASTA0093
          ENDIF                                                         ASTA0094
          CALL BANDIS(0.0,COEFF(3,NGRAPH),COEFF(2,NGRAPH),              ASTA0095
     &        COEFF(1,NGRAPH),RESOL,SVALUE(NGRAPH),CMPVAL,              ASTA0096
     &        YBAND(NGRAPH),BANDS,INOUT,REVERS)                         ASTA0097
          WRITE(7,240) DESC(NGRAPH), NVALUE(NGRAPH), SVALUE(NGRAPH),    ASTA0098
     &        CMPVAL, YBAND(NGRAPH), BANDS, INOUT                       ASTA0099
 240      FORMAT(19X,A30,I6,4X,F8.1,2X,F8.1,F8.1,3X,F8.1,3X,A)          ASTA0100
 300  CONTINUE                                                          ASTA0101
      ILINE = ILINE + 5                                                 ASTA0102
                                                                        ASTA0103
C---- Stereochemistry of side-chain statistics                          ASTA0104
      IF (ILINE.GE.NLINES - 18) CALL ASTHED                             ASTA0105
      WRITE(7,400)                                                      ASTA0106
 400  FORMAT(//,                                                        ASTA0107
     &    32X,'S T E R E O C H E M I S T R Y   O F   S I D E ',         ASTA0108
     &    '- C H A I N',/)                                              ASTA0109
      ILINE = ILINE + 4                                                 ASTA0110
      WRITE(7,220)                                                      ASTA0111
      ILINE = ILINE + 4                                                 ASTA0112
                                                                        ASTA0113
C---- Calculate differences from comparison values                      ASTA0114
      DO 500, NGRAPH = 7, 11                                            ASTA0115
          REVERS = .FALSE.                                              ASTA0116
          CALL BANDIS(0.0,COEFF(3,NGRAPH),COEFF(2,NGRAPH),              ASTA0117
     &        COEFF(1,NGRAPH),RESOL,SVALUE(NGRAPH),CMPVAL,              ASTA0118
     &        YBAND(NGRAPH),BANDS,INOUT,REVERS)                         ASTA0119
          WRITE(7,240) DESC(NGRAPH), NVALUE(NGRAPH), SVALUE(NGRAPH),    ASTA0120
     &        CMPVAL, YBAND(NGRAPH), BANDS, INOUT                       ASTA0121
 500  CONTINUE                                                          ASTA0122
      ILINE = ILINE + 5                                                 ASTA0123
                                                                        ASTA0124
      RETURN                                                            ASTA0125
      END                                                               ASTA0126
                                                                        ASTA0127
      SUBROUTINE HSTATS                                                 HSTA0001
C-----------------------------------------------------------------------HSTA0002
CHECK v.3.3.2-->                                                        HSTA0003
C                                                                       HSTA0004
C  SUBROUTINE HSTATS  -  Print summary of statistics in html format     HSTA0005
C                                                                       HSTA0006
C----------------------------------------------------------------------+HSTA0007
                                                                        HSTA0008
      INCLUDE 'pplot.inc'                                               HSTA0009
                                                                        HSTA0010
      CHARACTER*10  ASTALL, ASTCOR, ASTGEN, ASTOUT                      HSTA0011
      INTEGER       NTOTAL                                              HSTA0012
      REAL          ENDSPC, GLYPC, NONPGP, PROPC, TOTALP                HSTA0013
                                                                        HSTA0014
C---- Initialise values                                                 HSTA0015
      NTOTAL = NCORE + NALLOW + NGENER + NOUTSI + NGLY + NPRO + NENDCH  HSTA0016
      ENDSPC = 100.0 * REAL(NENDCH) / REAL(NRESID)                      HSTA0017
      GLYPC = 100.0 * REAL(NGLY) / REAL(NRESID)                         HSTA0018
      NONPGP = 100.0 * REAL(NONPG) / REAL(NRESID)                       HSTA0019
      PROPC = 100.0 * REAL(NPRO) / REAL(NRESID)                         HSTA0020
      TOTALP = 100.0 * REAL(NTOTAL) / REAL(NRESID)                      HSTA0021
                                                                        HSTA0022
C---- Determine how serious any of the percentages are                  HSTA0023
      ASTALL = ' '                                                      HSTA0024
      ASTCOR = ' '                                                      HSTA0025
      ASTGEN = ' '                                                      HSTA0026
      ASTOUT = ' '                                                      HSTA0027
      IF (COREPC.LE.80.0) THEN                                          HSTA0028
          ASTCOR = '<b>**</b>'                                          HSTA0029
      ELSE IF (COREPC.LE.90.0) THEN                                     HSTA0030
          ASTCOR = '<b>*</b>'                                           HSTA0031
      ENDIF                                                             HSTA0032
      IF (OUTSIP.GE.5.0) THEN                                           HSTA0033
          ASTOUT = '<b>**</b>'                                          HSTA0034
      ELSE IF (OUTSIP.GT.0.0) THEN                                      HSTA0035
          ASTOUT = '<b>*</b>'                                           HSTA0036
      ENDIF                                                             HSTA0037
                                                                        HSTA0038
C---- Ramachandran plot statistics                                      HSTA0039
      WRITE(15,100)                                                     HSTA0040
 100  FORMAT(//,'<h2>1. Ramachandran Plot statistics</h2>')             HSTA0041
      WRITE(15,110) '<pre><b>'                                          HSTA0042
 110  FORMAT(10A)                                                       HSTA0043
      WRITE(15,115)                                                     HSTA0044
 115  FORMAT('                                         No. of',/,       HSTA0045
     &       '                                        residues     ',   HSTA0046
     &    '%-tage',/,                                                   HSTA0047
     &       '                                         ------      ',   HSTA0048
     &    '------</b>')                                                 HSTA0049
      WRITE(15,120) NCORE, COREPC, ASTCOR, NALLOW, ALLOWP, ASTALL,      HSTA0050
     &    NGENER, GENERP, ASTGEN, NOUTSI, OUTSIP, ASTOUT                HSTA0051
 120  FORMAT('Most favoured regions      [A,B,L]       ',               HSTA0052
     &    I6,6X,F5.1,'%',A,/,                                           HSTA0053
     &       'Additional allowed regions [a,b,l,p]     ',               HSTA0054
     &    I6,6X,F5.1,'%',A,/,                                           HSTA0055
     &       'Generously allowed regions [~a,~b,~l,~p] ',               HSTA0056
     &    I6,6X,F5.1,'%',A,/,                                           HSTA0057
     &       'Disallowed regions         [XX]          ',               HSTA0058
     &    I6,6X,F5.1,'%',A,/,                                           HSTA0059
     &    43X,'----',6X,'------')                                       HSTA0060
      WRITE(15,140) NONPG, 100.0, NENDCH, NGLY, NPRO, NTOTAL            HSTA0061
 140  FORMAT('Non-glycine and non-proline residues     ',               HSTA0062
     &    I6,6X,F5.1,'%',//,                                            HSTA0063
     &       'End-residues (excl. Gly and Pro)         ',               HSTA0064
     &    I6,//,                                                        HSTA0065
     &       'Glycine residues                         ',               HSTA0066
     &    I6,/,                                                         HSTA0067
     &       'Proline residues                         ',               HSTA0068
     &    I6,/,                                                         HSTA0069
     &    43X,'----',/,                                                 HSTA0070
     &       'Total number of residues                 ',               HSTA0071
     &    I6,//)                                                        HSTA0072
      WRITE(15,110) '</pre>'                                            HSTA0073
      WRITE(15,160)                                                     HSTA0074
 160  FORMAT('<p>',                                                     HSTA0075
     &    'Based on an analysis of <b>118</b> structures of resolu',    HSTA0076
     &    'tion of at least <b>2.0</b> Angstroms and <em>R</em>-fac',   HSTA0077
     &    'tor no greater than <b>20.0</b> a good',/,                   HSTA0078
     &    'quality model would be expected to have over <b>90%</b> ',   HSTA0079
     &    'in the most favoured regions [A,B,L].')                      HSTA0080
      WRITE(15,110) '<hr>'                                              HSTA0081
                                                                        HSTA0082
      RETURN                                                            HSTA0083
      END                                                               HSTA0084
                                                                        HSTA0085
      SUBROUTINE BANDIS(A3,A2,A1,C,XVALUE,YVALUE,CMPVAL,BWIDTH,BANDS,   BAND0001
     &    INOUT,REVERS)                                                 BAND0002
C-----------------------------------------------------------------------BAND0003
CHECK v.3.3.2<--                                                        BAND0004
C                                                                       BAND0005
C  SUBROUTINE BANDIS  -  Calculate number of band-widths current        BAND0006
C                        stereochemical parameter is from the expected  BAND0007
C                        value                                          BAND0008
C                                                                       BAND0009
C----------------------------------------------------------------------+BAND0010
                                                                        BAND0011
      INCLUDE 'pplot.inc'                                               BAND0012
                                                                        BAND0013
      CHARACTER*7   INOUT                                               BAND0014
      LOGICAL       REVERS                                              BAND0015
      REAL          A1, A2, A3, BANDS, BWIDTH, C, CMPVAL, DIFF,         BAND0016
     &              XVALUE, YVALUE                                      BAND0017
                                                                        BAND0018
                                                                        BAND0019
C---- Calculate the comparison value, difference, and number of bands   BAND0020
C     difference                                                        BAND0021
      CMPVAL = A3 * XVALUE * XVALUE * XVALUE                            BAND0022
     &    + A2 * XVALUE * XVALUE                                        BAND0023
     &    + A1 * XVALUE + C                                             BAND0024
      DIFF = YVALUE - CMPVAL                                            BAND0025
      BANDS = DIFF / BWIDTH                                             BAND0026
      IF (REVERS) BANDS = -1.0 * BANDS                                  BAND0027
      IF (BANDS.GT.1.0) INOUT = 'WORSE'                                 BAND0028
      IF (BANDS.LE.1.0) INOUT = 'Inside'                                BAND0029
      IF (BANDS.LT.-1.0) INOUT = 'BETTER'                               BAND0030
      IF (REVERS) BANDS = -1.0 * BANDS                                  BAND0031
                                                                        BAND0032
      RETURN                                                            BAND0033
      END                                                               BAND0034
                                                                        BAND0035
      SUBROUTINE MCLASS                                                 MCLA0001
C-----------------------------------------------------------------------MCLA0002
C                                                                       MCLA0003
C  SUBROUTINE MCLASS  -  Print the Morris et al. classification of the  MCLA0004
C                        structure                                      MCLA0005
C                                                                       MCLA0006
C----------------------------------------------------------------------+MCLA0007
                                                                        MCLA0008
      INCLUDE 'pplot.inc'                                               MCLA0009
                                                                        MCLA0010
      INTEGER       I, ICLASS(3)                                        MCLA0011
      REAL          BAND(3,3), MORCHM, MORCHS, MORHBM, MORHBS,          MCLA0012
     &              TVALUE(3)                                           MCLA0013
                                                                        MCLA0014
      DATA  BAND  / 75.0, 65.0, 55.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 /    MCLA0015
      DATA  MORCHM, MORCHS / 18.2, 6.2  /                               MCLA0016
      DATA  MORHBM, MORHBS / 0.87, 0.24 /                               MCLA0017
                                                                        MCLA0018
C---- Initialise values                                                 MCLA0019
      BAND(1,1) = 100.0 - BAND(1,1)                                     MCLA0020
      BAND(2,1) = 100.0 - BAND(2,1)                                     MCLA0021
      BAND(3,1) = 100.0 - BAND(3,1)                                     MCLA0022
      BAND(1,2) = MORCHM - MORCHS                                       MCLA0023
      BAND(2,2) = MORCHM                                                MCLA0024
      BAND(3,2) = MORCHM + MORCHS                                       MCLA0025
      BAND(1,3) = MORHBM - MORHBS                                       MCLA0026
      BAND(2,3) = MORHBM                                                MCLA0027
      BAND(3,3) = MORHBM + MORHBS                                       MCLA0028
      TVALUE(1) = 100.0 - COREPC                                        MCLA0029
      TVALUE(2) = GPLDEV                                                MCLA0030
      TVALUE(3) = HBDEV                                                 MCLA0031
                                                                        MCLA0032
C---- Determine the three classes this structure falls into             MCLA0033
      DO 100, I = 1, 3                                                  MCLA0034
          ICLASS(I) = 4                                                 MCLA0035
          IF (TVALUE(I).LT.BAND(3,I)) ICLASS(I) = 3                     MCLA0036
          IF (TVALUE(I).LT.BAND(2,I)) ICLASS(I) = 2                     MCLA0037
          IF (TVALUE(I).LT.BAND(1,I)) ICLASS(I) = 1                     MCLA0038
 100  CONTINUE                                                          MCLA0039
                                                                        MCLA0040
C---- Start a new page if necessary                                     MCLA0041
      IF (ILINE.GE.NLINES - 10) CALL ASTHED                             MCLA0042
                                                                        MCLA0043
C---- Print column headings                                             MCLA0044
      NPRINT = 0                                                        MCLA0045
      WRITE(7,120)                                                      MCLA0046
 120  FORMAT(//,                                                        MCLA0047
     &    35X,'M O R R I S   E T   A L .   C L A S S I F I C A ',       MCLA0048
     &    'T I O N',/)                                                  MCLA0049
      ILINE = ILINE + 4                                                 MCLA0050
      WRITE(7,140)                                                      MCLA0051
 140  FORMAT(                                                           MCLA0052
     &    15X,'                        Mean  St.dev                 ',  MCLA0053
     &        'Classification',/,                                       MCLA0054
     &    15X,'Parameter                 m     s           1        ',  MCLA0055
     &        ' 2          3        4       Value     Class',/,         MCLA0056
     &    15X,'---------               ----   ---      -------------',  MCLA0057
     &        '-----------------------      -----     -----')           MCLA0058
      ILINE = ILINE + 3                                                 MCLA0059
                                                                        MCLA0060
C---- Write out the table of results                                    MCLA0061
      WRITE(7,160)                                                      MCLA0062
     &    (100.0 - BAND(I,1), I = 1, 3), 100.0 - BAND(3,1),             MCLA0063
     &    100.0 - TVALUE(1), ICLASS(1), MORCHM, MORCHS,                 MCLA0064
     &    (BAND(I,2), I = 1, 3), BAND(3,2), TVALUE(2), ICLASS(2),       MCLA0065
     &    MORHBM, MORHBS,                                               MCLA0066
     &    (BAND(I,3), I = 1, 3), BAND(3,3), TVALUE(3), ICLASS(3)        MCLA0067
 160  FORMAT(                                                           MCLA0068
     &    15X,'Phi-psi distribution','     -  ','    - ',3X,3(4X,'>',   MCLA0069
     &    F4.1,'%'),4X,'<',F4.1,'%',2X,F8.1,7X,I1,/,                    MCLA0070
     &    15X,'Chi-1 st.dev.       ',F8.1,F6.1,3X,3(4X,'<',F4.1,' '),   MCLA0071
     &    4X,'>',F4.1,' ',2X,F8.1,7X,I1,/,                              MCLA0072
     &    15X,'H-bond energy st dev',F9.2,F6.2,2X,3(4X,'<',F4.2,' '),   MCLA0073
     &    4X,'>',F4.2,' ',2X,F8.2,7X,I1)                                MCLA0074
      ILINE = ILINE + 3                                                 MCLA0075
                                                                        MCLA0076
CHECK v.3.2-->                                                          MCLA0077
C---- Save the Morris et al classification                              MCLA0078
      MCLAST(1) = ICLASS(1)                                             MCLA0079
      MCLAST(2) = ICLASS(2)                                             MCLA0080
      MCLAST(3) = ICLASS(3)                                             MCLA0081
CHECK v.3.2<--                                                          MCLA0082
                                                                        MCLA0083
      RETURN                                                            MCLA0084
      END                                                               MCLA0085
                                                                        MCLA0086
      SUBROUTINE GFACTS                                                 GFAC0001
C-----------------------------------------------------------------------GFAC0002
C                                                                       GFAC0003
C  SUBROUTINE GFACTS  -  Print the structure's G-factors - ie the measurGFAC0004
C                        showing how typical this protein's geometry is GFAC0005
C                                                                       GFAC0006
C----------------------------------------------------------------------+GFAC0007
                                                                        GFAC0008
      INCLUDE 'pplot.inc'                                               GFAC0009
                                                                        GFAC0010
      INTEGER       IDISTR                                              GFAC0011
                                                                        GFAC0012
C---- Start a new page if necessary                                     GFAC0013
      IF (ILINE.GE.NLINES - 26) CALL ASTHED                             GFAC0014
                                                                        GFAC0015
C---- Print column headings                                             GFAC0016
      NPRINT = 0                                                        GFAC0017
      WRITE(7,120)                                                      GFAC0018
 120  FORMAT(//,                                                        GFAC0019
     &    54X,'G - F A C T O R S',/)                                    GFAC0020
      ILINE = ILINE + 4                                                 GFAC0021
      WRITE(7,140)                                                      GFAC0022
 140  FORMAT(                                                           GFAC0023
     &    29X,'                                                       ',GFAC0024
     &    '   Average',/,                                               GFAC0025
     &    29X,'Parameter                                 Score        ',GFAC0026
     &    '    Score',/,                                                GFAC0027
     &    29X,'---------                                 -----        ',GFAC0028
     &    '    -----',/,                                                GFAC0029
     &    29X,'Dihedral angles:-')                                      GFAC0030
      ILINE = ILINE + 4                                                 GFAC0031
                                                                        GFAC0032
C---- Write out the table of results                                    GFAC0033
      WRITE(7,160) (GFACTR(IDISTR), IDISTR = 1, NDIHED + 1)             GFAC0034
 160  FORMAT(                                                           GFAC0035
     &    29X,'     Phi-psi distribution                ',F6.2,/,       GFAC0036
     &    29X,'     Chi1-chi2 distribution              ',F6.2,/,       GFAC0037
     &    29X,'     Chi1 only                           ',F6.2,/,       GFAC0038
     &    29X,'     Chi3 & chi4                         ',F6.2,/,       GFAC0039
     &    29X,'     Omega                               ',F6.2,/,       GFAC0040
     &    29X,'                                         ------        ',GFAC0041
     &    '   ',F6.2,/,                                                 GFAC0042
     &    29X,'                                                       ',GFAC0043
     &    '    =====')                                                  GFAC0044
      ILINE = ILINE + 7                                                 GFAC0045
                                                                        GFAC0046
      WRITE(7,180) (GFACTR(IDISTR), IDISTR = NDIHED + 2,                GFAC0047
     &     NDIHED + NCOVAL + 2)                                         GFAC0048
 180  FORMAT(                                                           GFAC0049
     &    29X,'Main-chain covalent forces:-',/,                         GFAC0050
     &    29X,'     Main-chain bond lengths             ',F6.2,/,       GFAC0051
     &    29X,'     Main-chain bond angles              ',F6.2,/,       GFAC0052
     &    29X,'                                         ------        ',GFAC0053
     &    '   ',F6.2,/,                                                 GFAC0054
     &    29X,'                                                       ',GFAC0055
     &    '    =====')                                                  GFAC0056
      ILINE = ILINE + 5                                                 GFAC0057
                                                                        GFAC0058
      WRITE(7,200) GFACTR(NDISTR)                                       GFAC0059
 200  FORMAT(//                                                         GFAC0060
     &    29X,'OVERALL AVERAGE                                        ',GFAC0061
     &    '   ',F6.2,/,                                                 GFAC0062
     &    29X,'                                                       ',GFAC0063
     &    '    =====',//,                                               GFAC0064
     &    29X,'Ideally, scores should be above -0.5. Values below -1.0',GFAC0065
     &    ' may need investigation.')                                   GFAC0066
      ILINE = ILINE + 6                                                 GFAC0067
                                                                        GFAC0068
      RETURN                                                            GFAC0069
      END                                                               GFAC0070
                                                                        GFAC0071
      SUBROUTINE GHTML                                                  GHTM0001
C-----------------------------------------------------------------------GHTM0002
CHECK v.3.3.2-->                                                        GHTM0003
C                                                                       GHTM0004
C  SUBROUTINE GHTML  -  Print the structure's G-factors to the output   GHTM0005
C                       html file                                       GHTM0006
C                                                                       GHTM0007
C----------------------------------------------------------------------+GHTM0008
                                                                        GHTM0009
      INCLUDE 'pplot.inc'                                               GHTM0010
                                                                        GHTM0011
      CHARACTER*6   BLDOFF, BOLDON                                      GHTM0012
      CHARACTER*25  DIHED(10)                                           GHTM0013
      CHARACTER*60  DDESC                                               GHTM0014
      INTEGER       DLEN, IDISTR                                        GHTM0015
                                                                        GHTM0016
      DATA DIHED  / 'Phi-psi distribution   ',                          GHTM0017
     &              'Chi1-chi2 distribution ',                          GHTM0018
     &              'Chi1 only              ',                          GHTM0019
     &              'Chi3 & chi4            ',                          GHTM0020
     &              'Omega                  ',                          GHTM0021
     &              '                       ',                          GHTM0022
     &              'Main-chain bond lengths',                          GHTM0023
     &              'Main-chain bond angles ',                          GHTM0024
     &              '                       ',                          GHTM0025
     &              'OVERALL AVERAGE        ' /                         GHTM0026
                                                                        GHTM0027
C---- Print column headings                                             GHTM0028
      WRITE(15,120)                                                     GHTM0029
 120  FORMAT('<h2>2. G-Factors</h2>',/)                                 GHTM0030
      WRITE(15,110) '<pre>'                                             GHTM0031
 110  FORMAT(10A)                                                       GHTM0032
      WRITE(15,140)                                                     GHTM0033
 140  FORMAT('<b>                                             ',        GHTM0034
     &    '   Average',/,                                               GHTM0035
     &       'Parameter                            Score   ',           GHTM0036
     &    '    Score',/,                                                GHTM0037
     &       '---------                            -----   ',           GHTM0038
     &    '    -----</b>',/,                                            GHTM0039
     &       '<em>Dihedral angles:-</em>')                              GHTM0040
                                                                        GHTM0041
C---- Write out the table of results for dihedral angles                GHTM0042
      DO 200, IDISTR = 1, NDIHED + 1                                    GHTM0043
          BLDOFF = ' '                                                  GHTM0044
          BOLDON = ' '                                                  GHTM0045
          DLEN = 31                                                     GHTM0046
          IF (GFACTR(IDISTR).LT.-1.0) THEN                              GHTM0047
              BOLDON = '<b>'                                            GHTM0048
              BLDOFF = '**</b>'                                         GHTM0049
              DLEN = DLEN + 3                                           GHTM0050
          ELSE IF (GFACTR(IDISTR).LT.-0.5) THEN                         GHTM0051
              BOLDON = '<em>'                                           GHTM0052
              BLDOFF = '*</em>'                                         GHTM0053
              DLEN = DLEN + 4                                           GHTM0054
          ENDIF                                                         GHTM0055
          DDESC = DIHED(IDISTR) // BOLDON                               GHTM0056
          IF (IDISTR.EQ.NDIHED + 1) DLEN = DLEN + 13                    GHTM0057
          WRITE(15,160) DDESC(1:DLEN), GFACTR(IDISTR), BLDOFF           GHTM0058
 160      FORMAT(5X,A,F6.2,A)                                           GHTM0059
 200  CONTINUE                                                          GHTM0060
      WRITE(15,220)                                                     GHTM0061
 220  FORMAT('                                                  ',      GHTM0062
     &    '=====')                                                      GHTM0063
                                                                        GHTM0064
C---- Write out the table of results for dihedral angles                GHTM0065
      WRITE(15,240)                                                     GHTM0066
 240  FORMAT('<em>Main-chain covalent forces:-</em>')                   GHTM0067
      DO 400, IDISTR = NDIHED + 2, NDISTR                               GHTM0068
          BLDOFF = ' '                                                  GHTM0069
          BOLDON = ' '                                                  GHTM0070
          DLEN = 31                                                     GHTM0071
          IF (GFACTR(IDISTR).LT.-1.0) THEN                              GHTM0072
              BOLDON = '<b>'                                            GHTM0073
              BLDOFF = '**</b>'                                         GHTM0074
              DLEN = DLEN + 3                                           GHTM0075
          ELSE IF (GFACTR(IDISTR).LT.-0.5) THEN                         GHTM0076
              BOLDON = '<em>'                                           GHTM0077
              BLDOFF = '*</em>'                                         GHTM0078
              DLEN = DLEN + 4                                           GHTM0079
          ENDIF                                                         GHTM0080
          DDESC = DIHED(IDISTR) // BOLDON                               GHTM0081
          IF (IDISTR.GE.NDIHED + NCOVAL + 2) DLEN = DLEN + 13           GHTM0082
          WRITE(15,160) DDESC(1:DLEN), GFACTR(IDISTR), BLDOFF           GHTM0083
          IF (IDISTR.GE.NDIHED + NCOVAL + 2) THEN                       GHTM0084
              WRITE(15,220)                                             GHTM0085
              WRITE(15,*)                                               GHTM0086
          ENDIF                                                         GHTM0087
 400  CONTINUE                                                          GHTM0088
                                                                        GHTM0089
C---- Write out explanatory text                                        GHTM0090
      WRITE(15,420)                                                     GHTM0091
 420  FORMAT('</pre>',/,'<p>',/,                                        GHTM0092
     &    '<b>G-factors</b> provide a measure of how <b>unusual</b>,',  GHTM0093
     &    ' or out-of-the-ordinary, a property is.')                    GHTM0094
      WRITE(15,440)                                                     GHTM0095
 440  FORMAT('<pre>',/,                                                 GHTM0096
     &       'Values below <em>-0.5*</em>  - unusual',/,                GHTM0097
     &       'Values below <b>-1.0**</b> - highly unusual')             GHTM0098
                                                                        GHTM0099
C---- Finish off print                                                  GHTM0100
      WRITE(15,110) '</pre>'                                            GHTM0101
      WRITE(15,110) '<b>Important note:</b> The main-chain'             GHTM0102
      WRITE(15,110) 'bond-lengths and bond angles are compared with'    GHTM0103
      WRITE(15,110) 'the Engh & Huber (1991) ideal values derived'      GHTM0104
      WRITE(15,110) 'from small-molecule data. Therefore, structures'   GHTM0105
      WRITE(15,110) 'refined using different restraints may show'       GHTM0106
      WRITE(15,110) 'apparently large deviations from normality.'       GHTM0107
      WRITE(15,110) '<hr>'                                              GHTM0108
                                                                        GHTM0109
      RETURN                                                            GHTM0110
      END                                                               GHTM0111
                                                                        GHTM0112
      SUBROUTINE WRIPAR                                                 WRIP0001
C-----------------------------------------------------------------------WRIP0002
CHECK v.3.3.2<--                                                        WRIP0003
C                                                                       WRIP0004
C  SUBROUTINE WRIPAR  -  Write out the stereochemical parameters to the WRIP0005
C                        .sco file                                      WRIP0006
C                                                                       WRIP0007
C----------------------------------------------------------------------+WRIP0008
                                                                        WRIP0009
      INCLUDE 'pplot.inc'                                               WRIP0010
                                                                        WRIP0011
      INTEGER       I                                                   WRIP0012
                                                                        WRIP0013
C---- Open output file, <filename>.sco                                  WRIP0014
      OPEN(UNIT=8, FILE=FILSCO, STATUS='UNKNOWN', FORM='FORMATTED',     WRIP0015
     &    ACCESS='SEQUENTIAL',                                          WRIP0016
CVAX     -    CARRIAGECONTROL='LIST',RECL=132,                          WRIP0017
     &    ERR=900)                                                      WRIP0018
                                                                        WRIP0019
C---- Write out the stereochemical parameters                           WRIP0020
      WRITE(8,110) RESOL, (SVALUE(I), I = 1, 10)                        WRIP0021
 110  FORMAT(F5.3,10F7.3)                                               WRIP0022
                                                                        WRIP0023
C---- Close the .sco file                                               WRIP0024
      CLOSE(8)                                                          WRIP0025
                                                                        WRIP0026
      GO TO 999                                                         WRIP0027
                                                                        WRIP0028
C---- Fatal errors                                                      WRIP0029
 900  CONTINUE                                                          WRIP0030
      PRINT*, '*** ERROR. Unable to open output file [', FILSCO, ']',   WRIP0031
     &    ' Program aborted'                                            WRIP0032
      GO TO 990                                                         WRIP0033
                                                                        WRIP0034
990   CONTINUE                                                          WRIP0035
      IFAIL = .TRUE.                                                    WRIP0036
                                                                        WRIP0037
999   CONTINUE                                                          WRIP0038
      RETURN                                                            WRIP0039
      END                                                               WRIP0040
                                                                        WRIP0041
      SUBROUTINE WRISUM                                                 WRIS0001
C-----------------------------------------------------------------------WRIS0002
CHECK v.3.2-->                                                          WRIS0003
C                                                                       WRIS0004
C  SUBROUTINE WRISUM  -  Write out the summary data to the summary file WRIS0005
C                                                                       WRIS0006
C----------------------------------------------------------------------+WRIS0007
                                                                        WRIS0008
      INCLUDE 'pplot.inc'                                               WRIS0009
                                                                        WRIS0010
      CHARACTER*6   CNUMB                                               WRIS0011
      CHARACTER*7   MNUMBS                                              WRIS0012
      CHARACTER*79  BLNKLN, SUMLIN                                      WRIS0013
      INTEGER       IPOS                                                WRIS0014
      REAL          GMIN                                                WRIS0015
                                                                        WRIS0016
      DATA BLNKLN( 1:40) / ' |                                      ' / WRIS0017
      DATA BLNKLN(41:79) / '                                      |'  / WRIS0018
                                                                        WRIS0019
C---- Residue properties                                                WRIS0020
      SUMLIN = BLNKLN                                                   WRIS0021
      SUMLIN(4:38) = 'Residue properties: Max.deviation:'               WRIS0022
      WRITE(CNUMB,100) OMAXDV(1)                                        WRIS0023
 100  FORMAT(F6.1)                                                      WRIS0024
      SUMLIN(40:45) = CNUMB                                             WRIS0025
      SUMLIN(60:72) = 'Bad contacts:'                                   WRIS0026
      WRITE(CNUMB,200) NBADPR                                           WRIS0027
 200  FORMAT(I5,1X)                                                     WRIS0028
      SUMLIN(73:77) = CNUMB(1:5)                                        WRIS0029
                                                                        WRIS0030
C---- Determine whether to mark the line with a + or a *                WRIS0031
      IF (OMAXDV(1).GT.3.0 .OR. NBADPR.GT.5) SUMLIN(1:1) = '+'          WRIS0032
      IF (OMAXDV(2).GT.5.0 .OR. NBADPR.GT.10) SUMLIN(1:1) = '*'         WRIS0033
                                                                        WRIS0034
C---- Write the line out to the summary file                            WRIS0035
      WRITE(14,300) SUMLIN                                              WRIS0036
 300  FORMAT(A)                                                         WRIS0037
                                                                        WRIS0038
C---- Main-chain bond lengths and angles                                WRIS0039
      SUMLIN = BLNKLN                                                   WRIS0040
      SUMLIN(24:38) = 'Bond len/angle:'                                 WRIS0041
      WRITE(CNUMB,100) OMAXDV(2)                                        WRIS0042
      SUMLIN(40:45) = CNUMB                                             WRIS0043
      SUMLIN(50:69) = 'Morris et al class:'                             WRIS0044
      WRITE(MNUMBS,400) MCLAST(1), MCLAST(2), MCLAST(3)                 WRIS0045
 400  FORMAT(I1,2X,I1,2X,I1)                                            WRIS0046
      SUMLIN(71:77) = MNUMBS                                            WRIS0047
                                                                        WRIS0048
C---- Determine whether to mark the line with a + or a *                WRIS0049
      IF (OMAXDV(2).GT.3.0) SUMLIN(1:1) = '+'                           WRIS0050
      IF (OMAXDV(2).GT.5.0) SUMLIN(1:1) = '*'                           WRIS0051
                                                                        WRIS0052
C---- Write the line out to the summary file                            WRIS0053
      WRITE(14,300) SUMLIN                                              WRIS0054
                                                                        WRIS0055
C---- If there are any cis-peptides or D-amino acids, write these out   WRIS0056
      IF (NDAM.GT.0 .OR. NCIS.GT.0) THEN                                WRIS0057
          SUMLIN = BLNKLN                                               WRIS0058
          IPOS = 3                                                      WRIS0059
                                                                        WRIS0060
C----     If any cis peptides, write out how many                       WRIS0061
          IF (NCIS.GT.0) THEN                                           WRIS0062
              WRITE(CNUMB,500) NCIS                                     WRIS0063
 500          FORMAT(I6)                                                WRIS0064
              SUMLIN(IPOS:IPOS + 5) = CNUMB                             WRIS0065
              SUMLIN(IPOS + 7:IPOS + 18) = 'cis-peptides'               WRIS0066
              IPOS = 24                                                 WRIS0067
          ENDIF                                                         WRIS0068
                                                                        WRIS0069
C----     If any D amino acids, write out how many                      WRIS0070
          IF (NDAM.GT.0) THEN                                           WRIS0071
              WRITE(CNUMB,500) NDAM                                     WRIS0072
              SUMLIN(IPOS:IPOS + 5) = CNUMB                             WRIS0073
              SUMLIN(IPOS + 7:IPOS + 19) = 'D amino acids'              WRIS0074
          ENDIF                                                         WRIS0075
                                                                        WRIS0076
C----     Determine whether to mark the line with a + or a *            WRIS0077
          SUMLIN(1:1) = '+'                                             WRIS0078
          IF (NDAM.GT.0 .OR. NCIS.GT.3) SUMLIN(1:1) = '*'               WRIS0079
                                                                        WRIS0080
C----     Write out the summary line                                    WRIS0081
          WRITE(14,300) SUMLIN                                          WRIS0082
                                                                        WRIS0083
C---- Otherwise, write out a blank line                                 WRIS0084
      ELSE                                                              WRIS0085
          WRITE(14,300) BLNKLN                                          WRIS0086
      ENDIF                                                             WRIS0087
                                                                        WRIS0088
C---- G-factors                                                         WRIS0089
      SUMLIN = BLNKLN                                                   WRIS0090
      SUMLIN(4:13) = 'G-factors'                                        WRIS0091
      WRITE(MNUMBS,600) GFACTR(NDIHED + 1)                              WRIS0092
 600  FORMAT(F7.2)                                                      WRIS0093
      SUMLIN(34:40) = MNUMBS                                            WRIS0094
      SUMLIN(24:33) = 'Dihedrals:'                                      WRIS0095
      WRITE(MNUMBS,600) GFACTR(NDIHED + NCOVAL + 2)                     WRIS0096
      SUMLIN(52:58) = MNUMBS                                            WRIS0097
      SUMLIN(43:51) = 'Covalent:'                                       WRIS0098
      WRITE(MNUMBS,600) GFACTR(NDISTR)                                  WRIS0099
      SUMLIN(71:77) = MNUMBS                                            WRIS0100
      SUMLIN(63:70) = 'Overall:'                                        WRIS0101
                                                                        WRIS0102
C---- Determine whether to mark the line with a + or a *                WRIS0103
      GMIN = MIN(GFACTR(NDIHED + 1),GFACTR(NDIHED + NCOVAL + 2))        WRIS0104
      GMIN = MIN(GFACTR(NDISTR),GMIN)                                   WRIS0105
      IF (GMIN.LT.-0.5) SUMLIN(1:1) = '+'                               WRIS0106
      IF (GMIN.LT.-2.0) SUMLIN(1:1) = '*'                               WRIS0107
                                                                        WRIS0108
C---- Write the line the the summary file                               WRIS0109
      WRITE(14,300) SUMLIN                                              WRIS0110
      WRITE(14,300) BLNKLN                                              WRIS0111
                                                                        WRIS0112
      RETURN                                                            WRIS0113
      END                                                               WRIS0114
