[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Mon Jul 14 21:17:13 UTC 2003
mwilkinson
Mon Jul 14 17:17:13 EDT 2003
Update of /home/repository/moby/moby-live/Perl/scripts/Services
In directory pub.open-bio.org:/tmp/cvs-serv2031/scripts/Services
Modified Files:
LocalServices.pm
Log Message:
added new subroutine to start dealing with Collection outputs. Added a service (untested so far) that outputs a collection of GO terms that are related to a keyword input
moby-live/Perl/scripts/Services LocalServices.pm,1.17,1.18
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm 2003/07/14 20:05:27 1.17
+++ /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm 2003/07/14 21:17:13 1.18
@@ -4,6 +4,7 @@
use lib "/var/www/cgi-bin";
use lib "/usr/local/apache/cgi-bin/bioperl/core";
use lib "/usr/local/apache/cgi-bin/MOBY05/";
+use lib "/export/root/BIOPERL/go/perl-api";
use strict;
use SOAP::Lite;
@@ -78,6 +79,73 @@
}
+
+sub RetrieveGOFromKeywords {
+ my $SOM = pop;
+ my ($self, $query) = @_;
+ use GO::AppHandle;
+
+ my $ua = new LWP::UserAgent;
+ my $req = new HTTP::Request GET => 'http://www.godatabase.org/dev/database/server.cfg';
+ my $res = $ua->request($req);
+ my $host;
+ if ($res->is_success) {
+ my $resp = $res->content;
+ $host = ($resp =~ /\w+\s+(.*)/ && $1);
+ &_LOG("found go database server at $host\n");
+ } else {
+ &_LOG("can't connect to godatabase nameserver\n");
+ return SOAP::Data->type('base64' => responseHeader() . responseFooter()); # base 64 encode it (optional)
+ }
+ my %connect_hash;
+ $connect_hash{-dbname}="go";
+ $connect_hash{-dbhost}=$host;
+
+ my $GO_API = GO::AppHandle->connect(%connect_hash);
+ &_LOG("made connection $GO_API\n");
+ unless ($GO_API){
+ &_LOG("unable to connect to the GO database at $host\n");
+ return SOAP::Data->type('base64' => responseHeader() . responseFooter()); # base 64 encode it (optional)
+ }
+
+ # first, get the valid URI for the namespace that we accept
+ my $OS = MOBY::Client::OntologyServer->new;
+ my ($s, $m, $VALID_NAMESPACE) = $OS->namespaceExists(term => 'Global_Keyword');
+ unless ($VALID_NAMESPACE){ # unless we could get the known namespace LSID's we should bail because somethign is very very wrong!
+ print STDERR "the namespace Global_Keyword does not exist in the MOBY namespace ontology\n";
+ return SOAP::Data->type('base64' => responseHeader() . responseFooter()); # base 64 encode it (optional)
+ }
+
+ # now start analyzing the input data
+ my @input_nodes = getInputArticles($query); # returns ([obj1, obj2], [obj3, obj4], [obj5], [obj6],...)
+ my $response;
+ foreach (@input_nodes){
+ my $input = $_->[0]; # we only allow one input object per query
+ my ($kw) = getSimpleArticleIDs($VALID_NAMESPACE, [$input]);
+ ($kw) = (($kw =~ /^\s*(.*)\s*$/) && ($1));
+ _LOG("searching for ||$kw||\n");
+ my @terms = @{$GO_API->get_terms({search=>"$kw"})};
+ _LOG("found term $terms[0]");
+ next unless($terms[0]);
+ _LOG("found term $terms[0]");
+ my @simples;
+ foreach my $term(@terms){
+ my $acc = $term->public_acc;
+ my $def = $term->definition;
+ my $name = $term->name;
+ push @simples, "<moby:GO_Term namespace='GO' id='$acc'>
+ <moby:String namespace='' id='' articleName='Term'>$term</moby:String>
+ <moby:String namespace='' id='' articleName='Definition'>$def</moby:String>
+ </moby:GO_Term>";
+ }
+ $response .= collectionResponse(\@simples);
+ }
+ $response = responseHeader() . $response . responseFooter();
+ my $SOAPResponse = SOAP::Data->type('base64' => $response);
+ return $SOAPResponse
+}
+
+
# ===============================================
# = Genbank Retrieval Scripts =
# = =
@@ -378,6 +446,11 @@
}
-
+sub _LOG {
+ open OUT, ">/tmp/LocalServices.log";
+ print OUT @_;
+ close OUT;
+}
+
1;
More information about the MOBY-guts
mailing list