[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Thu Dec 11 15:36:38 UTC 2003
mwilkinson
Thu Dec 11 10:36:38 EST 2003
Update of /home/repository/moby/moby-live/Perl/scripts/Services
In directory pub.open-bio.org:/tmp/cvs-serv3402/Perl/scripts/Services
Modified Files:
LocalServices.pm
Log Message:
the last of the Sequence services complete. We now return genbank flatfiles, fasta, Virtual, DNA, RNA, AA sequence objects for gi's, gb accessions, PDB, embl (embl doesn't work at the moment for unknown reasons), SP, and PIR. These services should be sufficient for me to de-register the services that are currently depending on genbank via bioperl. Unfortunately, genbank is sufficiently unreliable that I am embarrassed to build services that use their interfaces because as often as not they don't work...
moby-live/Perl/scripts/Services LocalServices.pm,1.44,1.45
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm 2003/12/10 22:45:11 1.44
+++ /home/repository/moby/moby-live/Perl/scripts/Services/LocalServices.pm 2003/12/11 15:36:38 1.45
@@ -12,6 +12,7 @@
use DBI;
use DBD::mysql;
use GO::AppHandle;
+use IO::String;
use MIME::Base64;
use XML::DOM;
use MOBY::Client::OntologyServer;
@@ -28,6 +29,46 @@
use vars qw(@ISA);
+##################################################
+##################################################
+# ALL BROWSERS PLEASE NOTE!!
+# Most of the subroutines in this module use the
+# following basic template for service
+# provision. They add a few more lines to do
+# error_checking and validations, but generally
+# speaking the few lines below are all
+# that a service requires :-)
+##################################################
+##################################################
+
+sub _generic_service_template {
+ my ($caller, $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 {
+ my $namespace = getSimpleArticleNamespaceURI($input);
+ my ($identifier) = getSimpleArticleIDs($input); # note array output!
+ # do your thing here!
+ }
+ }
+ return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));
+}
+
+##################################################
+##################################################
+##################################################
+##################################################
+
+
sub getGoTerm {
my ($caller, $message) = @_;
my $MOBY_RESPONSE;
@@ -204,29 +245,79 @@
# = namespace =
# ===============================================
-sub _generic_service_template {
+
+sub MOBYSHoundGetGenBankff {
my ($caller, $data) = @_;
- my $MOBY_RESPONSE;
+ my $MOBY_RESPONSE;
+
+ my $aa = SHoundInit("TRUE", "MOBY_SHoundGetGenBankff_Service"); # initialize SeqHound
+ $aa = SHoundIsInited(); # confirm initialization
+ return SOAP::Data->type('base64' => responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter) unless $aa eq "TRUE";
+
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!
+ my %validNS;
+ foreach (qw(NCBI_Acc NCBI_gi PIR Swiss-Prot EMBL PDB)){
+ my ($valid) = validateNamespaces($_); # we are going to ignore anything that is invalid
+ $validNS{$_} = $valid;
+ }
foreach (@inputs){
my ($articleType, $qID, $input) = @{$_};
- unless ($articleType == SIMPLE){
- $MOBY_RESPONSE .= simpleResponse("", "", $qID) ;
+ unless (($articleType == SIMPLE) && (defined($input))){ # we only accept simple inputs to this service
+ $MOBY_RESPONSE .= simpleResponse("", "", $qID) ; # send back a blank response for this queryID
next;
} else {
- my $namespace = getSimpleArticleNamespaceURI($input);
- my ($identifier) = getSimpleArticleIDs($input); # note array output!
- # do your thing here!
- }
+ 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
+ my ($identifier) = getSimpleArticleIDs($input);
+ (($MOBY_RESPONSE .= simpleResponse("", "No_Identifier_provided", $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("<genbank-flatfile namespace='NCBI_gi' id='$identifier'><![CDATA[$gb]]></genbank-flatfile>", "", $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 $gb = SHoundGetGenBankff($gi);
+ (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
+ $MOBY_RESPONSE .= simpleResponse("<genbank-flatfile namespace='NCBI_gi' id='$gi'>
+ <CrossReferences>
+ <Object namespace='$ns' id='$identifier'/>
+ </CrossReferences>
+ <![CDATA[$gb]]></genbank-flatfile>",
+ "", $qID);
+ } else {
+ my $gi = SHoundFindName($identifier);
+ (($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
+ my $gb = SHoundGetGenBankff($gi);
+ (($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
+ $MOBY_RESPONSE .= simpleResponse("<genbank-flatfile namespace='NCBI_gi' id='$gi'>
+ <CrossReferences>
+ <Object namespace='$ns' id='$identifier'/>
+ </CrossReferences>
+ <![CDATA[$gb]]></genbank-flatfile>",
+ "", $qID);
+ }
+ }
}
+ $aa = SHoundFini();
+ #print STDERR responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter;
return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));
}
-sub MOBYSHoundGetGenBankff {
+sub _makeSeqObj {
+ my ($id) = @_;
+ my $gb = SHoundGetGenBankff($id);
+ return undef unless $gb;
+ my $gbio = IO::String->new($gb);
+ my $sio = Bio::SeqIO->new(-fh => \*$gbio, '-format' => 'genbank');
+ my $seq = $sio->next_seq;
+ return ($seq, $seq->length, $seq->seq);
+}
+
+sub MOBYSHoundGetGenBankVirtSequence {
my ($caller, $data) = @_;
my $MOBY_RESPONSE;
@@ -254,30 +345,167 @@
my ($identifier) = getSimpleArticleIDs($input);
(($MOBY_RESPONSE .= simpleResponse("", "No_Identifier_provided", $qID)) && next) unless $identifier;
if ($ns eq $validNS{'NCBI_gi'}){ # gi numbers are used natively by SeqHound
- my $gb = SHoundGetGenBankff($identifier);
+ 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);
+ } 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'/>
+ </CrossReferences>
+ <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
+ </VirtualSequence>",
+ "", $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'/>
+ </CrossReferences>
+ <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
+ </VirtualSequence>",
+ "", $qID);
+ }
+ }
+ }
+ $aa = SHoundFini();
+ print STDERR responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter;
+ return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));
+}
+
+sub MOBYSHoundGetGenBankWhateverSequence {
+ my ($caller, $data) = @_;
+ my $MOBY_RESPONSE;
+
+ my %objtype = ('dna', "DNASequence", 'rna', "RNASequence", 'protein', "AminoAcidSequence");
+
+ my $aa = SHoundInit("TRUE", "MOBY_SHoundGetGenBankff_Service"); # initialize SeqHound
+ $aa = SHoundIsInited(); # confirm initialization
+ return SOAP::Data->type('base64' => responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter) unless $aa eq "TRUE";
+
+ my (@inputs)= genericServiceInputParser($data); # ([SIMPLE, $queryID, $simple],...)
+ return SOAP::Data->type('base64' => responseHeader() . responseFooter()) unless (scalar(@inputs));
+
+ my %validNS;
+ foreach (qw(NCBI_Acc NCBI_gi PIR Swiss-Prot EMBL PDB)){
+ my ($valid) = validateNamespaces($_); # we are going to ignore anything that is invalid
+ $validNS{$_} = $valid;
+ }
+
+ foreach (@inputs){
+ my ($articleType, $qID, $input) = @{$_};
+ unless (($articleType == SIMPLE) && (defined($input))){ # we only accept simple inputs to this service
+ $MOBY_RESPONSE .= simpleResponse("", "", $qID) ; # send back a blank response for this queryID
+ 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
+ my ($identifier) = getSimpleArticleIDs($input);
+ (($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 $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>
+ <String namespace='' id='' articleName='SequenceString'>".($SEQ->seq)."</String>
+ </$objType>", "", $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 $objType = $objtype{$SEQ->alphabet};
+ $MOBY_RESPONSE .= simpleResponse("<$objType namespace='NCBI_gi' id='$gi'>
+ <CrossReferences>
+ <Object namespace='$ns' id='$identifier'/>
+ </CrossReferences>
+ <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
+ <String namespace='' id='' articleName='SequenceString'>".($SEQ->seq)."</String>
+ </$objType>", "", $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 $objType = $objtype{$SEQ->alphabet};
+ $MOBY_RESPONSE .= simpleResponse("<$objType namespace='NCBI_gi' id='$gi'>
+ <CrossReferences>
+ <Object namespace='$ns' id='$identifier'/>
+ </CrossReferences>
+ <Integer namespace='' id='' articleName='Length'>".($SEQ->length)."</Integer>
+ <String namespace='' id='' articleName='SequenceString'>".($SEQ->seq)."</String>
+ </$objType>", "", $qID);
+ }
+ }
+ }
+ $aa = SHoundFini();
+ print STDERR responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter;
+ return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));
+}
+
+sub MOBYSHoundGetGenBankFasta {
+ my ($caller, $data) = @_;
+ my $MOBY_RESPONSE;
+
+ my $aa = SHoundInit("TRUE", "MOBY_SHoundGetGenBankff_Service"); # initialize SeqHound
+ $aa = SHoundIsInited(); # confirm initialization
+ return SOAP::Data->type('base64' => responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter) unless $aa eq "TRUE";
+
+ my (@inputs)= genericServiceInputParser($data); # ([SIMPLE, $queryID, $simple],...)
+ return SOAP::Data->type('base64' => responseHeader() . responseFooter()) unless (scalar(@inputs));
+
+ my %validNS;
+ foreach (qw(NCBI_Acc NCBI_gi PIR Swiss-Prot EMBL PDB)){
+ my ($valid) = validateNamespaces($_); # we are going to ignore anything that is invalid
+ $validNS{$_} = $valid;
+ }
+
+ foreach (@inputs){
+ my ($articleType, $qID, $input) = @{$_};
+ unless (($articleType == SIMPLE) && (defined($input))){ # we only accept simple inputs to this service
+ $MOBY_RESPONSE .= simpleResponse("", "", $qID) ; # send back a blank response for this queryID
+ 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
+ my ($identifier) = getSimpleArticleIDs($input);
+ (($MOBY_RESPONSE .= simpleResponse("", "No_Identifier_provided", $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("<genbank-flatfile namespace='NCBI_gi' id='$identifier'><![CDATA[$gb]]></genbank-flatfile>", "", $qID);
+ $MOBY_RESPONSE .= simpleResponse("<FASTA namespace='NCBI_gi' id='$identifier'><![CDATA[$gb]]></FASTA>", "", $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 $gb = SHoundGetGenBankff($gi);
+ my $gb = SHoundGetFasta($gi);
(($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
- $MOBY_RESPONSE .= simpleResponse("<genbank-flatfile namespace='NCBI_gi' id='$gi'>
+ $MOBY_RESPONSE .= simpleResponse("<FASTA namespace='NCBI_gi' id='$gi'>
<CrossReferences>
<Object namespace='$ns' id='$identifier'/>
</CrossReferences>
- <![CDATA[$gb]]></genbank-flatfile>",
+ <![CDATA[$gb]]></FASTA>",
"", $qID);
} else {
my $gi = SHoundFindName($identifier);
(($MOBY_RESPONSE .= simpleResponse("", "No_gi_found_for_accession", $qID)) && next) unless $gi;
- my $gb = SHoundGetGenBankff($gi);
+ my $gb = SHoundGetFasta($gi);
(($MOBY_RESPONSE .= simpleResponse("", "No_genbank_record_found", $qID)) && next) unless $gb;
- $MOBY_RESPONSE .= simpleResponse("<genbank-flatfile namespace='NCBI_gi' id='$gi'>
+ $MOBY_RESPONSE .= simpleResponse("<FASTA namespace='NCBI_gi' id='$gi'>
<CrossReferences>
<Object namespace='$ns' id='$identifier'/>
</CrossReferences>
- <![CDATA[$gb]]></genbank-flatfile>",
+ <![CDATA[$gb]]></FASTA>",
"", $qID);
}
}
@@ -287,6 +515,7 @@
return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter));
}
+
sub GenbankAccVirtualSequenceRetrieve {
my ($self, $data) = @_;
More information about the MOBY-guts
mailing list