[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Thu Jul 17 15:50:14 UTC 2003
mwilkinson
Thu Jul 17 11:50:14 EDT 2003
Update of /home/repository/moby/moby-live/Perl/scripts/Services
In directory pub.open-bio.org:/tmp/cvs-serv15177/scripts/Services
Modified Files:
LocalServices.pm
Log Message:
added a new service that takes Snapdragon allele names and returns a collection of base64-encoded images of that mutant. Also changed CommonSubs so that it does not take liberties with whitespace when constructing its XML, as this buggers up base64 encoded data
moby-live/Perl/scripts/Services LocalServices.pm,1.24,1.25
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm 2003/07/17 02:30:15 1.24
+++ /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm 2003/07/17 15:50:14 1.25
@@ -427,6 +427,85 @@
return $SOAPResponse;
}
+#################################################
+#################################################
+#### DragonDB Subroutines #####################
+#################################################
+#################################################
+
+sub getDragonMutantImages {
+ my $SOM = pop;
+ my ($self, $data) = @_;
+ use Ace;
+ use LWP::UserAgent;
+ use MIME::Base64;
+
+# prepare myself
+ my $OS = MOBY::Client::OntologyServer->new;
+ my ($s, $m, $nsAllele) = $OS->namespaceExists(term => "DragonDB_Allele");
+
+ unless ($nsAllele){ # unless we could get the known namespace LSID's we should bail because somethign is very very wrong!
+ print STDERR "the namespace DragonDB_Allele does not exist in the MOBY namespace ontology\n";
+ return SOAP::Data->type('base64' => responseHeader() . responseFooter()); # base 64 encode it (optional)
+ }
+# make the database connection once
+ my $db = Ace->connect(-host => 'bioinfo.usask.ca',
+ -port => 23100);
+###################################
+
+# now start retrieving the input data
+ my @input_nodes = getInputArticles($data); # returns ([obj1, obj2], [obj3, obj4], [obj5], [obj6],...)
+ 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){
+
+ 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
+ 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
+ next;
+ }
+# Prepare query on DragonDB with that allele name
+ 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";
+ 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!
+ my @simples;
+ foreach my $jpg (@jpgnames){
+ $jpg = $jpg->[0];
+ $jpg =~ s/([^\w\-\.\@])/$1 eq " "?"+":sprintf("%%%2.2x",ord($1))/eg; # URL Encode the image filename
+ $jpg = "http://antirrhinum.net/ace/images/DragonDB/external/".$jpg; # make the URL
+ my $ua = LWP::UserAgent->new;
+ my $req = HTTP::Request->new(GET => $jpg); # 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
+ }
+ }
+ $response .= collectionResponse(\@simples); # 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.
+}
+
+
+###############################################################
+###################### for My Machine Only ###################
sub _dbAccess {
my ($dbname) = @_;
return undef unless $dbname;
More information about the MOBY-guts
mailing list