|
| 1 | +#!/bin/bash |
| 2 | +error=0; |
| 3 | +####### FUNCTIONS ######### |
| 4 | +function usage |
| 5 | +{ |
| 6 | + echo "usage: configure [[[-p ] [-n]] | [-h]]" |
| 7 | + echo "choose flag -p or --protein_only if you want to run hamstr only on protein sequence data" |
| 8 | + echo "choose flag -n or --noublast if you want to run hamstr without the -ublast option" |
| 9 | +} |
| 10 | + |
| 11 | + |
| 12 | +## parsing command line option |
| 13 | +while [ "$1" != "" ]; do |
| 14 | + case $1 in |
| 15 | + -p | --protein_only ) protonly=1 |
| 16 | + ;; |
| 17 | + -n | --noublast ) noublast=1 |
| 18 | + ;; |
| 19 | + -h | --help ) usage |
| 20 | + exit |
| 21 | + ;; |
| 22 | + * ) usage |
| 23 | + exit 1 |
| 24 | + esac |
| 25 | + shift |
| 26 | +done |
| 27 | +################# USER SETTINGS ############### |
| 28 | +sedprog='sed'; |
| 29 | +grepprog='grep'; |
| 30 | +############################################### |
| 31 | +#### testing the user settings ################ |
| 32 | +sedpath=`which $sedprog 2>&1 |grep -v '\bno\b'` |
| 33 | +greppath=`which $grepprog 2>&1 |grep -v '\bno\b'` |
| 34 | +if [ ! $sedpath ] |
| 35 | +then |
| 36 | + echo "$sedprog could not be found. Please update the configure script"; |
| 37 | + exit; |
| 38 | +fi |
| 39 | +if [ ! $greppath ] |
| 40 | +then |
| 41 | + echo "$grepprog could not be found. Please update the configure script"; |
| 42 | + exit; |
| 43 | +fi |
| 44 | +############################################## |
| 45 | +########### update the sed and grep commands in the perl scripts |
| 46 | +$sedprog -i -e "s/\(my \$sedprog = '\).*/\1$sedprog';/" hamstr.pl; |
| 47 | +$sedprog -i -e "s/\(my \$grepprog = '\).*/\1$grepprog';/" hamstr.pl; |
| 48 | +$sedprog -i -e "s/\(my \$sedprog = '\).*/\1$sedprog';/" oneSeq.pl; |
| 49 | +$sedprog -i -e "s/\(my \$grepprog = '\).*/\1$grepprog';/" oneSeq.pl; |
| 50 | +############################################# |
| 51 | +## localize the perl installation |
| 52 | +echo "Updating paths" |
| 53 | +path2perl=`which perl` |
| 54 | +echo " updating path to perl: $path2perl" |
| 55 | +$sedprog -i -e "s|\#\!.*|\#\!$path2perl|g" hamstr.pl; |
| 56 | +$sedprog -i -e "s|\#\!.*|\#\!$path2perl|g" nentferner.pl; |
| 57 | +$sedprog -i -e "s|\#\!.*|\#\!$path2perl|g" translate.pl; |
| 58 | +$sedprog -i -e "s|\#\!.*|\#\!$path2perl|g" oneSeq.pl; |
| 59 | +$sedprog -i -e "s|\#\!.*|\#\!$path2perl|g" multifasta2oneSeq.pl; |
| 60 | + |
| 61 | +## get the path to the perl modules |
| 62 | +path2dir=`pwd |$sedprog -e 's/\(.*\)\/.*/\1/'`; |
| 63 | + |
| 64 | +echo " updating path to lib: $path2dir" |
| 65 | +$sedprog -i -e "s|use lib.*lib\(.*\)|use lib '$path2dir/lib\1|" hamstr.pl |
| 66 | +$sedprog -i -e "s|use lib.*|use lib '$path2dir/lib';|" nentferner.pl |
| 67 | +$sedprog -i -e "s|use lib.*|use lib '$path2dir/lib';|g" translate.pl |
| 68 | +$sedprog -i -e "s|use lib.*|use lib '$path2dir/lib';|g" oneSeq.pl |
| 69 | + |
| 70 | +## update the default paths to core_ortholog and blast_dir |
| 71 | +echo " updating default path to blast_dir and core_orthologs: $path2bin" |
| 72 | +$sedprog -i -e "s|\(my \$path = \).*|\1 '$path2dir';|g" hamstr.pl |
| 73 | + |
| 74 | + |
| 75 | +## checking dependencies |
| 76 | +echo "Checking dependencies" |
| 77 | +blastallpath=`which blastall 2>&1 |grep -v '\bno\b'` |
| 78 | +echo " checking blastall" |
| 79 | +if [ $blastallpath ] |
| 80 | + then |
| 81 | + echo " succeeded" #do nothing as this is default for hamstr |
| 82 | +else |
| 83 | + echo " blastall is not installed or not in the default path." |
| 84 | + echo " checking for blastp" |
| 85 | + blastpluspath=`which blastp 2>&1 |grep -v '\bno\b'` |
| 86 | + if [ $blastpluspath ] |
| 87 | + then |
| 88 | + echo " succeeded" |
| 89 | + $sedprog -i -e 's/^\(my $blast_prog .*blastall\)/\#\1/' hamstr.pl; |
| 90 | + $sedprog -i -e 's/^\(my $blast_prog .*blastall\)/\#\1/' oneSeq.pl; |
| 91 | + |
| 92 | + $sedprog -i -e 's/\#\(my $blast_prog .*blastp\)/\1/' hamstr.pl; |
| 93 | + $sedprog -i -e 's/\#\(my $blast_prog .*blastp\)/\1/' oneSeq.pl; |
| 94 | + else " FATAL: No blast program was found. Please install!" |
| 95 | + error=1; |
| 96 | + fi |
| 97 | +fi |
| 98 | +## Check for ublast |
| 99 | +if [ $noublast ] |
| 100 | + then |
| 101 | + echo " omitting check for usearch. Option --noublast has been chosen"; |
| 102 | + echo " updating hamstr.pl script" |
| 103 | + $sedprog -i -e 's/my $runublast = [0,1];/my $runublast = 0;/' hamstr.pl; |
| 104 | +else |
| 105 | + echo " checking ublast" |
| 106 | + usearchpath=`which usearch 2>&1 |grep -v '\bno\b'` |
| 107 | + if [ $usearchpath ] |
| 108 | + then |
| 109 | + echo " succeeded" #do nothing as this is default for hamstr |
| 110 | + $sedprog -i -e 's/my $runublast = [0,1];/my $runublast = 1;/' hamstr.pl; |
| 111 | + else |
| 112 | + echo " FATAL: usearch was not found and configure was run without the --noublast option" |
| 113 | + error=1; |
| 114 | + fi |
| 115 | +fi |
| 116 | +## Check for genewise |
| 117 | +if [ $protonly ] |
| 118 | + then |
| 119 | + echo " ommitting check for genewise. Option --protein_only has been chosen"; |
| 120 | + echo " updating hamstr.pl script" |
| 121 | + $sedprog -i -e 's/$check_genewise = [0,1];/$check_genewise = 0;/' hamstr.pl; |
| 122 | + |
| 123 | +else |
| 124 | +echo " checking genewise" |
| 125 | + $sedprog -i -e 's/$check_genewise = [0,1];/$check_genewise = 1;/' hamstr.pl; |
| 126 | +genewisepath=`which genewise 2>&1 |$grepprog -v '\bno\b'` |
| 127 | +if [ $genewisepath ] |
| 128 | + then |
| 129 | + echo " succeeded" |
| 130 | + echo " checking environmental variable WISECONFIGDIR" |
| 131 | + wisecfg=`echo $WISECONFIGDIR |$grepprog '/'` |
| 132 | + if [ $wisecfg ] |
| 133 | + then |
| 134 | + echo " succeeded: $wisecfg" |
| 135 | + else |
| 136 | + echo " FATAL: Please set the environmental variable WISECONFIGDIR according to the installation instructions of genewise. If you want to run HaMStR on protein data only, run configure --protein_only"; |
| 137 | + error=1; |
| 138 | + fi |
| 139 | + |
| 140 | +else |
| 141 | + echo " FATAL: genewise has not been installed properly. If you want to run HaMStR on protein data only, run configure --protein_only"; |
| 142 | + error=1; |
| 143 | +fi |
| 144 | +fi |
| 145 | +## Checking for environmental variable ONESEQDIR |
| 146 | +echo "Checking environmental variable ONESEQDIR" |
| 147 | +oneseqcfg=`echo $ONESEQDIR` |
| 148 | +if [ $oneseqcfg ] |
| 149 | + then |
| 150 | + echo " succeeded: $oneseqcfg" |
| 151 | +else |
| 152 | + echo "FATAL: Please set the environmental variable ONSEQDIR to point at the directory containing the oneseq files and directory" |
| 153 | + error=1; |
| 154 | +fi |
| 155 | +## Checking for hmmsearch |
| 156 | +echo " checking for hmmsearch" |
| 157 | +hmmsearchpath=`which hmmsearch 2>&1 |grep -v '\bno\b'` |
| 158 | +if [ $hmmsearchpath ] |
| 159 | + then |
| 160 | + echo " succeeded: $hmmsearchpath" |
| 161 | +else |
| 162 | + echo " FATAL: Please install the hmmer3 package" |
| 163 | + error=1; |
| 164 | +fi |
| 165 | +## Checking for clustalw2 |
| 166 | +echo " checking for clustalw2"; |
| 167 | +clustalpath=`which clustalw2 2>&1 |grep -v '\bno\b'` |
| 168 | +if [ $clustalpath ] |
| 169 | + then |
| 170 | + echo " succeeded: $clustalpath" |
| 171 | +else |
| 172 | + echo " checking for clustalw" |
| 173 | + clustalpath=`which clustalw 2>&1 |grep -v '\bno\b'` |
| 174 | + if [ $clustalpath ] |
| 175 | + then |
| 176 | + echo " succeeded: $clustalpath"; |
| 177 | + echo " updating hamstrscript"; |
| 178 | + $sedprog -i -e 's/clustalw2/clustalw/g' hamstr.pl; |
| 179 | + else |
| 180 | + echo " FATAL: Please install clustalw2" |
| 181 | + error=1; |
| 182 | + fi |
| 183 | +fi |
| 184 | +## Checking for Mafft |
| 185 | +echo " checking for mafft-linsi"; |
| 186 | +mafftpath=`which mafft-linsi 2>&1 |grep -v '\bno\b'` |
| 187 | +if [ $mafftpath ] |
| 188 | + then |
| 189 | + echo " succeeded: $mafftpath" |
| 190 | +else |
| 191 | + echo " FATAL: Please install mafft" |
| 192 | + error=1; |
| 193 | +fi |
| 194 | +### wrap up |
| 195 | +if [ $error == 1 ] |
| 196 | +then |
| 197 | + echo "Configuration of HaMStR failed. Please see the error messages above." |
| 198 | +else |
| 199 | + echo "Generating symbolic link hamstr -> hamstr.pl" |
| 200 | + ln -s -f ./hamstr.pl ./hamstr |
| 201 | + echo "All tests succeeded, HaMStR should be ready to run"; |
| 202 | + $sedprog -i -e 's/my $configure = .*/my $configure = 1;/' hamstr.pl; |
| 203 | + $sedprog -i -e 's/my $configure = .*/my $configure = 1;/' oneSeq.pl; |
| 204 | + $sedprog -i -e 's/my $configure = .*/my $configure = 1;/' multifasta2oneSeq.pl; |
| 205 | +fi; |
0 commit comments