[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Mon May 3 20:15:32 UTC 2004


mwilkinson
Mon May  3 16:15:32 EDT 2004
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv12497

Modified Files:
	CommonSubs.pm CommonSubs.html 
Log Message:
fixing documentation error that Bertrand spotted

moby-live/Perl/MOBY CommonSubs.pm,1.48,1.49 CommonSubs.html,1.9,1.10
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2004/05/03 15:07:51	1.48
+++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2004/05/03 20:15:32	1.49
@@ -314,7 +314,6 @@
                        <Object namespace=blah id=blah/>
                     </Simple>
                     <Parameter articleName='cutoff'>
-                       <datatype>Float</datatype>
                        <default>10</default>
                     </Parameter>
                 </mobyData>

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.html,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.html	2004/04/14 20:10:35	1.9
+++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.html	2004/05/03 20:15:32	1.10
@@ -86,9 +86,9 @@
         # Each element of the array is a queryInput block, or a mobyData block
         # the arrayref has the following structure:
         # [SIMPLE, $queryID, $simple]
-        # the first element is a constant &quot;SIMPLE&quot; or &quot;COLLECTION&quot;
+        # the first element is an exported constant SIMPLE, COLLECTION, SECONDARY
         # the second element is the queryID (required for enumerating the responses)
-        # the third element is the XML::DOM for the Simple or Collection block    
+        # the third element is the XML::DOM for the Simple, Collection, or Parameter block    
     my (@inputs)= genericServiceInputParser($data); 
         # or fail properly with an empty response
     return SOAP::Data-&gt;type('base64' =&gt; responseHeader(&quot;my.authURI.com&quot;) . responseFooter()) unless (scalar(@inputs));
@@ -206,25 +206,24 @@
 <pre>
  name     : genericServiceInputParser
  function : For the MOST SIMPLE SERVICES that take single Simple or Collection inputs
-            and no Secondaries this routine takes the MOBY message and
+            and no Secondaries/Parameters this routine takes the MOBY message and
             breaks the objects out of it in a useful way
  usage    : my @inputs = genericServiceInputParser($MOBY_mssage));
  args     : $message - this is the SOAP payload; i.e. the XML document containing the MOBY message
  returns  : @inputs - the structure of @inputs is a list of listrefs.
             Each listref has three components:
-                1. COLLECTION|SIMPLE|SECONDARY (i.e. constants 1, 2, 3)
-                2. queryID (undef for Secondary parameters)
+                1. COLLECTION|SIMPLE (i.e. constants 1, 2)
+                2. queryID
                 3. $data - the data takes several forms
                          a. $article XML::DOM node for Simples
-                            &lt;queryInput...&gt;...&lt;/queryInput&gt;
-                         b. \@article XML:DOM nodes for Collections
-                         c. $secondary XML::DOM node</pre>
+                            &lt;mobyData...&gt;...&lt;/mobyData&gt;
+                         b. \@article XML:DOM nodes for Collections</pre>
 <p>
 </p>
 <h2><a name="complexserviceinputparser">complexServiceInputParser</a></h2>
 <pre>
  name     : complexServiceInputParser
- function : For more complex services taht have multiple articles for each input
+ 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
             useful way.
@@ -238,33 +237,31 @@
             
             for example, the input message:
             
-                &lt;queryInput queryID = '1'&gt;
+                &lt;mobyData queryID = '1'&gt;
                     &lt;Simple articleName='name1'&gt;
                        &lt;Object namespace=blah id=blah/&gt;
                     &lt;/Simple&gt;
                     &lt;Parameter articleName='cutoff'&gt;
-                       &lt;datatype&gt;Float&lt;/datatype&gt;
                        &lt;default&gt;10&lt;/default&gt;
                     &lt;/Parameter&gt;
-                &lt;/queryInput&gt;</pre>
+                &lt;/mobyData&gt;</pre>
 <pre>
             will become:
             (note that SIMPLE, COLLECTION, and SECONDARY are exported constants from this module)
             
