ASP.NET example (using C#; .NET1.1)
seguidtest.zip
(a complete ASP.NET web application VS2003 solution in C#)
1) Unzip into a directory (add ASP.NET and IUSR_MACHINENAME with Read&Execute permissions)
2) Create virtual directory (seguidtest) in IIS
3) Edit the seguidtest.csproj.webinfo file (URLPath = "http://your.url/seguidtest/seguidtest.csproj" )
4) Change the aspx file if necessary
5) Questions? (
gbabnigg)
Perl examples (using SOAP::Lite)
SOAP-Match-Example.pl
(a complete example including submission and display of results)
#!/usr/bin/perl -w
####################################################################
# a complete example of using the SOAP-Match WS
# 1. a list of species is aquired
# 2. a taxonomyid is selected (from species list)
# 3. a regular expression ('search pattern') is generated
# 4. job submitted
# 5. check the returned jobid:
# a) JobId == 0 : something is wrong
# b) JobID > 0 : get status of this JobID
# A) status = 0 : wait (get length of Que, etc)
# B) status > 0 : display results
#####################################################################
$| = 1;
use SOAP::Lite;
use MIME::Base64;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/', 'http://bioinformatics.anl.gov/ws/regexsearch', $_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my ($method,@params,$result,$taxonomyId,$regex,$jobId);
########################################################
# 1. get a list of species (currently supported list)
########################################################
$method = SOAP::Data->name('getSpecies')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
# required input:
# int
@params = ( SOAP::Data
->type('int')
->name(numberOfColumns)
->value(2)
);
# call WS w/ params
$result = $soap->call($method => @params);
# display table
&displayTable($result,"SHA1PATTERNSOX");
###########################################################
# 2. select a taxonomy
# - two special cases are presented:
# a) taxonomyid (OX) = 0 -> non-redundant database
# b) taxonomyid (OX) = 1000000 -> RefSeq database
#
# we will use the non-redundant database (OX = 0)
###########################################################
$taxonomyId = 0;
###########################################################
# 3. generate regular expression
# - the 'search pattern' to use
###########################################################
my @az = (A..Z);
$regex = "";
my $c = 0;
srand(time);
for (my $i = 1; $i < 12; $i++){
my $s = $az[int(rand($#az))];
$regex .= ($s =~ /[BJOUXZ]/) ? "" : $s;
if((length($regex) > 3) && (rand(10) > 8)){last;}
if(rand(100) > 92){
$regex .= "[";
if(rand(100) > 77){$regex .= "^";}
my $insert = "";
for (my $j = 1; $j < int(rand(10)); $j++){
$s = $az[int(rand($#az))];
$insert .= ($s =~ /[BJOUXZ]/) ? "" : $s;
}
$regex .= ($insert ne "") ? $insert : "HI";
$regex .= "]";
}
if((rand(10) > 6) && ($regex ne "") && (substr($regex,-1,1) !~ /[\}\.]/)){$regex .= ".";}
if((rand(10) > 8) && ($regex ne "") && (substr($regex,-1,1) ne "}")){
my $randomNumber = int(rand(2));
my $randomNumber2 = $randomNumber + int(rand(5));
$regex .= "{" . $randomNumber . "," . ($randomNumber + int(rand(5)) + 1) . "}";
}
}
$regex =~ s/\.$//g;
my $testRegex = $regex;
$testRegex =~ s/\{\d+\,\d+\}//g;
$testRegex =~ s/\[^\[]/A/g;
if(length($testRegex) < 4){$regex .= "MATCH";}
print "\nRegular expression: $regex\n";
###########################################################
# 4. submit job
#
###########################################################
$method = SOAP::Data->name('insertJob')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
@params = ( SOAP::Data
->type('int')
->name(Ox)
->value($taxonomyId)
);
push (@params, SOAP::Data
->type('string')
->name(suppliedREGEX)
->value($regex)
);
push (@params, SOAP::Data
->type('string')
->name(suppliedIP)
->value('1.2.3.4') # IP address grabbed automatically
);
$jobId = $soap->call($method => @params)->result;
print "jobID: $jobId (this will be used in the following methods)\n";
####################################################################
# Check jobID
# a) JobId == 0 : something is wrong
# b) JobID > 0 : get status of this JobID
# A) status = 0 : wait (get length of Que, etc)
# B) status > 0 : display results
#####################################################################
if($jobId == 0){
# something is wrong
# 1. we reached our quota for the last 24 hours
$method = SOAP::Data->name('getAllowedCountForYourIP')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
if(($soap->call($method)->result) > 0){
print "\nProblem with regular expression\n";
}else{
print "\nThis IP address has reached its quota\n";
}
exit(0);
}else{
# get the status for this jobID
my $jobStatus = 0;
$method = SOAP::Data->name('getJobIDStatus')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
@params = ( SOAP::Data
->type('int')
->name(JobID)
->value($jobId)
);
$jobStatus = $soap->call($method => @params)->result;
# Decide on the status of this job
if($jobStatus == 0){
# size of Que?
$method = SOAP::Data->name('getSha1PatternsQue')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
@params = ( SOAP::Data
->type('int')
->name(jobID)
->value($jobId)
);
my $queLength = $soap->call($method => @params)->result;
# wait until this becomes 0 ... than check progress of this job
$tempQueLength = $queLength;
my $maxTrials = 100;
my $countTrials = 0;
while ($tempQueLength > 0){
$tempQueLength = $soap->call($method => @params)->result;
$countTrials++;
last if ($countTrials > $maxTrials);
print "*";
sleep(2);
}
if($tempQueLength > 0){
print "\nRan out of time ... check the status of this job later\n";
exit(0);
}
# que is 0 ... our job is running
$method = SOAP::Data->name('getJobIDStatus')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
@params = ( SOAP::Data
->type('int')
->name(JobID)
->value($jobId)
);
$jobStatus = $soap->call($method => @params)->result;
$maxTrials = 100;
$countTrials = 0;
while ($jobStatus == 0){
$jobStatus = $soap->call($method => @params)->result;
$countTrials++;
print ".";
last if($countTrials >= $maxTrials);
#
sleep(2);
}
if($jobStatus == 0){
print "\nRan out of time ... check the status of this job later\n";
exit(0);
}
&DisplayResults($jobId);
}else{
# the job is finished
&DisplayResults($jobId);
}
}#if($jobId == 0){
################################################
#
################################################
sub DisplayResults{
my $jobid = shift;
print "\nResults of search\n";
$method = SOAP::Data->name('getSha1PatternsCount')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
@params = ( SOAP::Data
->type('int')
->name(jobID)
->value($jobid)
);
$result = $soap->call($method => @params);
&displayTable($result,"SHA1PATTERNSCOUNT");
# get the patterns
$method = SOAP::Data->name('getSha1Patterns')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
@params = ( SOAP::Data
->type('int')
->name(jobID)
->value($jobid)
);
$result = $soap->call($method => @params);
print "\nDetails\n";
&displayTable($result,"SHA1PATTERNS");
# Save a .PNG image for this jobId
$method = SOAP::Data->name('getJobsegmentsDetailsBitmap')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
@params = ( SOAP::Data
->type('int')
->name(JobID)
->value($jobid)
);
$result = $soap->call($method => @params)->result;
open (OUT, ">performance-" . $jobid . ".png") || die "$!\n";
$decoded = decode_base64($result);
print OUT $decoded;
close (OUT);
exit(0);
}#sub DisplayResults{
################################################
# display a table of results (header and rows)
################################################
sub displayTable{
my $result = shift;
my $complexType = shift; # inferred from WSDL
my @nodes = $result->valueof('//' . $complexType);
my %node;
# print header if any data
if(defined $nodes[0]){
my %header = %{$nodes[0]};
foreach my $h (sort keys %header){
print "$h\t";
}
}# if(defined $nodes[0]){
print "\n";
# print rows
foreach $node (@nodes)
{
%node = %{$node};
foreach my $key (sort keys %node){
print "$node{$key}\t";
}
print "\n";
}
}#sub displayTable{
SOAP-Match-convertPrositeToRegex.pl
(convert PROSITE patterns to REGEX)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/',
'http://bioinformatics.anl.gov/ws/regexsearch',
$_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('convertPrositeToRegex')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
my @params = ( SOAP::Data
->type('string')
->name(suppliedPROSITE)
->value('[HYW]-x(9)-[DENQSTV]-[SA]-x(3)-[FYC]-[LIVM]-x(2,3)-[ACVWD]-x(2)-[LM]-x(2)-[FY]-[GM]-x-[DENQSTH]-[LIVMFYS]')
);
my $result = $soap->call($method => @params)->result;
# REGEX
print $result;
print "\n";
SOAP-Match-getAllowedCountForYourIP.pl
(get the current number of allowed submission for your IP address)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/',
'http://bioinformatics.anl.gov/ws/regexsearch',
$_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getAllowedCountForYourIP')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
my $result = $soap->call($method)->result;
# number of allowed submissions for your IP address
print $result;
print "\n";
SOAP-Match-getIP.pl
(display your IP address - according to SOAP-Match)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/',
'http://bioinformatics.anl.gov/ws/regexsearch',
$_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getIP')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
my @params = ( SOAP::Data
->type('string')
->name(suppliedIP)
->value('1.2.3.4')
);
my $result = $soap->call($method => @params)->result;
# your IP address according to the WS
print $result;
print "\n";
SOAP-Match-getJobIDStatus.pl
(get the status of a job - supply JobID)
#!/usr/bin/perl -w
use SOAP::Lite;
use MIME::Base64;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/',
'http://bioinformatics.anl.gov/ws/regexsearch',
$_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getJobIDStatus')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
my @params = ( SOAP::Data
->type('int')
->name(JobID)
->value(10000)
);
my $result = $soap->call($method => @params)->result;
# status values:
# 0: running
# 1: finished counts
# 1,2: patterns are inserted into database
print $result;
print "\n";
SOAP-Match-getJobsegmentsDetailsBitmap.pl
(get cluster image for job - supply JobID)
#!/usr/bin/perl -w
use SOAP::Lite;
use MIME::Base64;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/',
'http://bioinformatics.anl.gov/ws/regexsearch',
$_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getJobsegmentsDetailsBitmap')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
my @params = ( SOAP::Data
->type('int')
->name(JobID)
->value(10000)
);
my $result = $soap->call($method => @params)->result;
print $result;
print "\n";
open (OUT, ">pic.png") || die "$!\n";
$decoded = decode_base64($result);
print OUT $decoded;
close (OUT);
SOAP-Match-getListOfJobIDTorThisIP.pl
(get of jobs jobs submitted by your IP address)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/', 'http://bioinformatics.anl.gov/ws/regexsearch', $_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getListOfJobIDForThisIP')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
# no parameters are required
my $result = $soap->call($method);
my @nodes = $result->valueof('//SHA1PATTERNSCOUNT');
# print header if any data for this IP
if(defined $nodes[0]){
my %header = %{$nodes[0]};
foreach my $h (sort keys %header){
print "$h\t";
}
}
print "\n";
my %node;
foreach $node (@nodes)
{
%node = %{$node};
foreach my $key (sort keys %node){
print "$node{$key}\t";
}
print "\n";
}
SOAP-Match-getNrinfoSHA1.pl
(get annotation for given protein sequence - supply SEGUID)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/', 'http://bioinformatics.anl.gov/ws/regexsearch', $_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getNrinfoSHA1')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
# display columns
my @params = ( SOAP::Data
->type('string')
->name(Sha1)
->value('SUEg3EDgJOq9TPz2q3gIhfGR49M')
);
my $result = $soap->call($method => @params);
my @nodes = $result->valueof('//NRINFO');
# header if any data
if(defined $nodes[0]){
my %header = %{$nodes[0]};
foreach my $h (sort keys %header){
print "$h\t";
}
}
print "\n";
my %node;
foreach $node (@nodes)
{
%node = %{$node};
foreach my $key (sort keys %node){
print "$node{$key}\t";
}
print "\n";
}
SOAP-Match-getProteinsSHA1.pl
(get protein sequence - supply SEGUID)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/',
'http://bioinformatics.anl.gov/ws/regexsearch',
$_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getProteinsSHA1')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
my @params = ( SOAP::Data
->type('string')
->name(Sha1)
->value('5oecjK7F3I4VAZHZwUWwbAyM0U4')
);
# cC/Xo1TGZGL6qnBfFvoMB34VFCg
my $result = $soap->call($method => @params)->result;
# get keys
#my %nrinfo = $result->{'diffgram'}->{'NewDataSet'};
#foreach $key (keys %nrinfo){
# print "\n** $key: $nrinfo{$key}\n";
#}
# ref to nodes
my $nodes = $result->{'diffgram'}->{'NewDataSet'}->{'PROTEINS'};
%nodes = %{$nodes};
foreach $key (keys %nodes){
print "$key: $nodes{$key}\n";
}
print "\n$nodes->{'SHA1'}\n";
SOAP-Match-getSha1CountForThisIP.pl
(get summary information for your IP address)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/', 'http://bioinformatics.anl.gov/ws/regexsearch', $_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getSha1CountForThisIP')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
# no parameters are required
my $result = $soap->call($method);
my @nodes = $result->valueof('//SHA1PATTERNSCOUNT');
# print header if any data for this IP
if(defined $nodes[0]){
my %header = %{$nodes[0]};
foreach my $h (sort keys %header){
print "$h\t";
}
}
print "\n";
my %node;
foreach $node (@nodes)
{
%node = %{$node};
foreach my $key (sort keys %node){
print "$node{$key}\t";
}
print "\n";
}
SOAP-Match-getSha1Patterns.pl
(get results for a given job - supply JobID)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/', 'http://bioinformatics.anl.gov/ws/regexsearch', $_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getSha1Patterns')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
# display columns
my @params = ( SOAP::Data
->type('int')
->name(jobID)
->value(18275)
);
my $result = $soap->call($method => @params);
my @nodes = $result->valueof('//SHA1PATTERNS');
# header if any data
if(defined $nodes[0]){
my %header = %{$nodes[0]};
foreach my $h (sort keys %header){
print "$h\t";
}
}
print "\n";
my %node;
foreach $node (@nodes)
{
%node = %{$node};
foreach my $key (sort keys %node){
print "$node{$key}\t";
}
print "\n";
}
SOAP-Match-getSha1PatternsDetailedDownload.pl
(download results in tabular format - supply JobID)
#!/usr/bin/perl -w
###############################
# get result for a given jobID
# (tab-delimited file)
###############################
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/', 'http://bioinformatics.anl.gov/ws/regexsearch', $_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getSha1PatternsDetailedDownload')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
# get result for this jobID
my @params = ( SOAP::Data
->type('int')
->name(jobID)
->value(18275)
);
my $result = $soap->call($method => @params)->result;
print $result, "\n";
SOAP-Match-getSha1PatternsQue.pl
(get the number of jobs in queue prior to yours - supply JobID)
#!/usr/bin/perl -w
use SOAP::Lite;
use MIME::Base64;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/',
'http://bioinformatics.anl.gov/ws/regexsearch',
$_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getSha1PatternsQue')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
my @params = ( SOAP::Data
->type('int')
->name(jobID)
->value(10000)
);
my $result = $soap->call($method => @params)->result;
print $result;
print "\n";
SOAP-Match-getSpecies.pl
(get the list of species and their taxonomy information)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/', 'http://bioinformatics.anl.gov/ws/regexsearch', $_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('getSpecies')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
# display both columns (TAXONOMYNAME,OX)
my @params = ( SOAP::Data
->type('int')
->name(numberOfColumns)
->value(2)
);
my $result = $soap->call($method => @params);
my @nodes = $result->valueof('//SHA1PATTERNSOX');
foreach $node (@nodes)
{
%node = %{$node};
foreach $key (keys %node){
print "$key: $node{$key}\n";
}
print "\n";
}
SOAP-Match-insertJob.pl
(submit job)
#!/usr/bin/perl -w
use SOAP::Lite;
my $soap = SOAP::Lite
-> uri('http://bioinformatics.anl.gov/ws/regexsearch')
-> on_action( sub { join '/',
'http://bioinformatics.anl.gov/ws/regexsearch',
$_[1] } )
-> proxy('http://bioinformatics.anl.gov/ws/regexsearch.asmx');
my $method = SOAP::Data->name('insertJob')
->attr({xmlns => 'http://bioinformatics.anl.gov/ws/regexsearch'});
my @params = ( SOAP::Data
->type('int')
->name(Ox)
->value(0)
);
push (@params, SOAP::Data
->type('string')
->name(suppliedREGEX)
->value('PATTE')
);
push (@params, SOAP::Data
->type('string')
->name(suppliedIP)
->value('1.2.3.4')
);
my $result = $soap->call($method => @params)->result;
# this returns a jobID that can be tracked by
# getting the length of que: getSha1PatternsQue
# getting status of job: getJobIDStatus
# 0: running
# 1: count of pattern in db finished
# 2: patterns are inserted
print $result;
print "\n";