#!/usr/bin/perl # Description: This is a template example script. I reads fasta from STDIN and produces template annotation format output # Author: Edita Bartaseviciute # Email: edita@cbs.dtu.dk # Version: 1.02 ws0 # Date: 2008-09-15 # usage: perl chemprot.pl < example.fsa # include standard XML::Compile helper functions (used to initiate WSDL proxys) use Data::Dumper; use strict; require "xml-compile.pl"; # create proxy to genome atlas my $chemprot = WSDL2proxy ( 'http://www.cbs.dtu.dk/ws/ChemProt/ChemProt_1_02_ws0.wsdl' ); # append schema definitions $chemprot = appendSchemas ( $chemprot , "http://www.cbs.dtu.dk/ws/common/ws_common_1_0b.xsd" , "http://www.cbs.dtu.dk/ws/ChemProt/ws_chemprot_1_02_ws0.xsd" ); my %ops = addOperations ( $chemprot ) ; 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; } } my @sequence; for ( my $i = 0 ; $i < scalar ( @fasta ) ; $i ++ ) { push @sequence , { id => $fasta[$i]->{id} , comment => $fasta[$i]->{comment} , seq => $fasta[$i]->{seq} }; } my $response = $ops{runService}->( parameters => { parameters => { # organism => 'euk' , # method => 'nn+hmm' , # thnn => '0.43' , sequencedata => {sequence => [@sequence]} } }); 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"; } $response = $ops{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"; print " sequence comment : $ann->{sequence}->{comment}\n"; print " sequence : $ann->{sequence}->{seq}\n"; foreach my $annrecord (@{$ann->{annrecords}->{annrecord}}) { print join ( "\t", ( $annrecord->{feature}, $annrecord->{range}->{begin}->numify, $annrecord->{range}->{end}->numify, $annrecord->{score}[0]->{key}.':'.$annrecord->{score}[0]->{value}, ))."\n"; }}