[Bioperl-l] I can't access clustalw from my cgi perl program...

Mauricio Herrera Cuadra arareko at campus.iztacala.unam.mx
Wed May 21 23:14:46 UTC 2008


A couple of things inlined:

vdar at yorku.ca wrote:
> Yes, I've seen in that directory, but it doesn't exist. Another wierd thing
> which is being happening is that If I make this output file manually in that
> directory, it is read by the following code and printed on screen
> 
> 
> if ("out.aln.pfam"){
> 	open FH, "out.aln.pfam" || die "Alignment file doesn't exist</br>";
> 	while(<FH>){
> 
> 	print $_,"</br>";
> 	}
> 	close FH;
> }
> 
> only when this code is not followed by the original code. When its followed by
> the original code i.e.

Yeah, this works because you're placing the file there by hand, so it's 
found by the open() function, not the 'if ("out.aln.pfam")' statement 
(which, btw, always evaluates as TRUE). Something simpler like this will 
work as you expect and it's easier to understand:

open FH, "out.aln.pfam" or die "Alignment file doesn't exist<br />";
while (<FH>) {
     print $_, "<br />";
}
close FH;

> my  $in  = Bio::AlignIO->new(-file   => $file1 ,
> 				-format => 'fasta');
> 	my $out = Bio::AlignIO->new(-file   => ">out.aln.pfam" ,
> 				-format => 'pfam');
> 
> 
> 
> 	while ( my $aln1 = $in->next_aln() ) {
> 		$out->write_aln($aln1);
> 	}
> 
> 
> 
> 	if ("out.aln.pfam"){
> 	open FH, "out.aln.pfam" || die "Alignment file doesn't exist</br>";
> 	while(<FH>){
> 
> 	print $_,"</br>";
> 	}
> 	close FH;
> 	}
> 
> Nothing is printed on screen, while it stays there in the directory. I have
> changed the name of output file in this code but new file is not produced by
> this program. Does anyone know what is going on?

Apparently, this is a problem with permissions. Maybe your script lives 
under some directory (i.e. your home directory) which is owned by a 
different user than the one who is actually running the CGI interface 
(e.g. apache, nobody) ?? Check your Apache logs from another shell 
screen to see what is really happening while you run your script:

$ tail -f /path/to/your/apache/error.log

In a CGI environment, all Perl messages/warnings are printed to the 
webserver's log, not the standard output (your shell).

Mauricio.

> thanks
> nisa
> 
> 
> Quoting Mauricio Herrera Cuadra <arareko at campus.iztacala.unam.mx>:
> 
>> You're using '>out.aln.pfam' as the full path for the output file. Most
>> probably, the file is being produced but in the same location where the
>> CGI script lives. Check inside the same directory where you installed
>> your script.
>>
>>  Mauricio.
>>
>> vdar at yorku.ca wrote:
>>> ok thanks, its not giving me any error now, but its not doing anything too,
>> the
>>> following code works from commandline but not from my cgi script. I have
>> added
>>> the path to bioperl and have tried everything else that I could find...
>>>
>>>         my  $in  = Bio::AlignIO->new(-file   => $inputfilename ,
>>> 				-format => 'fasta');
>>> 	my $out = Bio::AlignIO->new(-file   => ">out.aln.pfam" ,
>>> 				-format => 'pfam');
>>>
>>>
>>>
>>> 	while ( my $aln1 = $in->next_aln() ) {
>>> 		$out->write_aln($aln1);
>>> 	}
>>>
>>>
>>> output file is not produced. what should I do?
>>>
>>> thanks
>>> nisa
>>>
>>>
>>> Quoting Sendu Bala <bix at sendu.me.uk>:
>>>
>>>> vdar at yorku.ca wrote:
>>>>> How can I find where bioperl is installed?
>>>> You already know where it's installed. See below.
>>>>
>>>>
>>>>> Quoting Mauricio Herrera Cuadra <arareko at campus.iztacala.unam.mx>:
>>>>>
>>>>>> Hi Nisa,
>>>>>>
>>>>>> CGI scripts are generally run by a different user than you, and which
>>>>>> user (e.g. apache, nobody) will depend on the platform you're running
>>>>>> the script on, thus the environment variables you currently have for
>>>>>> your login shell are not being inherited to the web interface. The best
>>>>>> workaround for this is to add a 'use lib' pragma at the top of your CGI
>>>>>> script:
>>>>>>
>>>>>> use lib '/path/to/your/bioperl/installation/';
>>>> [...]
>>>>>> vdar at yorku.ca wrote:
>>>>>>> export PERL5LIB="/opt/rocks/lib/perl5/site_perl/5.8.8"
>>>
>> --
>> MAURICIO HERRERA CUADRA
>> arareko at campus.iztacala.unam.mx
>> Laboratorio de Genética
>> Unidad de Morfofisiología y Función
>> Facultad de Estudios Superiores Iztacala, UNAM
>>
> 
> 

-- 
MAURICIO HERRERA CUADRA
arareko at campus.iztacala.unam.mx
Laboratorio de Genética
Unidad de Morfofisiología y Función
Facultad de Estudios Superiores Iztacala, UNAM



More information about the Bioperl-l mailing list