[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Thu Jul 28 18:33:10 UTC 2005


mwilkinson
Thu Jul 28 14:33:10 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv5118/MOBY

Modified Files:
	Central.pm OntologyServer.pm 
Log Message:
this code should now be compliant with the 0.85 version of teh API.  All situations where MOBY Central used to return an ontology term, it now returns both the term and its LSID. The behaviour SHOULD be consistent throughout all messages - a term is the content of a node, while its LSID is an attribute of the node.

moby-live/Perl/MOBY Central.pm,1.188,1.189 OntologyServer.pm,1.67,1.68
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -r1.188 -r1.189
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm	2005/07/27 17:29:10	1.188
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm	2005/07/28 18:33:10	1.189
@@ -1102,12 +1102,12 @@
 
 =over 3
 
-=item *  Simple
+=item *  Simple (note that the lsid attribute of the objectType and Namespace element need only be present in the article when it is present in a response document from MOBY Central such as the result of a findService call.  These attributes are ignored by MOBY Central when they appear in input messages such as registerService)
 
          <Simple articleName="NameOfArticle">
-           <objectType>ObjectOntologyTerm</objectType>
-           <Namespace>NamespaceTerm</Namespace>
-           <Namespace>...</Namespace><!-- one or more... -->
+           <objectType lsid='urn:lsid:...'>ObjectOntologyTerm</objectType>
+           <Namespace lsid='urn:lsid:...'>NamespaceTerm</Namespace>
+           <Namespace lsid='urn:lsid:...'>...</Namespace><!-- one or more... -->
          </Simple>
 
 =item *  Collection note that articleName of the contained Simple objects is not required, and is ignored.
@@ -1832,7 +1832,7 @@
 
  <Services>
   <Service authURI="authority.URI.here" serviceName="MyService" lsid="urn:lsid:authority.uri:serviceinstance:id">
-	<serviceType>Service_Ontology_Term</serviceType>
+	<serviceType lsid='urn:...'>Service_Ontology_Term</serviceType>
 	<Protocol>moby</Protocol> <!-- or 'cgi' or 'soap' -->
 	<authoritative>1</authoritative>
 	<contactEmail>your at email.address</contactEmail>
@@ -2401,8 +2401,9 @@
 		authority_uri => $AuthURI,
 		servicename   => $serviceName
 	);
+	my $servlsid = $SI->lsid;
 	my $wsdls;
-	return "<Service/>" unless ($SI);
+	return "<Services/>" unless ($SI);
 	if ( $SI->category eq 'moby' ) {
 		my $wsdl =
 		  &_getServiceWSDL( $SI, $InputXML, $OutputXML, $SecondaryXML );
@@ -2410,7 +2411,7 @@
 			if ( $wsdl =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
 				$wsdl = $1;
 			}
-			$wsdls .= "<Service><![CDATA[$wsdl]]></Service>\n";
+			$wsdls .= "<Service lsid='$servlsid'><![CDATA[$wsdl]]></Service>\n";
 		}
 
 		#$debug && &_LOG("WSDL_________________$wsdls\n____________________");
@@ -2498,7 +2499,7 @@
  Args      :	none
  XML       :
 	<serviceNames>
-	   <serviceName name="serviceName" authURI='authority.info.here'/>
+	   <serviceName name="serviceName" authURI='authority.info.here' lsid = 'urn:lsid...'/>
 		...
 		...
 	</serviceNames>
@@ -2514,7 +2515,10 @@
 	my $result = $adaptor->get_service_names();
 	my $names = "<serviceNames>\n";
 	foreach my  $row (@$result) {
-		$names .= "<serviceName name='$row->{servicename}' authURI='$row->{authority_uri}'/>\n";
+		my $name = $row->{servicename};
+		my $auth = $row->{authority_uri};
+		my $lsid = $row->{lsid};
+		$names .= "<serviceName name='$name' authURI='$auth' lsid='$lsid'/>\n";
 	}
 	$names .= "</serviceNames>\n";
 	return $names;
@@ -2543,12 +2547,13 @@
 	my $OS    = MOBY::OntologyServer->new( ontology => 'service' );
 	my %types = %{ $OS->retrieveAllServiceTypes() };
 	my $types = "<serviceTypes>\n";
-	while ( my ( $serv, $desc ) = each %types ) {
+	while ( my ( $serv, $descr ) = each %types ) {
+		my ($desc, $lsid) = @$descr;
 		if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
 			$desc = $1;
 		}
 		$types .=
-"<serviceType name='$serv'>\n<Description><![CDATA[$desc]]></Description>\n</serviceType>\n";
+"<serviceType name='$serv' lsid='$lsid'>\n<Description><![CDATA[$desc]]></Description>\n</serviceType>\n";
 	}
 	$types .= "</serviceTypes>\n";
 	return $types;
