[MOBY-guts] biomoby commit

Frank Gibbons fgibbons at pub.open-bio.org
Thu Sep 1 14:00:00 UTC 2005


fgibbons
Thu Sep  1 10:00:00 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv6010/MOBY

Modified Files:
	CommonSubs.pm 
Log Message:
 - Test for namespace agreement in a way that avoids warning messages. Also remove redundant 'name:' lines, which merely duplicate the =head2 lines above them.

moby-live/Perl/MOBY CommonSubs.pm,1.67,1.68
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2005/08/30 15:31:52	1.67
+++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2005/09/01 14:00:00	1.68
@@ -248,7 +248,6 @@
 
 =head2 genericServiceInputParser
 
- name     : genericServiceInputParser
  function : For the MOST SIMPLE SERVICES that take single Simple or Collection inputs
             and no Secondaries/Parameters this routine takes the MOBY message and
             breaks the objects out of it in a useful way
@@ -329,7 +328,7 @@
 
 =head2 serviceInputParser
 
- name     : DO NOT USE!!
+ DO NOT USE!!
  function : to take a MOBY message and break the objects out of it.  This is identical
             to the genericServiceInputParser method above, except that it returns the data as
             Objects rather than XML::LibXML nodes.  This is an improvement!
@@ -372,7 +371,6 @@
 
 =head2 complexServiceInputParser
 
- name     : complexServiceInputParser
  function : For more complex services that have multiple articles for each input
             and/or accept parameters, this routine will take a MOBY message and
             extract the Simple/Collection/Parameter objects out of it in a
@@ -534,7 +532,6 @@
 
 =head2 getSimpleArticleIDs
 
- name     : getSimpleArticleIDs
  function : to get the IDs of simple articles that are in the given namespace
  usage    : my @ids = getSimpleArticleIDs("NCBI_gi", \@SimpleArticles);
             my @ids = getSimpleArticleIDs(\@SimpleArticles);
@@ -566,15 +563,17 @@
   return undef unless scalar @{$input_nodes};
   my @input_nodes = @{$input_nodes};
   my $OS          = MOBY::Client::OntologyServer->new;
-  my ( $s, $m );
+  my ( $s, $m, $namespace_lsid );
   if ( $desired_namespace ) {
-    ( $s, $m, $desired_namespace ) =
+    ( $s, $m, $namespace_lsid ) =
       $OS->namespaceExists( term => $desired_namespace ); # returns (success, message, lsid)
     unless ( $s ) {    # bail if not successful
-      print STDERR
-	"MOBY::CommonSubs WARNING ** the namespace '$desired_namespace' does not exist in the MOBY ontology, and is not a valid LSID\n";
+      # Printing to STDERR is not very helpful - we should probably return something that can be dealt iwth programatically....
+      print STDERR "MOBY::CommonSubs WARNING ** the namespace '$desired_namespace' "
+	. "does not exist in the MOBY ontology, and does not have a valid LSID\n";
       return undef;
     }
+    $desired_namespace = $namespace_lsid; # Replace namespace with fully-qualified LSID
   }
   my @ids;
   foreach my $in ( @input_nodes ) {
@@ -593,13 +592,15 @@
 	  }
 	$ns = $ns->getValue;    # if we have a namespace, then get its value
 	( $s, $m, $ns ) = $OS->namespaceExists( term => $ns );
-	unless ( $ns eq $desired_namespace )
+	# A bad namespace will return 'undef' which makes for a bad comparison (Perl warning).
+	# Better to check directly for success ($s), THEN check that namespace is the one we wanted.
+	unless ( $s && $ns eq $desired_namespace ) 
 	  { # we are registering as working in a particular namespace, so check this
 	    push @ids, undef;    # and push undef onto the stack if it isn't
 	    next;
 	  }
       }
