Debian Codegraph @

etc/run_tblastn

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 PROG=tblastn
10
11
12 if [ $# = 4 -a x$1 = x-onefile ]
13 then
14 shift
15 ONEFILE=t
16 DATABASE=$3 export DATABASE
17 else
18 if [ $# = 2 ]
19 then
20 DATABASE=$2 export DATABASE
21 else
22 echo usage: $0 -onefile input_file output_file database 1>&2
23 echo or: $0 file_of_filenames database 1>&2
24 exit 1
25 fi
26 fi
27
28
29 # expand any ~ or environment variables
30 #EXPANDED_DATABASE=`echo "echo $DATABASE" | /bin/csh -f`
31 eval EXPANDED_DATABASE="$DATABASE"
32
33 ### change this function to suit your site:
34
35 run_one_prog () {
36 INPUT_FILE=$1
37 OUTPUT_FILE=$2
38 DATABASE_ARG=$3
39
40
41 ### change these lines:
42
43 PLATFORM_INFO=`uname`
44 if [ "$PLATFORM_INFO" = "Darwin" ]
45 then
46 # Mac OSX: Attempt to initialise environment variables from profile.
47 echo "running $HOME/.profile..."
48 source $HOME/.profile 2>/dev/null
49 fi
50
51 EXEC=${EXEC-`which $PROG 2>/dev/null`}
52
53 if [ "$EXEC" = "" ] && [ -x /usr/local/ncbi/blast/bin/$PROG ]
54 then
55 EXEC=/usr/local/ncbi/blast/bin/$PROG
56 fi
57
58 if [ ! -x "$EXEC" ]
59 then
60 echo "ERROR: Cannot find an executable $PROG blast program. Exiting."
61 exit 1
62 fi
63
64 #
65 # Check for setting of NCBI BLASTDB environment variable
66 #
67 if [ "$BLASTDB" = "" ]; then
68
69 DATABASE=`echo $DATABASE_ARG | sed 's|\%||'`
70
71 if [ ! -f "$DATABASE" ]
72 then
73
74 # Check home directory...
75 echo "Checking $HOME/blast-data/ for database..."
76 if [ -f "$HOME/blast-data/$DATABASE" ]
77 then
78 DATABASE=$HOME/blast-data/$DATABASE
79 fi
80 fi
81
82 if [ ! -f "$DATABASE" ]
83 then
84 echo "ERROR: Cannot find database $DATABASE. Exiting."
85 exit 1
86 fi
87
88 fi
89
90
91 COMMAND="$EXEC -db $DATABASE -query $INPUT_FILE -num_threads 2"
92
93 echo
94 echo "input file: $INPUT_FILE"
95 echo "output will be written to: $OUTPUT_FILE"
96 echo "executing command: $COMMAND" 1>&2
97
98 # add/change the flags to suit your site:
99 nice -n 19 $COMMAND 2>&1 > $OUTPUT_FILE | tee ${PROG}_errors.new 1>&2
100
101 #### end of changes
102
103
104 # Artemis can read compressed files
105 gzip -9 $OUTPUT_FILE &
106
107 if [ -s ${PROG}_errors.new ]
108 then
109 ( echo ERROR running $PROG: ; echo;
110 echo ===================================================
111 cat ${PROG}_errors.new ) >> $OUTPUT_FILE
112 cat ${PROG}_errors.new >> ${PROG}_errors
113 fi
114 }
115
116 (echo "#!/bin/sh -"; echo "kill $$") > $PROG.kill
117
118 chmod a+x $PROG.kill
119
120 if [ x$ONEFILE = x ]
121 then
122 for i in `cat $1`
123 do
124 run_one_prog $i $i.out $EXPANDED_DATABASE
125 done
126
127 else
128 run_one_prog $1 $2 $EXPANDED_DATABASE
129 fi
130
131 exit 0