3 # Install script for Biopieces.
4 # October 2011, Martin A. Hansen
6 bp_code="$HOME/biopieces"
7 bp_data="$HOME/BP_DATA"
11 # Function that renders a given message in ASCII green.
16 echo -e "\033[32;38m$msg\033[0m"
19 # Function that renders a given message in ASCII yellow.
24 echo -e "\033[33;38m$msg\033[0m"
27 # Function that renders a given message in ASCII red.
32 echo -e "\033[31;38m$msg\033[0m"
35 # Function to output an abort message and exit
43 # Function to create a directory is it doesn't exist.
48 echo -n "Creating $dir: "
50 if error=$( mkdir $dir 2>&1 ); then
59 # Function to prompt for continuation of installation.
60 function prompt_install
63 echo "Welcome to the Biopieces installer."
65 echo " This installer is experimental, and is being evaluated to replace"
66 echo " the previous, tedious way:"
68 echo " http://code.google.com/p/biopieces/wiki/Installation"
70 echo " If you experience problems, please report to the Google Group (see below)"
72 echo " The installer will now do the following:"
74 echo " - Check prerequisites:"
75 echo " * Subversion client"
77 echo " * Perl modules"
80 echo " * Auxillary programs"
82 echo " - Create installation directories"
83 echo " - Download code from repository"
84 echo " - Set environment in .bashrc"
87 echo " Problems? Check out the FAQ:"
89 echo " http://code.google.com/p/biopieces/wiki/FAQ"
91 echo " Help is available at the Biopieces Google Group:"
93 echo " http://groups.google.com/group/biopieces"
97 read -p "Continue (yes/no)? " answer
105 # Function to prompt the selection of the code directory.
106 function prompt_install_dir_code
108 read -p "Enter directory to install Biopieces code (default: $bp_code): " answer;
110 bp_code=${answer:-"$bp_code"}
112 if [ ! -d "$bp_code" ]; then
114 read -p "Create directory: $bp_code (yes/no)? " answer
116 [Yy]* ) dir_create $bp_code && break;;
123 # Function to prompt the selection of the data directory.
124 function prompt_install_dir_data
126 read -p "Enter directory to install Biopieces data (default: $bp_data): " answer;
128 bp_data=${answer:-"$bp_data"}
130 if [ ! -d "$bp_data" ]; then
132 read -p "Create directory: $bp_data (yes/no)? " answer
134 [Yy]* ) dir_create $bp_data && break;;
141 # Function to prompt the selection of the log directory.
142 function prompt_install_dir_log
144 read -p "Enter directory to install Biopieces log (default: $bp_log): " answer;
146 bp_log=${answer:-"$bp_log"}
148 if [ ! -d "$bp_log" ]; then
150 read -p "Create directory: $bp_log (yes/no)? " answer
152 [Yy]* ) dir_create $bp_log && break;;
159 # Function to prompt the selection of the tmp directory.
160 function prompt_install_dir_tmp
162 read -p "Enter directory to install Biopieces tmp (default: $bp_tmp): " answer;
164 bp_tmp=${answer:-"$bp_tmp"}
166 if [ ! -d "$bp_tmp" ]; then
168 read -p "Create directory: $bp_tmp (yes/no)? " answer
170 [Yy]* ) dir_create $bp_tmp && break;;
177 # Function to prompt the appending of a section to bashrc.
178 function prompt_append_bashrc
182 # >>>>>>>>>>>>>>>>>>>>>>> Enabling Biopieces <<<<<<<<<<<<<<<<<<<<<<<
184 export BP_DIR=\"$bp_code\"
185 export BP_DATA=\"$bp_data\"
186 export BP_TMP=\"$bp_tmp\"
187 export BP_LOG=\"$bp_log\"
189 source \"\$BP_DIR/bp_conf/bashrc\"
191 # >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<
195 echo_yellow "$section"
196 echo "We need to append the above section to your .bashrc file."
199 read -p "Continue (yes/no)? " answer
206 echo -n "Appending $HOME/.bashrc: "
208 cp "$HOME/.bashrc" "$HOME/.bashrc_biopieces"
210 echo "$section" >> "$HOME/.bashrc"
212 source "$HOME/.bashrc"
218 # Function to test if subversion client is in $PATH.
223 echo -n "Testing subversion client - \"$program\": "
225 if command -v $program >/dev/null; then
229 echo " Subversion client $program was not found."
234 # Function to test if the required version of Perl is installed.
237 echo -n "Testing Perl version: "
239 if error=$( perl -e 'use 5.8.0;' 2>&1 ); then
243 echo $error | sed "s/, stopped.*//"
248 # Function to test if a given Perl module is installed.
249 function test_perl_module
253 echo -n "Testing required Perl module - \"$module\": "
255 if ! error=$( perl -M$module -e '' 2>&1 > /dev/null ); then
257 echo " Try: perl -MCPAN -e 'install $module'"
264 # Function to test if the required version of Ruby is installed.
267 echo -n "Testing Ruby version: "
269 if error=$( ruby -e 'raise "Ruby version 1.9 required--this is only #{RUBY_VERSION}" if RUBY_VERSION < "1.9"' 2>&1 ); then
273 echo $error | sed "s/.*: //"
278 # Function to test if a given Ruby gem is installed.
279 function test_ruby_gem
283 echo -n "Testing required Ruby gem - \"$gem\": "
285 if error=$( gem list --local | grep $gem ); then
289 echo " Try: gem install $gem"
294 # Function to test is a given auxillary program is in $PATH.
295 function test_aux_program
299 echo -n "Testing auxiliary program - \"$program\": "
301 if command -v $program >/dev/null; then
304 echo_yellow "WARNING"
308 # Function to checkout the Biopieces code from subversion.
309 function checkout_code
311 echo -n "Downloading Biopieces code from repository: "
313 if error=$( svn checkout http://biopieces.googlecode.com/svn/trunk/ $bp_code ); then
322 # Function to checkout the Biopieces wiki from subversion.
323 function checkout_wiki
325 echo -n "Downloading Biopieces wiki from repository: "
327 if error=$( svn checkout http://biopieces.googlecode.com/svn/wiki/ "$bp_code/bp_usage" ); then
336 # Function to run the Biopieces test suite.
340 read -p "Run the Biopieces test suite (yes/no)? " answer
342 [Yy]* ) "$BP_DIR/bp_test/test_all" && break;;
352 test_perl_module "Inline"
353 test_perl_module "JSON::XS"
354 test_perl_module "SVG"
355 test_perl_module "Bit::Vector"
356 test_perl_module "Time::HiRes"
358 test_ruby_gem "gnuplot"
359 test_ruby_gem "narray"
360 test_aux_program "blastall"
361 test_aux_program "blat"
362 test_aux_program "bwa"
363 test_aux_program "bowtie"
364 test_aux_program "formatdb"
365 test_aux_program "gnuplot"
366 test_aux_program "idba"
367 test_aux_program "muscle"
368 test_aux_program "mummer"
369 test_aux_program "mysql"
370 test_aux_program "prodigal"
371 test_aux_program "Ray"
372 test_aux_program "scan_for_matches"
373 test_aux_program "uclust"
374 test_aux_program "velveth"
375 test_aux_program "velvetg"
376 test_aux_program "vmatch"
380 prompt_install_dir_code
381 prompt_install_dir_data
382 prompt_install_dir_log
383 prompt_install_dir_tmp
393 echo_green "Congratulations - you have now installed Biopieces."
395 echo " To list all available Biopieces try 'list_biopieces'"
397 echo " To see the synopsis of a Biopiece try 'read_fastq'"
399 echo " To see the full description and exampels try 'read_fastq -?'"
401 echo " Don't forget to join the Biopieces Google Group for important"
402 echo " messages, questions, discussion, and suggestions:"
404 echo " http://groups.google.com/group/biopieces"
406 echo " And of cause there is the introduction:"
408 echo " http://code.google.com/p/biopieces/wiki/Introduction"
410 echo " Happy hacking!"