#!/usr/bin/perl # Description: This is a ProtFun ws client script. It reads a protein fasta file from STDIN and produces an annotation output # Author: Peter Fischer Hallin # Email: pfh@cbs.dtu.dk # Version: 2.2 ws0 # Date: 2008-11-22 # usage: perl protfun.pl < example.fsa use strict; # include standard XML::Compile helper functions (used to initiate WSDL proxys) require "xml-compile.pl"; # construct proxy to service - WSDLclient is a custom function defined in "xml-compile.pl" my $protfun = WSDLclient( 'http://www.cbs.dtu.dk/ws/ProtFun/ProtFun_2_2_ws0.wsdl' ); # read fasta from stdin my @fasta; my $entry = -1; while (<>) { if (/^>(.*)/) { my ($id , $comment) = split (" ",$1); $entry++; $fasta[$entry]->{id} = $id; $fasta[$entry]->{comment} = $comment if defined $comment; } elsif (/^([A-Za-z]+)/) { $fasta[$entry]->{seq} .= $1; } } # loop over fasta entries and build sequence request my @sequence; foreach my $i ( 0 .. $#fasta ) { push @sequence , { id => $fasta[$i]->{id} , comment => $fasta[$i]->{comment} , seq => $fasta[$i]->{seq} }; } my $response = $protfun->{runService}->( parameters => { parameters => { sequencedata => {sequence => [@sequence]} } }); die unless defined $response->{parameters}->{queueentry} ; my $jobid = $response->{parameters}->{queueentry}->{jobid}; &wait_job ($protfun->{pollQueue},$jobid); $response = $protfun->{fetchResult}->(job => { jobid => $jobid }); print "# method : ".$response->{parameters}->{anndata}->{annsource}->{method}."\n"; print "# version : ".$response->{parameters}->{anndata}->{annsource}->{version}."\n"; foreach my $ann (@{$response->{parameters}->{anndata}->{ann}}) { print "# sequence id : $ann->{sequence}->{id}\n", "# sequence comment : $ann->{sequence}->{comment}\n", "# sequence : $ann->{sequence}->{seq}\n"; foreach my $annrecord (@{$ann->{annrecords}->{annrecord}}) { my $flag = "-"; $flag = "=>" if $annrecord->{score}[2]->{value}; print join ( "\t", ( $annrecord->{feature}, $flag, $annrecord->{score}[0]->{key}.':'.$annrecord->{score}[0]->{value}, $annrecord->{score}[1]->{key}.':'.$annrecord->{score}[1]->{value} ))."\n"; } }