[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Mon Feb 9 21:45:44 UTC 2004
mwilkinson
Mon Feb 9 16:45:44 EST 2004
Update of /home/repository/moby/moby-live/Perl/scripts/Services
In directory pub.open-bio.org:/tmp/cvs-serv1380/Perl/scripts/Services
Modified Files:
LocalServices.pm
Log Message:
Darn Pedantic Rebecca caught me breaking the API. She's right, the last change I made to my services caused them all to return an empty <Simple/> block instead of an empty <Response/> block in the result of an invalid service call. They should all now be fixed and behaving properly. Added a new service to return all of the GI's for a given taxon ID.
moby-live/Perl/scripts/Services LocalServices.pm,1.54,1.55
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm 2004/01/18 04:00:25 1.54
+++ /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm 2004/02/09 21:45:44 1.55
@@ -88,6 +88,41 @@
##################################################
##################################################
+
+sub getSHoundProteinsFromTaxID { # WORKS
+ 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("taxon"); # ONLY do this if you are intending to be namespace aware!
+ return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . responseFooter)) unless $validNS;
+
+ 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!
+ (($MOBY_RESPONSE .= collectionResponse([], "", $qID)) && next) unless ($namespace eq $validNS);
+ my $proteinGIs = SHoundProteinsFromTaxID($identifier);
+ (($MOBY_RESPONSE .= collectionResponse([], "", $qID)) && next) unless ($proteinGIs);
+ my @proteinGIs = split ",", $proteinGIs;
+ my @simples;
+ foreach my $gi (@proteinGIs){
+ next unless $gi;
+ $gi =~ s/\s//g;
+ push @simples, "<Object namespace='NCBI_gi' id='$gi'/>";
+ }
+ $MOBY_RESPONSE .= collectionResponse(\@simples, "", $qID);
+ }
+ }
+ print STDERR responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter;
+ return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));
+}
+
sub getTaxChildNodes { # WORKS
my ($caller, $data) = @_;
my $MOBY_RESPONSE;
@@ -105,9 +140,9 @@
} else {
my $namespace = getSimpleArticleNamespaceURI($input);
my ($identifier) = getSimpleArticleIDs($input); # note array output!
- $MOBY_RESPONSE .= collectionResponse([], "wrong_namespace", $qID) unless ($namespace eq $validNS);
+ (($MOBY_RESPONSE .= collectionResponse([], "", $qID)) && next) unless ($namespace eq $validNS);
my $children = SHoundGetTaxChildNodes($identifier);
- $MOBY_RESPONSE .= collectionResponse([], "nothing_found", $qID) unless ($children);
+ (($MOBY_RESPONSE .= collectionResponse([], "", $qID)) && next) unless ($children);
my @children = split ",", $children;
my @simples;
foreach my $taxon (@children){
@@ -139,9 +174,9 @@
} else {
my $namespace = getSimpleArticleNamespaceURI($input);
my ($identifier) = getSimpleArticleIDs($input); # note array output!
- $MOBY_RESPONSE .= simpleResponse("", "wrong_namespace", $qID) unless ($namespace eq $validNS);
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless ($namespace eq $validNS);
my $parent = SHoundGetTaxParent($identifier);
- $MOBY_RESPONSE .= simpleResponse("", "nothing_found", $qID) unless ($parent);
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless ($parent);
$parent && ($MOBY_RESPONSE .= simpleResponse("<Object namespace='taxon' id='$parent'/>", "", $qID));
}
}
@@ -167,9 +202,9 @@
} else {
my $namespace = getSimpleArticleNamespaceURI($input);
my ($identifier) = getSimpleArticleIDs($input); # note array output!
- $MOBY_RESPONSE .= simpleResponse("", "wrong_namespace", $qID) unless ($namespace eq $validNS);
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless ($namespace eq $validNS);
my $name = SHoundGetTaxNameFromTaxID($identifier);
- $MOBY_RESPONSE .= simpleResponse("", "nothing_found", $qID) unless ($name);
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless ($name);
$name && ($MOBY_RESPONSE .= simpleResponse("<String namespace='taxon' id='$identifier'>
<CrossReference>
<Object namespace='Global_Keyword' id='$name'/>
@@ -195,14 +230,14 @@
foreach (@inputs){
my ($articleType, $ID, $input) = @{$_};
unless ($articleType == SIMPLE){
- $MOBY_RESPONSE .= simpleResponse("", "Collection_Article_Not_allowed_as_input", $ID);
+ $MOBY_RESPONSE .= simpleResponse("", "", $ID);
next;
} else {
my $ns = getSimpleArticleNamespaceURI($input);
- (($MOBY_RESPONSE .= simpleResponse("", "Invalid_Namespace", $ID)) && (next)) unless validateThisNamespace($ns, @validNS); # only do this if you are truly validating namespaces
+ (($MOBY_RESPONSE .= simpleResponse("", "", $ID)) && (next)) unless validateThisNamespace($ns, @validNS); # only do this if you are truly validating namespaces
my ($accession) = defined(getSimpleArticleIDs($ns, [$input]))?getSimpleArticleIDs($ns,[$input]):undef;
unless (defined($accession)){
- $MOBY_RESPONSE .= simpleResponse("", "Invalid_Accession", $ID);
+ $MOBY_RESPONSE .= simpleResponse("", "", $ID);
next;
}
unless ($accession =~/^GO:/){
@@ -217,7 +252,7 @@
<moby:String namespace='' id='' articleName='Definition'>$def</moby:String>
</moby:GO_Term>", "GO_Term_From_ID", $ID)
} else {
- $MOBY_RESPONSE .= simpleResponse("", "NO_Term_Found", $ID)
+ $MOBY_RESPONSE .= simpleResponse("", "", $ID)
}
}
}
@@ -261,14 +296,14 @@
foreach (@inputs){
my ($articleType, $ID, $input) = @{$_};
unless ($articleType == SIMPLE){
- $MOBY_RESPONSE .= collectionResponse([], "Collection_Article_Input_Invalid", $ID) ;
+ $MOBY_RESPONSE .= collectionResponse([], "", $ID) ;
next;
} else {
my $ns = getSimpleArticleNamespaceURI($input);
- (($MOBY_RESPONSE .= $MOBY_RESPONSE .= collectionResponse([], "Invalid_Namespace", $ID)) && (next)) unless validateThisNamespace($ns, @validNS); # only do this if you are truly validating namespaces
+ (($MOBY_RESPONSE .= $MOBY_RESPONSE .= collectionResponse([], "", $ID)) && (next)) unless validateThisNamespace($ns, @validNS); # only do this if you are truly validating namespaces
my ($acc) = defined(getSimpleArticleIDs($ns, [$input]))?getSimpleArticleIDs($ns,[$input]):undef;
unless (defined($acc)){
- $MOBY_RESPONSE .= collectionResponse([], "Invalid_Accession", $ID);
+ $MOBY_RESPONSE .= collectionResponse([], "", $ID);
next;
}
unless ($acc =~/^GO:/){
@@ -316,13 +351,13 @@
foreach (@inputs){
my ($articleType, $ID, $input) = @{$_};
unless ($articleType == SIMPLE){
- $MOBY_RESPONSE .= collectionResponse([], "Collection_Input_Invalid", $ID) ;
+ $MOBY_RESPONSE .= collectionResponse([], "", $ID) ;
next;
} else {
my $ns = getSimpleArticleNamespaceURI($input);
- (($MOBY_RESPONSE .= collectionResponse([], "Invalid_Namespace", $ID)) && (next)) unless validateThisNamespace($ns, @validNS); # only do this if you are truly validating namespaces
+ (($MOBY_RESPONSE .= collectionResponse([], "", $ID)) && (next)) unless validateThisNamespace($ns, @validNS); # only do this if you are truly validating namespaces
my ($kw) = defined(getSimpleArticleIDs($ns, [$input]))?getSimpleArticleIDs($ns,[$input]):undef;
- ($MOBY_RESPONSE .= collectionResponse([], "No_Keyword", $ID) && (next)) unless defined $kw;
+ ($MOBY_RESPONSE .= collectionResponse([], "", $ID) && (next)) unless defined $kw;
($kw) = (($kw =~ /^\s*(.*)\s*$/) && ($1));
my @terms = @{$GO_API->get_terms({search=>"$kw"})};
next unless($terms[0]);
@@ -373,18 +408,18 @@
next;
} else {
my $ns = getSimpleArticleNamespaceURI($input);
- (($MOBY_RESPONSE .= simpleResponse("", "Invalid_Namespace", $qID)) && next) unless validateThisNamespace($ns, values(%validNS)); # return blank if they have sent us a namespace we don't understand
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless validateThisNamespace($ns, values(%validNS)); # return blank if they have sent us a namespace we don't understand
my ($identifier) = getSimpleArticleIDs($input);
- (($MOBY_RESPONSE .= simpleResponse("", "No_Identifier_provided", $qID)) && next) unless $identifier;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $identifier;
if ($ns eq $validNS{'NCBI_gi'}){ # gi numbers are used natively by SeqHound
my $gb = SHoundGetGenBankff($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gb;
$MOBY_RESPONSE .= simpleResponse("<genbank-flatfile namespace='NCBI_gi' id='$identifier'><![CDATA[$gb]]></genbank-flatfile>", "", $qID);
} elsif (($ns eq $validNS{'NCBI_Acc'}) || ($ns eq $validNS{'EMBL'})){
my $gi = SHoundFindAcc($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gi;
my $gb = SHoundGetGenBankff($gi);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gb;
$MOBY_RESPONSE .= simpleResponse("<genbank-flatfile namespace='NCBI_gi' id='$gi'>
<CrossReference>
<Object namespace='$ns' id='$identifier'/>
@@ -393,9 +428,9 @@
"", $qID);
} else {
my $gi = SHoundFindName($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gi;
my $gb = SHoundGetGenBankff($gi);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gb;
$MOBY_RESPONSE .= simpleResponse("<genbank-flatfile namespace='NCBI_gi' id='$gi'>
<CrossReference>
<Object namespace='$ns' id='$identifier'/>
@@ -454,9 +489,9 @@
next;
} else {
my $ns = getSimpleArticleNamespaceURI($input);
- (($MOBY_RESPONSE .= simpleResponse("", "Invalid_Namespace", $qID)) && next) unless validateThisNamespace($ns, values(%validNS)); # return blank if they have sent us a namespace we don't understand
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless validateThisNamespace($ns, values(%validNS)); # return blank if they have sent us a namespace we don't understand
my ($identifier) = getSimpleArticleIDs($input);
- (($MOBY_RESPONSE .= simpleResponse("", "No_Identifier_provided", $qID)) && next) unless $identifier;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $identifier;
if ($ns eq $validNS{'NCBI_gi'}){ # gi numbers are used natively by SeqHound
my ($SEQ, $length, $seq) = _makeSeqObj($identifier);
@@ -471,9 +506,9 @@
$MOBY_RESPONSE .= simpleResponse($tempresponse, "", $qID);
} elsif (($ns eq $validNS{'NCBI_Acc'}) || ($ns eq $validNS{'EMBL'})){
my $gi = SHoundFindAcc($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gi;
my ($SEQ, $length, $seq) = _makeSeqObj($gi);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $SEQ;
my ($acc, $kw, $taxon) = _getXrefs($SEQ);
my $tempresponse = "<VirtualSequence namespace='NCBI_gi' id='$gi'>\n<CrossReference>\n";
if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>\n"}
@@ -487,9 +522,9 @@
$MOBY_RESPONSE .= simpleResponse($tempresponse,"", $qID);
} else {
my $gi = SHoundFindName($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gi;
my ($SEQ, $length, $seq) = _makeSeqObj($gi);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $SEQ;
my ($acc, $kw, $taxon) = _getXrefs($SEQ);
my $tempresponse = "<VirtualSequence namespace='NCBI_gi' id='$gi'>\n<CrossReference>\n";
if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>\n"}
@@ -535,14 +570,14 @@
next;
} else {
my $ns = getSimpleArticleNamespaceURI($input);
- (($MOBY_RESPONSE .= simpleResponse("", "Invalid_Namespace", $qID)) && next) unless validateThisNamespace($ns, values(%validNS)); # return blank if they have sent us a namespace we don't understand
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless validateThisNamespace($ns, values(%validNS)); # return blank if they have sent us a namespace we don't understand
my ($identifier) = getSimpleArticleIDs($input);
- (($MOBY_RESPONSE .= simpleResponse("", "No_Identifier_provided", $qID)) && next) unless $identifier;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $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("", "", $qID)) && next) unless $SEQ;
my $tempresponse = "<$objType namespace='NCBI_gi' id='$identifier'><CrossReference>\n";
if ($taxon){ $tempresponse .="<Object namespace='taxon' id='$taxon'/>\n"}
if ($kw){$tempresponse .="<Object namespace='Global_Keyword' id='$kw'/>\n"}
@@ -554,9 +589,9 @@
$MOBY_RESPONSE .= simpleResponse($tempresponse, "", $qID);
} elsif (($ns eq $validNS{'NCBI_Acc'}) || ($ns eq $validNS{'EMBL'})){
my $gi = SHoundFindAcc($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gi;
my ($SEQ, $length, $seq) = _makeSeqObj($gi);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $SEQ;
my ($acc, $kw, $taxon) = _getXrefs($SEQ);
my $objType = $objtype{$SEQ->alphabet};
my $tempresponse = "<$objType namespace='NCBI_gi' id='$gi'>\n<CrossReference>\n";
@@ -572,9 +607,9 @@
$MOBY_RESPONSE .= simpleResponse($tempresponse,"", $qID);
} else {
my $gi = SHoundFindName($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gi;
my ($SEQ, $length, $seq) = _makeSeqObj($gi);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $SEQ;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $SEQ;
my ($acc, $kw, $taxon) = _getXrefs($SEQ);
my $objType = $objtype{$SEQ->alphabet};
my $tempresponse = "<$objType namespace='NCBI_gi' id='$gi'>\n<CrossReference>\n";
@@ -620,19 +655,19 @@
next;
} else {
my $ns = getSimpleArticleNamespaceURI($input);
- (($MOBY_RESPONSE .= simpleResponse("", "Invalid_Namespace", $qID)) && next) unless validateThisNamespace($ns, values(%validNS)); # return blank if they have sent us a namespace we don't understand
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless validateThisNamespace($ns, values(%validNS)); # return blank if they have sent us a namespace we don't understand
my ($identifier) = getSimpleArticleIDs($input);
- (($MOBY_RESPONSE .= simpleResponse("", "No_Identifier_provided", $qID)) && next) unless $identifier;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $identifier;
if ($ns eq $validNS{'NCBI_gi'}){ # gi numbers are used natively by SeqHound
my $gb = SHoundGetFasta($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gb;
$MOBY_RESPONSE .= simpleResponse("<FASTA namespace='NCBI_gi' id='$identifier'><![CDATA[$gb]]></FASTA>", "", $qID);
} elsif (($ns eq $validNS{'NCBI_Acc'}) || ($ns eq $validNS{'EMBL'})){
my $gi = SHoundFindAcc($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gi;
my $gb = SHoundGetFasta($gi);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gb;
$MOBY_RESPONSE .= simpleResponse("<FASTA namespace='NCBI_gi' id='$gi'>
<CrossReference>
<Object namespace='$ns' id='$identifier'/>
@@ -641,9 +676,9 @@
"", $qID);
} else {
my $gi = SHoundFindName($identifier);
- (($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gi;
my $gb = SHoundGetFasta($gi);
- (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
+ (($MOBY_RESPONSE .= simpleResponse("", "", $qID)) && next) unless $gb;
$MOBY_RESPONSE .= simpleResponse("<FASTA namespace='NCBI_gi' id='$gi'>
<CrossReference>
<Object namespace='$ns' id='$identifier'/>
More information about the MOBY-guts
mailing list