-      
+
       # Now do the same thing for ID's
       my $id = $_->getAttributeNode( 'id' ) || $_->getAttributeNode( 'moby:id' );
       unless ( $id ) {
@@ -619,7 +620,6 @@
 
 =head2 getSimpleArticleNamespaceURI
 
- name     : getSimpleArticleNamespaceURI
  function : to get the namespace of a simple article
  usage    : my $ns = getSimpleArticleNamespaceURI($SimpleArticle);
  args     : $Simple   - (required) a single XML::LibXML node representing a Simple Article
@@ -655,7 +655,6 @@
 
 =head2 simpleResponse
 
- name     : simpleResponse
  function : wraps a simple article in the appropriate (mobyData) structure
  usage    : $resp .= &simpleResponse($object, 'MyArticleName', $queryID);
  args     : (in order)
@@ -700,7 +699,6 @@
 
 =head2 collectionResponse
 
- name     : collectionResponse
  function : wraps a set of articles in the appropriate mobyData structure
  usage    : return responseHeader . &collectionResponse(\@objects, 'MyArticleName', $queryID) . responseFooter;
  args     : (in order)
@@ -753,7 +751,6 @@
 
 =head2 complexResponse
 
- name     : complexResponse
  function : wraps articles in the appropriate (mobyData) structure
  usage    : $resp .= &complexResponse(\@data, $qID);
  args     : (in order)
@@ -809,7 +806,6 @@
 
 =head2 responseHeader
 
- name     : responseHeader
  function : print the XML string of a MOBY response header +/- serviceNotes
  usage    : responseHeader('illuminae.com')
             responseHeader(
@@ -846,7 +842,6 @@
 
 =head2 responseFooter
 
- name     : responseFooter
  function : print the XML string of a MOBY response footer
  usage    : return responseHeader('illuminae.com') . $DATA . responseFooter;
  notes    :  returns everything required after the response articles themselves
@@ -880,7 +875,6 @@
 
 =head2 getInputs
 
- name     : getInputs
  function : get the mobyData block(s) as XML::LibXML nodes
  usage    : @queryInputs = getInputArticles($XML)
  args     : the raw XML of a <MOBY> query, or an XML::LibXML document
@@ -908,7 +902,6 @@
 
 =head2 getInputID
 
- name     : getInputID
  function : get the value of the queryID element
  usage    : @queryInputs = getInputID($XML)
  args     : the raw XML or XML::LibXML of a queryInput or mobyData block (e.g. from getInputs)
@@ -931,7 +924,7 @@
 
 =head2 getArticlesAsObjects
 
- name     : DO NOT USE!!
+  DO NOT USE!!
  function : get the Simple/Collection articles for a single mobyData
             or queryResponse node, rethrning them as SimpleArticle,
             SecondaryArticle, or ServiceInstance objects
@@ -970,7 +963,6 @@
 
 =head2 getCollectedSimples
 
- name     : getCollectedSimples
  function : get the Simple articles collected in a moby:Collection block
  usage    : @Simples = getCollectedSimples($XML)
  args     : raw XML or XML::LibXML of a moby:Collection block
@@ -995,7 +987,6 @@
 
 =head2 getInputArticles
 
- name     : getInputArticles
  function : get the Simple/Collection articles for each input query, in order
  usage    : @queries = getInputArticles($XML)
  args     : the raw XML of a moby:MOBY query
@@ -1050,7 +1041,6 @@
 
 =head2 isSimpleArticle
 
- name     : isSimpleArticle
  function : tests XML (text) or an XML DOM node to see if it represents a Simple article
  usage    : if (isSimpleArticle($node)){do something to it}
  input    : an XML::LibXML node, an XML::LibXML::Document or straight XML
@@ -1071,7 +1061,6 @@
 
 =head2 isCollectionArticle
 
- name     : isCollectionArticle
  function : tests XML (text) or an XML DOM node to see if it represents a Collection article
  usage    : if (isCollectionArticle($node)){do something to it}
  input    : an XML::LibXML node, an XML::LibXML::Document or straight XML
@@ -1090,7 +1079,6 @@
 
 =head2 isSecondaryArticle
 
- name     : isSecondaryArticle
  function : tests XML (text) or an XML DOM node to see if it represents a Secondary article
  usage    : if (isSecondaryArticle($node)){do something to it}
  input    : an XML::LibXML node, an XML::LibXML::Document or straight XML
@@ -1111,7 +1099,6 @@
 
 =head2 extractRawContent
 
- name     : extractRawContent
  function : pass me an article (Simple, or Collection) and I'll give you the
             content AS A STRING - i.e. the raw XML of the contained MOBY Object(s)
  usage    : extractRawContent($simple)
@@ -1133,7 +1120,6 @@
 
 =head2 getNodeContentWithArticle
 
- name     : getNodeContentWithArticle
  function : a very flexible way to get the stringified content of a node
             that has the correct element and article name
             or get the value of a Parameter element.
@@ -1296,7 +1282,6 @@
 
 =head2 validateNamespaces
 
- name     : validateNamespaces
  function : checks the namespace ontology for the namespace lsid
  usage    : @LSIDs = validateNamespaces(@namespaces)
  args     : ordered list of either human-readable or lsid presumptive namespaces
@@ -1321,7 +1306,6 @@
 
 =head2 validateThisNamespace
 
- name     : validateThisNamespace
  function : checks a given namespace against a list of valid namespaces
  usage    : $valid = validateThisNamespace($ns, @validNS);
  args     : ordered list of the namespace of interest and the list of valid NS's
@@ -1339,7 +1323,6 @@
 
 =head2 getResponseArticles (a.k.a. extractResponseArticles)
 
- name     : getResponseArticles
  function : get the DOM nodes corresponding to individual
             Simple or Collection outputs from a MOBY Response
  usage    : ($collections, $simples) = getResponseArticles($node)
@@ -1411,7 +1394,6 @@
 
 =head2 getServiceNotes
 
- name     : getServiceNotes
  function : to get the content of the Service Notes block of the MOBY message
  usage    : getServiceNotes($message)
  args     : $message is either the XML::LibXML of the MOBY message, or plain XML
@@ -1443,7 +1425,6 @@
 
 =head2 getCrossReferences
 
- name     : getCrossReferences
  function : to get the cross-references for a Simple article
  usage    : @xrefs = getCrossReferences($XML)
  args     : $XML is either a SIMPLE article (<Simple>...</Simple>)
@@ -1501,7 +1482,6 @@
 
 =head2 whichDeepestParentObject
 
- name     : whichDeepestParentObject
  function : select the parent node from nodeList that is
             closest to the querynode
  usage    : ($term, $lsid) = whichDeepestParentObject($CENTRAL, $queryTerm, \@termList)




More information about the MOBY-guts mailing list