-            $inputs-&gt;{1} = [ [SIMPLE, $DOM_name1],
-                             [SECONDARY, $DOM_cutoff]
+            $inputs-&gt;{1} = [ [SIMPLE, $DOM_name1], # the &lt;Simple&gt; block
+                             [SECONDARY, $DOM_cutoff]  # $DOM_cutoff= &lt;Parameter&gt; block
                            ]</pre>
 <pre>
             Please see the XML::DOM pod documentation for information about how
-            to parse XML DOM objects.
-            
-            
+            to parse XML DOM objects.</pre>
+<pre>
             Collections --------------------
             
             With inputs that have collections these are presented as a
             listref of Simple article DOM's.  So for the following message:
             
-                &lt;queryInput&gt;
+                &lt;mobyData&gt;
                     &lt;Collection articleName='name1'&gt;
                       &lt;Simple&gt;
                        &lt;Object namespace=blah id=blah/&gt;
@@ -277,12 +274,12 @@
                        &lt;datatype&gt;Float&lt;/datatype&gt;
                        &lt;default&gt;10&lt;/default&gt;
                     &lt;/Parameter&gt;
-                &lt;/queryInput&gt;</pre>
+                &lt;/mobyData&gt;</pre>
 <pre>
             will become
             
-            $inputs-&gt;{1} = [ [COLLECTION, [$DOM, $DOM] ],
-                             [SECONDARY, $DOM_cutoff]
+            $inputs-&gt;{1} = [ [COLLECTION, [$DOM, $DOM] ], # $DOM is the &lt;Simple&gt; Block!
+                             [SECONDARY, $DOM_cutoff]  # $DOM_cutoff = &lt;Parameter&gt; Block
                            ]</pre>
 <pre>
             Please see the XML::DOM pod documentation for information about how
@@ -292,12 +289,11 @@
 <h2><a name="getarticles">getArticles</a></h2>
 <pre>
  name     : getArticles
- function : get the Simple/Collection/Parameter articles for a single queryInput
-            or queryResponse node
+ function : get the Simple/Collection/Parameter articles for a single mobyData
  usage    : @articles = getArticles($XML)
  args     : raw XML or XML::DOM of a queryInput, mobyData, or queryResponse block (e.g. from getInputs)
- returns  : a list of listrefs; each listref is one component of the queryInput.
-            a single queryInput/Response may consist of one or more named or unnamed
+ returns  : a list of listrefs; each listref is one component of the queryInput or mobyData block
+            a single block may consist of one or more named or unnamed
             simple, collection, or parameter articles.
             The listref structure is thus [name, $ARTICLE_DOM]:
             
@@ -305,17 +301,17 @@
 <pre>
             generated from the following sample XML:</pre>
 <pre>
-                &lt;queryInput&gt;
+                &lt;mobyData&gt;
                     &lt;Simple articleName='name1'&gt;
                       &lt;Object namespace=blah id=blah/&gt;
                     &lt;/Simple&gt;
-                &lt;/queryInput&gt;
+                &lt;/mobyData&gt;
         
     or  :  @articles = ['name1', $COLL_DOM], ['paramname1', $PARAM_DOM]</pre>
 <pre>
             generated from the following sample XML:</pre>
 <pre>
-                &lt;queryInput&gt;
+                &lt;mobyData&gt;
                     &lt;Collection articleName='name1'&gt;
                       &lt;Simple&gt;
                        &lt;Object namespace=blah id=blah/&gt;
@@ -328,7 +324,7 @@
                        &lt;datatype&gt;Float&lt;/datatype&gt;
                        &lt;default&gt;10&lt;/default&gt;
                     &lt;/Parameter&gt;
-                &lt;/queryInput&gt;</pre>
+                &lt;/mobyData&gt;</pre>
 <p>
 </p>
 <h2><a name="genericserviceinputparserasobject">genericServiceInputParserAsObject</a></h2>
@@ -381,13 +377,13 @@
 <h2><a name="simpleresponse">simpleResponse</a></h2>
 <pre>
  name     : simpleResponse
- function : wraps a simple article in the appropriate queryResponse structure
+ function : wraps a simple article in the appropriate (mobyData) structure
  usage    : $resp .= &amp;simpleResponse($object, 'MyArticleName', $queryID);
  args     : (in order)
             $object   - (optional) a MOBY Object as raw XML
             $article  - (optional) an articeName for this article
             $query    - (optional, but strongly recommended) the queryID value for the
-                        queryInput block to which you are responding
+                        mobyData block to which you are responding
  notes    : as required by the API you must return a response for every input.
             If one of the inputs was invalid, you return a valid (empty) MOBY
             response by calling &amp;simpleResponse(undef, undef, $queryID) with no arguments.</pre>
@@ -396,12 +392,12 @@
 <h2><a name="collectionresponse">collectionResponse</a></h2>
 <pre>
  name     : collectionResponse
- function : wraps a set of articles in the appropriate queryResponse structure
+ function : wraps a set of articles in the appropriate mobyData structure
  usage    : return responseHeader . &amp;collectionResponse(\@objects, 'MyArticleName', $queryID) . responseFooter;
  args     : (in order)
             \@objects - (optional) a listref of MOBY Objects as raw XML
             $article  - (optional) an articeName for this article
-            $queryID  - (optional, but strongly recommended) the queryInput ID
+            $queryID  - (optional, but strongly recommended) the mobyData ID
                         to which you are responding
  notes    : as required by the API you must return a response for every input.
             If one of the inputs was invalid, you return a valid (empty) MOBY
@@ -442,7 +438,7 @@
 <h2><a name="getinputs">getInputs</a></h2>
 <pre>
  name     : getInputs
- function : get the queryInput block(s) as XML::DOM nodes
+ function : get the mobyData block(s) as XML::DOM nodes
  usage    : @queryInputs = getInputArticles($XML)
  args     : the raw XML of a &lt;MOBY&gt; query, or an XML::DOM document
  returns  : a list of XML::DOM::Node's, each is a queryInput or mobyData block.
@@ -467,11 +463,11 @@
 <h2><a name="getarticlesasobjects">getArticlesAsObjects</a></h2>
 <pre>
  name     : DO NOT USE!!
- function : get the Simple/Collection articles for a single queryInput
+ function : get the Simple/Collection articles for a single mobyData
             or queryResponse node, rethrning them as SimpleArticle,
             SecondaryArticle, or ServiceInstance objects
  usage    : @articles = getArticles($XML)
- args     : raw XML or XML::DOM of a moby:queryInput, moby:queryResponse block
+ args     : raw XML or XML::DOM of a moby:mobyData block
  returns  :</pre>
 <p>
 </p>
@@ -555,15 +551,20 @@
 <h2><a name="getnodecontentwitharticle">getNodeContentWithArticle</a></h2>
 <pre>
  name     : getNodeContentWithArticle
- function : get the stringified content of a node that has the correct element and article name
+ 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.
  usage    : @strings = getNodeContentWithArticle($node, $tagname, $articleName)
  args     : (in order)
-            $node        - the XML::DOM node we are searching
-            $tagname     - the tagname (effectively from the Object type ontology)
+            $node        - an XML::DOM node, or straight XML.  It may even
+                           be the entire mobyData block.
+            $tagname     - the tagname (effectively from the Object type ontology),
+                           or &quot;Parameter&quot; if you are trying to get secondaries
             $articleName - the articleName that we are searching for
             
  returns  : an array of the stringified text content for each
             node that matched the tagname/articleName specified.
+            note that each line of content is an element of the string.
  notes    : This was written for the purpose of getting the values of
             String, Integer, Float, Date_Time, and other such primitives.
             For example, in the following XML:
@@ -584,15 +585,49 @@
              
             would be analysed as follows:
               
-              my ($query) = @_;  # get the incoming MOBY query XML
-              my @queries = getInputArticles($query);  # returns DOM nodes
-              foreach (@queries){
-                 my @inputs = @{$_}; #(may be more than one Simple/Collection input per query)
-                 foreach my $input(@inputs){
-                     @sequences = getNodeContentWithArticle($_, &quot;String&quot;, &quot;SequenceString&quot;);
-                     print &quot;matching node contents were &quot;.(join &quot;\n\n&quot;, @sequences).&quot;\n&quot;; # join all lines of string
-                 }   
-              }</pre>
+              # get $input - e.g. from genericServiceInputParser or complexServiceInputParser
+              @sequences = getNodeContentWithArticle($input, &quot;String&quot;, &quot;SequenceString&quot;);</pre>
+<pre>
+            For Parameters, such as the following
+             ...
+             ...
+             &lt;moby:mobyContent&gt;
+                &lt;moby:mobyData&gt;
+                    &lt;Simple&gt;
+                      &lt;Sequence namespace=blah id=blah&gt;
+                           &lt;Integer namespace='' id='' articleName=&quot;Length&quot;&gt;3&lt;/Integer&gt;
+                           &lt;String namespace='' id='' articleName=&quot;SequenceString&quot;&gt;ATG&lt;/String&gt;
+                      &lt;/Sequence&gt;
+                    &lt;/Simple&gt;
+                    &lt;Parameter articleName='cutoff'&gt;
+                        &lt;Value&gt;24&lt;/Value&gt;
+                    &lt;/Parameter&gt;
+                &lt;/moby:mobyData&gt;
+             &lt;/moby:mobyContent&gt;
+             ...
+             ...
+            
+            You would parse it as follows:
+            
+              # get $input - e.g. from genericServiceInputParser or complexServiceInputParser
+              @sequences = getNodeContentWithArticle($input, &quot;String&quot;, &quot;SequenceString&quot;);
+              @cutoffs = getNodeContentWithArticle($input, &quot;Parameter&quot;, &quot;cutoff&quot;);</pre>
+<pre>
+ EXAMPLE  :
+           my $inputs = complexServiceInputParser($MOBY_mssage));
+               # $inputs-&gt;{$queryID} = [ [TYPE, $DOM], [TYPE, $DOM], [TYPE, $DOM] ]
+           my (@enumerated) = keys %{$inputs};
+           foreach $no (@enumerated){
+             my @articles = @{$inputs-&gt;{$no}};
+             foreach my $article(@articles){
+                my ($type, $DOM) = @{$article};
+                if ($type == SECONDARY){
+                    $cutoff = getNodeContentsWithArticle($DOM, &quot;Parameter&quot;, &quot;cutoff&quot;);
+                } else {
+                   $sequences = getNodeContentWithArticle($DOM, &quot;String&quot;, &quot;SequenceString&quot;);
+                }
+             }
+           }</pre>
 <p>
 </p>
 <h2><a name="validatenamespaces">validateNamespaces</a></h2>




More information about the MOBY-guts mailing list