[Bioperl-l] SOAP::Lite and bioperl
Al Park
apark at dyax.com
Thu Sep 25 15:35:09 EDT 2003
Hello everyone,
I have been stumped for the past two days trying to figure out why I can't get the following code to work properly. I get an error telling me that it "Can't call method "run" on undefined value". Any help or suggestions for what I'm doing wrong?
Thanks in advance.
Al
######Soap::lite server code
#!/usr/bin/perl
use lib '/var/www/MODs';
use SOAP::Transport::HTTP;
use testpms;
my $server = SOAP::Transport::HTTP::CGI
->on_action(sub{return})
->dispatch_to('testpms::runTool');
$server->serializer->maptype->{SOAPStruct} = 'xsd1';
$server->handle;
######testpms.pm code
package testpms;
use strict;
use lib '/var/www/MODs';
use SoapExSeq;
use EmbossTools;
sub runTool{
my ($class,$program,$ids,$chain) = @_;
my ($dbh,$rc) = SoapExSeq::connectDB();
my $file = SoapExSeq::getSeq($dbh,$rc,$ids,$chain);
SoapExSeq::disconnectDB($dbh,$rc);
my $emboss = new EmbossTools;
my $hashRef = $emboss->eTools($program,$file);
my @val;
my %hash = %$hashRef;
foreach my $x (keys %hash){
if($x =~ /^\d+/){
my $value = $hash{$x};
my $item = SOAP::Data
->type("SOAPStruct")
->value({"isolate" => $x,
"value" => $value});
push(@val, $item);
}
}
return SOAP::Data->name("results" => \@val);
}
1;
#######EmbossTools.pm code
package EmbossTools;
use strict;
use Bio::Factory::EMBOSS;
BEGIN {
$ENV{EMBOSSDIR} = '/usr/local/bin/emboss/';
}
sub new{
my $class = shift;
my $self = {};
bless ($self, $class);
return $self;
}
sub eTools{
my $self = shift;
my ($program,$seq_to_test) = @_;
my (%hash);
my $outfile = sprintf "/var/www/tmp/out.%s.$program", time;
my $factory = new Bio::Factory::EMBOSS;
my $application = $factory->program($program);
if($program eq "iep"){ #handles fasta file
$application->run({ '-sequencea' => $seq_to_test,
'-graph' => 'none',
'-outfile' => $outfile});
}
my @all;
if($outfile){
if($outfile =~ /iep/){
my($isolate,$iep_value);
open(FH, "$outfile");
while(<FH>){
chomp;
if($_ =~ /IEP/){
($isolate = $_) =~ s/\w+\s\w+\s(.+)\sfrom.+$/$1/g;
}
if($_ =~ /Isoelectric/){
($iep_value = $_) =~ s/\w+\s\w+\s\=\s(.+)/$1/g;
$hash{$isolate} = $iep_value;
push(@all, $isolate, $iep_value);
}
}
close FH;
}
return (\%hash);
}
1;
More information about the Bioperl-l
mailing list