[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Wed Nov 23 20:58:36 UTC 2005


mwilkinson
Wed Nov 23 15:58:36 EST 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory pub.open-bio.org:/tmp/cvs-serv17528/MOBY/Client

Modified Files:
	Central.pm 
Log Message:
modified the Perl Client API a little bit (in a way that is reflective of how I would like to modify it overall).  Changed the Relationships call such that it returns (a) the articleName as well as the related object,and (b) returns these as a hashref rather than a listref.  The MOBY Central API for the Relationships call has also changed in a way that should not break any existing code.  A new attribute has been added to the objectType element in the Relationship call response.  The attribute is articleName and it reflects the articleName of the associated objectType in the context of that relationship.

moby-live/Perl/MOBY/Client Central.pm,1.127,1.128
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2005/11/20 16:13:23	1.127
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2005/11/23 20:58:36	1.128
@@ -1709,10 +1709,13 @@
 
  Usage     :	$def = $MOBY->Relationships(%args)
  Function  :	traverse and return the relationships in the ontology
- Returns   :    hashref of   $hash{relationship_type}=\@lsids
+ Returns   :    hashref of
+                FOR SERVICES:
+		        $hash{'isa'}=[{lsid => $lsid, term => 'termy'},...]
+		FOR OBJECTS:
+		        $hash{relationship_type}=[{lsid => $lsid, articleName => 'thingy', term => 'termy'},...]
  Args      :	EITHER serviceType => $term_or_lsid
                 OR     objectType => $term_or_lsid
-                
                 Relationships => \@relationship_types (optional, 'all' if parameter is missing)
                 Registry => $registry_name  (optional)
                 expandRelationships => [1/0] (optional)
@@ -1769,6 +1772,7 @@
 	return &_relationshipsPayload($payload);
 }
 
+
 sub _relationshipsPayload {
 	my ($payload) = @_;
 	return undef unless $payload;
@@ -1779,23 +1783,32 @@
 	my $x                = $doc->getElementsByTagName("Relationship");
 	my $no_relationships = $x->size();
 	for ( my $n = 1 ; $n <= $no_relationships ; ++$n ) {
-		my $relationshipType =
-		  $x->get_node($n)->getAttributeNode('relationshipType')
-		  ;    # may or may not have a name
+		my $relationshipType = $x->get_node($n)->getAttributeNode('relationshipType');    # may or may not have a name
 		if ($relationshipType) {
 			$relationshipType = $relationshipType->getValue();
-		}
-		else {
-			return
-			  "FAILED! must include a relationshipType in every relationship\n";
+		} else {
+			return "FAILED! must include a relationshipType in every relationship\n";
 		}
 		my @child = $x->get_node($n)->childNodes;
-		foreach (@child) {
-			next unless $_->nodeType == ELEMENT_NODE;
-			my @child2 = $_->childNodes;
-			foreach (@child2) {
-				next unless $_->nodeType == TEXT_NODE;
-				push @{ $relationships{$relationshipType} }, $_->toString;
+		foreach my $child(@child) {
+			my ($lsid, $article, $term) = ("", "", "");
+			next unless $child->nodeType == ELEMENT_NODE;
+			my $lsidattr = $child->getAttributeNode('lsid');    # may or may not have a name
+			if ($lsidattr) {
+				$lsid = $lsidattr->getValue();
+			}
+			my $ARTattr = $child->getAttributeNode('articleName');    # may or may not have a name
+			if ($ARTattr) {
+				$article = $ARTattr->getValue();
+			}
+			my %info;
+			$info{lsid} = $lsid;
+			($info{articleName} = $article) if $article;
+			my @child2 = $child->childNodes;
+			foreach my $child2(@child2) {
+				next unless $child2->nodeType == TEXT_NODE;
+				$info{term} = $child2->toString;
+				push @{ $relationships{$relationshipType} }, \%info;
 			}
 		}
 	}




More information about the MOBY-guts mailing list