[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Sat Dec 27 20:15:45 UTC 2003


mwilkinson
Sat Dec 27 15:15:45 EST 2003
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv30014/Perl/MOBY

Modified Files:
	CommonSubs.pm CommonSubs.html 
Log Message:
Gbrowse client needed a new utility routine in CommonSubs.  This will take a list of 'known' Object ontology nodes and check it against the parentage of an in-hand object type, returning to you the term from your list that is DEEPEST in the ontology in the ISA parentage of your in-hand object.  Why? (you might ask)  Well, because when you want to assign renderers to objects you want the most complex renderer possible to deal with your in-hand object, so if you have rendrers for a variety of base object types, you want to chose the one that is best able to deal with whatever you have in-hand, thus you want the node closest to your object type

moby-live/Perl/MOBY CommonSubs.pm,1.36,1.37 CommonSubs.html,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2003/12/22 19:57:04	1.36
+++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2003/12/27 20:15:45	1.37
@@ -175,6 +175,7 @@
     getResponseArticles
     getCrossReferences
     genericServiceInputParser
+    whichDeepestParentObject
     COLLECTION
     SIMPLE
     BE_NICE
@@ -202,6 +203,7 @@
     getResponseArticles
     getCrossReferences
     genericServiceInputParser
+    whichDeepestParentObject
     COLLECTION
     SIMPLE
     BE_NICE
@@ -1071,6 +1073,43 @@
 	return @XREFS;
 }
 
+
+
+=head2 whichDeepestParentObject
+
+ name     : whichDeepestParentObject
+ function : select the parent node from nodeList that is
+            closest to the querynode
+ usage    : whichDeepestParentObject($CENTRAL, $queryNode, \@nodeList)
+ args     : $CENTRAL - your MOBY::Client::Central object
+            $queryNode - the node I am interested in
+            \@nodelist - the list of nodes that I know about
+ returns  : an ontology term as a scalar, or undef if there
+            is no parent of this node in the nodelist
+
+=cut
+
+
+sub whichDeepestParentObject {
+    use MOBY::Client::OntologyServer;
+    my ($CENTRAL, $queryTerm, $termlist) = @_;
+    return undef unless ($CENTRAL && $queryTerm && $termlist && (ref($termlist) =~ /ARRAY/));
+    my %nodeLSIDs;
+    foreach (@$termlist){ # get list of known LSIDs
+        my $lsid = $CENTRAL->ObjLSID($_);
+        $nodeLSIDs{$lsid}=1;
+    }
+    my $queryLSID = $CENTRAL->ObjLSID($queryTerm);
+    return undef unless keys(%nodeLSIDs);
+    my $isa = $CENTRAL->ISA($queryTerm, 'Object'); # set the complete parentage in the cache if it isn't already
+    return undef unless $isa; # this should return true or we are in BIIIG trouble!
+    my @lsids = $CENTRAL->ISA_CACHE($queryTerm);  # returns **LSIDs** in order, so we can shift our way back to root
+    while (my $thisnode = shift @lsids){  # @isas are lsid's
+        return $thisnode if $nodeLSIDs{$thisnode};
+    }
+    return undef
+}
+
 sub _makeXrefType {
     my ($xref) = @_;
     my $ns = $xref->getAttributeNode('namespace');

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.html	2003/11/08 17:21:31	1.6
+++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.html	2003/12/27 20:15:45	1.7
@@ -4,7 +4,7 @@
 <title>MOBY::CommonSubs.pm - a set of exportable subroutines that are
 useful in clients and services to deal with the input/output from
 MOBY Services</title>
-<link rev="made" href="mailto:markw at illuminae.(none)" />
+<link rev="made" href="mailto:markw at illuminae.com" />
 </head>
 
 <body style="background-color: white">
@@ -41,9 +41,12 @@
 		<li><a href="#issimplearticle">isSimpleArticle</a></li>
 		<li><a href="#iscollectionarticle">isCollectionArticle</a></li>
 		<li><a href="#getnodecontentwitharticle">getNodeContentWithArticle</a></li>
+		<li><a href="#extractrawcontent">extractRawContent</a></li>
 		<li><a href="#validatenamespaces">validateNamespaces</a></li>
-		<li><a href="#getresponsearticles_(a.k.a._extractresponsearticles)">getResponseArticles (a.k.a. extractResponseArticles)</a></li>
+		<li><a href="#validatethisnamespace">validateThisNamespace</a></li>
+		<li><a href="#getresponsearticles__a_k_a__extractresponsearticles_">getResponseArticles (a.k.a. extractResponseArticles)</a></li>
 		<li><a href="#getcrossreferences">getCrossReferences</a></li>
+		<li><a href="#whichdeepestparentobject">whichDeepestParentObject</a></li>
 	</ul>
 
 </ul>
@@ -181,17 +184,19 @@
  name     : getSimpleArticleIDs
  function : to get the IDs of simple articles that are in the given namespace
  usage    : my @ids = getSimpleArticleIDs(&quot;NCBI_gi&quot;, \@SimpleArticles);
- args     : (in order)
-            $Namespace  - (required) a namespace stringfrom the MOBY namespace ontology
+            my @ids = getSimpleArticleIDs(\@SimpleArticles);
+ args     : $Namespace  - (optional) a namespace stringfrom the MOBY namespace ontology, or undef if you don't care
             \@Simples   - (required) a listref of Simple XML::DOM nodes
                           i.e. the XML::DOM representing an XML structure like this:
                               &lt;Simple&gt;
                                   &lt;Object namespace=&quot;NCBI_gi&quot; id=&quot;163483&quot;/&gt;
                               &lt;/Simple&gt;
- note     : it will return *only* the ids that are in the given namespace
-            but since you are required to return an output for every input
-            (even if it is invalid) this routine will return undef for
-            those articles that are not in that namespace</pre>
+ note     : If you provide a namespace, it will return *only* the ids that are in the given namespace,
+            but will return 'undef' for any articles in the WRONG namespace so that you get an
+            equivalent number of outputs to inputs.
+            
+            Note that if you call this with a single argument, this is assumed to
+            be \@Articles, so you will get ALL id's regardless of namespace!</pre>
 <p>
 </p>
 <h2><a name="getsimplearticlenamespaceuri">getSimpleArticleNamespaceURI</a></h2>
@@ -417,6 +422,16 @@
               }</pre>
 <p>
 </p>
