#!/usr/bin/perl # Description: This script runs the NetNES 1.1.ws0 Web Service. It reads FASTA file from STDIN and produces predictions in a simple table. # Author: Edita Bartaseviciute # Email: edita@cbs.dtu.dk # Version: 1.1 ws0 # Date: 2010-03-24 # usage: perl netnes.pl < example.fsa use strict; # include standard XML::Compile helper functions (used to initiate WSDL proxys) require "xml-compile.pl"; # downloadable from the same site as this script # create proxy to NetNES Web Service my $netnes = WSDL2proxy ( 'http://www.cbs.dtu.dk/ws/NetNES/NetNES_1_1_ws0.wsdl' ); # append schema definitions $netnes = appendSchemas ( $netnes , "http://www.cbs.dtu.dk/ws/common/ws_common_1_0b.xsd" , "http://www.cbs.dtu.dk/ws/NetNES/ws_netnes_1_1_ws0.xsd", "http://bioxsd.org/BioXSD-1.0.xsd" ); # create hash of operations from proxy my %ops = addOperations ( $netnes ) ; # Get sequence in fasta format 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; } } # Create sequence for request my @sequence; for ( my $i = 0 ; $i < scalar ( @fasta ) ; $i ++ ) { push @sequence , { sequence => $fasta[$i]->{seq}, formalReference => {accession => $fasta[$i]->{id} }}; } # Do the request my $response = $ops{runService}->( parameters => { parameters => { sequenceRecord => [@sequence]} } ); # uncomment the two following lines to inspect the structure of $response # use Data::Dumper; # print Dumper($response); # get job id which can be used to get the results later my $jobid; if ( ! defined ( $response->{parameters}->{queueentry}) ) { die "error obtaining jobid\n"; } else { $jobid = $response->{parameters}->{queueentry}->{jobid}; print STDERR "# waiting for job $jobid"; my $status = "UNKNOWN";; while ( $status =~ /ACTIVE|RUNNING|QUEUED|WAITING|PENDING|UNKNOWN/ ) { my $response = $ops{pollQueue}->( job => { job => { jobid => $jobid } }) ; $status = $response->{queueentry}->{queueentry}->{status}; print STDERR "."; } die "\nunexpected job status '$status'\n" unless $status eq "FINISHED"; print STDERR "\n# job has finished\n"; } # when the job is done, fetch the result $response = $ops{fetchResult}->(job => { jobid => $jobid }); # uncomment the two following lines to inspect the structure of $response # use Data::Dumper; # print Dumper($response); #printing the results my ($id, $pos, $score_ANN, $score_HMM, $score_NES, $finding); foreach my $annotatedSequence (@{$response->{parameters}->{annotatedSequence}}) { if (exists $annotatedSequence->{sequenceRecord}->{formalReference}) { $id = $annotatedSequence->{sequenceRecord}->{formalReference}->{accession}; } print ">$id - netNES 1.1 prediction\n", "#Seq-Pos-Residue\tANN\tHMM\tNES\tPredicted\n", "#---------------------------------------------------------\n"; foreach my $cho (@{$annotatedSequence->{cho_annotation}}) { foreach my $occurence (@{$cho->{annotation}->{occurence}}) { $pos = $occurence->{position}->{point}->{_}; foreach my $evidence (@{$occurence->{evidence}}){ if ($evidence->{predicted}->{verdict} eq "Impossible") { $finding = "-"; } elsif ($evidence->{predicted}->{verdict} eq "Present") { $finding = "Yes"; } foreach my $score (@{$evidence->{predicted}->{score}}) { if ($score->{type} eq "ANN") { $score_ANN = sprintf ("%.3f", $score->{value}); } elsif ($score->{type} eq "HMM") { $score_HMM = sprintf ("%.3f", $score->{value}); } elsif ($score->{type} eq "NES") { $score_NES = sprintf ("%.3f", $score->{value}); } } } print "$id-$pos\t\t$score_ANN\t$score_HMM\t$score_NES\t$finding\n"; } } print "\n"; }