@@ -2583,14 +2588,15 @@
 	my $OS       = MOBY::OntologyServer->new( ontology => 'relationship' );
 	my %types    = %{ $OS->getRelationshipTypes( ontology => $ontology ) };
 	my $types    = "<relationshipTypes>\n";
-	while ( my ( $name, $authdesc ) = each %types ) {
-		my $auth = $authdesc->[0];
-		my $desc = $authdesc->[1];
+	while ( my ( $lsid, $authdesc ) = each %types ) {
+		my $name = $authdesc->[0];
+		my $auth = $authdesc->[1];
+		my $desc = $authdesc->[2];
 		if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
 			$desc = $1;
 		}
 		$types .=
-"<relationshipType relationship='$name' authority='$auth'>\n<Description><![CDATA[$desc]]></Description>\n</relationshipType>\n";
+"<relationshipType relationship='$name' authority='$auth' lsid='$lsid'>\n<Description><![CDATA[$desc]]></Description>\n</relationshipType>\n";
 	}
 	$types .= "</relationshipTypes>\n";
 	return $types;
@@ -2619,12 +2625,13 @@
 	my $OS    = MOBY::OntologyServer->new( ontology => 'object' );
 	my %types = %{ $OS->retrieveAllObjectTypes() };
 	my $obj   = "<objectNames>\n";
-	while ( my ( $name, $desc ) = each %types ) {
+	while ( my ( $name, $descr ) = each %types ) {
+		my ($desc, $lsid) = @$descr;
 		if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
 			$desc = $1;
 		}
 		$obj .=
-"<Object name='$name'>\n<Description><![CDATA[$desc]]></Description>\n</Object>\n";
+"<Object name='$name' lsid='$lsid'>\n<Description><![CDATA[$desc]]></Description>\n</Object>\n";
 	}
 	$obj .= "</objectNames>\n";
 	return $obj;
@@ -2648,8 +2655,8 @@
                     human readable description
                     of data type]]>
             </Description>
-            <Relationship relationshipType="RelationshipOntologyTerm">
-               <objectType articleName="SomeName">ExistingObjectType</objectType>
+            <Relationship relationshipType="urn:lsid...">
+               <objectType articleName="SomeName" lsid="urn:lsid...">ExistingObjectType</objectType>
             </Relationship>
             ...
             ...
@@ -2679,7 +2686,7 @@
 	}
 	my $response;
 	$response = "<retrieveObjectDefinition>
-	<objectType>$def{objectType}</objectType>
+	<objectType lsid='$def{objectLSID}'>$def{objectType}</objectType>
 	<Description><![CDATA[$def{description}]]></Description>
 	<authURI>$def{authURI}</authURI>
 	<contactEmail>$def{contactEmail}</contactEmail>\n";
@@ -2688,10 +2695,10 @@
 	while ( my ( $rel, $objdefs ) = each %relationships ) {
 		$response .= "<Relationship relationshipType='$rel'>\n";
 		foreach my $def ( @{$objdefs} ) {
-			my ( $lsid, $articlename ) = @{$def};
+			my ( $lsid, $articlename,$type, $def, $auth, $contac ) = @{$def};
 			$articlename = "" unless defined $articlename;
 			$response .=
-			  "<objectType articleName='$articlename'>$lsid</objectType>\n";
+			  "<objectType articleName='$articlename' lsid='$lsid'>$type</objectType>\n";
 		}
 		$response .= "</Relationship>\n";
 	}
@@ -2722,12 +2729,13 @@
 	my $OS    = MOBY::OntologyServer->new( ontology => 'namespace' );
 	my %types = %{ $OS->retrieveAllNamespaceTypes() };
 	my $ns    = "<Namespaces>\n";
-	while ( my ( $namespace, $desc ) = each %types ) {
+	while ( my ( $namespace, $descr ) = each %types ) {
+		my ($desc, $lsid, $auth, $contact) = @$descr;
 		if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
 			$desc = $1;
 		}
 		$ns .=
-"<Namespace name='$namespace'>\n<Description><![CDATA[$desc]]></Description>\n</Namespace>\n";
+"<Namespace name='$namespace' lsid='$lsid'>\n<Description><![CDATA[$desc]]></Description>\n</Namespace>\n";
 	}
 	$ns .= "</Namespaces>";
 	return $ns;
@@ -2810,8 +2818,8 @@
  outputXML :
   <Relationships>
     <Relationship relationshipType="RelationshipOntologyTerm">
-       <objectType>ExistingServiceType</objectType>
-       <objectType>ExistingServiceType</objectType>
+       <objectType lsid='urn:lsid...'>ExistingServiceType</objectType>
+       <objectType lsid='urn:lsid...'>ExistingServiceType</objectType>
     </Relationship>
     <Relationship relationshipType="AnotherRelationshipTerm">
         ....
