[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Thu Dec 11 18:08:14 UTC 2003


mwilkinson
Thu Dec 11 13:08:14 EST 2003
Update of /home/repository/moby/moby-live/Perl/scripts/Services
In directory pub.open-bio.org:/tmp/cvs-serv4290/Services

Modified Files:
	LocalServices.pm 
Log Message:
added Xrefs to my new services.  Small change in the client program to improve readability

moby-live/Perl/scripts/Services LocalServices.pm,1.45,1.46
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm	2003/12/11 15:36:38	1.45
+++ /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm	2003/12/11 18:08:14	1.46
@@ -9,6 +9,7 @@
 use strict;
 use SeqHound;
 use SOAP::Lite;
+use Bio::SeqIO;
 use DBI;
 use DBD::mysql;
 use GO::AppHandle;
@@ -317,6 +318,16 @@
 	return ($seq, $seq->length, $seq->seq);	
 }
 
+sub _getXrefs {
+	my ($seq) = @_;  # bioperl seq object
+	#my $gi = $seq->primary_id;		  # e.g. 163483
+	#print STDERR "\n\n*********************$ gi\n\n";
+	my $acc = $seq->accession;        # e.g. A123434
+	my $kw = $seq->species->binomial; # e.g. mus musculus
+	my $taxon = $seq->species->ncbi_taxid;  # e.g. 1234
+	return ($acc, $kw, $taxon);
+}		
+
 sub MOBYSHoundGetGenBankVirtSequence {
     my ($caller, $data) = @_;
 	my $MOBY_RESPONSE;
@@ -346,39 +357,53 @@
             (($MOBY_RESPONSE .= simpleResponse("", "No_Identifier_provided", $qID)) && next) unless $identifier;
 			if ($ns eq $validNS{'NCBI_gi'}){  # gi numbers are used natively by SeqHound
 				my ($SEQ, $length, $seq) = _makeSeqObj($identifier);
-	            (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
-				$MOBY_RESPONSE .= simpleResponse("<VirtualSequence namespace='NCBI_gi' id='$identifier'>
-												 <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
-												 </VirtualSequence>", "", $qID);
+
+				my ($acc, $kw, $taxon) = _getXrefs($SEQ);
+				my $tempresponse = "<VirtualSequence namespace='NCBI_gi' id='$identifier'><CrossReferences>\n";
+				if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>\n"}
+				if ($kw){$tempresponse .="<Object namespace='Global_Keyword' id='$kw'/>\n"}
+				if ($acc){$tempresponse .="<Object namespace='NCBI_Acc' id='$acc'/>\n"}
+				$tempresponse .="<Object namespace='NCBI_gi' id='$identifier'/>\n";
+				$tempresponse .="</CrossReferences>\n<Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
+												 </VirtualSequence>";
+				$MOBY_RESPONSE .= simpleResponse($tempresponse, "", $qID);
 			} elsif ($ns eq $validNS{'NCBI_Acc'}){  # THIS ONE DOESN'T WORK YET????
 				my $gi = SHoundFindAcc($identifier);
 				(($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
 				my ($SEQ, $length, $seq) = _makeSeqObj($gi);
 	            (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
-				$MOBY_RESPONSE .= simpleResponse("<VirtualSequence namespace='NCBI_gi' id='$gi'>
-					<CrossReferences>
-						<Object namespace='$ns' id='$identifier'/>
+				my ($acc, $kw, $taxon) = _getXrefs($SEQ);
+				my $tempresponse = "<VirtualSequence namespace='NCBI_gi' id='$gi'>\n<CrossReferences>\n";
+				if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>\n"}
+				if ($kw){$tempresponse .="<Object namespace='Global_Keyword' id='$kw'/>\n"}
+				if ($acc){$tempresponse .="<Object namespace='NCBI_Acc' id='$acc'/>\n"}
+				$tempresponse .="<Object namespace='NCBI_gi' id='$gi'/>\n";
+				$tempresponse .="<Object namespace='$ns' id='$identifier'/>
 					</CrossReferences>
-					<Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
-					</VirtualSequence>",
-					"", $qID);
+					 <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
+					 </VirtualSequence>";
+				$MOBY_RESPONSE .= simpleResponse($tempresponse,"", $qID);
 			} else {
 				my $gi = SHoundFindName($identifier);
 				(($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
 				my ($SEQ, $length, $seq) = _makeSeqObj($gi);
 	            (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
-				$MOBY_RESPONSE .= simpleResponse("<VirtualSequence namespace='NCBI_gi' id='$gi'>
-					<CrossReferences>
-						<Object namespace='$ns' id='$identifier'/>
+				my ($acc, $kw, $taxon) = _getXrefs($SEQ);
+				my $tempresponse = "<VirtualSequence namespace='NCBI_gi' id='$gi'>\n<CrossReferences>\n";
+				if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>\n"}
+				if ($kw){$tempresponse .="<Object namespace='Global_Keyword' id='$kw'/>\n"}
+				if ($acc){$tempresponse .="<Object namespace='NCBI_Acc' id='$acc'/>\n"}
+				$tempresponse .="<Object namespace='NCBI_gi' id='$gi'/>\n";
+				$tempresponse .="<Object namespace='$ns' id='$identifier'/>
 					</CrossReferences>
-					<Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
-					</VirtualSequence>",
-					"", $qID);
+					 <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
+					 </VirtualSequence>";
+				$MOBY_RESPONSE .= simpleResponse($tempresponse,"", $qID);
 			}
 		}
     }
 	$aa = SHoundFini();
-	print STDERR responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter;
+#	print STDERR responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter;
     return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));    
 }
 
@@ -413,43 +438,59 @@
             (($MOBY_RESPONSE .= simpleResponse("", "No_Identifier_provided", $qID)) && next) unless $identifier;
 			if ($ns eq $validNS{'NCBI_gi'}){  # gi numbers are used natively by SeqHound
 				my ($SEQ, $length, $seq) = _makeSeqObj($identifier);
+				my ($acc, $kw, $taxon) = _getXrefs($SEQ);
 				my $objType = $objtype{$SEQ->alphabet};
 	            (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
-				$MOBY_RESPONSE .= simpleResponse("<$objType namespace='NCBI_gi' id='$identifier'>
-												 <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
+				my $tempresponse = "<$objType namespace='NCBI_gi' id='$identifier'><CrossReferences>\n";
+				if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>\n"}
+				if ($kw){$tempresponse .="<Object namespace='Global_Keyword' id='$kw'/>\n"}
+				if ($acc){$tempresponse .="<Object namespace='NCBI_Acc' id='$acc'/>\n"}
+				$tempresponse .="<Object namespace='NCBI_gi' id='$identifier'/>\n";
+				$tempresponse .="</CrossReferences>\n<Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
 												 <String namespace='' id='' articleName='SequenceString'>".($SEQ->seq)."</String>
-												 </$objType>", "", $qID);
+												 </$objType>";
+				$MOBY_RESPONSE .= simpleResponse($tempresponse, "", $qID);
 			} elsif ($ns eq $validNS{'NCBI_Acc'}){  # THIS ONE DOESN'T WORK YET????
 				my $gi = SHoundFindAcc($identifier);
 				(($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
 				my ($SEQ, $length, $seq) = _makeSeqObj($gi);
 	            (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
+				my ($acc, $kw, $taxon) = _getXrefs($SEQ);
 				my $objType = $objtype{$SEQ->alphabet};
-				$MOBY_RESPONSE .= simpleResponse("<$objType namespace='NCBI_gi' id='$gi'>
-					<CrossReferences>
-						<Object namespace='$ns' id='$identifier'/>
+				my $tempresponse = "<$objType namespace='NCBI_gi' id='$gi'>\n<CrossReferences>\n";
+				if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>\n"}
+				if ($kw){$tempresponse .="<Object namespace='Global_Keyword' id='$kw'/>\n"}
+				if ($acc){$tempresponse .="<Object namespace='NCBI_Acc' id='$acc'/>\n"}
+				$tempresponse .="<Object namespace='NCBI_gi' id='$gi'/>\n";
+				$tempresponse .="<Object namespace='$ns' id='$identifier'/>
 					</CrossReferences>
 					 <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
 					 <String namespace='' id='' articleName='SequenceString'>".($SEQ->seq)."</String>
-					 </$objType>", "", $qID);
+					 </$objType>";
+				$MOBY_RESPONSE .= simpleResponse($tempresponse,"", $qID);
 			} else {
 				my $gi = SHoundFindName($identifier);
 				(($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
 				my ($SEQ, $length, $seq) = _makeSeqObj($gi);
 	            (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
+				my ($acc, $kw, $taxon) = _getXrefs($SEQ);
 				my $objType = $objtype{$SEQ->alphabet};
-				$MOBY_RESPONSE .= simpleResponse("<$objType namespace='NCBI_gi' id='$gi'>
-					<CrossReferences>
-						<Object namespace='$ns' id='$identifier'/>
+				my $tempresponse = "<$objType namespace='NCBI_gi' id='$gi'>\n<CrossReferences>\n";
+				if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>\n"}
+				if ($kw){$tempresponse .="<Object namespace='Global_Keyword' id='$kw'/>\n"}
+				if ($acc){$tempresponse .="<Object namespace='NCBI_Acc' id='$acc'/>\n"}
+				$tempresponse .="<Object namespace='NCBI_gi' id='$gi'/>\n";
+				$tempresponse .="<Object namespace='$ns' id='$identifier'/>
 					</CrossReferences>
 					 <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
 					 <String namespace='' id='' articleName='SequenceString'>".($SEQ->seq)."</String>
-					 </$objType>", "", $qID);
+					 </$objType>";
+				$MOBY_RESPONSE .= simpleResponse($tempresponse,"", $qID);
 			}
 		}
     }
 	$aa = SHoundFini();
-	print STDERR responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter;
+#	print STDERR responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter;
     return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));    
 }
 
@@ -516,335 +557,6 @@
 }
 
 
-sub GenbankAccVirtualSequenceRetrieve {
-    my ($self, $data) = @_;
-
-    my $MOBY_RESPONSE;
-    my (@inputs)= genericServiceInputParser($data); # ([SIMPLE, $queryID, $simple],...)
-    return SOAP::Data->type('base64' => responseHeader() . responseFooter()) unless (scalar(@inputs));
-
-    my @validNS = validateNamespaces("NCBI_Acc");  # ONLY do this if you are intending to be namespace aware!
-
-    foreach (@inputs){
-        my ($articleType, $qID, $input) = @{$_};
-        unless ($articleType == SIMPLE){
-            $MOBY_RESPONSE .= simpleResponse("", "", $qID) ;
-            next;
-        } else {
-			(($MOBY_RESPONSE .= simpleResponse("", "no_input_object", $qID)) && (next)) unless (defined $input);
-			my $ns = getSimpleArticleNamespaceURI($input);
-			(($MOBY_RESPONSE .= simpleResponse([], "Invalid_Namespace", $qID)) && (next)) unless validateThisNamespace($ns, @validNS);  # only do this if you are truly validating namespaces
-			my ($acc) = defined(getSimpleArticleIDs($ns, [$input]))?getSimpleArticleIDs($ns,[$input]):undef;
-            ($MOBY_RESPONSE .= collectionResponse([], "No_Accession_provided", $qID) && (next)) unless defined $acc;
-			use Bio::DB::GenBank;
-			my $gb = new Bio::DB::GenBank(-retrievaltype => 'io_string');
-			my $seq = $gb->get_Seq_by_acc($acc);
-			my $length;
-			if ($seq){$length = $seq->length;}
-			if ($length){
-				$MOBY_RESPONSE .= simpleResponse("
-			<moby:VirtualSequence namespace='NCBI_Acc' id='$acc'>
-				<moby:Integer namespace='' id='' articleName='Length'>$length</moby:Integer>
-			</moby:VirtualSequence>", "", $qID);
-			} else {
-				$MOBY_RESPONSE .= simpleResponse("", "sequence_has_no_length", $qID);
-			}
-		}
-	}
-    return SOAP::Data->type('base64' => responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter);    
-}
-
-sub GenbankAccSequenceRetrieve {
-    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 => 'NCBI_Acc');
-	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 NCBI_Acc 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($data); # returns ([obj1, obj2], [obj3, obj4], [obj5], [obj6],...)
-	my @inputs;
-	foreach (@input_nodes){
-		push @inputs, $_->[0];  # we only allow one input object per query
-	}
-	@accessions = getSimpleArticleIDs($VALID_NAMESPACE, \@inputs);
-	foreach my $acc(@accessions){
-		unless (defined $acc){
-			$response .= simpleResponse("");
-			next;
-		}
-		use Bio::DB::GenBank;
-		my $gb = new Bio::DB::GenBank(-retrievaltype => 'io_string');
-		my $seq = $gb->get_Seq_by_acc($acc);
-		my $length;my $sequence;
-		if ($seq){$length = $seq->length;$sequence = $seq->seq}
-		if ($length){
-			$response .= simpleResponse("
-		<moby:GenericSequence namespace='NCBI_Acc' id='$acc'>
-			<moby:Integer namespace='' id='' articleName='Length'>$length</moby:Integer>
-			<moby:String namespace='' id='' articleName='SequenceString'>$sequence</moby:String>
-		</moby:GenericSequence>");
-		} else {
-			$response .= simpleResponse("");
-		}
-	}
-	
-    $response =  responseHeader() . $response . responseFooter();
-    my $SOAPResponse = SOAP::Data->type('base64' => $response);
-    return $SOAPResponse   
-}
-sub GenbankGIVirtualSequenceRetrieve {
-    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 => 'NCBI_gi');
-	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 NCBI_gi 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($data); # returns ([obj1, obj2], [obj3, obj4], [obj5], [obj6],...)
-	my @inputs;
-	foreach (@input_nodes){
-		push @inputs, $_->[0];  # we only allow one input object per query
-	}
-	@accessions = getSimpleArticleIDs($VALID_NAMESPACE, \@inputs);
-	foreach my $acc(@accessions){
-		unless (defined $acc){
-			$response .= simpleResponse("");
-			next;
-		}
-		use Bio::DB::GenBank;
-		my $gb = new Bio::DB::GenBank(-retrievaltype => 'io_string');
-		my $seq = $gb->get_Seq_by_gi($acc);
-		my $length;
-		if ($seq){$length = $seq->length;}
-		if ($length){
-			$response .= simpleResponse("
-		<moby:VirtualSequence namespace='NCBI_gi' id='$acc'>
-			<moby:Integer namespace='' id='' articleName='Length'>$length</moby:Integer>
-		</moby:VirtualSequence>");
-		} else {
-			$response .= simpleResponse("");
-		}
-	}
-	
-    $response =  responseHeader() . $response . responseFooter();
-    my $SOAPResponse = SOAP::Data->type('base64' => $response);
-    return $SOAPResponse   
-}
-
-sub GenbankGISequenceRetrieve {
-    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 => 'NCBI_gi');
-	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 NCBI_gi 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($data); # returns ([obj1, obj2], [obj3, obj4], [obj5], [obj6],...)
-	my @inputs;
-	foreach (@input_nodes){
-		push @inputs, $_->[0];  # we only allow one input object per query
-	}
-	@accessions = getSimpleArticleIDs($VALID_NAMESPACE, \@inputs);
-	foreach my $acc(@accessions){
-		unless (defined $acc){
-			$response .= simpleResponse("");
-			next;
-		}
-		use Bio::DB::GenBank;
-		my $gb = new Bio::DB::GenBank(-retrievaltype => 'io_string');
-		my $seq = $gb->get_Seq_by_gi($acc);  # get the sequence object for each gi
-		my $length;my $sequence;
-		if ($seq){$length = $seq->length;$sequence = $seq->seq}  # if it exists, get the length and sequence
-		if ($length){  # and construct the response
-			$response .= simpleResponse("
-		<moby:GenericSequence namespace='NCBI_gi' id='$acc'>
-			<moby:Integer namespace='' id='' articleName='Length'>$length</moby:Integer>
-			<moby:String namespace='' id='' articleName='SequenceString'>$sequence</moby:String>
-		</moby:GenericSequence>");
-		} else {
-			$response .= simpleResponse("");
-		}
-	}
-    $response =  responseHeader() . $response . responseFooter();
-    my $SOAPResponse = SOAP::Data->type('base64' => $response);
-    return $SOAPResponse;
-}
-#=================================================
-#=================================================
-#=================================================
-
-sub GenbankCompleteSequenceRetrieve {
-
-# this service is registered as consuming NCBI_Acc OR NCBI_gi
-# and producing GenericSequence objects.  However, it will
-# actually produce DNA, RNA or PRotein objects, as appropriate
-# and will produce a cross-reference block as well
-
-    my ($self, $data) = @_;
-    my $response; my @gis;
-
-	my ($GB_Acc_LSID, $GB_gi_LSID) = validateNamespaces('NCBI_Acc', 'NCBI_gi');
-	unless ($GB_Acc_LSID && $GB_gi_LSID){  # unless we could get the known namespace LSID's we should bail because somethign is very very wrong!
-		print STDERR "the namespace NCBI_Acc or NCBI_gi 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($data); # returns ([obj1, obj2], [obj3, obj4], [obj5], [obj6],...)
-	my @inputs;
-	foreach (@input_nodes){
-		push @inputs, $_->[0];  # we only allow one input object per query
-	}
-	foreach my $node(@inputs){
- 
-		my $namespace_LSID = getSimpleArticleNamespaceURI($node);  # get the LSID of the namespace for this input object
-		unless (($namespace_LSID eq $GB_Acc_LSID) || ($namespace_LSID eq $GB_gi_LSID)){ # validate the namespace
-			$response .= simpleResponse("");  # because we have to send one response per input, send a blank if bad namespace
-			next;
-		}
-			
-		my ($ID)= getSimpleArticleIDs($namespace_LSID, [$node]);  # get the ID within this namespace
-		unless (defined $ID){  # send a blank if we failed to get an id, 
-			$response .= simpleResponse("");  # because we have to send one response per input
-			next;
-		}
-
-		use Bio::DB::GenBank;
-		my $gb = new Bio::DB::GenBank(-retrievaltype => 'io_string');  # now that we have a namespace and ID, we are ready to retrieve
-		my $seq;
-		if ($namespace_LSID eq $GB_Acc_LSID){  # if the namespace is a genbank Accession thebn
-			$seq = $gb->get_Seq_by_acc($ID);  # get the sequence object for the accession
-		} elsif ($namespace_LSID  eq $GB_gi_LSID) { # if the namespace is a genbank gi
-			$seq = $gb->get_Seq_by_gi($ID);  # get the sequence object for the gi
-		} else {
-			$response .= simpleResponse("");  # if it is neither,then send a blank as required by the API
-			next;
-		}
-			
-		my $length;my $sequence;
-		if ($seq){
-			$length = $seq->length;$sequence = $seq->seq;  # if it exists, get the length and sequence
-		} else {
-			$response .= simpleResponse("");  # if we got nada, then send a blank as required
-			next;
-		}
-
-		my $gi = $seq->primary_id;		  # e.g. 163483
-		my $acc = $seq->accession;        # e.g. A123434
-		my $kw = $seq->species->binomial; # e.g. mus musculus
-		my $moltype = $seq->alphabet;     #  'dna', 'rna', 'protein'
-		my $taxon = $seq->species->ncbi_taxid;  # e.g. 1234
-		
-		my $ObjectType="GenericSequence";           # set it as the generic as default
-		if ($moltype eq 'dna'){$ObjectType = "DNASequence"}  # set to DNA
-		elsif ($moltype eq 'rna'){$ObjectType = "RNASequence"} # set to RNA
-		elsif ($moltype eq 'protein'){$ObjectType = "AminoAcidSequence"}  # set to Protein
-		
-		if ($length){  # and construct the response; luckily, all of these objects have exactly the same structure :-)
-			my $tempresponse .= "
-		<moby:$ObjectType namespace='$namespace_LSID' id='$ID'>
-			<CrossReference>";
-			if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>"}
-			if ($kw){$tempresponse .="<Object namespace='Global_Keyword' id='$kw'/>"}
-			if ($acc && !($namespace_LSID eq $GB_Acc_LSID)){$tempresponse .="<Object namespace='NCBI_Acc' id='$acc'/>"}
-			if ($gi && !($namespace_LSID eq $GB_gi_LSID)){$tempresponse .="<Object namespace='NCBI_gi' id='$gi'/>"}
-			$tempresponse .="</CrossReference>
-			<moby:Integer namespace='' id='' articleName='Length'>$length</moby:Integer>
-			<moby:String namespace='' id='' articleName='SequenceString'>$sequence</moby:String>
-		</moby:$ObjectType>";
-			$response .= simpleResponse($tempresponse);
-		} else {
-			$response .= simpleResponse("");  # if we failed to get a sequence length, then something weird happened, so just ignore it
-		}
-	}
-    my $fullresponse =  responseHeader() . $response . responseFooter();  # add the headers and footers
-    my $SOAPResponse = SOAP::Data->type('base64' => $fullresponse);  # base 64 encode it (optional)
-    return $SOAPResponse;	
-}
-
-
-sub GenbankRecordRetrieve {
-	use Bio::SeqIO;
-	use IO::String;
-    my ($self, $data) = @_;
-    my $response; # prepare a variable to hold the responses
-
-	# Step 1 - validate the namespaces you plan to accept as input
-	my ($GB_Acc_LSID, $GB_gi_LSID, $EMBL_LSID) = validateNamespaces('NCBI_Acc', 'NCBI_gi', 'EMBL');
-	unless ($GB_Acc_LSID && $GB_gi_LSID && $EMBL_LSID){  # unless we could get the known namespace LSID's we should bail because somethign is very very wrong!
-		print STDERR "the namespace NCBI_Acc, NCBI_gi, or EMBL_LSID that we are expecting does not exist in the MOBY namespace ontology\n";
-		return SOAP::Data->type('base64' => responseHeader() . responseFooter());  # base 64 encode it (optional)
-	}
-
-	# Step 2 - get your input objects
-	# in this case, we have registered as accepting
-	# only simple inputs (not collections), therefore
-	# we can insist on that constraint.
-	my @inputs = getInputArticles($data); # returns ([SimpleDOM], [SimpleDOM],...), each represents a unique query input
-	foreach my $node(@inputs){
-		# do a bit of simple validation
-		# the next 12 lines or so are ~cut-n-paste for every service
-		unless (isSimpleArticle($node)){ 		# we only allow Simple inputs to this service, ignore anything else
-			$response .= simpleResponse("");	# because we have to send one response per input, send a blank if it fails
-			next;
-		}
-		my $namespace_LSID = getSimpleArticleNamespaceURI($node);  # get the LSID of the namespace for this input object
-		unless (($namespace_LSID eq $GB_Acc_LSID) || ($namespace_LSID eq $GB_gi_LSID) || $namespace_LSID eq $EMBL_LSID){ # validate the namespace
-			$response .= simpleResponse("");  # because we have to send one response per input, send a blank if bad namespace
-			next;
-		}
-		my ($ID)= getSimpleArticleIDs($namespace_LSID, [$node]);  # get the ID within this namespace
-		unless (defined $ID){  # send a blank if we failed to get an id, 
-			$response .= simpleResponse("");  # because we have to send one response per input, send a blank if there is no id (?!?)
-			next;
-		}
-
-		# Now, do the analysis
-		use Bio::DB::GenBank;
-		use Bio::DB::EMBL;
-		my $gb = new Bio::DB::GenBank(-retrievaltype => 'io_string');  # now that we have a namespace and ID, we are ready to retrieve
-		my $emb = new Bio::DB::EMBL(-retrievaltype => 'io_string');
-		my $seq;
-		if ($namespace_LSID eq $GB_Acc_LSID){  # if the namespace is a genbank Accession thebn
-			$seq = $gb->get_Seq_by_acc($ID);  # get the sequence object for the accession
-		} elsif ($namespace_LSID  eq $GB_gi_LSID) { # if the namespace is a genbank gi
-			$seq = $gb->get_Seq_by_gi($ID);  # get the sequence object for the gi
-		} elsif ($namespace_LSID  eq $EMBL_LSID) { # if the namespace is a genbank gi
-			$seq = $gb->get_Seq_by_acc($ID);  # get the sequence object for the gi
-		} else {
-			$response .= simpleResponse("");  # if it is neither,then send a blank as required by the API
-			next;
-		}
-
-		my $string;
-		my $stringio = IO::String->new($string);
-		my $out = Bio::SeqIO->new('-fh' => $stringio,
-							   '-format' => 'genbank');
-		# output goes into $string
-		$out->write_seq($seq);
-		$response .= simpleResponse("<moby:genbank-flatfile namespace='$namespace_LSID' id='$ID'><![CDATA[$string]]></moby:genbank-flatfile>"); # append this queryResponse to the list
-	}
-    my $fullresponse =  responseHeader() . $response . responseFooter();  # add the headers and footers around all queryResponses
-    my $SOAPResponse = SOAP::Data->type('base64' => $fullresponse);  # base 64 encode it (optional)
-    return $SOAPResponse;	# and yer done!
-}
-
 
 #################################################
 #################################################




More information about the MOBY-guts mailing list