[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Wed Jun 18 22:57:02 UTC 2003


mwilkinson
Wed Jun 18 18:57:02 EDT 2003
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory pub.open-bio.org:/tmp/cvs-serv12078/Perl/MOBY/Client

Modified Files:
	Central.html Central.pm 
Log Message:
new method 'Relationships' will retrieve the top-level relationships (ISA, HASA, HAS) for the given Object or Service ontology term.  Wrapped in MOBY::Client::Central.  Documentation updated.

moby-live/Perl/MOBY/Client Central.html,1.4,1.5 Central.pm,1.34,1.35
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.html	2003/06/11 20:36:59	1.4
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.html	2003/06/18 22:57:02	1.5
@@ -38,6 +38,7 @@
 		<li><a href="#retrievenamespaces">retrieveNamespaces</a></li>
 		<li><a href="#retrieveobject">retrieveObject</a></li>
 		<li><a href="#retrieveobjectdefinition">retrieveObjectDefinition</a></li>
+		<li><a href="#relationships">Relationships</a></li>
 		<li><a href="#dump">DUMP</a></li>
 	</ul>
 
@@ -371,6 +372,18 @@
  Args      :    $name - object name (from ontology)</pre>
 <p>
 </p>
+<h2><a name="relationships">Relationships</a></h2>
+<pre>
+ Title     :    Relationships
+ Usage     :    $def = $MOBY-&gt;Relationships(%args)
+ Function  :
+ Returns   :    hashref of   $hash{relationship_type}=\@lsids
+ Args      :    EITHER serviceType =&gt; $term_or_lsid
+                OR     objectType =&gt; $term_or_lsid
+                
+                Registry =&gt; $registry_name  (optional)</pre>
+<p>
+</p>
 <h2><a name="dump">DUMP</a></h2>
 <pre>
  Title     :    DUMP

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2003/06/18 16:30:56	1.34
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2003/06/18 22:57:02	1.35
@@ -1168,6 +1168,75 @@
 }
 
 
+
+=head2 Relationships
+
+ Title     :    Relationships
+ Usage     :	$def = $MOBY->Relationships(%args)
+ Function  :
+ Returns   :    hashref of   $hash{relationship_type}=\@lsids
+ Args      :	EITHER serviceType => $term_or_lsid
+                OR     objectType => $term_or_lsid
+                
+                Registry => $registry_name  (optional)
+
+=cut
+
+
+sub Relationships {
+	my ($self, %args) = @_;
+	my $object = $args{'objectType'};
+	my $service = $args{'serviceType'};
+	my $reg = $args{'Registry'};
+	my $m; my $payload;
+	return {} unless ($object || $service);
+	if ($object){
+		$m = "
+		<Relationships>
+            <objectType>$object</objectType>
+	    </Relationships>";
+		$reg =$reg?$reg:$self->default_MOBY_servername;
+		return undef unless ($self->SOAP_connection($reg));
+		my $payload = $self->SOAP_connection($reg)->call('Relationships' => ($m))->paramsall;
+	} elsif ($service){
+		$m = "
+		<Relationships>
+            <serviceType>$service</serviceType>
+	    </Relationships>";
+		$reg =$reg?$reg:$self->default_MOBY_servername;
+		return undef unless ($self->SOAP_connection($reg));
+		my $payload = $self->SOAP_connection($reg)->call('Relationships' => ($m))->paramsall;
+		
+		
+	}
+	return &_relationshipsPayload($payload);
+	
+}
+
+sub _relationshipsPayload{
+	my ($payload) = @_;
+	return undef unless $payload;
+	my %att_value; my %relationships;
+	my $Parser = new XML::DOM::Parser;
+	my $doc = $Parser->parse($payload);
+    my $x = $doc->getElementsByTagName("Relationship");
+    my $no_relationships = $x->getLength;
+    for (my $n=0; $n<$no_relationships; ++$n){
+		my $relationshipType = $x->item($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"}		
+		my @child = $x->item($n)->getChildNodes;
+		foreach (@child){
+			next unless $_->getNodeType == ELEMENT_NODE;
+			my @child2 = $_->getChildNodes;
+			foreach (@child2){
+				next unless $_->getNodeType == TEXT_NODE;
+				push @{$relationships{$relationshipType}}, $_->toString;
+			}
+		}
+	}
+	return \%relationships;
+}
+
 =head2 DUMP
 
 
@@ -1193,41 +1262,42 @@
 }
 
 
-
-sub ISA {
-	my ($self)= shift;
-	my ($obj) = shift;
-	my ($reg) = shift;
-	return undef unless $obj;
-	my $message = "
-	<ISA>
-	 <objectType>$obj</objectType>
-	</ISA>";
-
-	$reg =$reg?$reg:$self->default_MOBY_servername;
-	return undef unless ($self->SOAP_connection($reg));
-	my $return = $self->SOAP_connection($reg)->call('ISA' => ($message))->paramsall;
-	#<Relationships>
-	#   <objectType>QueryObject</objectType>
-	#   <ISA>
-	#	  <objectType>ParentObject</objectType>
-	#	  ...
-	#	  ...
-	#    </ISA>
-	#	<HASA>
-	#	  <objectType>ContainedObject</objectType>
-	#	  ...
-	#	  ...
-	#	</HASA>
-	#</Relationships>
-    my $parser = new XML::DOM::Parser;
-    my $doc = $parser->parse($return);
-    my $root = $doc->getDocumentElement;
-	my @ISAs = &_nodeArrayContent($doc, "ISA");
-	my @HASA = &_nodeArrayContent($doc, "HASA");
-    return (\@ISAs, \@HASA);
-}
-
+#
+#
+#sub ISA {
+#	my ($self)= shift;
+#	my ($obj) = shift;
+#	my ($reg) = shift;
+#	return undef unless $obj;
+#	my $message = "
+#	<ISA>
+#	 <objectType>$obj</objectType>
+#	</ISA>";
+#
+#	$reg =$reg?$reg:$self->default_MOBY_servername;
+#	return undef unless ($self->SOAP_connection($reg));
+#	my $return = $self->SOAP_connection($reg)->call('ISA' => ($message))->paramsall;
+#	#<Relationships>
+#	#   <objectType>QueryObject</objectType>
+#	#   <ISA>
+#	#	  <objectType>ParentObject</objectType>
+#	#	  ...
+#	#	  ...
+#	#    </ISA>
+#	#	<HASA>
+#	#	  <objectType>ContainedObject</objectType>
+#	#	  ...
+#	#	  ...
+#	#	</HASA>
+#	#</Relationships>
+#    my $parser = new XML::DOM::Parser;
+#    my $doc = $parser->parse($return);
+#    my $root = $doc->getDocumentElement;
+#	my @ISAs = &_nodeArrayContent($doc, "ISA");
+#	my @HASA = &_nodeArrayContent($doc, "HASA");
+#    return (\@ISAs, \@HASA);
+#}
+#
 
 sub _parseServices {
     my ($self, $Registry, $XML) = @_;




More information about the MOBY-guts mailing list