#!/usr/bin/perl # Description: This script runs the hERG 1.0c.ws0 Web Service. It requires no input; to be used for testing in the EMBRACE WS Registry. # Author: Edita Bartaseviciute # Email: edita@cbs.dtu.dk # Version: 1.0c ws0 # Date: 2009-04-22 # usage: perl test_herg.pl [-s] # include standard XML::Compile helper functions (used to initiate WSDL proxys) use strict; use Data::Dumper; require "xml-compile.pl"; # downloadable from the same site as this script my $soption = $ARGV[0]; # create proxy to hERG Web Service my $herg = WSDL2proxy ( 'http://www.cbs.dtu.dk/ws/hERG/hERG_1_0c_ws0.wsdl' ); # append schema definitions $herg = appendSchemas ( $herg , "http://www.cbs.dtu.dk/ws/common/ws_common_1_0c.xsd" , "http://www.cbs.dtu.dk/ws/hERG/ws_herg_1_0c_ws0.xsd" ); my %ops = addOperations ( $herg ) ; my @molecule; while () { if (/^(\S+)\s(\w+)/) { push @molecule , { id => $2 , smiles => $1 }; } } my $response; if ($soption) { $response = $ops{runService}->( parameters => { parameters => { sort => 'required', moleculedata => {molecule => [@molecule]} } }); } else { $response = $ops{runService}->( parameters => { parameters => { moleculedata => {molecule => [@molecule]} } }); } 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 } }) ; #print Dumper ( $response ) ; $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 }); #printing the results my ($score,$comment); print "# Score \tToxicity\tCompound\n". "# ===================================================\n"; foreach my $ann (@{$response->{parameters}->{anndata}->{ann}}) { foreach my $annrecord (@{$ann->{annrecords}->{annrecord}}) { $score = sprintf("%.3f", $annrecord->{score}[0]->{value}); $comment = sprintf ("%-8s", $annrecord->{comment}); if ($score < 0) { $score = " $score"; } else { $score = " $score"; } } print "$score\t$comment\t$ann->{sequence}->{id}\n"; } print "# ===================================================\n"; __DATA__ CC(=O)OC1=CC=CC=C1C(=O)O Aspirin CCOC(=O)C1=CC=C(C=C1)N Benzocaine C1C2C(C(C1Cl)Cl)C3(C(=C(C2(C3(Cl)Cl)Cl)Cl)Cl)Cl Chlordane CCOC(=O)CC(C(=O)OCC)SP(=S)(OC)OC Malathion