#!/bin/csh -f
#
# File: CreateDictObjFile.csh
# Date: 15-April-2004  J. Westbrook
#

if ("$1" == "" ) then 
   echo "Usage:  $0 <Dictionary name (e.g. mmcif_pdbx)>"
   exit 1
endif

set d = "$1"

if (! -e dict-mmcif_ddl/mmcif_ddl.dic ) then 
   echo "Missing DDL file dict-mmcif_ddl/mmcif_ddl.dic"
   exit 1
endif

set log = "odb/$d.log"

rm -f ./odb/$d.odb
rm -f DDLParser.log
rm -f DICParser.log
rm -f Diagnostics.log

./bin/DictObjFileCreator  -ddl dict-mmcif_ddl/mmcif_ddl.dic \
                -dict dict-$d/$d.dic \
                   -o odb/$d.odb >& $log
chmod 644 odb/$d.odb

if (-e DDLParser.log && ! -z DDLParser.log ) then
    echo " " >> $log
    echo " ========    DDL parser diagnostics ========= " >>  $log
    echo " " >> $log
    cat DDLParser.log >> $log
else
    echo " " >> $log
    echo "No DDL parsing errors." >> $log
endif

if (-e DICParser.log && ! -z DICParser.log ) then
    echo " " >> $log
    echo " ========    Dictionary parser diagnostics ========= " >>  $log
    echo " " >> $log
    cat DICParser.log >> $log
else
    echo " " >> $log
    echo "No dictionary parsing errors." >> $log
endif

if (-e Diagnostics.log && ! -z Diagnostics.log ) then
    echo " " >> $log
    echo " ========    Dictionary consistency diagnostics ========= " >>  $log
    echo " " >> $log
    cat Diagnostics.log >> $log
else
    echo " " >> $log
    echo "No dictionary consistency errors." >> $log
endif

rm -f DDLParser.log
rm -f DICParser.log
rm -f Diagnostics.log

#
#
