      Subroutine dsset(part1,  part2,  dsdsts, scangs, scaaat, scatin,  DSSE001
CHECK v.3.2-->                                                          DSSE002
C     +                 atomin, mcaaat, dsdef,  dspart, typefl, seqlen) DSSE003
     &                 atomin, mcaaat, dsdef,  dspart, typefl)          DSSE004
CHECK v.3.2<--                                                          DSSE005
c                                                                       DSSE006
c     calculate all the features for a disulphide bridge. that is 3 chi DSSE007
c     angles, calpha, cbeta, and ss distances. set in the partner and   DSSE008
c     definition fields. Check for conflict with author defined records DSSE009
c     or previously defined bridges                                     DSSE010
c                                                                       DSSE011
      include 'sstruc.par'                                              DSSE012
CHECK v.3.2-->                                                          DSSE013
C      integer   part1, part2, dspart(maxres), seqlen                   DSSE014
      integer   part1, part2, dspart(maxres)                            DSSE015
CHECK v.3.2<--                                                          DSSE016
      real      dsdsts(3,maxres), scangs(nsdang,maxres),                DSSE017
     &          scaaat(ncoord,sdchna,maxres),                           DSSE018
     &          mcaaat(ncoord,mnchna,maxres)                            DSSE019
      logical   scatin(sdchna,maxres), atomin(mnchna,maxres)            DSSE020
      character dsdef(maxres)*1, typefl*1                               DSSE021
      real      atdist, dihed                                           DSSE022
                                                                        DSSE023
      character*1 botdef, autdef                                        DSSE024
      real        mxdis                                                 DSSE025
      parameter  (botdef = 'B', autdef = 'A', mxdis = 9.9)              DSSE026
      integer     nxdis                                                 DSSE027
                                                                        DSSE028
      If ((dspart(part1) .ne. 0 .and. dspart(part1) .ne. part2) .or.    DSSE029
     &   (dspart(part1) .eq. 0 .and. dspart(part2) .ne. 0)) then        DSSE030
         if (dsdef(part1) .ne. space .or. dsdef(part2) .ne. space) then DSSE031
            write(errfi,100) part1, part2                               DSSE032
  100       format('conflict with author defined disulphide -',         DSSE033
CHECK v.2.1.4-->                                                        DSSE034
C     +             ' abandonning ',I4,x,I4)                            DSSE035
     &             ' abandoning ',I4,1x,I4)                             DSSE036
CHECK v.2.1.4<--                                                        DSSE037
         else                                                           DSSE038
            write(errfi,200) part1, part2                               DSSE039
CHECK v.3.4-->                                                          DSSE040
C  200       format('conflict with previously defined disulphide -'     DSSE041
  200       format('conflict with previously defined disulphide -',     DSSE042
CHECK v.3.4<--                                                          DSSE043
CHECK v.2.1.4-->                                                        DSSE044
C     +             ' abandoning ',I4,x,I4)                             DSSE045
     &             ' abandoning ',I4,1x,I4)                             DSSE046
CHECK v.2.1.4<--                                                        DSSE047
         end if                                                         DSSE048
      else                                                              DSSE049
         if (dsdef(part1) .eq. autdef) then                             DSSE050
            dsdef(part1) = botdef                                       DSSE051
            dsdef(part2) = botdef                                       DSSE052
         else                                                           DSSE053
            dspart(part1) = part2                                       DSSE054
            dspart(part2) = part1                                       DSSE055
            dsdef(part1) = typefl                                       DSSE056
            dsdef(part2) = typefl                                       DSSE057
            if (atomin(calph,part1) .and. scatin(cbeta,part1) .and.     DSSE058
     &         scatin(sgamma,part1) .and. scatin(sgamma,part2))         DSSE059
     &         scangs(2,part1) = dihed(nmnang+2,                        DSSE060
     &         mcaaat(1,calph,part1), scaaat(1,cbeta,part1),            DSSE061
     &         scaaat(1,sgamma,part1), scaaat(1,sgamma,part2))          DSSE062
            if (scatin(cbeta,part1) .and. scatin(sgamma,part1) .and.    DSSE063
     &         scatin(sgamma,part2) .and. scatin(cbeta,part2)) then     DSSE064
               scangs(3,part1) = dihed(nmnang+3,                        DSSE065
     &         scaaat(1,cbeta,part1), scaaat(1,sgamma,part1),           DSSE066
     &         scaaat(1,sgamma,part2), scaaat(1,cbeta,part2))           DSSE067
               scangs(3,part2) = scangs(3,part1)                        DSSE068
            end if                                                      DSSE069
            if (atomin(calph,part2) .and. scatin(cbeta,part2) .and.     DSSE070
     &         scatin(sgamma,part2) .and. scatin(sgamma,part1))         DSSE071
     &         scangs(2,part2) = dihed(nmnang+2,                        DSSE072
     &         mcaaat(1,calph,part2), scaaat(1,cbeta,part2),            DSSE073
     &         scaaat(1,sgamma,part2), scaaat(1,sgamma,part1))          DSSE074
            do 1000, nxdis = 1, 3                                       DSSE075
            dsdsts(nxdis,part1) = -1.0                                  DSSE076
 1000       continue                                                    DSSE077
            If (atomin(calph,part1) .and. atomin(calph,part2))          DSSE078
     &         dsdsts(1,part1) = atdist(mcaaat(1,calph,part1),          DSSE079
     &         mcaaat(1,calph,part2))                                   DSSE080
            If (scatin(cbeta,part1) .and. atomin(cbeta,part2))          DSSE081
     &         dsdsts(2,part1) = atdist(scaaat(1,cbeta,part1),          DSSE082
     &         scaaat(1,cbeta,part2))                                   DSSE083
            If (scatin(sgamma,part1) .and. scatin(sgamma,part2))        DSSE084
     &         dsdsts(3,part1) = atdist(scaaat(1,sgamma,part1),         DSSE085
     &         scaaat(1,sgamma,part2))                                  DSSE086
            do 1200, nxdis = 1, 3                                       DSSE087
            if (dsdsts(nxdis,part1) .gt. mxdis) then                    DSSE088
               write(errfi,1100) part1, part2, dsdsts(nxdis,part1)      DSSE089
 1100          format('disulphide distance too large for',              DSSE090
CHECK v.2.1.4-->                                                        DSSE091
C     +                I4,x,I4,x,f5.1)                                  DSSE092
     &                I4,1x,I4,1x,f5.1)                                 DSSE093
CHECK v.2.1.4<--                                                        DSSE094
               dsdsts(nxdis,part1) = mxdis                              DSSE095
            end if                                                      DSSE096
 1200       continue                                                    DSSE097
            do 1500, nxdis = 1,3                                        DSSE098
            dsdsts(nxdis,part2) = dsdsts(nxdis,part1)                   DSSE099
 1500       continue                                                    DSSE100
         end if                                                         DSSE101
      end if                                                            DSSE102
      END                                                               DSSE103
