[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 "SIMPLE" or "COLLECTION"
+ # 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->type('base64' => responseHeader("my.authURI.com") . 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
- <queryInput...>...</queryInput>
- b. \@article XML:DOM nodes for Collections
- c. $secondary XML::DOM node</pre>
+ <mobyData...>...</mobyData>
+ 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:
- <queryInput queryID = '1'>
+ <mobyData queryID = '1'>
<Simple articleName='name1'>
<Object namespace=blah id=blah/>
</Simple>
<Parameter articleName='cutoff'>
- <datatype>Float</datatype>
<default>10</default>
</Parameter>
- </queryInput></pre>
+ </mobyData></pre>
<pre>
will become:
(note that SIMPLE, COLLECTION, and SECONDARY are exported constants from this module)
- $inputs->{1} = [ [SIMPLE, $DOM_name1],
- [SECONDARY, $DOM_cutoff]
+ $inputs->{1} = [ [SIMPLE, $DOM_name1], # the <Simple> block
+ [SECONDARY, $DOM_cutoff] # $DOM_cutoff= <Parameter> 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:
- <queryInput>
+ <mobyData>
<Collection articleName='name1'>
<Simple>
<Object namespace=blah id=blah/>
@@ -277,12 +274,12 @@
<datatype>Float</datatype>
<default>10</default>
</Parameter>
- </queryInput></pre>
+ </mobyData></pre>
<pre>
will become
- $inputs->{1} = [ [COLLECTION, [$DOM, $DOM] ],
- [SECONDARY, $DOM_cutoff]
+ $inputs->{1} = [ [COLLECTION, [$DOM, $DOM] ], # $DOM is the <Simple> Block!
+ [SECONDARY, $DOM_cutoff] # $DOM_cutoff = <Parameter> 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>
- <queryInput>
+ <mobyData>
<Simple articleName='name1'>
<Object namespace=blah id=blah/>
</Simple>
- </queryInput>
+ </mobyData>
or : @articles = ['name1', $COLL_DOM], ['paramname1', $PARAM_DOM]</pre>
<pre>
generated from the following sample XML:</pre>
<pre>
- <queryInput>
+ <mobyData>
<Collection articleName='name1'>
<Simple>
<Object namespace=blah id=blah/>
@@ -328,7 +324,7 @@
<datatype>Float</datatype>
<default>10</default>
</Parameter>
- </queryInput></pre>
+ </mobyData></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 .= &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 &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 . &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 <MOBY> 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 "Parameter" 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($_, "String", "SequenceString");
- print "matching node contents were ".(join "\n\n", @sequences)."\n"; # join all lines of string
- }
- }</pre>
+ # get $input - e.g. from genericServiceInputParser or complexServiceInputParser
+ @sequences = getNodeContentWithArticle($input, "String", "SequenceString");</pre>
+<pre>
+ For Parameters, such as the following
+ ...
+ ...
+ <moby:mobyContent>
+ <moby:mobyData>
+ <Simple>
+ <Sequence namespace=blah id=blah>
+ <Integer namespace='' id='' articleName="Length">3</Integer>
+ <String namespace='' id='' articleName="SequenceString">ATG</String>
+ </Sequence>
+ </Simple>
+ <Parameter articleName='cutoff'>
+ <Value>24</Value>
+ </Parameter>
+ </moby:mobyData>
+ </moby:mobyContent>
+ ...
+ ...
+
+ You would parse it as follows:
+
+ # get $input - e.g. from genericServiceInputParser or complexServiceInputParser
+ @sequences = getNodeContentWithArticle($input, "String", "SequenceString");
+ @cutoffs = getNodeContentWithArticle($input, "Parameter", "cutoff");</pre>
+<pre>
+ EXAMPLE :
+ my $inputs = complexServiceInputParser($MOBY_mssage));
+ # $inputs->{$queryID} = [ [TYPE, $DOM], [TYPE, $DOM], [TYPE, $DOM] ]
+ my (@enumerated) = keys %{$inputs};
+ foreach $no (@enumerated){
+ my @articles = @{$inputs->{$no}};
+ foreach my $article(@articles){
+ my ($type, $DOM) = @{$article};
+ if ($type == SECONDARY){
+ $cutoff = getNodeContentsWithArticle($DOM, "Parameter", "cutoff");
+ } else {
+ $sequences = getNodeContentWithArticle($DOM, "String", "SequenceString");
+ }
+ }
+ }</pre>
<p>
</p>
<h2><a name="validatenamespaces">validateNamespaces</a></h2>
More information about the MOBY-guts
mailing list