[MOBY-l] The server code

Mark Wilkinson mwilkinson at gene.pbi.nrc.ca
Wed Oct 31 22:27:47 UTC 2001


An immediate avalanche of requests for the server code... here it is.  I
implemented it as a CGI, though there are other ways which are ~equally as
simple.

Just remember, you are NOT allowed to make fun of my Perl code!!    I know it
isn't pretty, but this was just thrown together to see if it worked at all!
:-)

M


--
--------------------------------
"Speed is subsittute fo accurancy."
________________________________

Dr. Mark Wilkinson
Bioinformatics Group
National Research Council of Canada
Plant Biotechnology Institute
110 Gymnasium Place
Saskatoon, SK
Canada


-------------- next part --------------
#!/usr/bin/perl -w
# _________________________________________________________________

use SOAP::Transport::HTTP;
my $debug = 0;

my $x = new SOAP::Transport::HTTP::CGI;
$x->dispatch_to('PrimarySeq');
$x->handle;

sub PrimarySeq { 
	my ($class, $ac) = @_;  
	# for some reason class is always "main"???  
	# I haven't fully devined how SOAP::Lite works... 

	# this is just a LOG file for my own interest
	# it isn't necessary for the service to run
	_LOG ("\ndata in sub: ", (join "\n", @_));
	
	use LWP::UserAgent;
	my $ua = LWP::UserAgent->new();                          # prepare for net connection

	# this retrieves a sequence from SRS based on genbank id
	my $URL = "http://www.cbr.nrc.ca/srs6bin/cgi-bin/wgetz?-id+6OtPo1HPYMQ+-e+[GENBANK:'" . $ac . "']";
	my $req = new HTTP::Request GET => $URL;
    my $content = $ua->request($req)->as_string;             # execute HTTP call and receive respone
	
	my $seq = (($content =~ /<I>Sequence<\/I>.*?<pre>(.*?)<\/pre>/s) && $1); # simply strip the sequence out of the HTML
	$seq =~ s/\W//g; # clean it up
	$seq =~ s/\d//g; # clean it up more

	# prepare the MOBY-compatible output
	# note that the structure of the output 
	# will normally also be defined 
	# in the service.wsdl, etc.  documents
	# but I haven't got around to that yet
	my $soapseq = SOAP::Data->name(PrimarySeq => $seq);  # PrimarySeq data type
	my $mib = SOAP::Data->name(MIB => "<ref2 name value/>\n<ref2 name2 value2/>\n");  # MIB data type with dummy X-refs
	my $moby = SOAP::Data->name(MOBY => ($mib,$soapseq));	# the entire MOBY block
	return $moby;  # and return it.
}
# _____________________________________________________________________



sub _LOG {
	return unless $debug;
	open LOG, ">>/tmp/ServLogOut.txt" or die "can't open logfile $!\n";
	print LOG join "\n", @_;
	print LOG "\n---\n";
	close LOG;
}

1;



More information about the moby-l mailing list