CCP4 Coordinate Library Project

RWBROOK interface functions: Examples.



c
c .------------------------------------------------------------------.
c !                                                                  !
c !          Test-demonstration of API mmdb_rwbrook.h                !
c !                                                                  !
c `------------------------------------------------------------------'
c
      real           CellD(6),CVol
      real           x,y,z,occ,BIso,U(6)
      integer        ArgNCode,iSer,iResN,IZ,iRet
      character*(20) AtNam,ResNam,ChnNam,ResNo
      character*(20) InsCod,AltCod,SegID,ID
      character*(40) SpaceGroup
c
c
c .------------------------------------------------------------------.
c !                                                                  !
c !  1. On the top of each application, RWBROOK must be initialized  !
c !                                                                  !
c `------------------------------------------------------------------'
c
      call XYZInit()
c
c
c .------------------------------------------------------------------.
c !                                                                  !
c !  2. Test #1: read a PDB file and write it as a binary file under !
c !     different name                                               !
c !                                                                  !
c `------------------------------------------------------------------'
c
c  XYZOpen1 associates a unit number (1 in this call) with a disk file;
c  if this file is intended for input, it is read all immediately.
      call AutoSerials ( 1 )
      call XYZOpen1    ( 'in.file','INPUT','PDB',1,iRet )
c
c  RBErrStop will either stop or issue a warning in the case of an
c  error, giving identification of the error and particlular call
c  caused it
      call RBErrStop  ( 1,iRet,1,0 )
c
c  change the file type to binary/output
      call XYZSetType ( 1,'BIN','OUTPUT',iRet )
c
c  RBCheckErr is merely a simple error messenger which works only
c  if called immediately after an API function. "0" means "stop
c  if error".
      call RBCheckErr ( 2,0 )
c
c  change the file name
      call XYZSetName ( 1,'out.bin.file',iRet )
      call RBCheckErr ( 3,0 )
c
c  XYZClose writes the output file and completely disposes it
c  from memory
      call XYZClose   ( 1,iRet )
      call RBCheckErr ( 4,0 )
c
c
c .------------------------------------------------------------------.
c !                                                                  !
c !  3. Test #2: read binary file and write it as a PDB file under   !
c !     different name. The steps are quite identical to those       !
c !     in Test #1; we use unit 2 now.                               !
c !                                                                  !
c `------------------------------------------------------------------'
c
      call XYZOpen1   ( 'out.bin.file','INPUT','BIN',2,iRet )
      call RBCheckErr ( 5,0 )
c
      call XYZSetType ( 2,'PDB','OUTPUT',iRet )
      call RBCheckErr ( 6,0 )
      call XYZSetName ( 2,'out.pdb.file',iRet )
      call RBCheckErr ( 7,0 )
c
      call XYZClose   ( 2,iRet )
      call RBCheckErr ( 8,0 )
