Debian Codegraph @

etc/run_netblastp

raw
1 #!/bin/sh -
2
3 # this script will run a search program on a sequence input file or on each
4 # file in a file of filenames
5
6 # to customise this script see the function called run_one_prog below
7
8
9 RCS_HEADER="$Header: //tmp/pathsoft/artemis/etc/run_netblastp,v 1.1 2008-12-01 08:52:51 tjc Exp $"
10
11 PROG=`echo $RCS_HEADER | sed 's/.*run_\(.*\),v.*/\1/'`
12
13
14 if [ $# = 4 -a x$1 = x-onefile ]
15 then
16 shift
17 ONEFILE=t
18 DATABASE=$3 export DATABASE
19 else
20 if [ $# = 2 ]
21 then
22 DATABASE=$2 export DATABASE
23 else
24 echo usage: $0 -onefile input_file output_file database
25 echo or: $0 file_of_filenames database
26 exit 1
27 fi
28 fi
29
30
31 # expand any ~ or environment variables
32 EXPANDED_DATABASE=`echo "echo $DATABASE" | /bin/csh -f`
33
34
35 ### change this function to suit your site:
36
37 run_one_prog () {
38 INPUT_FILE=$1
39 OUTPUT_FILE=$2
40 DATABASE=$3
41
42
43 ### change these lines:
44
45 EXEC=${EXEC-`which $PROG 2>/dev/null`}
46
47 #
48 # Mac specific - NCBI .dmg installation area
49 #
50 PLATTMP=`uname`
51 if [ "$PLATTMP" = "Darwin" ] && [ "$EXEC" = "" ] && [ -x /usr/local/ncbi/blast/bin/$PROG ]
52 then
53 EXEC=/usr/local/ncbi/blast/bin/$PROG
54 fi
55
56 if [ ! -x "$EXEC" ]
57 then
58 echo "ERROR: Cannot find an executable $PROG blast program. Exiting."
59 exit 1
60 fi
61
62
63 # Use remote flag for a NCBI command line search...
64 COMMAND="$EXEC -db $DATABASE -query $INPUT_FILE -remote"
65
66 echo
67 echo "input file: $INPUT_FILE"
68 echo "output will be written to: $OUTPUT_FILE"
69 echo "executing command: $COMMAND" 1>&2
70
71 # add/change the flags to suit your site:
72 nice -n 19 $COMMAND 2>&1 > $OUTPUT_FILE | tee ${PROG}_errors.new 1>&2
73
74 #### end of changes
75
76
77 # Artemis can read compressed files
78 gzip -9 $OUTPUT_FILE &
79
80 if [ -s ${PROG}_errors.new ]
81 then
82 ( echo ERROR running $PROG: ; echo;
83 echo ===================================================
84 cat ${PROG}_errors.new ) >> $OUTPUT_FILE
85 cat ${PROG}_errors.new >> ${PROG}_errors
86 fi
87 }
88
89 (echo "#!/bin/sh -"; echo "kill $$") > $PROG.kill
90
91 chmod a+x $PROG.kill
92
93 if [ x$ONEFILE = x ]
94 then
95 for i in `cat $1`
96 do
97 run_one_prog $i $i.out $EXPANDED_DATABASE
98 done
99
100 else
101 run_one_prog $1 $2 $EXPANDED_DATABASE
102 fi
103
104 exit 0