[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Tue Aug 23 21:58:38 UTC 2005


mwilkinson
Tue Aug 23 17:58:38 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv23454/MOBY

Modified Files:
	OntologyServer.pm 
Log Message:
can't get out of checking the inheritence in order ISA, HAS, HASA, otherwise it will fail in some cases. Order of addition of relationships is now ISA HASA HAS

moby-live/Perl/MOBY OntologyServer.pm,1.79,1.80
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm	2005/08/23 19:07:29	1.79
+++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm	2005/08/23 21:58:38	1.80
@@ -517,6 +517,12 @@
 	my ($exists3, $desc3, $haslsid) = $OSrel->relationshipExists(term => 'has', ontology => 'object');
 	
 	return 1 unless ($exists1 && $exists2 && $exists3);  # this is bad, since it returns boolean suggesting that it found a common articlename rather than finding that a given relationship doesn't exist, but... hey....
+		# check the hasa relationships for common articleName
+	$foundCommonArticleNameFlag += _compareArticleNames(OS => $OS, type => $args{term}, relationship => $hasalsid, targetArticleName => $articleName);
+		# check the has relationships for common articleName		
+	$foundCommonArticleNameFlag += _compareArticleNames(OS => $OS, type => $args{term}, relationship => $haslsid, targetArticleName => $articleName);
+
+	# now get all of its inherited parents
 	my $relationships = $OS->Relationships(
 		ontology => 'object',
 		term => $args{term},
@@ -527,40 +533,39 @@
 	my ($isa) = keys(%$relationships);  # can only be one key returned, and must be isa in this case
 	my @ISAlist;
 	(@ISAlist = @{$relationships->{$isa}}) if ($relationships->{$isa}) ;
+	# for each of the inherited parents, check their articleNames
 	foreach my $ISA(@ISAlist){  # $ISA = [lsid, articleName] (but articleName shuld be null anyway in this case)
 		my $what_it_is = shift @$ISA;
-		my $hasarelationships = $OS->Relationships(
-			ontology => 'object',
-			term => $what_it_is,
-			relationship => $hasalsid,
-			direction => 'root',
-			);
-		if ($hasarelationships){
-			#$hasarelationships{relationship} = [[lsid1,articleNmae], [lsid2, articleName], [lsid3, articleName]]	
-		       my ($hasa) = keys(%$hasarelationships);
-		       if ($hasarelationships->{$hasa}){
-				my @HASAlist = @{$hasarelationships->{$hasa}};
-				foreach my $HASA(@HASAlist){
-					$foundCommonArticleNameFlag = 1 if ($HASA->[1] eq $articleName);
-				}
-		       }
-		}
-		my $hasrelationships = $OS->Relationships(
-			ontology => 'object',
-			term => $what_it_is,
-			relationship => $haslsid,
-			direction => 'root',
-			);
-		if ($hasrelationships){
-			#$hasrelationships{relationship} = [[lsid1,articleNmae], [lsid2, articleName], [lsid3, articleName]]	
-		       my ($has) = keys(%$hasrelationships);
-		       if ($hasrelationships->{$has}){
-			my @HASlist = @{$hasrelationships->{$has}};
-			foreach my $HAS(@HASlist){
-				$foundCommonArticleNameFlag = 1 if ($HAS->[1] eq $articleName);
+		# check the hasa relationships for common articleName
+		$foundCommonArticleNameFlag += _compareArticleNames(OS => $OS, type => $what_it_is, relationship => $hasalsid, targetArticleName => $articleName);
+		# check the has relationships for common articleName		
+		$foundCommonArticleNameFlag += _compareArticleNames(OS => $OS, type => $what_it_is, relationship => $haslsid, targetArticleName => $articleName);
+	}
+	return $foundCommonArticleNameFlag;
+}
+
+sub _compareArticleNames {
+	my (%args) = @_;
+	my $OS =  $args{OS};
+	my $what_it_is = $args{type};
+	my $lsid = $args{relationshipLSID};
+	my $targetArticleName = $args{targetArticleName};
+	my $foundCommonArticleNameFlag = 0;
+	my $contents = $OS->Relationships(
+		ontology => 'object',
+		term => $what_it_is,
+		relationship => $lsid,
+		direction => 'root',
+		);
+	if ($contents){
+		#$hasarelationships{relationship} = [[lsid1,articleNmae], [lsid2, articleName], [lsid3, articleName]]	
+	       my ($content) = keys(%$contents);
+	       if ($contents->{$content}){
+			my @CONTENTlist = @{$contents->{$content}};
+			foreach my $CONTAINED(@CONTENTlist){
+				$foundCommonArticleNameFlag = 1 if ($CONTAINED->[1] eq $targetArticleName); #->[1] is the articleName field
 			}
-		       }
-		}
+	       }
 	}
 	return $foundCommonArticleNameFlag;
 }




More information about the MOBY-guts mailing list