Modify Jpred for JABAWS
[jabaws.git] / binaries / src / jpred / lib / Paths.pm
1 package Paths;
2
3 use strict;
4 use warnings;
5 use base qw(Exporter);
6 use Sys::Hostname ();
7
8 =head1 NAME
9
10 Paths - Sets paths for executable programs
11
12 =head1 DESCRIPTION
13
14 This module gathers together all of the little pieces of information that would other wise be 
15 floating around in all of the other modules that run external programs. Namely, the path to 
16 the executable and nessecery environment variables. 
17
18 Putting it all here should mean that this is the only file that needs updating when their 
19 location changes, or it's redeployed. Plus some degree of automagic can be used to try 
20 and detect changes.
21
22 =cut
23
24 our @EXPORT_OK = qw(
25   $ff_bignet
26   $analyze
27   $batchman
28   $sov
29   $pairwise
30   $oc
31   $jnet
32   $fastacmd
33   $hmmbuild
34   $hmmconvert
35   $psiblastbin
36   check_OS
37   setup_env
38 );
39
40 my $HOME = $ENV{HOME};
41 #
42 # main production path
43 #my $SOFTDIR = '/homes/www-jpred/live/jpred/bin';
44 #my $platform_dir = "x86_64";
45 #
46 # development path
47 #my $SOFTDIR = '/homes/www-jpred/devel/jpred/bin';
48 #my $platform_dir = "x86_64";
49 #
50 # my laptop test path
51 my $SOFTDIR       = '/home/asherstnev/Projects/Jpred.project/jpred/branches/portable';
52 my $platform_name = "x86_64";
53
54 our $pairwise    = "$SOFTDIR/$platform_name/pairwise";
55 our $oc          = "$SOFTDIR/$platform_name/oc";
56 our $jnet        = "$SOFTDIR/$platform_name/jnet";
57 our $fastacmd    = "$SOFTDIR/$platform_name/fastacmd";
58 our $hmmbuild    = "$SOFTDIR/$platform_name/hmmbuild";
59 our $hmmconvert  = "$SOFTDIR/$platform_name/hmmconvert";
60 our $psiblastbin = "$SOFTDIR/$platform_name/blastpgp";
61
62 # required for training with SNNS, but unused currently
63 our $ff_bignet = "$HOME/projects/Jnet/bin/snns/ff_bignet";    # CC modified for new path (SNNS app)
64 our $analyze   = "$HOME/projects/Jnet/bin/snns/analyze";      # CC modified for new path (SNNS app)
65 our $batchman  = "$HOME/projects/Jnet/bin/snns/batchman";     # CC modified for new path (SNNS app)
66 our $sov       = "$HOME/projects/Jnet/bin/sov";
67
68 sub setup_env {
69   my $newsoftdir       = shift;
70   my $newplatform_name = shift;
71
72   if ( defined $newsoftdir ) {
73     if ( -d $newsoftdir ) {
74       $SOFTDIR = $newsoftdir;
75     } else {
76       warn "setup_env: directory with Jpred software $newsoftdir does not exist. The default directory is used...\n";
77     }
78   }
79   if ( defined $newplatform_name ) {
80     $platform_name = $newplatform_name;
81   }
82
83   $oc          = "$SOFTDIR/$platform_name/oc";
84   $jnet        = "$SOFTDIR/$platform_name/jnet";
85   $fastacmd    = "$SOFTDIR/$platform_name/fastacmd";
86   $pairwise    = "$SOFTDIR/$platform_name/pairwise";
87   $hmmbuild    = "$SOFTDIR/$platform_name/hmmbuild";
88   $psiblastbin = "$SOFTDIR/$platform_name/blastpgp";
89   $hmmconvert  = "$SOFTDIR/$platform_name/hmmconvert";
90 }
91
92 sub check_OS {
93   if ( "linux" eq $^O or "Linux" eq $^O ) {
94     my $status = system "uname -m > .platform";
95     open my $PLH, "<", ".platform" or die "can't check platform information";
96     my $plt = <$PLH>;
97     close $PLH;
98     chop $plt;
99     $platform_name = "i686" if ( $plt =~ /i[3-6]86/ );
100   } elsif ( "MSWin32" eq $^O ) {
101     $platform_name = "win";
102   } else {
103     warn "check_OS: unknown platform, I'll try to use x86_64 binaries....";
104   }
105
106 #  print "\n\ncheck_OS: SOFTDIR -> $SOFTDIR\n\n";
107
108   $oc          = "$SOFTDIR/$platform_name/oc";
109   $jnet        = "$SOFTDIR/$platform_name/jnet";
110   $fastacmd    = "$SOFTDIR/$platform_name/fastacmd";
111   $pairwise    = "$SOFTDIR/$platform_name/pairwise";
112   $hmmbuild    = "$SOFTDIR/$platform_name/hmmbuild";
113   $psiblastbin = "$SOFTDIR/$platform_name/blastpgp";
114   $hmmconvert  = "$SOFTDIR/$platform_name/hmmconvert";
115
116   return $platform_name;
117 }
118
119 =head1 AUTOMATED CHANGES
120
121 Currently the paths are altered on the basis of per host rules.
122
123 =cut
124
125 1;