@@ -2822,8 +2830,8 @@
 
   <Relationships>    
     <Relationship relationshipType="RelationshipOntologyTerm">
-       <serviceType>ExistingServiceType</serviceType>
-       <serviceType>ExistingServiceType</serviceType>
+       <serviceType lsid='urn:lsid...'>ExistingServiceType</serviceType>
+       <serviceType lsid='urn:lsid...'>ExistingServiceType</serviceType>
     </Relationship>
     <Relationship relationshipType="AnotherRelationshipTerm">
         ....
@@ -2858,25 +2866,19 @@
 	}
 	my $term = &_nodeTextContent( $doc, "objectType" );
 	$ontology = "object"
-	  if $term
-	  ; # pick up the ontology "object" that we used here if we got an object term
+	  if $term; # pick up the ontology "object" that we used here if we got an object term
 	$term ||=
-	  &_nodeTextContent( $doc, "serviceType" )
-	  ;    # if we didn't get anything using objectType try serviceType
+	  &_nodeTextContent( $doc, "serviceType" );    # if we didn't get anything using objectType try serviceType
 	return undef unless $term;    # and bail out if we didn't succeed
-	$ontology ||= "service"
-	  ; # if we have now succeeded and haven't already taken the ontology then it must be the service ontology
+	$ontology ||= "service"; # if we have now succeeded and haven't already taken the ontology then it must be the service ontology
 	&_LOG("Ontology was $ontology; Term was $term\n");
 	my $OS = MOBY::OntologyServer->new( ontology => $ontology );
-	my %rels =
-	  %{ $OS->Relationships( term => $term, expand => $expand_relationship )
-	  };    # %rels = $rels{relationship} = [lsid, lsid,lsid]
+	my %rels = %{ $OS->Relationships( term => $term, expand => $expand_relationship )};    # %rels = $rels{relationship} = [lsid, lsid,lsid]
 	my $response = "<Relationships>\n";
 	my $OSrel    = MOBY::OntologyServer->new( ontology => 'relationship' );
 
 	foreach ( keys %reltypes ) {    # for each of our desired types
-		my $rellsid =
-		  $OSrel->getRelationshipURI( $ontology, $_ );    # get the LSID
+		my $rellsid = $OSrel->getRelationshipURI( $ontology, $_ );    # get the LSID
 		delete $reltypes{$_};    # remove the non-LSID version from the hash
 		$reltypes{$rellsid} = 1; # set the LSID as valid
 	}
@@ -2886,15 +2888,17 @@
 		my $rellsid = $OSrel->getRelationshipURI( $ontology, $_ );
 		next unless $rellsid;
 		if ( keys %reltypes ) {
-			next
-			  unless $reltypes{ $rellsid
-			  };   # next unless it is one ofthe relationship types we requested
+			next unless $reltypes{ $rellsid};   # next unless it is one ofthe relationship types we requested
 		}
 		my $lsids = $rels{$rellsid};
 		next unless $lsids->[0];
-		$response .= "<Relationship relationshipType='$rellsid'>\n";
+		$response .= "<Relationship relationshipType='$_' lsid='$rellsid'>\n";
 		foreach my $lsid ( @{$lsids} ) {
-			$response .= "<${ontology}Type>$lsid</${ontology}Type>\n";
+			# ugh... I have to cheat here because the term is not returned from the Ontology Server
+			# one day we may have to fix this...
+			$lsid =~ /urn\:lsid\:[^\:]+\:[^\:]+\:([^\:]+)/;  # get the term portion of the LSID
+			$term = $1;
+			$response .= "<${ontology}Type lsid='$lsid'>$term</${ontology}Type>\n";
 		}
 		$response .= "</Relationship>\n";
 	}
@@ -3314,10 +3318,10 @@
 			my @nsURIs = split ",", $nsURI;
 			$article ||= "";
 			$output .= "\t\t<Simple articleName='$article'>\n";
-			$output .= "\t\t\t<objectType>$objName</objectType>\n";
+			$output .= "\t\t\t<objectType lsid='$objURI'>$objName</objectType>\n";
 			foreach my $ns (@nsURIs) {
 				my $NSname = $OSns->getNamespaceCommonName($ns);
-				$output .= "\t\t\t<Namespace>$NSname</Namespace>\n" if $NSname;
+				$output .= "\t\t\t<Namespace lsid='$ns'>$NSname</Namespace>\n" if $NSname;
 			}
 			$output .= "\t\t</Simple>\n";
 		}
@@ -3342,10 +3346,10 @@
 				my @nsURIs = split ",", $nsURI;
 				$article ||= "";
 				$output .= "\t\t\t<Simple articleName='$article'>\n";
