julio_514 has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks, Obviously, I still have a lot to learn on perl. Here is my latest prob: I wrote some code in perl using the bioperl modules. Everything went fine! Now I changed some of the script (added some cgi lines and stuff), to make it accessible for a web service. Basically, the user enters some input data (dna sequences) and the perl script returns an output analysis. However, it seems that I have a prob with the temporary directory, because on the server error log, I get error messages saying this:
align' is not recognized as an internal or external command, operable +program or batch file. -------------------- WARNING --------------------- MSG: Clustalw call ( align -infile=\\tmp\\WPGAS2NLA8\\jHRbMLTo05 -out +put=gcg -ktuple=2 -matrix=BLOSUM -outfile=\\tmp\\WPGAS2NLA8\\XTFEoZ +HFGV) crashed: 256 ---------------------------------------------------, Can't call method "uniq_seq" on an undefined value at C:/perl/site/lib +/transposonTool.pm line 67, <GEN0> line 4.,
Now on the documentation of Bio::Tools::Run::Alignment::Clustalw, it is said that this type of error occurs when the input directory or input file is wrong... Like I said before the script works perfect when I use it "offline". Is it possible that when my script is called from a web form, the tmp dir is somehow different than what it is normally? Is there anyway around it? Can I change something in the httpd.conf file ? I don't know what to try anymore... Julio

Replies are listed 'Best First'.
Re: perl - apache - winxp tmp dir???
by CountZero (Bishop) on Feb 08, 2009 at 22:59 UTC
    The webserver is most likely to run as a different user than you and as such there is a fair chance that indeed it uses different temporary directories or (even more likely) that the temporary directory you want to use cannot be accessed by the webserver.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: perl - apache - winxp tmp dir???
by wol (Hermit) on Feb 09, 2009 at 13:11 UTC
    As noted above, the Apache Windows service does indeed run as a different account ("Local System"). It has a completely different environment, and rather limited access rights. (Unless you configure the service to run as a specific user. But think twice before running your web service as a "real person" with rights to wreak a lot more havoc.)

    To illustrate the environment differences, compare the output of "set" at your command line with the output of system("set") in a perl CGI script.

    (Annoyingly, I don't think it's possible to run a command shell with the same account/privileges as Local System to help debug things like this. Please let me know if this isn't true!)

    In this particular case, you might like to start looking at the SystemDrive env variable that your CGI script sees, as the paths that the bioperl modules try to access will be relative to that. In concrete terms, maybe the file is created in D:\tmp\blah, but it's attempting to read it from C:\tmp\blah ?

    --
    use JAPH;
    print JAPH::asString();

Re: perl - apache - winxp tmp dir???
by almut (Canon) on Feb 09, 2009 at 14:36 UTC

    Try setting the environment variable CLUSTALDIR to the directory where the clustalw program is installed — presumably, that environment variable is not set in the context of the webserver. For example, you could write in your Perl code (somewhere near the top):

    BEGIN { $ENV{CLUSTALDIR} = 'C:/path/to/clustalw1.8/'; }

    Reasoning:  the above error message is generated by this code fragment from Bio/Tools/Run/Alignment/Clustalw.pm (in subroutine _run()):

    my $commandstring = $self->executable." $command"." $instring". " -output=$output". " $param_string"; $self->debug( "clustal command = $commandstring"); my $status = system($commandstring); $self->throw( "Clustalw call ($commandstring) crashed: $? \n") unl +ess $status==0;

    As it seems, $self->executable is empty/undefined, so that $commandstring begins with ' align' (the value of $command). As this isn't an executable, but rather a sub-command to the clustalw program, you're getting the generic error "align is not recognized as an internal or external command...", issued by the Windows command shell.

    $self->executable is a method inherited from Bio::Tools::Run::WrapperBase (which itself is part of the BioPerl distribution). That method calls another method program_path(), which in turn needs the method program_dir(). The latter is abstract/virtual in WrapperBase.pm, but is implemented in Bio::Tools::Run::Alignment::Clustalw:

    sub program_dir { return Bio::Root::IO->catfile($ENV{CLUSTALDIR}) if $ENV{CLUSTALDIR}; }

    As you can see, it gets the directory from CLUSTALDIR... — The docs also talk about a variable $clustdir ("to install clustalw on your system, edit the variable $clustdir in Clustalw.pm to point to the clustalw program"), however, that variable doesn't seem to occur anywhere except in that phrase...  OTOH, there's also this comment in the Clustalw.pm sources:

    # You will need to enable Clustalw to find the clustalw program. This # can be done in (at least) two ways: # # 1. define an environmental variable CLUSTALDIR: # export CLUSTALDIR=/home/peter/clustalw1.8 # # 2. include a definition of an environmental variable CLUSTALDIR in # every script that will use Clustal.pm. # $ENV{CLUSTALDIR} = '/home/peter/clustalw1.8/';

    Good luck!

      Thanx a lot for your answers! I surely missed that part on the Clustalw.pm CLUSTALDIR variable. Ok, I'll set that up tonight and come back with the results. I will also check that SystemDrive env... But in all cases, I guess that the best thing to do is to set my server in a linux env right?...Julio
        Ok, I solved the prob. As almut thought, the prob was with the environment variable CLUSTALDIR. What I needed to do was to set the env variable in the httpd.conf file. So I added the following line:
        setenv CLUSTALDIR c:/CLUSTALW/
        tada! Jesus I really spent time on this issue... Thank you again for your replies, I really appreciate it. Julio