c
c
c .------------------------------------------------------------------.
c !                                                                  !
c !  4. Test #3: read binary file (on unit 1) and use it for         !
c !     atom-after-atom composition of the other file (on unit 2).   !
c !     The other file is saved in ASCII PDB format.                 !
c !                                                                  !
c `------------------------------------------------------------------'
c
      call XYZOpen1   ( 'out.bin.file','INPUT','BIN',1,iRet )
      call RBCheckErr ( 9,0 )
c
c  RBCell1 reads crystallographic information which is needed
c  for proper translation of atom coordinates
      call RBCell1    ( 1,CellD,CVol,ArgNCode,SpaceGroup,iRet )
      call RBCheckErr ( 10,0 )
c
      call XYZOpen1   ( 'out1.pdb.file','OUTPUT','PDB',2,iRet )
      call RBCheckErr ( 11,0 )
c
c  RBFrac3 stores the crystallographic information into file
c  and computes all necessary transformation matrices
      call RBFrac3    ( 2,CellD(1),CellD(2),CellD(3),CellD(4),
     .                    CellD(5),CellD(6),ArgNCode,
     .                    SpaceGroup,iRet )
      call RBCheckErr ( 12,0 )
c
c  atom read/write cycle
      iSer1 = 0
 10   continue
c
        call XYZAdvance1 ( 1,0,iRet )
        if (iRet.eq.2)  goto 20
        if ((iRet.ne.1).and.(iRet.ne.3))  then
          call RBCheckErr  ( 13,0 )
        endif
        call XYZAtom1    ( 1,iSer,AtNam,ResNam,ChnNam,iResN,
     .                     ResNo,InsCod,AltCod,SegID,IZ,ID,iRet )
        call RBCheckErr  ( 14,0 )
        call XYZCoord1   ( 1,'F','F',x,y,z,occ,BIso,U,iRet )
        call RBCheckErr  ( 15,0 )
c
        call XYZAdvance1 ( 2,0,iRet )
        call RBCheckErr  ( 16,0 )
c
c  since 'ter' cards will be skipped, we number all atoms
c  on a fly. If we do not, multiple warnings may appear.
        iSer1 = iSer1 + 1
        call XYZAtom1    ( 2,iSer1,AtNam,ResNam,ChnNam,iResN,
     .                     ResNo,InsCod,AltCod,SegID,IZ,ID,iRet )
        call RBCheckErr  ( 17,0 )
        call XYZCoord1   ( 2,'F','F',x,y,z,occ,BIso,U,iRet )
        call RBCheckErr  ( 18,0 )
c
      goto 10
c
 20   continue
c
c  close files
      call XYZClose   ( 1,iRet )
      call RBCheckErr ( 19,0 )
      call XYZClose   ( 2,iRet )
      call RBCheckErr ( 20,0 )
c
c
c .------------------------------------------------------------------.
c !                                                                  !
c !  5. Test #4: same as #3 but "TER" and "HETATM" cards are taken   !
c !     care of.                                                     !
c !                                                                  !
c `------------------------------------------------------------------'
c
      call XYZOpen1   ( 'out.bin.file','INPUT','BIN',1,iRet )
      call RBCheckErr ( 21,0 )
      call RBCell1    ( 1,CellD,CVol,ArgNCode,SpaceGroup,iRet )
      call RBCheckErr ( 22,0 )
      call XYZOpen1   ( 'out2.pdb.file','OUTPUT','PDB',2,iRet )
      call RBCheckErr ( 23,0 )
      call RBFrac3    ( 2,CellD(1),CellD(2),CellD(3),CellD(4),
     .                    CellD(5),CellD(6),ArgNCode,
     .                    SpaceGroup,iRet )
      call RBCheckErr ( 24,0 )
c
 30   continue
        call XYZAdvance1 ( 1,1,iFlag )
        if (iFlag.eq.2)  goto 40
        if ((iFlag.ne.1).and.(iFlag.ne.3))  then
          call RBCheckErr  ( 25,0 )
        endif
        call XYZAtom1    ( 1,iSer,AtNam,ResNam,ChnNam,iResN,
     .                     ResNo,InsCod,AltCod,SegID,IZ,ID,iRet )
        call RBCheckErr  ( 26,0 )
        call XYZCoord1   ( 1,'F','F',x,y,z,occ,BIso,U,iRet )
        call RBCheckErr  ( 27,0 )
c
        call XYZAdvance1 ( 2,0,iRet )
        call RBCheckErr  ( 28,0 )
        call XYZAtom1    ( 2,iSer,AtNam,ResNam,ChnNam,iResN,
     .                     ResNo,InsCod,AltCod,SegID,IZ,ID,iRet )
        call RBCheckErr  ( 29,0 )
        if (iFlag.eq.1)  then
          call XYZSetTer ( 2,iRet )
        else if (iFlag.eq.3)  then
          call XYZCoord1 ( 2,'HF','F',x,y,z,occ,BIso,U,iRet )
        else
          call XYZCoord1 ( 2,'F','F',x,y,z,occ,BIso,U,iRet )
        endif
        call RBCheckErr  ( 30,0 )
c
      goto 30
c
 40   continue
c
c  close files
      call XYZClose   ( 1,iRet )
      call RBCheckErr ( 31,0 )
      call XYZClose   ( 2,iRet )
      call RBCheckErr ( 32,0 )
c
c
c
c .------------------------------------------------------------------.
c !                                                                  !
c !  6. Before quitting any application, rwbrook must be disposed.   !
c !     Note that RBErrStop does it automatically if it stops.       !
c !                                                                  !
c `------------------------------------------------------------------'
c
      call XYZQuit    ()
      call RBCheckErr ( 100,0 )
c
      stop
c
      end

 


Back to index