+<h2><a name="extractrawcontent">extractRawContent</a></h2>
+<pre>
+ 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)
+ input    : the one element of the output from getArticles
+ returns  : string</pre>
+<p>
+</p>
 <h2><a name="validatenamespaces">validateNamespaces</a></h2>
 <pre>
  name     : validateNamespaces
@@ -427,7 +442,16 @@
             presumptive namespaces; undef for each namespace that was invalid</pre>
 <p>
 </p>
-<h2><a name="getresponsearticles_(a.k.a._extractresponsearticles)">getResponseArticles (a.k.a. extractResponseArticles)</a></h2>
+<h2><a name="validatethisnamespace">validateThisNamespace</a></h2>
+<pre>
+ 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
+ returns  : boolean</pre>
+<p>
+</p>
+<h2><a name="getresponsearticles__a_k_a__extractresponsearticles_">getResponseArticles (a.k.a. extractResponseArticles)</a></h2>
 <pre>
  name     : getResponseArticles
  function : get the DOM nodes corresponding to individual
@@ -461,6 +485,19 @@
           }
       }
    }</pre>
+<p>
+</p>
+<h2><a name="whichdeepestparentobject">whichDeepestParentObject</a></h2>
+<pre>
+ name     : whichDeepestParentObject
+ function : select the parent node from nodeList that is
+            closest to the querynode
+ usage    : whichDeepestParentObject($CENTRAL, $queryNode, \@nodeList)
+ args     : $CENTRAL - your MOBY::Client::Central object
+            $queryNode - the node I am interested in
+            \@nodelist - the list of nodes that I know about
+ returns  : an ontology term as a scalar, or undef if there
+            is no parent of this node in the nodelist</pre>
 
 </body>
 




More information about the MOBY-guts mailing list