[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Sun Sep 14 23:44:40 EDT 2003
mwilkinson
Sun Sep 14 22:44:40 EDT 2003
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory pub.open-bio.org:/tmp/cvs-serv20093/Client
Modified Files:
Central.pm
Log Message:
writing in the expandRelationship function that is in the API but had not been implemented
moby-live/Perl/MOBY/Client Central.pm,1.51,1.52
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2003/09/01 15:57:58 1.51
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2003/09/15 02:44:40 1.52
@@ -1277,7 +1277,7 @@
Title : Relationships
Usage : $def = $MOBY->Relationships(%args)
- Function :
+ Function : traverse and return the relationships in the ontology
Returns : hashref of $hash{relationship_type}=\@lsids
Args : EITHER serviceType => $term_or_lsid
OR objectType => $term_or_lsid
@@ -1293,6 +1293,8 @@
my ($self, %args) = @_;
my $object = $args{'objectType'};
my $service = $args{'serviceType'};
+ my $expand = $args{'expandRelationships'};
+
my @relationships;
@relationships = @{$args{'Relationships'}} if ($args{'Relationships'} && (ref($args{'Relationships'}) =~ /array/i));
my $reg = $args{'Registry'};
@@ -1305,6 +1307,7 @@
foreach (@relationships){
$m .= "<relationshipType>$_</relationshipType>\n";
}
+ $m .= "<expandRelationship>1</expandRelationship>\n" if $expand;
$m .= "</Relationships>";
$reg =$reg?$reg:$self->default_MOBY_servername;
return undef unless ($self->Connection($reg));
@@ -1317,6 +1320,7 @@
foreach (@relationships){
$m .= "<relationshipType>$_</relationshipType>\n";
}
+ $m .= "<expandRelationship>1</expandRelationship>\n" if $expand;
$m .= "</Relationships>";
$reg =$reg?$reg:$self->default_MOBY_servername;
return undef unless ($self->Connection($reg));
@@ -1351,6 +1355,37 @@
return \%relationships;
}
+
+
+=head2 ISA
+
+ Title : ISA
+ Usage : $def = $MOBY->ISA($class1, $class2)
+ Function : a pre-canned use of the Relationships function
+ to quickly get an answer to whether class1 ISA class2
+ Returns : Boolean
+ Args : $class1 - an Object ontology term
+ $class2 - an Object ontology term
+
+=cut
+
+
+sub ISA {
+ my ($self, $class1, $class2) = @_;
+ my $OS = MOBY::Client::OntologyServer->new;
+ my ($s, $d, $lsid1) = $OS->objectExists($class1);
+ return 0 unless $s;
+ my ($s2, $d2, $lsid2) = $OS->objectExists($class2);
+ return 0 unless $s2;
+ my $resp = $self->Relationships(objectType => $lsid1, expandRelationship => 1);
+ my $lsids = $resp->{'urn:lsid:biomoby.org:objectrelation:isa'};
+ foreach (@$lsids){
+ return 1 if $_ eq $lsid2;
+ }
+ return 0;
+}
+
+
=head2 DUMP
More information about the MOBY-guts
mailing list