[MOBY-l] CommonSubs updated for new message structure

Mark Wilkinson markw at illuminae.com
Sat Nov 8 17:23:46 UTC 2003


Okay, it looks like the new CommonSubs routine does not break the old
routines, so people can begin to migrate over to the new message
structure as they see fit.

I will update all of my services in the LocalServices example module
over the next few days, but below is a paradigmatic MOBY Service, using
the various new routines in CommonSubs:


sub myServiceName {
  my ($caller, $message) = @_;  # get the incoming MOBY query XML

  my @queries = getInputs($message);  # returns XML::DOM nodes
  my $RESPONSE = "";    # set empty response
 
  foreach my $query(@queries){

     my $queryID = getInputID($query);  # get the queryID attribute     
     my @input_articles = getArticles($query); 

     foreach my $input(@input_articles){       # input is a listref

        my ($articleName, $article) = @{$input}; # get the named article
        my $simple = isSimpleArticle($article);  # simple or collection
        my $collection = isCollectionArticle($article);

        if ($collection){

            # do something wtih the collection...
            # for example...
            my @simples = getCollectedSimples($article);
            # blah blah blah...
            
        } elsif ($simple){
            # maybe you just need the ID of the incoming query:
            my ($id) = getSimpleArticleIDs('NCBI_gi', $article); 

            # or maybe you are going to do something with the content?
            # for example, this will get the array of text lines
            # for the moby:String object with articleName
'SequenceString'
            # that is in this $article
            @s = getNodeContentWithArticle(
		$article, 
		"String", 
		"SequenceString");

            #  DO YOUR ANALYSIS HERE
            my $result = ""; #whatever you analysis says
            
            $RESPONSE .= simpleResponse($result, "someName", $queryID);
        }
     }
   }
   # note that responseHeader now takes an authority argument
   return responseHeader("my.authURI.com") . $RESPONSE . responseFooter;
 }


M


-- 
Mark Wilkinson <markw at illuminae.com>
Illuminae




More information about the moby-l mailing list