Modify Jpred for JABAWS
[jabaws.git] / binaries / src / jpred / lib / Paths.pm
index 6db85dc..9fa5ca3 100644 (file)
@@ -11,26 +11,44 @@ Paths - Sets paths for executable programs
 
 =head1 DESCRIPTION
 
-This module gathers together all of the little pieces of information that would other wise be floating around in all of the 
-other modules that run external programs. Namely, the path to the executable and nessecery environment variables. 
+This module gathers together all of the little pieces of information that would other wise be 
+floating around in all of the other modules that run external programs. Namely, the path to 
+the executable and nessecery environment variables. 
 
-Putting it all here should mean that this is the only file that needs updating when their location changes, or it's redeployed. 
-Plus some degree of automagic can be used to try and detect changes.
+Putting it all here should mean that this is the only file that needs updating when their 
+location changes, or it's redeployed. Plus some degree of automagic can be used to try 
+and detect changes.
 
 =cut
 
-our @EXPORT_OK = qw($ff_bignet $analyze $batchman $sov $pairwise $oc $jnet $fastacmd $hmmbuild $hmmconvert $psiblastbin check_OS);
+our @EXPORT_OK = qw(
+  $ff_bignet
+  $analyze
+  $batchman
+  $sov
+  $pairwise
+  $oc
+  $jnet
+  $fastacmd
+  $hmmbuild
+  $hmmconvert
+  $psiblastbin
+  check_OS
+  setup_env
+);
 
 my $HOME = $ENV{HOME};
-
+#
 # main production path
 #my $SOFTDIR = '/homes/www-jpred/live/jpred/bin';
 #my $platform_dir = "x86_64";
+#
 # development path
 #my $SOFTDIR = '/homes/www-jpred/devel/jpred/bin';
 #my $platform_dir = "x86_64";
+#
 # my laptop test path
-my $SOFTDIR = '/home/asherstnev/Projects/Jpred.project/jpred/branches/portable';
+my $SOFTDIR       = '/home/asherstnev/Projects/Jpred.project/jpred/branches/portable';
 my $platform_name = "x86_64";
 
 our $pairwise    = "$SOFTDIR/$platform_name/pairwise";
@@ -47,26 +65,46 @@ our $analyze   = "$HOME/projects/Jnet/bin/snns/analyze";      # CC modified for
 our $batchman  = "$HOME/projects/Jnet/bin/snns/batchman";     # CC modified for new path (SNNS app)
 our $sov       = "$HOME/projects/Jnet/bin/sov";
 
-=head1 AUTOMATED CHANGES
+sub setup_env {
+  my $newsoftdir       = shift;
+  my $newplatform_name = shift;
 
-Currently the paths are altered on the basis of per host rules.
+  if ( defined $newsoftdir ) {
+    if ( -d $newsoftdir ) {
+      $SOFTDIR = $newsoftdir;
+    } else {
+      warn "setup_env: directory with Jpred software $newsoftdir does not exist. The default directory is used...\n";
+    }
+  }
+  if ( defined $newplatform_name ) {
+    $platform_name = $newplatform_name;
+  }
 
-=cut
+  $oc          = "$SOFTDIR/$platform_name/oc";
+  $jnet        = "$SOFTDIR/$platform_name/jnet";
+  $fastacmd    = "$SOFTDIR/$platform_name/fastacmd";
+  $pairwise    = "$SOFTDIR/$platform_name/pairwise";
+  $hmmbuild    = "$SOFTDIR/$platform_name/hmmbuild";
+  $psiblastbin = "$SOFTDIR/$platform_name/blastpgp";
+  $hmmconvert  = "$SOFTDIR/$platform_name/hmmconvert";
+}
 
 sub check_OS {
-  if ("linux" eq $^O or "Linux" eq $^O) {
+  if ( "linux" eq $^O or "Linux" eq $^O ) {
     my $status = system "uname -m > .platform";
     open my $PLH, "<", ".platform" or die "can't check platform information";
     my $plt = <$PLH>;
     close $PLH;
     chop $plt;
-    $platform_name = "i686" if ($plt =~ /i[3-6]86/);
-  } elsif ("MSWin32" eq $^O) {
+    $platform_name = "i686" if ( $plt =~ /i[3-6]86/ );
+  } elsif ( "MSWin32" eq $^O ) {
     $platform_name = "win";
   } else {
     warn "check_OS: unknown platform, I'll try to use x86_64 binaries....";
   }
 
+#  print "\n\ncheck_OS: SOFTDIR -> $SOFTDIR\n\n";
+
   $oc          = "$SOFTDIR/$platform_name/oc";
   $jnet        = "$SOFTDIR/$platform_name/jnet";
   $fastacmd    = "$SOFTDIR/$platform_name/fastacmd";