Next version of JABA
[jabaws.git] / binaries / src / tcoffee / install
1 #!/usr/bin/env perl
2 #Version 2.01 (25/02/03)
3 use Cwd;
4 use File::Path;
5 use FileHandle;
6 use strict;
7
8
9 our (%MODE, %PG, %ENV_SET, %SUPPORTED_OS);
10
11
12 our $EXIT_SUCCESS=0;
13 our $EXIT_FAILURE=1;
14 our $INTERNET=0;
15
16 #our $CP="cp -d ";
17 our $CP="cp "; #was causing a crash on MacOSX
18 our $SILENT=">/dev/null 2>/dev/null";
19 our $WEB_BASE="http://www.tcoffee.org";
20 our $TCLINKDB_ADDRESS="$WEB_BASE/Resources/tclinkdb.txt";
21 our $OS=get_os();
22 our $ROOT=&get_root();
23 our $CD=cwd();
24 our $CDIR=$CD;
25 our $HOME=$ENV{'HOME'};
26 ###########   DEFINITIONS ##############################
27 #
28 #
29 our $CXX="g++";
30 our $CXXFLAGS="";
31
32 our $CPP="g++";
33 our $CPPFLAGS="";
34
35 our $CC="gcc";
36 our $CFLAGS="";
37
38 our $FC="f77";
39 our $FFLAGS="";
40
41 my $install="all";
42 my $default_update_action="no_update";
43 ########################################################
44 my @required_applications=("wget_OR_curl");
45 ########### Mode Definitions ##############################
46 #
47 #
48 my @smode=("all", "clean", "install");
49
50 ########################################################
51 &initialize_PG();
52
53 #Parse The Command Line
54 my $cl=join( " ", @ARGV);
55 if ($#ARGV==-1 || ($cl=~/-h/) ||($cl=~/-H/) )
56   {
57      print "\n!!!!!!! ./install  t_coffee             --> installs t_coffee only";
58      print "\n!!!!!!! ./install  all                  --> installs all the modes [mcoffee, expresso, psicoffee,rcoffee..]";
59      print "\n!!!!!!! ./install  [mcoffee|rcoffee|..] --> installs the specified mode";
60      print "\n!!!!!!! ./install  -h                   --> print usage\n\n";
61      if ( $#ARGV==-1){exit ($EXIT_FAILURE);}
62    }
63      
64 if (($cl=~/-h/) ||($cl=~/-H/) )
65   {
66     my $m;
67     print "\n\n!!!!!!! advanced mode\n";
68     foreach $m ((keys (%MODE)),@smode)
69       {
70         print "!!!!!!!       ./install $m\n";
71       }
72     
73     print "!!!!!!! ./install [target:package|mode|] [-update|-force|-exec=dir|-dis=dir|-root|-tclinkdb=file|-] [CC=|FCC=|CXX=|CFLAGS=|CXXFLAGS=]\n";
74     print "!!!!!!! ./install clean    [removes all executables]\n";
75     print "!!!!!!! ./install [optional:target] -update               [updates package already installed]\n";
76     print "!!!!!!! ./install [optional:target] -force                [Forces recompilation over everything]\n";
77     
78     print "!!!!!!! ./install [optional:target] -root                 [You are running as root]\n";
79     print "!!!!!!! ./install [optional:target] -exec=/foo/bar/       [address for the T-Coffee executable]\n";
80     print "!!!!!!! ./install [optional:target] -dis=/foo/bar/        [Address where distributions should be stored]\n";
81     print "!!!!!!! ./install [optional:target] -tclinkdb=foo|update  [file containing all the packages to be installed]\n";
82     print "!!!!!!! ./install [optional:target] -tclinkdb=foo|update  [file containing all the packages to be installed]\n";
83     print "!!!!!!! ./install [optional:target] -clean                [clean everything]\n";
84     print "!!!!!!! ./install [optional:target] -plugins              [plugins directory]\n";
85     print "!!!!!!! mode:";
86     foreach $m (keys(%MODE)){print "$m ";}
87     print "\n";
88     print "!!!!!!! Packages:";
89     foreach $m (keys (%PG)){print "$m ";}
90     print "\n";
91     
92     print "\n\n";
93     exit ($EXIT_FAILURE);
94   }
95
96
97
98 # parse compiler flags
99 my (@argl)=($cl=~/(\S+=[^=]+)\s\w+=/g);
100 push (@argl, ($cl=~/(\S+=[^=]+\S)\s*$/g));
101
102 foreach $a (@argl)
103   {
104     if ( ($cl=~/CXX=(.*)/)){$CXX=$1;}
105     if ( ($cl=~/-CC=(.*)/    )){$CC=$1;}
106     if ( ($cl=~/-FC=(.*)/    )){$FC=$1;}
107     if ( ($cl=~/-CFLAGS=(.*)/)){$CFLAGS=$1;}
108     if ( ($cl=~/-CXXFLAGS=(.*)/)){$CXXFLAGS=$1;}
109   }
110 #parse install flags
111 our ($ROOT_INSTALL, $NO_QUESTION, $default_update_action,$BINARIES_ONLY,$force, $default_update_action, $INSTALL_DIR, $PLUGINS_DIR, $DISTRIBUTIONS,$tclinkdb, $proxy, $clean);
112 if ( ($cl=~/-root/)){$ROOT_INSTALL=1;}
113 if ( ($cl=~/-no_question/)){$NO_QUESTION=1;}
114 if ( ($cl=~/-update/)){$default_update_action="update";}
115 if ( ($cl=~/-binaries/)){$BINARIES_ONLY=1;}
116 if ( ($cl=~/-force/)){$force=1;$default_update_action="update"}
117 if ( ($cl=~/-exec=\s*(\S+)/)){$INSTALL_DIR=$1;}
118 if ( ($cl=~/-plugins=\s*(\S+)/)){$PLUGINS_DIR=$1;}
119 if ( ($cl=~/-dis=\s*(\S+)/)){$DISTRIBUTIONS=$1;}
120
121 if ( ($cl=~/-tclinkdb=\s*(\S+)/)){$tclinkdb=$1;}
122 if ( ($cl=~/-proxy=\s*(\S+)/)){$proxy=$1;}
123 if ( ($cl=~/-clean/)){$clean=1;}
124 #automated update
125 if ($tclinkdb){&update_tclinkdb ($tclinkdb);}
126
127 #Prepare the T-Coffee directory structure
128 our $TCDIR=$ENV{DIR_4_TCOFFEE};
129 our $TCCACHE=$ENV{CACHE_4_TCOFFEE};
130 our $TCTMP=$ENV{CACHE_4_TCOFFEE};
131 our $TCM=$ENV{MCOFFEE_4_TCOFFEE};
132 our $TCMETHODS=$ENV{METHODS_4_TCOFFEE};
133 our $TCPLUGINS=$ENV{PLUGINS_4_TCOFFEE};
134 our $PLUGINS_DIR="";
135 our $INSTALL_DIR="";
136
137 &add_dir ($TCDIR="$HOME/.t_coffee");
138 &add_dir ($TCCACHE="$TCDIR/cache");
139 &add_dir ($TCTMP="$CDIR/tmp");
140 &add_dir ($TCM="$TCDIR/mcoffee");
141 &add_dir ($TCMETHODS="$TCDIR/methods");
142 &add_dir ($TCPLUGINS="$TCDIR/plugins/$OS");
143
144 #Prepare the Installation Structure
145
146 our $BASE="$CD/bin";
147 our $BIN="$BASE/binaries/$OS";
148 our $DOWNLOAD_DIR="$BASE/download";
149 our $DOWNLOAD_FILE="$DOWNLOAD_DIR/files";
150 our $TMP="$BASE/tmp";
151
152 &add_dir($BASE);
153 &add_dir($BIN);
154 &add_dir($DOWNLOAD_DIR);
155 &add_dir($DOWNLOAD_FILE);
156 if (!$DISTRIBUTIONS){$DISTRIBUTIONS="$DOWNLOAD_DIR/distributions";}
157 &add_dir ($DISTRIBUTIONS);
158 &add_dir ($TMP);
159
160
161 #set the directory for the plugins 
162 if    (!$PLUGINS_DIR && !$ROOT_INSTALL){$PLUGINS_DIR=$TCPLUGINS;}
163 elsif (!$PLUGINS_DIR &&  $ROOT_INSTALL){$PLUGINS_DIR="/usr/local/bin/";}
164
165 #set the directory for t_coffee
166 if    (!$INSTALL_DIR && !$ROOT_INSTALL){$INSTALL_DIR="$HOME/bin/";mkpath ($INSTALL_DIR);}
167 elsif (!$INSTALL_DIR &&  $ROOT_INSTALL){$INSTALL_DIR="/usr/local/bin/";}
168
169 #prepare mcoffee files [Only if vanilla installation]
170 if (-d "mcoffee"){`cp mcoffee/* $TCM`;}
171
172
173 #prepare the environement
174 our $ENV_FILE="$TCDIR/t_coffee_env";
175 &env_file2putenv ($ENV_FILE);
176 &set_proxy($proxy);
177 my ($target, $p, $r);
178 $target=$p;
179
180 foreach $p (  ((keys (%PG)),(keys(%MODE)),(@smode)) )
181   {
182     if ($ARGV[0] eq $p && $target eq ""){$target=$p;}
183   }
184 if ($target eq ""){exit ($EXIT_FAILURE);}
185
186
187 # Check the basic requirements are met
188 foreach $r (@required_applications)
189   {
190     my @app_list;
191     my $i;
192     $i=0;
193     
194     @app_list=split (/_OR_/, $r);
195     foreach my $pg (@app_list)
196       {
197         $i+=&pg_is_installed ($pg);
198       }
199     if ($i==0)
200       {
201       print "One of the following packages must be installed to proceed: ";
202       foreach my $pg (@app_list)
203         {
204           print ("$pg ");
205         }
206       die;
207     }
208   }
209
210
211 # Set the mains paths and create directories
212 # distrib_dir/install/bin
213 # distrib_dir/install/Downloads
214 # distrib_dir/install/Downloads/Files
215 # distrib_dir/install/Downloads/Distributions
216 # distrib_dir/tmp
217
218 #Directory structure of the installation WITHIN the distribution dir
219
220
221
222 #sign the license
223 &sign_license_ni();
224
225
226 #Configure the copilers and their optins
227 $PG{C}{compiler}=get_C_compiler($CC);
228 $PG{Fortran}{compiler}=get_F_compiler($FC);
229 $PG{CXX}{compiler}=$PG{CPP}{compiler}=$PG{GPP}{compiler}=get_CXX_compiler($CXX);
230 if ($CXXFLAGS){$PG{CPP}{options}=$PG{GPP}{options}=$PG{CXX}{options}=$CXXFLAGS;}
231 if ($CFLAGS){$PG{C}{options}=$CFLAGS;}
232 foreach my $c (keys(%PG))
233   {
234     my $arguments;
235     if ($PG{$c}{compiler})
236       {
237         $arguments="$PG{$c}{compiler_flag}=$PG{$c}{compiler} ";
238         if ($PG{$c}{options})
239           {
240             $arguments.="$PG{$c}{options_flag}=$PG{$c}{options} ";
241           }
242         $PG{$c}{arguments}=$arguments;
243       }
244   }
245
246 # select the list of packages to update
247 if ($PG{$target}){$PG{$target}{install}=1;}
248 else
249   {
250     foreach my $pg (keys(%PG))
251       {
252         if ( $target eq "all" || ($PG{$pg}{mode}=~/$target/))
253           {
254             $PG{$pg} {install}=1;
255           }
256       }
257   }
258
259 foreach my $pg (keys(%PG))
260   {
261     if (!$PG{$pg}{update_action}){$PG{$pg}{update_action}=$default_update_action;}
262     elsif ($PG{$pg}{update_action} eq "never"){$PG{$pg}{install}=0;}
263     if ( $force && $PG{$pg}{install})
264       {
265         `rm $BIN/$pg $BIN/$pg.exe $SILENT`;
266       }
267     if ($PG{$pg}{update_action} eq "update" && $PG{$pg}{install}){$PG{$pg}{update}=1;}
268   }
269
270 #Execute the target: install/remove all the selected components
271 if (($target=~/clean/))
272   {
273     print "------- cleaning executables -----\n";
274     `rm bin/* $SILENT`;
275     exit ($EXIT_SUCCESS);
276   }
277
278 if ( !$PG{$target}){print "------- Installing T-Coffee Modes\n";}
279
280 #1 - Installing various modes
281 foreach my $m (keys(%MODE))
282   {
283     if ( $target eq "all" || $target eq $m)
284       {
285         print "\n------- The installer will now install the $m components $MODE{$m}{description}\n";
286         foreach my $pg (keys(%PG))
287           {
288             if ( $PG{$pg}{mode} =~/$m/ && $PG{$pg}{install})
289               {
290                 if ($PG{$pg}{touched}){print "------- $PG{$pg}{dname}: already processed\n";}
291                 else {$PG{$pg}{success}=&install_pg($pg);$PG{$pg}{touched}=1;}
292               }
293           }
294       }
295   }
296
297 #2 - Installing Various Packages
298 if ( $PG{$target}){print "------- Installing Individual Package\n";}
299 foreach my $pg (keys (%PG))
300   {
301     
302     if ( $PG{$pg}{install} && !$PG{$pg}{touched})
303       {
304         print "\n------- Install $pg\n";
305         $PG{$pg}{success}=&install_pg($pg);$PG{$pg}{touched}=1;
306       }
307   }
308 print "------- Finishing The installation\n";
309 my $final_report=&install ($INSTALL_DIR);
310
311 print "\n";
312 print "*********************************************************************\n";
313 print "********              INSTALLATION SUMMARY          *****************\n";
314 print "*********************************************************************\n";
315 print "------- SUMMARY package Installation:\n";
316 foreach my $pg (keys(%PG))
317   {
318     if ( $PG{$pg}{install})
319       {
320         my $bin_status=($PG{$pg}{from_binary} && $PG{$pg}{success})?"[from binary]":"";
321         if     ( $PG{$pg}{new} && !$PG{$pg}{old})                     {print "*------        $PG{$pg}{dname}: installed $bin_status\n"; $PG{$pg}{status}=1;}
322         elsif  ( $PG{$pg}{new} &&  $PG{$pg}{old})                     {print "*------        $PG{$pg}{dname}: updated $bin_status\n"  ; $PG{$pg}{status}=1;} 
323         elsif  (!$PG{$pg}{new} &&  $PG{$pg}{old} && !$PG{$pg}{update}){print "*------        $PG{$pg}{dname}: previous\n" ; $PG{$pg}{status}=1;}
324         elsif  (!$PG{$pg}{new} &&  $PG{$pg}{old} &&  $PG{$pg}{update}){print "*------        $PG{$pg}{dname}: failed update (previous installation available)\n";$PG{$pg}{status}=0;}
325         else                                                          {print "*------        $PG{$pg}{dname}: failed installation";$PG{$pg}{status}=0;}
326       }
327   }
328
329 if ( !$PG{$target}){print "*------ SUMMARY mode Installation:\n";}
330 foreach my $m (keys(%MODE))
331   {
332     if ( $target eq "all" || $target eq $m)
333       {
334         my $succesful=1;
335         foreach my $pg (keys(%PG))
336           {
337             if (($PG{$pg}{mode}=~/$m/) && $PG{$pg}{install} && $PG{$pg}{status}==0)
338               {
339                 $succesful=0;
340                 print "*!!!!!!       $PG{$pg}{dname}: Missing\n";
341               }
342           }
343         if ( $succesful)
344           {
345             $MODE{$m}{status}=1;
346             print "*------       MODE $MODE{$m}{dname} SUCCESFULY installed\n";
347           }
348         else
349           {
350             $MODE{$m}{status}=0;
351             print "*!!!!!!       MODE $MODE{$m}{dname} UNSUCCESFULY installed\n";
352           }
353       }
354   }
355
356 if ($clean==1 && ($BASE=~/install4tcoffee/) ){print "*------ Clean Installation Directory: $BASE\n";`rm -rf $BASE`;}
357 #failure if one program was not well installed
358 foreach my $pg (keys(%PG)){if ($PG{$pg}{install} && $PG{$pg}{status}==0){exit ($EXIT_FAILURE);}}
359 exit ($EXIT_SUCCESS);  
360
361 #################################################################################
362 #                                                                               #
363 #                                                                               #
364 #                                                                               #
365 #                   GENERIC INSTALLATION                                        #
366 #                                                                               #
367 #                                                                               #
368 #                                                                               #
369 #################################################################################
370 sub get_CXX_compiler
371   {
372     my $c=@_[0];
373     my (@clist)=("g++");
374     
375     return get_compil ($c, @clist);
376  }
377 sub get_C_compiler
378   {
379     my $c=@_[0];
380     my (@clist)=("gcc", "cc", "icc");
381     
382     return get_compil ($c, @clist);
383  }
384
385 sub get_F_compiler
386   {
387     my ($c)=@_[0];
388     my @clist=("f77", "g77", "gfortran", "ifort");
389     return get_compil ($c, @clist);
390   } 
391        
392 sub get_compil
393   {
394     my ($fav,@clist)=(@_);
395     
396     #return the first compiler found installed in the system. Check first the favorite
397     foreach my $c ($fav,@clist)
398       {
399         if  (&pg_is_installed ($c)){return $c;}
400       }
401     return "";
402   }
403 sub exit_if_pg_not_installed
404   {
405     my (@arg)=(@_);
406     
407     foreach my $p (@arg)
408       {
409         if ( !&pg_is_installed ($p))
410           {
411             print "!!!!!!!! The $p utility must be installed for this installation to proceed [FATAL]\n";
412             die;
413           }
414       }
415     return 1;
416   }
417 sub set_proxy
418   {
419     my ($proxy)=(@_);
420     my (@list,$p);
421     
422     @list= ("HTTP_proxy", "http_proxy", "HTTP_PROXY", "ALL_proxy", "all_proxy","HTTP_proxy_4_TCOFFEE","http_proxy_4_TCOFFEE");
423     
424     if (!$proxy)
425       {
426         foreach my $p (@list)
427           {
428             if ( ($ENV_SET{$p}) || $ENV{$p}){$proxy=$ENV{$p};}
429           }
430       }
431     foreach my $p(@list){$ENV{$p}=$proxy;}
432   }
433         
434 sub check_internet_connection
435   {
436     my $internet;
437     
438     if ( -e "x"){unlink ("x");}
439     if     (&pg_is_installed    ("wget")){`wget www.google.com -Ox >/dev/null 2>/dev/null`;}
440     elsif  (&pg_is_installed    ("curl")){`curl www.google.com -ox >/dev/null 2>/dev/null`;}
441     else
442       {
443         printf stderr "\nERROR: No pg for remote file fetching [wget or curl][FATAL]\n";
444         exit ($EXIT_FAILURE);
445       }
446     
447     if ( !-e "x" || -s "x" < 10){$internet=0;}
448     else {$internet=1;}
449     if (-e "x"){unlink "x";}
450     return $internet;
451   }
452 sub url2file
453   {
454     my ($cmd, $file,$wget_arg, $curl_arg)=(@_);
455     my ($exit,$flag, $pg, $arg);
456     
457     if ($INTERNET || check_internet_connection ()){$INTERNET=1;}
458     else
459       {
460         print STDERR "ERROR: No Internet Connection [FATAL:install.pl]\n";
461         exit ($EXIT_FAILURE);
462       }
463     
464     if     (&pg_is_installed    ("wget")){$pg="wget"; $flag="-O";$arg=$wget_arg;}
465     elsif  (&pg_is_installed    ("curl")){$pg="curl"; $flag="-o";$arg=$curl_arg;}
466     else
467       {
468         printf stderr "\nERROR: No pg for remote file fetching [wget or curl][FATAL]\n";
469         exit ($EXIT_FAILURE);
470       }
471     
472     
473     if (-e $file){unlink($file);}
474     $exit=system "$pg $cmd $flag$file $arg";
475     return $exit;
476   }
477
478 sub pg_is_installed
479   {
480     my ($p, $dir)=(@_);
481     my ($r,$m);
482     my ($supported, $language, $compil);
483     
484     if ( $PG{$p})
485       {
486         $language=$PG{$p}{language2};
487         $compil=$PG{$language}{compiler};
488       }
489     
490     if ( $compil eq "CPAN")
491       {
492         if ( system ("perl -M$p -e 1")==$EXIT_SUCCESS){return 1;}
493         else {return 0;}
494       }
495     elsif ($dir)
496       {
497         if (-e "$dir/$p" || -e "$dir/$p\.exe"){return 1;}
498         else {return 0;}
499       }
500     elsif (-e "$PLUGINS_DIR/$p" || -e "$PLUGINS_DIR/$p.exe"){return 1;}
501     else
502       {
503         $r=`which $p 2>/dev/null`;
504         if ($r eq ""){return 0;}
505         else {return 1;}
506       }
507     return 0;
508   }
509 sub install
510   {
511     my ($new_bin)=(@_);
512     my ($copied, $report);
513
514     
515     if (!$ROOT_INSTALL)
516       {
517         
518         if (-e "$BIN/t_coffee"){`$CP $BIN/t_coffee $INSTALL_DIR`};
519         `cp $BIN/* $PLUGINS_DIR`;
520         $copied=1;
521       }
522     else
523       {
524         $copied=&root_run ("You must be root to finalize the installation", "$CP $BIN/* $INSTALL_DIR $SILENT");
525       }
526     
527      
528   if ( !$copied)
529     {
530       $report="*!!!!!! Installation unsuccesful. The executables have been left in $BASE/bin\n";
531     }
532   elsif ( $copied && $ROOT)
533     {
534       $report="*------ Installation succesful. Your executables have been copied in $new_bin and are on your PATH\n";
535     }
536   elsif ( $copied && !$ROOT)
537     {
538       $report= "*!!!!!! T-Coffee and associated packages have been copied in: $new_bin\n";
539       $report.="*!!!!!! This address is NOT in your PATH sytem variable\n";
540       $report.="*!!!!!! You can do so by adding the following line in your ~/.bashrc file:\n";
541       $report.="*!!!!!! export PATH=$new_bin:\$PATH\n";
542     }
543   return $report;
544 }
545
546 sub sign_license_ni
547   {
548     my $F=new FileHandle;
549     open ($F, "license.txt");
550     while (<$F>)
551       {
552         print "$_";
553       }
554     close ($F);
555     
556     return;
557   }
558 #################################################################################
559 #                                                                               #
560 #                                                                               #
561 #                                                                               #
562 #                   INDIVIDUAL MULTIPLE SEQUENCE ALIGNMNT PACKAGES INSTALLATION #
563 #                                                                               #
564 #                                                                               #
565 #                                                                               #
566 #################################################################################
567
568 sub install_pg
569   {
570     my ($pg)=(@_);
571     my ($report, $previous, $language, $compiler, $return);
572     
573     if (!$PG{$pg}{install}){return 1;}
574     
575     $previous=&pg_is_installed ($pg);
576     
577     if ($PG{$pg}{update_action} eq "no_update" && $previous)
578       {
579         $PG{$pg}{old}=1;
580         $PG{$pg}{new}=0;
581         $return=1;
582       }
583     else
584       {
585         $PG{$pg}{old}=$previous;
586         
587         if ($PG{$pg} {language2} eq "Perl"){&install_perl_package ($pg);}
588         elsif ($BINARIES_ONLY && &install_binary_package ($pg)){$PG{$pg}{from_binary}=1;}
589         elsif (&install_source_package ($pg)){;}
590         else 
591           {
592             
593             if (!&supported_os($OS))
594               {
595                 print "!!!!!!!! $pg compilation failed, binary unsupported for $OS\n"; 
596               }
597             elsif (!($PG{$pg}{from_binary}=&install_binary_package ($pg)))
598               {
599                 print "!!!!!!!! $pg compilation and  binary installation failed\n";
600               }
601           }
602         $PG{$pg}{new}=$return=&pg_is_installed ($pg,$BIN);
603       }
604
605     
606     return $return;
607   }
608 sub install_perl_package
609   {
610     my ($pg)=(@_);
611     my ($report, $language, $compiler);
612     
613     $language=$PG{$pg} {language2};
614     $compiler=$PG{$language}{compiler};
615     
616     if (!&pg_is_installed ($pg))
617       {
618         if ( $OS eq "windows"){`perl -M$compiler -e 'install $pg'`;}
619         elsif ( $ROOT eq "sudo"){system ("sudo perl -M$compiler -e 'install $pg'");}
620         else {system ("su root -c perl -M$compiler -e 'install $pg'");}
621       }
622     return &pg_is_installed ($pg);
623   }
624
625
626
627 sub install_source_package
628   {
629     my ($pg)=(@_);
630     my ($report, $download, $arguments, $language, $address, $name, $ext, $main_dir, $distrib);
631     my $wget_tmp="$TMP/wget.tmp";
632     my (@fl);
633     if ( -e "$BIN/$pg" || -e "$BIN/$pg.exe"){return 1;}
634     
635     if ($pg eq "t_coffee")  {return   &install_t_coffee ($pg);}
636     elsif ($pg eq "TMalign"){return   &install_TMalign ($pg);}
637     
638     chdir $DISTRIBUTIONS;
639     
640     $download=$PG{$pg}{source};
641     
642     if (($download =~/tgz/))
643       {
644         ($address,$name,$ext)=($download=~/(.+\/)([^\/]+)(\.tgz)/);
645       }
646     elsif (($download=~/tar\.gz/))
647       {
648         ($address,$name,$ext)=($download=~/(.+\/)([^\/]+)(\.tar\.gz)/);
649       }
650     elsif (($download=~/tar/))
651       {
652         ($address,$name,$ext)=($download=~/(.+\/)([^\/]+)(\.tar)/);
653       }
654     else
655       {
656         ($address,$name)=($download=~/(.+\/)([^\/]+)/);
657         $ext="";
658       }
659     $distrib="$name$ext";
660     
661     if ( !-d $pg){mkdir $pg;}
662     chdir $pg;
663    
664     #get the distribution if available
665     if ( -e "$DOWNLOAD_DIR/$distrib")
666       {
667         `$CP $DOWNLOAD_DIR/$distrib .`;
668       }
669     #UNTAR and Prepare everything
670     if (!-e "$name.tar" && !-e "$name")
671       {
672         &check_rm ($wget_tmp);
673         print "\n------- Downloading/Installing $pg\n";
674         if (!-e $distrib && &url2file ("$download", "$wget_tmp")==$EXIT_SUCCESS)
675           {
676             
677             `mv $wget_tmp $distrib`;
678             `$CP $distrib $DOWNLOAD_DIR/`;
679           }
680
681         if (!-e $distrib)
682           {
683             print "!!!!!!! Download of $pg distribution failed\n";
684             print "!!!!!!! Check Address: $PG{$pg}{source}\n";
685             return 0;
686           }
687         print "\n------- unzipping/untaring $name\n";
688         if (($ext =~/z/))
689           { 
690             &flush_command ("gunzip $name$ext");
691             
692           }
693         if (($ext =~/tar/) || ($ext =~/tgz/))
694           {
695             &flush_command("tar -xvf $name.tar");
696           }
697       }
698     #Guess and enter the distribution directory
699     @fl=ls($p);
700     foreach my $f (@fl)
701       {
702         if (-d $f)
703           {
704             $main_dir=$f;
705           }
706       }
707     if (-d $main_dir)
708           {chdir $main_dir;}
709     
710     print "\n------- Compiling/Installing $pg\n";
711     `make clean $SILENT`;
712     #sap
713     if ($pg eq "sap")
714       {
715         `rm *.o sap  sap.exe ./util/aa/*.o  ./util/wt/.o $SILENT`;
716         &flush_command ("make $arguments sap");
717         &check_cp ($pg, "$BIN");
718       }
719     elsif ($pg eq "clustalw2")
720       {
721         &flush_command("./configure");
722         &flush_command("make $arguments");
723         &check_cp ("./src/$pg", "$BIN");
724         
725       }
726     elsif ($pg eq "clustalw")
727       {
728         &flush_command("make $arguments clustalw");
729         `$CP $pg $BIN $SILENT`;
730       }
731     
732     elsif ($pg eq "mafft")
733       {
734         my $base=cwd();
735         my $c;
736         
737         #compile core
738         mkpath ("./mafft/bin");
739         mkpath ("./mafft/lib");
740         chdir "$base/core";
741         `make clean $SILENT`;
742         &flush_command ("make $arguments");
743         &flush_command ("make install LIBDIR=../mafft/lib BINDIR=../mafft/bin");
744         
745         #compile extension
746         chdir "$base/extensions";
747         `make clean $SILENT`;
748         &flush_command ("make $arguments");
749         &flush_command ("make install LIBDIR=../mafft/lib BINDIR=../mafft/bin");
750         
751         #put everything in mafft and copy the coompiled stuff in bin
752         chdir "$base";
753         if ($ROOT_INSTALL)
754           {
755             &root_run ("You Must be Roor to Install MAFFT\n", "mkdir /usr/local/mafft/;$CP mafft/lib/* /usr/local/mafft;$CP mafft/lib/mafft* /usr/local/bin ;$CP mafft/bin/mafft /usr/local/bin/; ");
756           }
757         else
758           {
759             `$CP mafft/lib/*  $BIN`;
760             `$CP mafft/bin/mafft  $BIN`;
761           }
762         `tar -cvf mafft.tar mafft`;
763         `gzip mafft.tar`;
764         `mv mafft.tar.gz $BIN`;
765       }
766     elsif ( $pg eq "dialign-tx")
767       {
768         my $f;
769         my $base=cwd();
770
771         chdir "./source";
772         &flush_command (" make CPPFLAGS='-O3 -funroll-loops' all");
773         
774         chdir "..";
775         &check_cp ("./source/$pg", "$BIN");
776         &check_cp ("./source/$pg", "$BIN/dialign-t");
777       }
778     elsif ($pg eq "poa")
779       {
780         &flush_command ("make $arguments poa");
781         &check_cp ("$pg", "$BIN");
782       }
783     elsif ( $pg eq "probcons")
784       {
785         `rm *.exe $SILENT`;
786         &flush_command ("make $arguments probcons");
787         &check_cp("$pg", "$BIN/$pg");
788       }
789     elsif ( $pg eq "probcons" || $pg eq "probconsRNA")
790       {
791         `rm *.exe $SILENT`;
792         &flush_command ("make $arguments probcons");
793         &check_cp("probcons", "$BIN/$pg");
794       }
795
796     elsif (  $pg eq "muscle")
797       {
798         `rm *.o muscle muscle.exe $SILENT`;
799         &flush_command ("make $arguments all");
800         &check_cp("$pg", "$BIN");
801       }
802     elsif ( $pg eq "pcma")
803       {
804         &flush_command ("make $arguments pcma");
805         &check_cp("$pg", "$BIN");
806       }
807     elsif ($pg eq "kalign")
808       {
809         &flush_command ("./configure");
810         &flush_command("make $arguments");
811         &check_cp ("$pg",$BIN);
812       }
813     elsif ( $pg eq "amap")
814       {
815         chdir "align";
816         `make clean $SILENT`;
817         &flush_command ("make $arguments all");
818         &check_cp ("$pg", $BIN);
819       }
820     elsif ( $pg eq "proda")
821       {
822         &flush_command ("make $arguments all");
823         &check_cp ("$pg", $BIN);
824       }
825     elsif ( $pg eq "prank")
826       {
827         &flush_command ("make $arguments all");
828         &check_cp ("$pg", $BIN);
829       }
830     elsif ( $pg eq "mustang")
831       {
832         &flush_command ("make $arguments all");
833         if ( $OS=~/windows/){&check_cp("./bin/MUSTANG_v.3", "$BIN/mustang.exe");}
834         else {&check_cp("./bin/MUSTANG_v.3", "$BIN/mustang");}
835       }
836     elsif ( $pg eq "RNAplfold")
837       {
838         &flush_command("./configure");
839         &flush_command ("make $arguments all");
840         &check_cp("./Progs/RNAplfold", "$BIN");
841       }
842     chdir $CDIR;
843     return &pg_is_installed ($pg, $BIN);
844   }
845
846 sub install_t_coffee
847   {
848     my ($pg)=(@_);
849     my ($report,$cflags, $arguments, $language, $compiler) ;
850     #1-Install T-Coffee
851     chdir "t_coffee_source";
852     &flush_command ("make clean");
853     print "\n------- Compiling T-Coffee\n";
854     $language=$PG{$pg} {language2};
855     $arguments=$PG{$language}{arguments};
856     if (!($arguments =~/CFLAGS/)){$arguments .= " CFLAGS=-O2 ";}
857
858     if ( $CC ne ""){&flush_command ("make -i $arguments t_coffee");}
859     &check_cp ($pg, $BIN);
860     
861     chdir $CDIR;
862     return &pg_is_installed ($pg, $BIN);
863   }
864 sub install_TMalign
865   {
866     my ($pg)=(@_);
867     my $report;
868     chdir "t_coffee_source";
869     print "\n------- Compiling TMalign\n";
870     `rm TMalign TMalign.exe $SILENT`;
871     if ( $FC ne ""){&flush_command ("make -i $PG{Fortran}{arguments} TMalign");}
872     &check_cp ($pg, $BIN);
873     if ( !-e "$BIN/$pg" && pg_has_binary_distrib ($pg))
874       {
875         print "!!!!!!! Compilation of $pg impossible. Will try to install from binary\n";
876         return &install_binary_package ($pg);
877       }
878     chdir $CDIR;
879     return &pg_is_installed ($pg, $BIN);
880   }
881
882 sub pg_has_binary_distrib
883   {
884     my ($pg)=(@_);
885     if ($PG{$pg}{windows}){return 1;}
886     elsif ($PG{$pg}{osx}){return 1;}
887     elsif ($PG{$pg}{linux}){return 1;}
888     return 0;
889   }
890 sub install_binary_package
891   {
892     my ($pg)=(@_);
893     my ($base,$report,$name, $download, $arguments, $language, $dir);
894     my $isdir;
895     &input_os();
896     
897     if (!&supported_os($OS)){return 0;}
898     if ( $PG{$pg}{binary}){$name=$PG{$pg}{binary};}
899     else 
900       {
901         $name=$pg;
902         if ( $OS eq "windows"){$name.=".exe";}
903       }
904     
905     $download="$WEB_BASE/Packages/Binaries/$OS/$name";
906     
907     $base=cwd();
908     chdir $TMP;
909     
910     if (!-e $name)
911       {
912         `rm x $SILENT`;
913         if ( url2file("$download","x")==$EXIT_SUCCESS)
914           {
915             `mv x $name`;
916           }
917       }
918     
919     if (!-e $name)
920       {
921         print "!!!!!!! $PG{$pg}{dname}: Download of $pg binary failed\n";
922         print "!!!!!!! $PG{$pg}{dname}: Check Address: $download\n";
923         return 0;
924       }
925     print "\n------- Installing $pg\n";
926     
927     if ($name =~/tar\.gz/)
928       {
929         `gunzip  $name`;
930         `tar -xvf $pg.tar`;
931         chdir $pg;
932         if ( $pg eq "mafft")
933           {
934             if ($ROOT_INSTALL)
935               {
936                 &root_run ("You Must be Roor to Install MAFFT\n", "$CP mafft/bin/* /usr/local/mafft;mkdir /usr/local/mafft/; $CP mafft/lib/* /usr/local/bin/");
937               }
938             else
939               {
940                 `$CP $TMP/$pg/bin/* $BIN $SILENT`;
941                 `$CP $TMP/$pg/lib/* $BIN $SILENT`;
942               }
943           }
944         else
945           {
946             if (-e "$TMP/$pg/data"){`$CP $TMP/$pg/data/* $TCM $SILENT`;}
947             if (!($pg=~/\*/)){`rm -rf $pg`;}
948           }
949       }
950     else
951       {
952         &check_cp ("$pg", "$BIN");
953         `chmod u+x $BIN/$pg`; 
954         unlink ($pg);
955       }
956     chdir $base;
957     $PG{$pg}{from_binary}=1;
958     return &pg_is_installed ($pg, $BIN);
959   }
960
961 ################################################################################
962 #                                                                               #
963 #                                                                               #
964 #                                                                               #
965 #                   Simple Utilities                                            #
966 #                                                                               #
967 #                                                                               #
968 #                                                                               #
969 #################################################################################
970 sub add_dir 
971   {
972     my $dir=@_[0];
973     
974     if (!-e $dir && !-d $dir)
975       {
976         return mkpath ($dir);
977       }
978     else
979       {
980         return 0;
981       }
982   }
983 sub check_rm 
984   {
985     my ($file)=(@_);
986     
987     if ( -e $file)
988       {
989         return unlink($file);
990       }
991     return 0;
992   }
993 sub check_cp
994   {
995     my ($from, $to)=(@_);
996     if ( !-e $from && -e "$from\.exe"){$from="$from\.exe";}
997     if ( !-e $from){return 0;}
998         
999     `$CP $from $to`;
1000     return 1;
1001   }
1002 sub check_file_list_exists 
1003   {
1004     my ($base, @flist)=(@_);
1005     my $f;
1006
1007     foreach $f (@flist)
1008       {
1009         if ( !-e "$base/$f"){return 0;}
1010       }
1011     return 1;
1012   }
1013 sub ls
1014   {
1015     my $f=@_[0];
1016     my @fl;
1017     chomp(@fl=`ls -1 $f`);
1018     return @fl;
1019   }
1020 sub flush_command
1021   {
1022     my $command=@_[0];
1023     my $F=new FileHandle;
1024     open ($F, "$command|");
1025     while (<$F>){print "    --- $_";}
1026     close ($F);
1027   }    
1028
1029 sub input_installation_directory
1030   {
1031     my $dir=@_[0];
1032     my $new;
1033     
1034     print "------- The current installation directory is: [$dir]\n";
1035     print "??????? Return to keep the default or new value:";
1036    
1037     if ($NO_QUESTION==0)
1038       {
1039         chomp ($new=<stdin>);
1040         while ( $new ne "" && !input_yes ("You have entered $new. Is this correct? ([y]/n):"))
1041           {
1042             print "???????New installation directory:";
1043             chomp ($new=<stdin>);
1044           }
1045         $dir=($new eq "")?$dir:$new;
1046         $dir=~s/\/$//;
1047       }
1048     
1049     if ( -d $dir){return $dir;}
1050     elsif (&root_run ("You must be root to create $dir","mkdir $dir")==$EXIT_SUCCESS){return $dir;}
1051     else
1052       {
1053         print "!!!!!!! $dir could not be created\n";
1054         if ( $NO_QUESTION)
1055           {
1056             return "";
1057           }
1058         elsif ( &input_yes ("??????? Do you want to provide a new directory([y]/n)?:"))
1059           {
1060             return input_installation_directory ($dir);
1061           }
1062         else
1063           {
1064             return "";
1065           }
1066       }
1067     
1068   }
1069 sub input_yes
1070   {
1071     my $question =@_[0];
1072     my $answer;
1073
1074     if ($NO_QUESTION==1){return 1;}
1075     
1076     if ($question eq ""){$question="??????? Do you wish to proceed ([y]/n)?:";}
1077     print $question;
1078     chomp($answer=lc(<STDIN>));
1079     if (($answer=~/^y/) || $answer eq ""){return 1;}
1080     elsif ( ($answer=~/^n/)){return 0;}
1081     else
1082       {
1083         return input_yes($question);
1084       }
1085   }
1086 sub root_run
1087   {
1088     my ($txt, $cmd)=(@_);
1089     
1090     if ( system ($cmd)==$EXIT_SUCCESS){return $EXIT_SUCCESS;}
1091     else 
1092       {
1093         print "------- $txt\n";
1094         if ( $ROOT eq "sudo"){return system ("sudo $cmd");}
1095         else {return system ("su root -c \"$cmd\"");}
1096       }
1097   }
1098 #analyze environement
1099 sub get_root
1100   {
1101     if (&pg_is_installed ("sudo")){return "sudo";}
1102     else {return "su";}
1103   }
1104
1105 sub get_os
1106   {
1107     my $raw_os=`uname`;
1108     my $os;
1109
1110     $raw_os=lc ($raw_os);
1111     
1112     if ($raw_os =~/cygwin/){$os="windows";}
1113     elsif ($raw_os =~/linux/){$os="linux";}
1114     elsif ($raw_os =~/osx/){$os="macosx";}
1115     elsif ($raw_os =~/darwin/){$os="macosx";}
1116     else
1117       {
1118         $os=$raw_os;
1119       }
1120     return $os;
1121   }
1122 sub input_os
1123   {
1124     my $answer;
1125     if ($OS) {return $OS;}
1126     
1127     print "??????? which os do you use: [w]indows, [l]inux, [m]acosx:?";
1128     $answer=lc(<STDIN>);
1129
1130     if (($answer=~/^m/)){$OS="macosx";}
1131     elsif ( ($answer=~/^w/)){$OS="windows";}
1132     elsif ( ($answer=~/^linux/)){$OS="linux";}
1133     
1134     else
1135       {
1136         return &input_os();
1137       }
1138     return $OS;
1139   }
1140
1141 sub supported_os
1142   {
1143     my ($os)=(@_[0]);
1144     return $SUPPORTED_OS{$os};
1145   }
1146     
1147     
1148 ################################################################################
1149 #                                                                               #
1150 #                                                                               #
1151 #                                                                               #
1152 #                  update/initialize links                                      #
1153 #                                                                               #
1154 #                                                                               #
1155 #                                                                               #
1156 #################################################################################
1157
1158
1159 sub update_tclinkdb 
1160   {
1161     my $file =@_[0];
1162     my $name;
1163     my $F=new FileHandle;
1164     my ($download, $address, $name, $l, $db);
1165     
1166     if ( $file eq "update"){$file=$TCLINKDB_ADDRESS;}
1167     
1168     if ( $file =~/http:\/\// || $file =~/ftp:\/\//)
1169       {
1170         ($address, $name)=($download=~/(.*)\/([^\/]+)$/);
1171         `rm x $SILENT`;
1172         if (&url2file ($file,"x")==$EXIT_SUCCESS)
1173           {
1174             print "------- Susscessful upload of $name";
1175             `mv x $name`;
1176             $file=$name;
1177           }
1178       }
1179     open ($F, "$file");
1180     while (<$F>)
1181       {
1182         my $l=$_;
1183         if (($l =~/^\/\//) || ($db=~/^#/)){;}
1184         elsif ( !($l =~/\w/)){;}
1185         else
1186           {
1187             my @v=split (/\s+/, $l);
1188             if ( $l=~/^MODE/)
1189               {
1190                 $MODE{$v[1]}{$v[2]}=$v[3];
1191               }
1192             elsif ($l=~/^PG/)
1193               {
1194                 $PG{$v[1]}{$v[2]}=$v[3];
1195               }
1196           }
1197       }
1198     close ($F);
1199     &post_process_PG();
1200     return;
1201   }
1202
1203
1204
1205 sub initialize_PG
1206   {
1207     
1208 $PG{"t_coffee"}{"4_TCOFFEE"}="TCOFFEE";
1209 $PG{"t_coffee"}{"type"}="sequence_multiple_aligner";
1210 $PG{"t_coffee"}{"ADDRESS"}="http://www.tcoffee.org";
1211 $PG{"t_coffee"}{"language"}="C";
1212 $PG{"t_coffee"}{"language2"}="C";
1213 $PG{"t_coffee"}{"source"}="http://www.tcoffee.org/Packages/T-COFFEE_distribution.tar.gz";
1214 $PG{"t_coffee"}{"update_action"}="always";
1215 $PG{"t_coffee"}{"mode"}="tcoffee,mcoffee,rcoffee,expresso,3dcoffee";
1216 $PG{"clustalw2"}{"4_TCOFFEE"}="CLUSTALW2";
1217 $PG{"clustalw2"}{"type"}="sequence_multiple_aligner";
1218 $PG{"clustalw2"}{"ADDRESS"}="http://www.clustal.org";
1219 $PG{"clustalw2"}{"language"}="C++";
1220 $PG{"clustalw2"}{"language2"}="CXX";
1221 $PG{"clustalw2"}{"source"}="http://www.clustal.org/download/2.0.10/clustalw-2.0.10-src.tar.gz";
1222 $PG{"clustalw2"}{"mode"}="mcoffee,rcoffee";
1223 $PG{"clustalw"}{"4_TCOFFEE"}="CLUSTALW";
1224 $PG{"clustalw"}{"type"}="sequence_multiple_aligner";
1225 $PG{"clustalw"}{"ADDRESS"}="http://www.clustal.org";
1226 $PG{"clustalw"}{"language"}="C";
1227 $PG{"clustalw"}{"language2"}="C";
1228 $PG{"clustalw"}{"source"}="http://www.clustal.org/download/1.X/ftp-igbmc.u-strasbg.fr/pub/ClustalW/clustalw1.82.UNIX.tar.gz";
1229 $PG{"clustalw"}{"mode"}="mcoffee,rcoffee";
1230 $PG{"dialign-t"}{"4_TCOFFEE"}="DIALIGNT";
1231 $PG{"dialign-t"}{"type"}="sequence_multiple_aligner";
1232 $PG{"dialign-t"}{"ADDRESS"}="http://dialign-tx.gobics.de/";
1233 $PG{"dialign-t"}{"DIR"}="/usr/share/dialign-tx/";
1234 $PG{"dialign-t"}{"language"}="C";
1235 $PG{"dialign-t"}{"language2"}="C";
1236 $PG{"dialign-t"}{"source"}="http://dialign-tx.gobics.de/DIALIGN-TX_1.0.1.tar.gz";
1237 $PG{"dialign-t"}{"mode"}="mcoffee";
1238 $PG{"dialign-t"}{"binary"}="dialign-t";
1239 $PG{"dialign-tx"}{"4_TCOFFEE"}="DIALIGNTX";
1240 $PG{"dialign-tx"}{"type"}="sequence_multiple_aligner";
1241 $PG{"dialign-tx"}{"ADDRESS"}="http://dialign-tx.gobics.de/";
1242 $PG{"dialign-tx"}{"DIR"}="/usr/share/dialign-tx/";
1243 $PG{"dialign-tx"}{"language"}="C";
1244 $PG{"dialign-tx"}{"language2"}="C";
1245 $PG{"dialign-tx"}{"source"}="http://dialign-tx.gobics.de/DIALIGN-TX_1.0.1.tar.gz";
1246 $PG{"dialign-tx"}{"mode"}="mcoffee";
1247 $PG{"dialign-tx"}{"binary"}="dialign-tx";
1248 $PG{"poa"}{"4_TCOFFEE"}="POA";
1249 $PG{"poa"}{"type"}="sequence_multiple_aligner";
1250 $PG{"poa"}{"ADDRESS"}="http://www.bioinformatics.ucla.edu/poa/";
1251 $PG{"poa"}{"language"}="C";
1252 $PG{"poa"}{"language2"}="C";
1253 $PG{"poa"}{"source"}="http://downloads.sourceforge.net/poamsa/poaV2.tar.gz";
1254 $PG{"poa"}{"DIR"}="/usr/share/";
1255 $PG{"poa"}{"FILE1"}="blosum80.mat";
1256 $PG{"poa"}{"mode"}="mcoffee";
1257 $PG{"poa"}{"binary"}="poa";
1258 $PG{"probcons"}{"4_TCOFFEE"}="PROBCONS";
1259 $PG{"probcons"}{"type"}="sequence_multiple_aligner";
1260 $PG{"probcons"}{"ADDRESS"}="http://probcons.stanford.edu/";
1261 $PG{"probcons"}{"language2"}="CXX";
1262 $PG{"probcons"}{"language"}="C++";
1263 $PG{"probcons"}{"source"}="http://probcons.stanford.edu/probcons_v1_12.tar.gz";
1264 $PG{"probcons"}{"mode"}="mcoffee";
1265 $PG{"probcons"}{"binary"}="probcons";
1266 $PG{"mafft"}{"4_TCOFFEE"}="MAFFT";
1267 $PG{"mafft"}{"type"}="sequence_multiple_aligner";
1268 $PG{"mafft"}{"ADDRESS"}="http://align.bmr.kyushu-u.ac.jp/mafft/online/server/";
1269 $PG{"mafft"}{"language"}="C";
1270 $PG{"mafft"}{"language"}="C";
1271 $PG{"mafft"}{"source"}="http://align.bmr.kyushu-u.ac.jp/mafft/software/mafft-6.603-with-extensions-src.tgz";
1272 $PG{"mafft"}{"windows"}="http://align.bmr.kyushu-u.ac.jp/mafft/software/mafft-6.603-mingw.tar";
1273 $PG{"mafft"}{"mode"}="mcoffee,rcoffee";
1274 $PG{"mafft"}{"binary"}="mafft.tar.gz";
1275 $PG{"muscle"}{"4_TCOFFEE"}="MUSCLE";
1276 $PG{"muscle"}{"type"}="sequence_multiple_aligner";
1277 $PG{"muscle"}{"ADDRESS"}="http://www.drive5.com/muscle/";
1278 $PG{"muscle"}{"language"}="C++";
1279 $PG{"muscle"}{"language2"}="GPP";
1280 $PG{"muscle"}{"source"}="http://www.drive5.com/muscle/downloads3.6/muscle3.6_src.tar.gz";
1281 $PG{"muscle"}{"windows"}="http://www.drive5.com/muscle/downloads3.6/muscle3.6_win32.zip";
1282 $PG{"muscle"}{"linux"}="http://www.drive5.com/muscle/downloads3.6/muscle3.6_linux_ia32.tar.gz";
1283 $PG{"muscle"}{"mode"}="mcoffee,rcoffee";
1284 $PG{"pcma"}{"4_TCOFFEE"}="PCMA";
1285 $PG{"pcma"}{"type"}="sequence_multiple_aligner";
1286 $PG{"pcma"}{"ADDRESS"}="ftp://iole.swmed.edu/pub/PCMA/";
1287 $PG{"pcma"}{"language"}="C";
1288 $PG{"pcma"}{"language2"}="C";
1289 $PG{"pcma"}{"source"}="ftp://iole.swmed.edu/pub/PCMA/pcma.tar.gz";
1290 $PG{"pcma"}{"mode"}="mcoffee";
1291 $PG{"kalign"}{"4_TCOFFEE"}="KALIGN";
1292 $PG{"kalign"}{"type"}="sequence_multiple_aligner";
1293 $PG{"kalign"}{"ADDRESS"}="http://msa.cgb.ki.se";
1294 $PG{"kalign"}{"language"}="C";
1295 $PG{"kalign"}{"language2"}="C";
1296 $PG{"kalign"}{"source"}="http://msa.cgb.ki.se/downloads/kalign/current.tar.gz";
1297 $PG{"kalign"}{"mode"}="mcoffee";
1298 $PG{"amap"}{"4_TCOFFEE"}="AMAP";
1299 $PG{"amap"}{"type"}="sequence_multiple_aligner";
1300 $PG{"amap"}{"ADDRESS"}="http://bio.math.berkeley.edu/amap/";
1301 $PG{"amap"}{"language"}="C++";
1302 $PG{"amap"}{"language2"}="CXX";
1303 $PG{"amap"}{"source"}="http://baboon.math.berkeley.edu/amap/download/amap.2.2.tar.gz";
1304 $PG{"amap"}{"mode"}="mcoffee";
1305 $PG{"proda"}{"4_TCOFFEE"}="PRODA";
1306 $PG{"proda"}{"type"}="sequence_multiple_aligner";
1307 $PG{"proda"}{"ADDRESS"}="http://proda.stanford.edu";
1308 $PG{"proda"}{"language"}="C++";
1309 $PG{"proda"}{"language2"}="CXX";
1310 $PG{"proda"}{"source"}="http://proda.stanford.edu/proda_1_0.tar.gz";
1311 $PG{"proda"}{"mode"}="mcoffee";
1312 $PG{"prank"}{"4_TCOFFEE"}="PRANK";
1313 $PG{"prank"}{"type"}="sequence_multiple_aligner";
1314 $PG{"prank"}{"ADDRESS"}="http://www.ebi.ac.uk/goldman-srv/prank/";
1315 $PG{"prank"}{"language"}="C++";
1316 $PG{"prank"}{"language2"}="CXX";
1317 $PG{"prank"}{"source"}="http://www.ebi.ac.uk/goldman-srv/prank/src/old/prank.src.081202.tgz";
1318 $PG{"prank"}{"mode"}="mcoffee";
1319 $PG{"sap"}{"4_TCOFFEE"}="SAP";
1320 $PG{"sap"}{"type"}="structure_pairwise_aligner";
1321 $PG{"sap"}{"ADDRESS"}="http://mathbio.nimr.mrc.ac.uk/wiki/Software";
1322 $PG{"sap"}{"language"}="C";
1323 $PG{"sap"}{"language2"}="C";
1324 $PG{"sap"}{"source"}="http://www.tcoffee.org/Packages/sap_distribution_TCC_0.6.tar.gz";
1325 $PG{"sap"}{"mode"}="expresso,3dcoffee";
1326 $PG{"TMalign"}{"4_TCOFFEE"}="TMALIGN";
1327 $PG{"TMalign"}{"type"}="structure_pairwise_aligner";
1328 $PG{"TMalign"}{"ADDRESS"}="http://zhang.bioinformatics.ku.edu/TM-align/TMalign.f";
1329 $PG{"TMalign"}{"language"}="Fortran";
1330 $PG{"TMalign"}{"language2"}="Fortran";
1331 $PG{"TMalign"}{"source"}="http://zhang.bioinformatics.ku.edu/TM-align/TMalign.f";
1332 $PG{"TMalign"}{"linux"}="http://zhang.bioinformatics.ku.edu/TM-align/TMalign_32.gz";
1333 $PG{"TMalign"}{"mode"}="expresso,3dcoffee";
1334 $PG{"mustang"}{"4_TCOFFEE"}="MUSTANG";
1335 $PG{"mustang"}{"type"}="structure_pairwise_aligner";
1336 $PG{"mustang"}{"ADDRESS"}="http://www.cs.mu.oz.au/~arun/mustang";
1337 $PG{"mustang"}{"language"}="C++";
1338 $PG{"mustang"}{"language2"}="CXX";
1339 $PG{"mustang"}{"source"}="http://www.cs.mu.oz.au/~arun/mustang/mustang_v.3.tgz";
1340 $PG{"mustang"}{"mode"}="expresso,3dcoffee";
1341 $PG{"lsqman"}{"4_TCOFFEE"}="LSQMAN";
1342 $PG{"lsqman"}{"type"}="structure_pairwise_aligner";
1343 $PG{"lsqman"}{"ADDRESS"}="empty";
1344 $PG{"lsqman"}{"language"}="empty";
1345 $PG{"lsqman"}{"language2"}="empty";
1346 $PG{"lsqman"}{"source"}="empty";
1347 $PG{"lsqman"}{"update_action"}="never";
1348 $PG{"lsqman"}{"mode"}="expresso,3dcoffee";
1349 $PG{"align_pdb"}{"4_TCOFFEE"}="ALIGN_PDB";
1350 $PG{"align_pdb"}{"type"}="structure_pairwise_aligner";
1351 $PG{"align_pdb"}{"ADDRESS"}="empty";
1352 $PG{"align_pdb"}{"language"}="empty";
1353 $PG{"align_pdb"}{"language2"}="empty";
1354 $PG{"align_pdb"}{"source"}="empty";
1355 $PG{"align_pdb"}{"update_action"}="never";
1356 $PG{"align_pdb"}{"mode"}="expresso,3dcoffee";
1357 $PG{"fugueali"}{"4_TCOFFEE"}="FUGUE";
1358 $PG{"fugueali"}{"type"}="structure_pairwise_aligner";
1359 $PG{"fugueali"}{"ADDRESS"}="http://www-cryst.bioc.cam.ac.uk/fugue/download.html";
1360 $PG{"fugueali"}{"language"}="empty";
1361 $PG{"fugueali"}{"language2"}="empty";
1362 $PG{"fugueali"}{"source"}="empty";
1363 $PG{"fugueali"}{"update_action"}="never";
1364 $PG{"fugueali"}{"mode"}="expresso,3dcoffee";
1365 $PG{"dalilite.pl"}{"4_TCOFFEE"}="DALILITEc";
1366 $PG{"dalilite.pl"}{"type"}="structure_pairwise_aligner";
1367 $PG{"dalilite.pl"}{"ADDRESS"}="built_in";
1368 $PG{"dalilite.pl"}{"ADDRESS2"}="http://www.ebi.ac.uk/Tools/webservices/services/dalilite";
1369 $PG{"dalilite.pl"}{"language"}="Perl";
1370 $PG{"dalilite.pl"}{"language2"}="Perl";
1371 $PG{"dalilite.pl"}{"source"}="empty";
1372 $PG{"dalilite.pl"}{"update_action"}="never";
1373 $PG{"dalilite.pl"}{"mode"}="expresso,3dcoffee";
1374 $PG{"probconsRNA"}{"4_TCOFFEE"}="PROBCONSRNA";
1375 $PG{"probconsRNA"}{"type"}="RNA_multiple_aligner";
1376 $PG{"probconsRNA"}{"ADDRESS"}="http://probcons.stanford.edu/";
1377 $PG{"probconsRNA"}{"language"}="C++";
1378 $PG{"probconsRNA"}{"language2"}="CXX";
1379 $PG{"probconsRNA"}{"source"}="http://probcons.stanford.edu/probconsRNA.tar.gz";
1380 $PG{"probconsRNA"}{"mode"}="mcoffee,rcoffee";
1381 $PG{"sfold"}{"4_TCOFFEE"}="CONSAN";
1382 $PG{"sfold"}{"type"}="RNA_pairwise_aligner";
1383 $PG{"sfold"}{"ADDRESS"}="http://selab.janelia.org/software/consan/";
1384 $PG{"sfold"}{"language"}="empty";
1385 $PG{"sfold"}{"language2"}="empty";
1386 $PG{"sfold"}{"source"}="empty";
1387 $PG{"sfold"}{"update_action"}="never";
1388 $PG{"sfold"}{"mode"}="rcoffee";
1389 $PG{"RNAplfold"}{"4_TCOFFEE"}="RNAPLFOLD";
1390 $PG{"RNAplfold"}{"type"}="RNA_secondarystructure_predictor";
1391 $PG{"RNAplfold"}{"ADDRESS"}="http://www.tbi.univie.ac.at/~ivo/RNA/";
1392 $PG{"RNAplfold"}{"language"}="C";
1393 $PG{"RNAplfold"}{"language2"}="C";
1394 $PG{"RNAplfold"}{"source"}="http://www.tbi.univie.ac.at/~ivo/RNA/ViennaRNA-1.7.2.tar.gz";
1395 $PG{"RNAplfold"}{"mode"}="rcoffee";
1396 $PG{"hmmtop"}{"4_TCOFFEE"}="HMMTOP";
1397 $PG{"hmmtop"}{"type"}="protein_secondarystructure_predictor";
1398 $PG{"hmmtop"}{"ADDRESS"}="www.enzim.hu/hmmtop/";
1399 $PG{"hmmtop"}{"language"}="C";
1400 $PG{"hmmtop"}{"language2"}="C";
1401 $PG{"hmmtop"}{"source"}="empty";
1402 $PG{"hmmtop"}{"update_action"}="never";
1403 $PG{"hmmtop"}{"mode"}="tcoffee";
1404 $PG{"gorIV"}{"4_TCOFFEE"}="GOR4";
1405 $PG{"gorIV"}{"type"}="protein_secondarystructure_predictor";
1406 $PG{"gorIV"}{"ADDRESS"}="http://mig.jouy.inra.fr/logiciels/gorIV/";
1407 $PG{"gorIV"}{"language"}="C";
1408 $PG{"gorIV"}{"language2"}="C";
1409 $PG{"gorIV"}{"source"}="http://mig.jouy.inra.fr/logiciels/gorIV/GOR_IV.tar.gz";
1410 $PG{"gorIV"}{"update_action"}="never";
1411 $PG{"gorIV"}{"mode"}="tcoffee";
1412 $PG{"wublast.pl"}{"4_TCOFFEE"}="EBIWUBLASTc";
1413 $PG{"wublast.pl"}{"type"}="protein_homology_predictor";
1414 $PG{"wublast.pl"}{"ADDRESS"}="built_in";
1415 $PG{"wublast.pl"}{"ADDRESS2"}="http://www.ebi.ac.uk/Tools/webservices/services/wublast";
1416 $PG{"wublast.pl"}{"language"}="Perl";
1417 $PG{"wublast.pl"}{"language2"}="Perl";
1418 $PG{"wublast.pl"}{"source"}="empty";
1419 $PG{"wublast.pl"}{"update_action"}="never";
1420 $PG{"wublast.pl"}{"mode"}="psicoffee,expresso,3dcoffee";
1421 $PG{"blastpgp.pl"}{"4_TCOFFEE"}="EBIBLASTPGPc";
1422 $PG{"blastpgp.pl"}{"type"}="protein_homology_predictor";
1423 $PG{"blastpgp.pl"}{"ADDRESS"}="built_in";
1424 $PG{"blastpgp.pl"}{"ADDRESS2"}="http://www.ebi.ac.uk/Tools/webservices/services/blastpgp";
1425 $PG{"blastpgp.pl"}{"language"}="Perl";
1426 $PG{"blastpgp.pl"}{"language2"}="Perl";
1427 $PG{"blastpgp.pl"}{"source"}="empty";
1428 $PG{"blastpgp.pl"}{"update_action"}="never";
1429 $PG{"blastpgp.pl"}{"mode"}="psicoffee,expresso,3dcoffee";
1430 $PG{"blastcl3"}{"4_TCOFFEE"}="NCBIWEBBLAST";
1431 $PG{"blastcl3"}{"type"}="protein_homology_predictor";
1432 $PG{"blastcl3"}{"ADDRESS"}="ftp://ftp.ncbi.nih.gov/blast/executables/LATEST";
1433 $PG{"blastcl3"}{"language"}="C";
1434 $PG{"blastcl3"}{"language2"}="C";
1435 $PG{"blastcl3"}{"source"}="empty";
1436 $PG{"blastcl3"}{"update_action"}="never";
1437 $PG{"blastcl3"}{"mode"}="psicoffee,expresso,3dcoffee";
1438 $PG{"blastpgp"}{"4_TCOFFEE"}="NCBIBLAST";
1439 $PG{"blastpgp"}{"type"}="protein_homology_predictor";
1440 $PG{"blastpgp"}{"ADDRESS"}="ftp://ftp.ncbi.nih.gov/blast/executables/LATEST";
1441 $PG{"blastpgp"}{"language"}="C";
1442 $PG{"blastpgp"}{"language2"}="C";
1443 $PG{"blastpgp"}{"source"}="empty";
1444 $PG{"blastpgp"}{"update_action"}="never";
1445 $PG{"blastpgp"}{"mode"}="psicoffee,expresso,3dcoffee";
1446 $PG{"SOAP::Lite"}{"4_TCOFFEE"}="SOAPLITE";
1447 $PG{"SOAP::Lite"}{"type"}="library";
1448 $PG{"SOAP::Lite"}{"ADDRESS"}="http://cpansearch.perl.org/src/MKUTTER/SOAP-Lite-0.710.08/Makefile.PL";
1449 $PG{"SOAP::Lite"}{"language"}="Perl";
1450 $PG{"SOAP::Lite"}{"language2"}="Perl";
1451 $PG{"SOAP::Lite"}{"source"}="empty";
1452 $PG{"SOAP::Lite"}{"mode"}="psicoffee,expresso,3dcoffee";
1453 $MODE{"tcoffee"}{"name"}="tcoffee";
1454 $MODE{"rcoffee"}{"name"}="rcoffee";
1455 $MODE{"3dcoffee"}{"name"}="3dcoffee";
1456 $MODE{"mcoffee"}{"name"}="mcoffee";
1457 $MODE{"expresso"}{"name"}="expresso";
1458 #TclinkdbEnd End tag for the list updating
1459
1460 ########### Compilers ##############################
1461 #
1462 #
1463
1464 $PG{C}{compiler}="gcc";
1465 $PG{C}{compiler_flag}="CC";
1466 $PG{C}{options}="";
1467 $PG{C}{options_flag}="CFLAGS";
1468 $PG{C}{type}="compiler";
1469
1470 $PG{"CXX"}{compiler}="g++";
1471 $PG{"CXX"}{compiler_flag}="CXX";
1472 $PG{"CXX"}{options}="";
1473 $PG{"CXX"}{options_flag}="CXXFLAGS";
1474 $PG{CXX}{type}="compiler";
1475
1476 $PG{"CPP"}{compiler}="g++";
1477 $PG{"CPP"}{compiler_flag}="CPP";
1478 $PG{"CPP"}{options}="";
1479 $PG{"CPP"}{options_flag}="CPPFLAGS";
1480 $PG{CPP}{type}="compiler";
1481
1482 $PG{"GPP"}{compiler}="g++";
1483 $PG{"GPP"}{compiler_flag}="GPP";
1484 $PG{"GPP"}{options}="";
1485 $PG{"GPP"}{options_flag}="CFLAGS";
1486 $PG{GPP}{type}="compiler";
1487
1488 $PG{Fortran}{compiler}="g77";
1489 $PG{Fortran}{compiler_flag}="FCC";
1490 $PG{Fortran}{type}="compiler";
1491
1492 $PG{Perl}{compiler}="CPAN";
1493 $PG{Perl}{type}="compiler";
1494
1495 $SUPPORTED_OS{macox}="Macintosh";
1496 $SUPPORTED_OS{linux}="Linux";
1497 $SUPPORTED_OS{windows}="Cygwin";
1498
1499
1500
1501 $MODE{t_coffee}{description}=" for regular multiple sequence alignments";
1502 $MODE{rcoffee} {description}=" for RNA multiple sequence alignments";
1503
1504 $MODE{psicoffee} {description}=" for Homology Extended multiple sequence alignments";
1505 $MODE{expresso}{description}=" for very accurate structure based multiple sequence alignments";
1506 $MODE{"3dcoffee"}{description}=" for multiple structure alignments";
1507 $MODE{mcoffee} {description}=" for combining alternative multiple sequence alignment packages\n------- into a unique meta-package. The installer will upload several MSA packages and compile them\n
1508 ";
1509
1510
1511 &post_process_PG();
1512 return;
1513 }
1514
1515 sub post_process_PG
1516   {
1517     my $p;
1518     
1519     %PG=&name2dname (%PG);
1520     %MODE=&name2dname(%MODE);
1521     foreach $p (keys(%PG)){if ( $PG{$p}{type} eq "compiler"){$PG{$p}{update_action}="never";}}
1522     
1523   }
1524
1525 sub name2dname
1526   {
1527     my (%L)=(@_);
1528     my ($l, $ml);
1529     
1530     foreach my $pg (keys(%L))
1531       {
1532         $l=length ($pg);
1533         if ( $l>$ml){$ml=$l;}
1534       }
1535     $ml+=1;
1536     foreach my $pg (keys(%L))
1537       {
1538         my $name;
1539         $l=$ml-length ($pg);
1540         $name=$pg;
1541         for ( $b=0; $b<$l; $b++)
1542           {
1543             $name .=" ";
1544           }
1545         $L{$pg}{dname}=$name;
1546       }
1547     return %L;
1548   }
1549
1550 sub env_file2putenv
1551   {
1552     my $f=@_[0];
1553     my $F=new FileHandle;
1554     my $n;
1555     
1556     open ($F, "$f");
1557     while (<$F>)
1558       {
1559         my $line=$_;
1560         my($var, $value)=($_=~/(\S+)\=(\S*)/);
1561         $ENV{$var}=$value;
1562         $ENV_SET{$var}=1;
1563         $n++;
1564       }
1565     close ($F);
1566     return $n;
1567   }
1568