| 1 |
#!/bin/csh -f |
| 2 |
############################################################################ |
| 3 |
############################################################################ |
| 4 |
## File: blast_search |
| 5 |
# $Id: blast_search,v 1.4 1997/11/23 16:53:56 mieg Exp $ |
| 6 |
# This file is part of the ACEDB package |
| 7 |
# Author: J Thierry-Mieg, ([email protected]) |
| 8 |
# Copyright (C) R.Durbin & J Thierry-Mieg, 1995 |
| 9 |
#------------------------------------------------------------------- |
| 10 |
# Usage: Usage blast_search pid export_file_name fasta_file blast_pgm db |
| 11 |
# The order is crucial, because pid export_file_name are added |
| 12 |
# by externalAsynchroneCommand() |
| 13 |
#------------------------------------------------------------------- |
| 14 |
# Description: |
| 15 |
# Calls blast on the vega server on the given fasta file |
| 16 |
# Reformats the result in .ace using Erik Sonhamer MSPcrunch |
| 17 |
# Exports the result in export_file_name.out |
| 18 |
# be careful to the .out which is automatically added for |
| 19 |
# compatibility with the acedb main code |
| 20 |
# Sends a signal to pid |
| 21 |
# |
| 22 |
#------------------------------------------------------------------- |
| 23 |
# Configuration: |
| 24 |
# For this system to run on your own server |
| 25 |
# you must duplicate the vega environment, contact us about that |
| 26 |
# To run the client, you need perl and the network |
| 27 |
# |
| 28 |
############################################################################ |
| 29 |
############################################################################ |
| 30 |
## Choose the blast server |
| 31 |
|
| 32 |
echo blast_search $1 $2 $3 $4 $5 |
| 33 |
|
| 34 |
|
| 35 |
setenv server vega.crbm.cnrs-mop.fr |
| 36 |
setenv blastPort 20200 |
| 37 |
|
| 38 |
############################################################################ |
| 39 |
## Check for particular args and default paths |
| 40 |
|
| 41 |
if ($5 == "") goto usage |
| 42 |
|
| 43 |
if (! -e $3) goto usage |
| 44 |
|
| 45 |
setenv ici `pwd` |
| 46 |
|
| 47 |
if ($?ACEDB) then |
| 48 |
setenv s $ACEDB/wscripts |
| 49 |
else |
| 50 |
# echo ACEDB not defined |
| 51 |
if (-d wscripts) then |
| 52 |
setenv s $ici/wscripts |
| 53 |
else |
| 54 |
setenv s $ici |
| 55 |
endif |
| 56 |
endif |
| 57 |
cd $s |
| 58 |
|
| 59 |
if ($?ACEDB_SRC) then |
| 60 |
if (-d $?ACEDB_SRC) then |
| 61 |
cd $?ACEDB_SRC |
| 62 |
endif |
| 63 |
endif |
| 64 |
|
| 65 |
if ($?ACEDB_MACHINE) then |
| 66 |
if (-d bin.$ACEDB_MACHINE) then |
| 67 |
cd bin.$ACEDB_MACHINE |
| 68 |
else |
| 69 |
if ($?ACEMBLY) then |
| 70 |
if ($?ACEDB_MACHINE) then |
| 71 |
if (-d $ACEMBLY/bin.$ACEDB_MACHINE) then |
| 72 |
cd $ACEMBLY/bin.$ACEDB_MACHINE |
| 73 |
endif |
| 74 |
endif |
| 75 |
endif |
| 76 |
endif |
| 77 |
endif |
| 78 |
|
| 79 |
if (-x gnbkclient) then |
| 80 |
setenv gnbkclient `pwd`/gnbkclient |
| 81 |
else if (-x /usr/local/bin/gnbkclient) then |
| 82 |
setenv gnbkclient /usr/local/bin/gnbkclient |
| 83 |
else |
| 84 |
echo Sorry Can t find /usr/local/bin/gnbkclient |
| 85 |
goto usage |
| 86 |
endif |
| 87 |
endif |
| 88 |
|
| 89 |
cd $ici |
| 90 |
|
| 91 |
|
| 92 |
############################################################################ |
| 93 |
## Check for necessary software |
| 94 |
|
| 95 |
/bin/env perl < /dev/null || goto noperl |
| 96 |
|
| 97 |
if ( ! -x $gnbkclient) then |
| 98 |
echo Sorry Can t find $gnbkclient |
| 99 |
goto usage |
| 100 |
endif |
| 101 |
|
| 102 |
if ( ! -x $s/client.pl) then |
| 103 |
echo Sorry Can t find client.pl in directory $s, from ici=$ici |
| 104 |
goto usage |
| 105 |
endif |
| 106 |
|
| 107 |
############################################################################ |
| 108 |
## Start blast search |
| 109 |
|
| 110 |
setenv blast_pgm $4 |
| 111 |
setenv blast_db $5 |
| 112 |
setenv upper 70 |
| 113 |
if ($6 != "") setenv upper $6 |
| 114 |
|
| 115 |
setenv seq `head -1 $3 | sed s'/>//'` |
| 116 |
echo 'pr='"$blast_pgm"'&db='"$blast_db"'&co='$seq >! $2.a |
| 117 |
echo '>'$seq >> $2.a |
| 118 |
# blast does not support - signs |
| 119 |
tail +2 $3 | sed s'/-/n/g' >> $2.a |
| 120 |
# cp $2.a ~/toto12 # debugging |
| 121 |
# exit # debugging |
| 122 |
echo END >> $2.a |
| 123 |
echo MSPupper 40 >> $2.a |
| 124 |
|
| 125 |
# Actual execution of the search on the remote server |
| 126 |
# Segmentation fault is a bug on $server server. ignore it. |
| 127 |
echo // `date` >! $2.b |
| 128 |
$s/client.pl $server $blastPort < $2.a | grep -v '^Segmentation fault' >! $2.h |
| 129 |
echo // `date` >> $2.b |
| 130 |
|
| 131 |
# Extract the protein names in various nomenclatures |
| 132 |
echo // extract the proteins >> $2.b |
| 133 |
nawk '/^Protein/{print $2;}' $2.h | sort -u >! $2.prot |
| 134 |
#nawk '/gp\|/ {pp = substr($1,4) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n%s\n",pq);}' $2.prot > ! $2.gp |
| 135 |
nawk '/sp\|/ {pp = substr($1,4) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n%s;\n",pq);}' $2.prot > ! $2.swiss |
| 136 |
nawk '/pir\|S\|/ {pp = substr($1,7) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n%s\n",pq);}' $2.prot > ! $2.pir |
| 137 |
|
| 138 |
|
| 139 |
# Extract the sequence names in various nomenclatures |
| 140 |
echo // extract the sequences >> $2.b |
| 141 |
nawk '/^Sequence/{print $2;}' $2.h | sort -u >! $2.seq |
| 142 |
nawk '/gb\|/ {pp = substr($1,4) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n%s;\n",pq);}' $2.seq > ! $2.gb |
| 143 |
nawk '/emb\|/ {pp = substr($1,5) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n%s\n",pq);}' $2.seq > ! $2.emb |
| 144 |
|
| 145 |
#Prepare a .ace rename file |
| 146 |
|
| 147 |
# BUG: i should really use -R, but dec 18 96, i found a bug in the ace kernel |
| 148 |
# so i change to -Alias temporarilly |
| 149 |
|
| 150 |
|
| 151 |
echo // nawk to list the various database calls >> $2.b |
| 152 |
#nawk '/gp\|/ {old = $1 ; pp = substr($1,4) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n-A Protein %s GP:%s\n",old, pq);}' $2.prot > $2.r.ace |
| 153 |
nawk '/sp\|/ {old = $1 ; pp = substr($1,4) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n-A Protein %s SP:%s\n",old, pq);}' $2.prot >! $2.r.ace |
| 154 |
nawk '/pir\|S\|/ {old = $1 ; pp = substr($1,7) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n-A Protein %s PIR:%s\n",old, pq);}' $2.prot >> $2.r.ace |
| 155 |
|
| 156 |
nawk '/gb\|/ {old = $1 ; pp = substr($1,4) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n-A Sequence %s GenBank:%s\n",old, pq);}' $2.seq >> $2.r.ace |
| 157 |
|
| 158 |
nawk '/emb\|/ {old = $1 ; pp = substr($1,5) ; i = index(pp, "|") ; if (i) pq = substr(pp,1,i-1) ; else pq = substr(pp,1) ; printf("\n-A Sequence %s EMBL:%s\n",old, pq);}' $2.seq >> $2.r.ace |
| 159 |
|
| 160 |
# arrange so that aliased objects are not empty when alias command is run |
| 161 |
echo '// Create a non empty entry for all proteins that should be aliased' >! $2.R.ace |
| 162 |
echo ' ' >> $2.R.ace |
| 163 |
nawk '{if ($2 != "") printf("%s %s\nTitle\n\n%s %s\nTitle\n\n",$2,$3,$2,$4);}' $2.r.ace >> $2.R.ace |
| 164 |
echo ' ' >> $2.R.ace |
| 165 |
|
| 166 |
|
| 167 |
#Collect the protein sequences on the server |
| 168 |
echo // Import the proteins from $server >> $2.b |
| 169 |
$gnbkclient -host $server -port 20000111 < $2.swiss | nawk -f $s/swiss.awk >! $2.swiss.out.ace |
| 170 |
$gnbkclient -host $server -port 20000112 < $2.pir | nawk -f $s/pir.awk >! $2.pir.out.ace |
| 171 |
|
| 172 |
$gnbkclient -host $server -port 20000110 < $2.gb | nawk -f $s/gb.awk >! $2.gb.out.ace |
| 173 |
$gnbkclient -host $server -port 20000110 < $2.emb | nawk -f $s/emb.awk >! $2.emb.out.ace |
| 174 |
|
| 175 |
# I don t know how to parse pir.out |
| 176 |
#accumulate everything in $2.b in the correct order |
| 177 |
echo // Accumulate >> $2.b |
| 178 |
cat $2.R.ace $2.r.ace $2.pir.out.ace $2.swiss.out.ace $2.gb.out.ace >> $2.b |
| 179 |
cat $2.emb.out.ace $2.h >> $2.b |
| 180 |
|
| 181 |
# Copy localy the input and the output file |
| 182 |
cp $2.a /var/tmp/$seq.a # if you want to keep a copy for debugging |
| 183 |
if (! -d blast_results) mkdir blast_results |
| 184 |
if (-d blast_results) then |
| 185 |
cp $2.b ./blast_results/$seq.out.ace |
| 186 |
echo blast_search done result saved as: ./blast_results/$seq.out.ace |
| 187 |
else |
| 188 |
cp $2.b ./$seq.out.ace |
| 189 |
echo blast_search done result saved as: ./$seq.out.ace |
| 190 |
endif |
| 191 |
echo parms $* |
| 192 |
|
| 193 |
# Finally, mv $2.b to $2.out and signal acedb |
| 194 |
mv $2.b $2.out |
| 195 |
if ($1 != "0") kill -USR1 $1 |
| 196 |
|
| 197 |
# Clean up |
| 198 |
#\rm $2.gp $2.gp.out.ace |
| 199 |
rm $2.a $2.prot $2.swiss $2.pir $2.r.ace $2.R.ace $2.gb $2.emb $2.h $2.seq |
| 200 |
rm $2.swiss.out.ace $2.pir.out.ace $2.gb.out.ace $2.emb.out.ace |
| 201 |
exit 0 |
| 202 |
|
| 203 |
|
| 204 |
############################################################################ |
| 205 |
|
| 206 |
usage: |
| 207 |
echo '-----------------blast_search error----------------------------' |
| 208 |
echo Usage blast_search pid export_file_name fasta_file blast_pgm db |
| 209 |
echo Example: blast_search 3867 /var/tmp/bb.a /var/tmp/bb.fasta blast_x pir |
| 210 |
echo You called: blast_search "$*" |
| 211 |
echo '---------------------------------------------------------------' |
| 212 |
exit 1 |
| 213 |
|
| 214 |
noperl: |
| 215 |
echo Sorry Can t find /usr/local/bin/perl |
| 216 |
exit 1 |
| 217 |
|
| 218 |
############################################################################ |
| 219 |
############################################################################ |
| 220 |
|