



      SUBROUTINE SC2001

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HSTINC.INC'
      LOGICAL       CHKTODO, HASPROTEIN
      EXTERNAL      PDBC52







      CALL SC2004



      CALL SC2005
      CALL SC2012



      IF (CHKTODO('RAP')) CALL PDBC51 (PDBC52)



      IF (CHKTODO('HST').AND.HASPROTEIN()) THEN
         HSTDON=.FALSE.
         CALL PDBMES ('DSSP')
      END IF













      RETURN
      END   
      SUBROUTINE SC2002

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, IAA, IERR
      LOGICAL       FOUND, LFOUND, WIFIRW
      CHARACTER*1   CHAF, SC2003







      DO 10 IAA=1,NUMAAT
         IF (.NOT.WIFIRW(IAA)) THEN
            IF (CHANAM(IAA).NE.' ') GOTO 20
         END IF
 10   CONTINUE



      GOTO 998



 20   CONTINUE



      FOUND=.FALSE.



      DO 50 ISOUP=1,NUMSOU



         LFOUND=.FALSE.
         CHAF=' '
         DO 30 IAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)
            IF (CHANAM(IAA).EQ.' ') THEN
               LFOUND=.TRUE.
               FOUND=.TRUE.
            ELSE
               CHAF=CHANAM(IAA)
            END IF
 30      CONTINUE



         IF (LFOUND) THEN
            IF (CHAF.EQ.' ') CHAF=SC2003()
            DO 40 IAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)
               CHANAM(IAA)=CHAF
 40         CONTINUE
         END IF
 50   CONTINUE



      IF (FOUND) THEN



         CALL CDB013 ('SOUPBAD2',' ','SOUPOK2')



         DO 60 ISOUP=1,NUMSOU
            CALL SOUTEX (ISOUP,BIGLIN,IERR)
            CALL PDBC93 (BIGLIN)
 60      CONTINUE
         CALL CDB012
      END IF



  998 CONTINUE


      RETURN
      END   
      CHARACTER*1 FUNCTION SC2003()

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IND, IUSE
      LOGICAL       CHUSED(36), GVFIBN







      CALL GVSBTF (CHUSED,36)
      SC2003='+'



      DO 10 IAA=1,NUMAAF
         IND=INDEX(CHADEF2,CHANAM(IAA))
         IF (GVFIBN(IND,1,36)) CHUSED(IND)=.TRUE.
 10   CONTINUE



      DO 20 IUSE=1,36
         IF (.NOT.CHUSED(IUSE)) THEN
            SC2003=CHADEF2(IUSE:IUSE)
            GOTO 998
         END IF
 20   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC2004

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HSTINC.INC'
      INTEGER       ISOUP, IERR







      CALL TEXSECT ('?CHKM29')



      CALL CDB013 ('SOUPBAD',' ','SOUPOK')
      DO 10 ISOUP=1,NUMSOU
         CALL SOUTEX (ISOUP,BIGLIN,IERR)
         CALL PDBC93 (BIGLIN)
 10   CONTINUE
      CALL CDB012





      RETURN
      END
      SUBROUTINE SC2005

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'







      CALL PDBMES ('SOUSTAT')





      RETURN
      END   
      SUBROUTINE SC2006

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       NAA, NNU, NSU, NWA, BAA, BNU, BSU, BWA







      CALL SC2007 (NAA,NNU,NSU,NWA,BAA,BNU,BSU,BWA)
      IF (NAA.GT.0) THEN
         CALL GVSTTI ('Number of amino acids',NAA)
         CALL TEXTXT (' ')
         IF (BAA.GE.1) CALL SC2008 (BAA,1)
      END IF
      IF (NNU.GT.0) THEN
         CALL GVSTTI ('Number of nucleic acids',NNU)
         CALL TEXTXT (' ')
         IF (BNU.GE.1) CALL SC2008 (BNU,1)
      END IF
      IF (NSU.GT.0) THEN
         CALL GVSTTI ('Number of (recognized) sugars',NSU)
         CALL TEXTXT (' ')
         IF (BSU.GE.1) CALL SC2008 (BSU,1)
      END IF
      IF (NWA.GT.0) THEN
         CALL GVSTTI ('Number of water molecules',NWA)
         CALL TEXTXT (' ')
         IF (BWA.GE.1) CALL SC2008 (BWA,2)
      END IF



      CALL SC2009
      CALL SC2010



      CALL SC2011





      RETURN
      END   
      SUBROUTINE SC2007 (NAA,NNU,NSU,NWA,BAA,BNU,BSU,BWA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       NAA, NNU, NSU, NWA, BAA, BNU, BSU, BWA, IAA, IAT, 
     +              BADATM
      LOGICAL       WIFIRA, WIFIRN, WIFIRZ, WIFIRW







      NAA=0
      NNU=0
      NSU=0
      NWA=0
      BAA=0
      BNU=0
      BSU=0
      BWA=0



      DO 20 IAA=1,NUMAAT
         BADATM=0
         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (WEIGHT(IAT).LT.0.1.OR.XBFACT(IAT).GT.99.9) THEN
               BADATM=BADATM+1
            END IF
 10      CONTINUE
         IF (WIFIRA(IAA)) THEN
            NAA=NAA+1
            IF (BADATM.GE.1) BAA=BAA+1
         ELSE IF (WIFIRN(IAA)) THEN
            NNU=NNU+1
            IF (BADATM.GE.1) BNU=BNU+1
         ELSE IF (WIFIRZ(IAA)) THEN
            NSU=NSU+1
            IF (BADATM.GE.1) BSU=BSU+1
         ELSE IF (WIFIRW(IAA)) THEN
            NWA=NWA+PNTAAE(IAA)-PNTAAS(IAA)+1
            BWA=BADATM
         END IF
 20   CONTINUE





      RETURN
      END   
      SUBROUTINE SC2008 (NUMBER,MODE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       NUMBER, MODE







      CALL GVSCTB (BIGLIN,132)



      IF (MODE.EQ.1) THEN
         WRITE (BIGLIN,1010,ERR=999) NUMBER
      ELSE IF (MODE.EQ.2) THEN
         WRITE (BIGLIN,1020,ERR=999) NUMBER
      ELSE IF (MODE.EQ.3) THEN
         WRITE (BIGLIN,1030,ERR=999) NUMBER
      ELSE IF (MODE.EQ.4) THEN
         WRITE (BIGLIN,1040,ERR=999) NUMBER
      ELSE IF (MODE.EQ.5) THEN
         WRITE (BIGLIN,1050,ERR=999) NUMBER
      ELSE IF (MODE.EQ.6) THEN
         WRITE (BIGLIN,1060,ERR=999) NUMBER
      ELSE IF (MODE.EQ.7) THEN
         WRITE (BIGLIN,1070,ERR=999) NUMBER
      END IF



      CALL GVSRDB (BIGLIN)
      CALL GVSTT6 (BIGLIN)
      CALL TEXTXT (' ')



      IF (MODE.EQ.1.OR.MODE.EQ.2.OR.MODE.EQ.3.OR.MODE.EQ.4.OR.
     + MODE.EQ.5.OR.MODE.EQ.6) 
     + CALL TEXTXT (' ')
      
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('SC2008')



  998 CONTINUE


 1010 FORMAT ('of which',I5,' have poor or missing atoms.')
 1020 FORMAT ('of which',I5,' are poor.')
 1030 FORMAT (I5,' Residues (protein, nucleic acid, sugars) have',
     + ' a negative residue number.')
 1040 FORMAT (I5,' Residues (protein, nucleic acid, sugars) have',
     + ' residue number 0 (zero).')
 1050 FORMAT (I5,' Residues (protein, nucleic acid, sugars) have',
     + ' the same residue number as the one just before it in the',
     + ' PDB file.')
 1060 FORMAT (I5,' Residues (protein, nucleic acid, sugars) have',
     + ' lower residue number than the one just before it in the',
     + ' PDB file.')
 1070 FORMAT ('In',I5,' cases the insertion code has not been set',
     + ' satisfactorily')

      RETURN
      END   
      SUBROUTINE SC2009

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, INEG, IZERO, IBAD, NUMB







      INEG=0
      IZERO=0
      IBAD=0



      DO 20 IAA=1,NUMAAF
         READ (NUMNAM(IAA),'(I4)',ERR=10,END=999) NUMB
         IF (NUMB.LT.0) INEG=INEG+1
         IF (NUMB.EQ.0) IZERO=IZERO+1
         GOTO 20
 10      CONTINUE
         IBAD=IBAD+1
 20   CONTINUE



      IF (INEG.GT.0) CALL SC2008 (INEG,3)
      IF (IZERO.GT.0) CALL SC2008 (IZERO,4)
      GOTO 998



  999 CONTINUE
      CALL GVSEIR ('SC2009')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC2010

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, INEG, IZERO, IBAD, NUMB, IPREV, IINS, ICM, IC







      IF (NUMAAF.LE.1) GOTO 998



      INEG=0
      IZERO=0
      IBAD=0
      IINS=0
      READ (NUMNAM(1),'(I4)',ERR=999,END=999) IPREV



      DO 10 IAA=2,NUMAAF
         IF (CHANAM(IAA).EQ.CHANAM(IAA-1).OR.MODNMB(IAA).EQ.
     +    MODNMB(IAA-1)) GOTO 10
         READ (NUMNAM(IAA),'(I4)',ERR=10,END=999) NUMB
         IF (NUMB.LT.IPREV) THEN
            INEG=INEG+1



         END IF
         IF (NUMB.EQ.IPREV) THEN
            IZERO=IZERO+1



            ICM=ICHAR(INSRTC(IAA-1))
            IF (INSRTC(IAA-1).EQ.' ') ICM=-99999
            IC=ICHAR(INSRTC(IAA))
            IF (INSRTC(IAA).EQ.' ') IC=-99999
            IF (ICM.GE.IC) IINS=IINS+1
         END IF
         IPREV=NUMB
 10   CONTINUE



      IF (INEG.GT.0) CALL SC2008 (INEG,5)
      IF (IZERO.GT.0) THEN
         CALL SC2008 (IZERO,6)
         IF (IINS.LE.0) THEN
            CALL GVSTT6 ('?M5207')
            CALL TEXTXT (' ')
         ELSE
            CALL SC2008 (IINS,7)
         END IF
      END IF
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('SC2009')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC2011

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, LSOUP, CN1, CN2, CN3, CN4







      CALL MOL311A



      LSOUP=CHAINN(2,NUMAAF)
      IF (LSOUP.LE.5) GOTO 998



      DO 10 ISOUP=1,LSOUP-3
         CN1=ICHAR(CHANAM(SOUADM(1,ISOUP)))
         CN2=ICHAR(CHANAM(SOUADM(1,ISOUP+1)))
         CN3=ICHAR(CHANAM(SOUADM(1,ISOUP+2)))
         CN4=ICHAR(CHANAM(SOUADM(1,ISOUP+3)))
         IF (CN2-CN1.EQ.1.AND.CN4-CN3.EQ.1.AND.CN3-CN2.EQ.2) THEN
            CALL GVSCTB (BIGLIN,132)
            WRITE (BIGLIN,1000,ERR=999)
            CALL GVSCBC (BIGLIN,CHANAM(SOUADM(1,ISOUP)))
            CALL GVSCPC (BIGLIN,',')
            CALL GVSCBC (BIGLIN,CHANAM(SOUADM(1,ISOUP+1)))
            CALL GVSCPC (BIGLIN,',')
            CALL GVSCBC (BIGLIN,CHANAM(SOUADM(1,ISOUP+2)))
            CALL GVSCPC (BIGLIN,',')
            CALL GVSCBC (BIGLIN,CHANAM(SOUADM(1,ISOUP+3)))
            CALL GVSCPC (BIGLIN,'.')
            CALL GVSTT6 (BIGLIN)
            CALL TEXTXT (' ')
         END IF
 10   CONTINUE
      
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('SC2011')



  998 CONTINUE
      CALL MOL312


 1000 FORMAT ('Strange discontinuity in the chain names. Consecutive',
     + ' chains observed:')

      RETURN
      END   
      SUBROUTINE SC2012

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, LENCHA, ISELF, IOTHR, JAA, JAT, IAA, IAT,
     +              GVFPOS
      REAL          WIFDST, RADIUS
      LOGICAL       WIFIRR, WIFIRM, FOUND







      IF (NUMAAT.LE.NUMAAF) GOTO 998



      LENCHA=0
      FOUND=.FALSE.
      CALL GVSCTB (LINE1000,1000)
      CALL GVSBTF (WRK3TF,NUMAAT)



      DO 10 ISOUP=1,NUMSOU
         IF (WIFIRR(SOUADM(1,ISOUP))) THEN
            IF (LENCHA.EQ.0) THEN
               LENCHA=1
               LINE1000(1:1)=CHANAM(SOUADM(1,ISOUP))
            ELSE
               IF (GVFPOS(LINE1000(1:LENCHA),CHANAM(SOUADM(1,ISOUP))) 
     +             .EQ.0) THEN
                  LENCHA=LENCHA+1
                  LINE1000(LENCHA:LENCHA)=CHANAM(SOUADM(1,ISOUP))
               END IF
            END IF
         END IF
 10   CONTINUE




      DO 40 IAA=NUMAAF+1,NUMAAT
         IF (WIFIRM(IAA)) THEN

            IF (GVFPOS(LINE1000(1:LENCHA),CHANAM(IAA)).NE.0) THEN
               IAT=PNTAAS(IAA)
               RADIUS=3.0
 15            CONTINUE
                  ISELF=0
                  IOTHR=0
                  RADIUS=RADIUS-0.2
                  DO 30 JAA=1,NUMAAF
                     DO 20 JAT=PNTAAS(JAA),PNTAAE(JAA)
                        IF (WIFDST(IAT,JAT).LT.RADIUS) THEN
                           IF (CHANAM(IAA).EQ.CHANAM(JAA)) THEN
                              ISELF=ISELF+1
                           ELSE
                              IOTHR=IOTHR+1
                           END IF
                        END IF
 20                  CONTINUE
 30               CONTINUE

               IF (IOTHR+ISELF.GT.10) GOTO 15
               WRK3TF(IAA)=(IOTHR.GT.ISELF)
               FOUND=.TRUE.

            END IF
         END IF
 40   CONTINUE



      IF (FOUND) THEN
         CALL CDB013 ('WCHABAD',' ','WCHAOK')
         DO 50 IAA=NUMAAF+1,NUMAAT
            IF (WRK3TF(IAA)) THEN
               CALL PDBC92A (IAA,0)
               CALL PDBC93 (LINE92)

            END IF
 50      CONTINUE
         CALL CDB012
      END IF



  998 CONTINUE



      RETURN
      END   
