Perl examples

Here is a really simple Perl example of running a query against one of the predictors (GECO). If you want to send a query through the entire FuncNet pipeline, see the source code page.

#!/usr/bin/perl -w
 
# Really really simple demonstration script for FuncNet predictors (in this case GECO).
# This downloads and parses the WSDL, submits a job (two lists of proteins, query and
# reference) and prints out the results.
#
# Using this script for a different predictor requires you to change the URL, port,
# service and binding strings.
 
use strict;
use warnings;
 
use Data::Dumper;
use LWP::UserAgent;
use XML::Compile::WSDL11;
use XML::Compile::Transport::SOAPHTTP;
use XML::Compile::Schema;
 
my $ua = LWP::UserAgent->new;
my $wsdl_url = "http://funcnet.eu/soap/Geco.wsdl";
my $response = $ua->get( $wsdl_url );
unless( $response->is_success )
{
    warn "Could not retrieve $wsdl_url: ", $response->status_line, "\n";
    exit 1;
}
 
my $wsdl = XML::Compile::WSDL11->new( $response->content );
 
# warn "got: $wsdl";
 
my @op_defs = $wsdl->operations();
 
# warn "operations: ", join (", ", Dumper( @op_defs ) );
 
# warn "\$wsdl->compileClient( '{http://funcnet.eu/FuncNet_1_0/}GecoService' );";
 
my $op   = $wsdl->operation(
                operation   => 'ScorePairwiseRelations',
                port        => 'GecoPort',
                service     => '{http://funcnet.eu/FuncNet_1_0/}GecoService' ,
                binding     => '{http://funcnet.eu/FuncNet_1_0/}GecoBinding'
             );
 
my $op_call = $op->compileClient();
 
# proteins1 is query set, proteins2 is reference set
my $parameters = {
    proteins1 => { p => [ 'A3EXL0', 'A4D2E0', 'Q8NFN7', 'O75865', 'A8K8W3', 'A8K3I6' ] },
    proteins2 => { p => [ 'Q5SR05', 'Q9H8H3', 'P22676', 'Q9UHT8', 'P56277', 'P49366' ] }
};
 
my ( $answer, $trace ) = $op_call->( parameters => $parameters );
 
# warn Dumper( $trace );
 
# warn "Answer:", Dumper(  $answer->{ parameters } );
 
print "Prot 1\tProt 2\tP-value\n";
 
foreach my $result ( @{ $answer->{ parameters }->{ s } } )
{
    print $result->{ p1 } . "\t" . $result->{ p2 } . "\t" . $result->{ pv } . "\n";
}

If you have any problems with this script, check that your Perl libraries are up to date. In particular, we used the following modules:

LWP::UserAgent 5.826
XML::Compile::WSDL11 2.04
XML::Compile::Transport::SOAPHTTP 2.04
XML::Compile::Schema 1.05

See also the proper Perl client on CPAN.

Share/save this page:

  • email
  • Print
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Reddit
  • StumbleUpon
  • Technorati
  • DZone
  • Slashdot
  • Facebook
  • LinkedIn
  • Live
  • connotea

Leave a Reply