[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Sun Jan 18 03:45:23 UTC 2004


mwilkinson
Sat Jan 17 22:45:22 EST 2004
Update of /home/repository/moby/moby-live/Perl/scripts/Services
In directory pub.open-bio.org:/tmp/cvs-serv3246/Services

Modified Files:
	LocalServices.pm 
Log Message:
added a couple of new DragonDB services that retrieve allele collections from a locus name, and annotated image collections from an allele name

moby-live/Perl/scripts/Services LocalServices.pm,1.50,1.51
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm	2004/01/11 05:51:10	1.50
+++ /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm	2004/01/18 03:45:22	1.51
@@ -8,6 +8,9 @@
 
 use strict;
 use SeqHound;
+use Ace;
+use LWP::UserAgent;
+use MIME::Base64;
 use SOAP::Lite;
 use Bio::SeqIO;
 use DBI;
@@ -666,9 +669,6 @@
 sub getDragonMutantImages {
 
     my ($self, $data) = @_;
-	use Ace;
-	use LWP::UserAgent;
-	use MIME::Base64;
 
 # prepare myself
 	my $OS = MOBY::Client::OntologyServer->new;
@@ -684,30 +684,39 @@
 ###################################
 	
 # now start retrieving the input data
-	my @input_nodes = getInputArticles($data); # returns ([obj1, obj2], [obj3, obj4], [obj5], [obj6],...)
+	my @input_nodes = genericServiceInputParser($data); 
 	my @inputs;
-	foreach (@input_nodes){
-		push @inputs, $_->[0];  # we only allow one input object per query
-	}
 
 # Start iterating through the queries
 	my $response; 
-	foreach my $node(@inputs){
- 
+	foreach my $input(@input_nodes){
+        my ($articleType, $qID, $node) = @{$input};
+        unless (($articleType == SIMPLE) && (defined($input))){  # we only accept simple inputs to this service
+            $response .= collectionResponse([], "", $qID) ;  # send back a blank response for this queryID
+            next;
+        }
 		my $namespace_LSID = getSimpleArticleNamespaceURI($node);  # get the LSID of the namespace for this input object
 		unless ($namespace_LSID eq $nsAllele){ # validate the namespace
-			$response .= collectionResponse([]);  # because we have to send one response per input, send a blank if bad namespace
+			$response .= collectionResponse([], "", $qID);  # because we have to send one response per input, send a blank if bad namespace
 			next;
 		}
 			
 		my ($Allele)= getSimpleArticleIDs($namespace_LSID, [$node]);  # get the ID within this namespace
 		unless (defined $Allele){  # send a blank if we failed to get an id, 
-			$response .= collectionResponse([]);  # because we have to send one response per input
+			$response .= collectionResponse([], "", $qID);  # because we have to send one response per input
 			next;
 		}
 # Prepare query on DragonDB with that allele name
+
+
+#			my $q= qq{select Gif from Gif in object("Allele","$identifier")};
+#			my $db = Ace->connect(-host => 'bioinfo.usask.ca', -port => 23100);
+#			my @res = $db->aql($q);
+#
+
+
 		my $query = qq(select Gif from Gif in object("Allele","$Allele") -> Phenotype_picture -> Pick_me_to_call[2]);
-		print STDERR "QUERY TO DRAGONDB WAS $query\n";
+#		print STDERR "QUERY TO DRAGONDB WAS $query\n";
 		my @jpgnames= $db->aql($query);
 		# I really need to learn AQL better so that I can also retrieve the
 		# Locus as a Cross-reference, and the Sequence as a cross-reference!
@@ -726,13 +735,101 @@
 				push @simples, "<moby:b64_encoded_jpeg namespace='$namespace_LSID' id='$Allele'>$image_data</moby:b64_encoded_jpeg>";  # push it onto the collection list
 			}
 		}
-		$response .= collectionResponse(\@simples); # after all images have been collected, create the collection
+		$response .= collectionResponse(\@simples, "", $qID); # after all images have been collected, create the collection
 	}
     $response =  responseHeader() . $response . responseFooter();  # now wrap the collection(s) with the appropriate headers etc
     my $SOAPResponse = SOAP::Data->type('base64' => $response);
     return $SOAPResponse	# and return them.	
 }
 
