#!/bin/csh -f
# ======================================================================
#        brookhaven - crude PDB data management script [6/87 PEB]
#
# assumes: 1. You are using the C shell
#          2. You have the PDB as a set of file xxxx.pdb in the same
#             directory where xxxx is the 4 character PDB code.
#          3. You have created a file DIRECTORY which is also
#             in the smae place the PDB files hang out and was
#             crated as follows:
#                 head -1 *.pdb > DIRECTORY
#          4, You have compiled format and have it in the same
#             directory as this script.
# ======================================================================
#
#  set PDB directory
set pdb_directory = /pdb
#
# retain original directory pointer
set current_directory = `pwd`
pushd $pdb_directory
#
echo "    cuhhca Brookhaven Database Utility Program `date` "
#
# prevent control c exits
onintr menu
menu:
echo " "
echo "   The following options are available:"
echo " "
echo "          I   list identity of the database"
echo "          D   list a directory of the database contents"
echo "          SD  search the directory listing for keywords"
echo "          SF  search full database for keywords"
echo "          T   list a database entry at the terminal"
echo "          C   copy database entry with possible format conversion"
echo "          Q   quit the database"
echo " "
echo -n  "Option> "
set command = $<
goto $command
#
#	identity option
#       [modify this for each new release]
#
I:
i:
echo " "
echo "             The Brookhaven database of April 1992"
#
goto menu
#
#	directory option
#
D:
d:
echo "            Type control c to return to menu"
echo " " 
echo "            The 4 character alphanumeric code at the end of each entry"
echo "            is the protein recognition code and should be used in "
echo "            association with the other options."
echo " "  
cat $pdb_directory'/DIRECTORY'
goto menu
#
#	search directory for keywords option
#
SD:
sd:
echo " "
echo "            The directory of the data base contains the HEADER record "
echo "            of each database entry.  "
echo "            The 4 character alphanumeric code at the end of"
echo "            each entry represents the protein regognition code and"
echo "            should be used in association with other options."
echo " " 
echo -n "keyword(s):- "
set string = $<
grep -i "$string" $pdb_directory'/DIRECTORY'
goto menu
#
#	search files for string
#
sf:
SF:
echo "          The 4 character alphanumeric code given in cols. 77-80 of"
echo "          each record represents the protein recognition code and "
echo "          should be remembered for use in other options."
echo " "
echo -n "Keyword(s):- "
set string = $<
grep -i $string $pdb_directory'/*.pdb'
goto menu
#
#	list a database entry
#
T:
t:
echo -n "Protein recognition code:-"
set entry = $<
cat $pdb_directory'/'$entry'.pdb'
goto menu
#
#	Copy entry
#
C:
c:
echo -n "Protein recognition code:- "
set temp_filein = $<
set filein = $pdb_directory'/'$temp_filein'.pdb'
echo -n "Filename for output coordinates: "
set fileout = $<
ln -s $filein  fort.1
ln -s $current_directory/$fileout fort.2
format
rm fort.*
goto menu
#
#	FINITO
#
Q:
q:
echo "    Exit Brookhaven database utility program     `date` "
popd
exit
