[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Tue Dec 9 21:06:51 UTC 2003


mwilkinson
Tue Dec  9 16:06:51 EST 2003
Update of /home/repository/moby/moby-live/Perl/scripts/Services
In directory pub.open-bio.org:/tmp/cvs-serv28169/Perl/scripts/Services

Modified Files:
	LocalServices.pm 
Log Message:
added a generic server-side parser to CommonSubs that should basically do all of the work for you and be compatible with the 0.6 API.  Not yet documented; just testing on my own services first.

moby-live/Perl/scripts/Services LocalServices.pm,1.36,1.37
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm	2003/10/21 14:09:21	1.36
+++ /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm	2003/12/09 21:06:51	1.37
@@ -8,6 +8,8 @@
 
 use strict;
 use SOAP::Lite;
+use DBI;
+use DBD::mysql;
 use MIME::Base64;
 use XML::DOM;
 use MOBY::Client::OntologyServer;
@@ -26,37 +28,27 @@
                                        # last parameter passed to the subroutine
 
 sub getGoTerm {
+    my ($caller, $message) = @_;
+    my $MOBY_RESPONSE;
+    my (@inputs)= genericServiceInputParser($message, []); # ([SIMPLE, $queryID, $simple],...)
+    return SOAP::Data->type('base64' => responseHeader() . responseFooter()) unless (scalar(@inputs));
 
-    my $SOM = pop;  # NOTA BENE!!  You only do this if you have set @ISAQ = qw(SOAP::Server::Parameters) above!!!!!
-    my ($self, $data) = @_;
-    my $response = "";
-	my @accessions;
-	# 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 => 'GO');
-	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 GO does not exist in the MOBY namespace ontology\n";
-		return SOAP::Data->type('base64' => responseHeader() . responseFooter());  # base 64 encode it (optional)
-	}
+    my @validNS = validateNamespaces();  # ONLY do this if you are intending to be namespace aware!
 
-	# now start analyzing the input data
-	my @input_nodes = getInputArticles($data);
-	foreach (@input_nodes){
-		my ($input) = @{$_}; # this service only allows one input per query, so take the first
-		my $ns = getSimpleArticleNamespaceURI($input);
-		push @accessions, undef unless $ns eq $VALID_NAMESPACE; # if we have been sent an invalid namespace, then stack an undef as a response
-		my ($id) = getSimpleArticleIDs($ns, [$input]);
-		if (defined $id){
-			push @accessions, $id;
-		} else {
-			push @accessions, undef;
-		}
+	my @accessions;
+    foreach (@inputs){
+        my ($articleType, $ID, $input) = @{$_};
+        unless ($articleType == SIMPLE){
+            $MOBY_RESPONSE .= simpleResponse("", "", $ID) ;
+            next;
+        } else {
+			my $ns = getSimpleArticleNamespaceURI($input);
+			((push @accessions, undef) && (next)) unless validateThisNamespace($ns, @validNS);
+			push @accessions, defined(getSimpleArticleIDs($ns, [$input]))?getSimpleArticleIDs($ns,[$input]):1;
+        }
     }
-
-    use DBI;
-    use DBD::mysql;
     my $dbh = _dbAccess('go');
-    die "can't connecvt to database\n" unless $dbh;
+    die "can't connect to GO database\n" unless $dbh;
     my $sth = $dbh->prepare(q{select name, term_definition from term, term_definition where term.id = term_definition.term_id and acc=?});
     
     foreach my $acc(@accessions){
@@ -66,20 +58,16 @@
         $sth->execute($acc);        
         my ($term, $def) = $sth->fetchrow_array;
         if ($term){
-            $response .= simpleResponse("
+            $MOBY_RESPONSE .= simpleResponse("
                 <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>")
         } else {
-            $response .= simpleResponse("")
+            $MOBY_RESPONSE .= simpleResponse("")
         }
     }
-
-    $response =  responseHeader() . $response . responseFooter();
-    my $SOAPResponse = SOAP::Data->type('base64' => $response);
-    return $SOAPResponse
-    
+    return SOAP::Data->type('base64' => responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter);    
 }
 
 




More information about the MOBY-guts mailing list