+sub getDragonSimpleAnnotatedImages{
+    my ($caller, $data) = @_;
+    my $MOBY_RESPONSE;
+    my (@inputs)= genericServiceInputParser($data); # ([SIMPLE, $queryID, $simple],...)
+    return SOAP::Data->type('base64' => responseHeader("illuminae.com") . responseFooter()) unless (scalar(@inputs));
+
+    my @validNS = validateNamespaces("DragonDB_Allele");  # ONLY do this if you are intending to be namespace aware!
+
+    foreach (@inputs){
+        my ($articleType, $qID, $input) = @{$_};
+        unless (($articleType == SIMPLE) && ($input)){
+            $MOBY_RESPONSE .= collectionResponse([], "", $qID) ;
+            next;
+        } else {
+            my $namespace = getSimpleArticleNamespaceURI($input);
+			my ($identifier) = getSimpleArticleIDs($input);  # note array output!
+			my $q= qq{select Gif from Gif in object("Allele","$identifier")};
+			my $db = Ace->connect(-host => 'bioinfo.usask.ca', -port => 23100);
+			my @res = $db->aql($q);
+			unless ($res[0]){
+				$MOBY_RESPONSE .= collectionResponse([], "", $qID) ;
+				next;
+			}
+			my @simples;
+			foreach (@res){
+				my $Allele = shift @{$_};
+				my @Alleledesc = $Allele->Description("Phenotype");
+				my $Locus = $Allele->Source("Gene");
+				foreach my $pic($Allele->Phenotype_picture){
+					my $picdesc = $pic->Description;
+					$picdesc = $picdesc."\n".(join "\n", at Alleledesc);
+					my $img = $pic->Pick_me_to_call->right;
+					$img =~ s/([^\w\-\.\@])/$1 eq " "?"+":sprintf("%%%2.2x",ord($1))/eg; # URL Encode the image filename
+					$img = "http://antirrhinum.net/ace/images/DragonDB/external/".$img; # make the URL
+					my $ua = LWP::UserAgent->new; 
+					my $req = HTTP::Request->new(GET => $img);  # get the image
+					my $res = $ua->request($req);
+					# Check the outcome of the response
+					if ($res->is_success) {  # if successful, then base64 encide the data
+						my $image_data = encode_base64($res->content);  # and create the simple image object
+	#					push @simples, "<moby:b64_encoded_jpeg namespace='$namespace_LSID' id='$Allele'>$image_data</moby:b64_encoded_jpeg>";  # push it onto the collection list
+						push @simples, qq{<SimpleAnnotatedJPEGImage namespace="DragonDB_Allele" id="$identifier">
+										  <CrossReference>
+										  <Object namespace="DragonDB_Gene" id="$Locus">
+										  </CrossReference>$image_data<String namespace="" id="" articleName="Description">$picdesc</String>};
+					} # no else
+				}
+			}
+			$MOBY_RESPONSE .= collectionResponse(\@simples, "", $qID); # after all images have been collected, create the collection
+        }
+    }
+    return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));    
+}
+
+sub getDragonLocusAlleles{
+    my ($caller, $data) = @_;
+    my $MOBY_RESPONSE;
+    my (@inputs)= genericServiceInputParser($data); # ([SIMPLE, $queryID, $simple],...)
+    return SOAP::Data->type('base64' => responseHeader("illuminae.com") . responseFooter()) unless (scalar(@inputs));
+
+    my @validNS = validateNamespaces("DragonDB_Gene");  # ONLY do this if you are intending to be namespace aware!
+
+    foreach (@inputs){
+        my ($articleType, $qID, $input) = @{$_};
+        unless (($articleType == SIMPLE) && ($input)){
+            $MOBY_RESPONSE .= collectionResponse([], "", $qID) ;
+            next;
+        } else {
+            my $namespace = getSimpleArticleNamespaceURI($input);
+			my ($identifier) = getSimpleArticleIDs($input);  # note array output!
+			my $q= qq{select Locus->Allele from Locus in object("Locus","$identifier")};
+			my $db = Ace->connect(-host => 'bioinfo.usask.ca', -port => 23100);
+			my @res = $db->aql($q);
+			unless ($res[0]){
+				$MOBY_RESPONSE .= collectionResponse([], "", $qID) ;
+				next;
+			}
+			my @simples;
+			foreach (@res){
+				my $Allele = shift @{$_};
+				push @simples, qq{<Object namespace="DragonDB_Allele" id="$Allele">};
+			}
+			$MOBY_RESPONSE .= collectionResponse(\@simples, "", $qID); # after all images have been collected, create the collection
+        }
+    }
+    return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));    
+}
+
 
 ###############################################################
 ######################  for My Machine Only ###################




More information about the MOBY-guts mailing list