Newer
Older
#!/bin/sh -
# this script will run a search program on a sequence input file or on each
# file in a file of filenames
# to customise this script see the function called run_one_prog below
PROG=fastx
PROG_VERSION=36
EXENAME=${PROG}${PROG_VERSION}
if [ $# = 4 -a x$1 = x-onefile ]
then
shift
ONEFILE=t
DATABASE=$3 export DATABASE
else
if [ $# = 2 ]
then
DATABASE=$2 export DATABASE
else
echo usage: $0 -onefile input_file output_file database 1>&2
echo or: $0 file_of_filenames database 1>&2
exit 1
fi
fi
# expand any ~ or environment variables
#EXPANDED_DATABASE=`echo "echo $DATABASE" | /bin/csh -f`
eval EXPANDED_DATABASE="$DATABASE"
### change this function to suit your site:
run_one_prog () {
INPUT_FILE=$1
OUTPUT_FILE=$2
DATABASE_ARG=$3
PLATFORM_INFO=`uname`
if [ "$PLATFORM_INFO" = "Darwin" ]
then
# Mac OSX: Attempt to initialise environment variables from profile.
echo "running $HOME/.profile..."
source $HOME/.profile 2>/dev/null
fi
EXEC=${EXEC-`which $EXENAME 2>/dev/null`}
if [ ! -x "$EXEC" ] && [ -x "/usr/local/fasta/bin/$EXENAME" ]
EXEC=/usr/local/fasta/bin/$EXENAME
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
if [ ! -x "$EXEC" ]
then
echo "ERROR: Cannot find an executable $EXENAME program. Exiting."
exit 1
fi
if [ ! -f "$FASTLIBS" ]; then
DATABASE=`echo $DATABASE_ARG | sed 's|\%||'`
if [ ! -f "$DATABASE" ]
then
# Check home directory...
echo "Checking $HOME/blast-data/ for database..."
if [ -f "$HOME/blast-data/$DATABASE" ]
then
DATABASE=$HOME/blast-data/$DATABASE
fi
fi
if [ ! -f "$DATABASE" ]
then
echo "ERROR: Cannot find database $DATABASE. Exiting."
exit 1
fi
fi
# add/change the flags to suit your site (note: ktup is set to 2):
COMMAND="$EXEC -S -q -b 40 -H $INPUT_FILE $DATABASE 2"
echo
echo "input file: $INPUT_FILE"
echo "output will be written to: $OUTPUT_FILE"
echo "executing command: $COMMAND" 1>&2
nice -n 19 $COMMAND 2>&1 > $OUTPUT_FILE | tee ${PROG}_errors.new 1>&2
#### end of changes
}
(echo "#!/bin/sh -"; echo "kill $$") > $PROG.kill
chmod a+x $PROG.kill
if [ x$ONEFILE = x ]
then
for i in `cat $1`
do
run_one_prog $i $i.out $EXPANDED_DATABASE
done
else
run_one_prog $1 $2 $EXPANDED_DATABASE
fi
exit 0