-				$output .= "\t\t\t\t<objectType>$objName</objectType>\n";
+				$output .= "\t\t\t\t<objectType lsid=$objURI>$objName</objectType>\n";
 				foreach my $ns (@nsURIs) {
 					my $NSname = $OSns->getNamespaceCommonName($ns);
-					$output .= "\t\t\t\t<Namespace>$NSname</Namespace>\n"
+					$output .= "\t\t\t\t<Namespace lsid='$ns'>$NSname</Namespace>\n"
 					  if $NSname;
 				}
 				$output .= "\t\t\t</Simple>\n";
@@ -3368,10 +3372,10 @@
 		    my @nsURIs = split ",", $nsURI;
 		    $article ||= "";
 		    $output .= "\t\t<Simple articleName='$article'>\n";
-		    $output .= "\t\t\t<objectType>$objName</objectType>\n";
+		    $output .= "\t\t\t<objectType lsid='$objURI'>$objName</objectType>\n";
 		    foreach my $ns (@nsURIs) {
 			my $NSname = $OSns->getNamespaceCommonName($ns);
-			$output .= "\t\t\t<Namespace>$NSname</Namespace>\n" if $NSname;
+			$output .= "\t\t\t<Namespace lsid='$ns'>$NSname</Namespace>\n" if $NSname;
 		    }
 		    $output .= "\t\t</Simple>\n";
 		}
@@ -3394,10 +3398,10 @@
 			my @nsURIs = split ",", $nsURI;
 			$article ||= "";
 			$output .= "\t\t\t<Simple articleName='$article'>\n";
-			$output .= "\t\t\t\t<objectType>$objName</objectType>\n";
+			$output .= "\t\t\t\t<objectType lsid='$objURI'>$objName</objectType>\n";
 			foreach my $ns (@nsURIs) {
 			    my $NSname = $OSns->getNamespaceCommonName($ns);
-			    $output .= "\t\t\t\t<Namespace>$NSname</Namespace>\n"
+			    $output .= "\t\t\t\t<Namespace lsid='$ns'>$NSname</Namespace>\n"
 				if $NSname;
 			}
 			$output .= "\t\t\t</Simple>\n";

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm	2005/07/28 16:00:10	1.67
+++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm	2005/07/28 18:33:10	1.68
@@ -321,11 +321,16 @@
 	my $relationship_type = $row->{relationship_type};
 	my $objectlsid = $row->{object_lsid};
 	my $article = $row->{object2_articlename};
+	my $contact = $row->{contact_email};
+	my $def = $row->{definition};
+	my $auth = $row->{authority};
+	my $type = $row->{object_type};
 
-	push @{ $rel{$relationship_type} }, [ $objectlsid, $article ];
+	push @{ $rel{$relationship_type} }, [ $objectlsid, $article, $type, $def, $auth, $contact ];
 	}
 	return {
-			 objectType    => $lsid,
+			 objectType	=> $type,
+			 objectLSID    => $lsid,
 			 description   => $desc,
 			 contactEmail  => $contact,
 			 authURI       => $auth,
@@ -845,7 +850,7 @@
 
 	my %response;
 	foreach (@$types) {
-		$response{ $_->{service_type} } = $_->{description};
+		$response{ $_->{service_type} } = [$_->{description}, $_->{service_lsid}];
 	}
 	return \%response;
 }
@@ -862,7 +867,7 @@
 
 	my %response;
 	foreach (@$types) {
-		$response{ $_->{namespace_type} } = $_->{description};
+		$response{ $_->{namespace_type} } = [$_->{description}, $_->{namespace_lsid}, $_->{authority}, $_->{contact_email}];
 	}
 	return \%response;
 }
@@ -879,7 +884,7 @@
 
 	my %response;
 	foreach (@$types) {
-		$response{ $_->{object_type} } = $_->{description};
+		$response{ $_->{object_type} } = [$_->{description}, $_->{object_lsid}];
 	}
 	return \%response;
 }
@@ -1065,11 +1070,8 @@
 			push @{ $results{$rel} }, $lsid;
 		}
 		last unless ($expand);
-		last
-		  unless ( $direction eq "root" )
-		  ; # if we aren't going to root, then be careful or we'll loop infnitely
-		$term = $lsid
-		  ; # this entire subroutine assumes that there is NOT multiple parenting...
+		last unless ( $direction eq "root" ); # if we aren't going to root, then be careful or we'll loop infnitely
+		$term = $lsid; # this entire subroutine assumes that there is NOT multiple parenting...
 	}
 	return \%results;    #results(relationship} = [lsid1, lsid2, lsid3]
 }




More information about the MOBY-guts mailing list