[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Mon Jul 9 20:53:46 UTC 2007


kawas
Mon Jul  9 16:53:46 EDT 2007
Update of /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies
In directory dev.open-bio.org:/tmp/cvs-serv31370/RDF/Ontologies

Modified Files:
	Objects.pm 
Log Message:
renamed a few routines and applied url + base64 to articlenames in the URI portion of HAS/HASA members.
moby-live/Perl/MOBY/RDF/Ontologies Objects.pm,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Objects.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Objects.pm	2007/07/09 19:54:31	1.2
+++ /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Objects.pm	2007/07/09 20:53:46	1.3
@@ -27,6 +27,8 @@
 
 use MOBY::RDF::Utils;
 
+use MIME::Base64;
+use CGI;
 use strict;
 
 #-----------------------------------------------------------------
@@ -72,8 +74,9 @@
 
 	# create an object
 	my $self = bless {}, ref($class) || $class;
-	$self->{uri}       = 'http://biomoby.org/RESOURCES/MOBY-S/Objects#';
-	$self->{uri_comp}       = 'http://biomoby.org/RESOURCES/MOBY_SUB_COMPONENT/Objects#';
+	$self->{uri}      = 'http://biomoby.org/RESOURCES/MOBY-S/Objects#';
+	$self->{uri_comp} =
+	  'http://biomoby.org/RESOURCES/MOBY_SUB_COMPONENT/Objects#';
 	$self->{query_all} = <<END;
 SELECT ot1.object_type, rt.relationship_type, ot2.object_type, rt.object2_articlename, ot1.description, ot1.object_lsid, ot1.authority, ot1.contact_email 
 FROM object as ot1, object_term2term as rt, object as ot2 
@@ -134,9 +137,13 @@
 		my $lsid         = $$ref[5];
 		my $authority    = $$ref[6];
 		my $email        = $$ref[7];
-		
+
 		my $resource = new RDF::Core::Resource( $self->{uri}, $subject );
-		$self->_foo($model, $resource, $subject, $relationship, $object, $articlename, $description, $lsid, $authority, $email);
+		$self->_processDatatype(
+			$model,     $resource,    $subject,     $relationship,
+			$object,    $articlename, $description, $lsid,
+			$authority, $email
+		);
 
 	}
 	$sth->finish();
@@ -185,7 +192,7 @@
 	# add root of ontology
 	$self->_addOntologyRoot($model);
 	my $node_factory = new RDF::Core::NodeFactory();
-	
+
 	do {
 		my $CONF = MOBY::Config->new;
 		my $adap = $CONF->getDataAdaptor( source => "mobyobject" );
@@ -211,7 +218,11 @@
 			my $authority    = $$ref[6];
 			my $email        = $$ref[7];
 			my $resource = new RDF::Core::Resource( $self->{uri}, $subject );
-			$self->_foo($model, $resource, $subject, $relationship, $object, $articlename, $description, $lsid, $authority, $email);
+			$self->_processDatatype(
+				$model,     $resource,    $subject,     $relationship,
+				$object,    $articlename, $description, $lsid,
+				$authority, $email
+			);
 			do {
 				$term = $object;
 			} if $relationship =~ m/.*\:isa$/;
@@ -240,6 +251,9 @@
 	return $xml;
 }
 
+
+#####-----------------------Private Routines--------------------------#####
+
 sub _addOntologyRoot {
 	my ( $self, $model ) = @_;
 	my $resource = new RDF::Core::Resource( $self->{uri}, "Object" );
@@ -293,135 +307,141 @@
 
 }
 
-sub _foo {
+sub _processDatatype {
+
+	my (
+		$self,         $model,     $resource,    $subject,
+		$relationship, $object,    $articlename, $description,
+		$lsid,         $authority, $email
+	  )
+	  = @_;
 
-my ($self,$model, $resource, $subject, $relationship, $object, $articlename, $description, $lsid, $authority, $email) = @_;
-		
+	#		$model->addStmt(
+	#			new RDF::Core::Statement(
+	#				$resource,
+	#				$resource->new( MOBY::RDF::Predicates::RDF->type ),
+	#				new RDF::Core::Resource( MOBY::RDF::Predicates::OWL->Class )
+	#			)
+	#		);
+	$model->addStmt(
+		new RDF::Core::Statement(
+			$resource,
+			$resource->new( MOBY::RDF::Predicates::RDFS->label ),
+			new RDF::Core::Literal($subject)
+		)
+	);
+	$model->addStmt(
+		new RDF::Core::Statement(
+			$resource,
+			$resource->new( MOBY::RDF::Predicates::RDFS->comment ),
+			new RDF::Core::Literal($description)
+		)
+	);
+	$model->addStmt(
+		new RDF::Core::Statement(
+			$resource,
+			$resource->new( MOBY::RDF::Predicates::DC_PROTEGE->publisher ),
+			new RDF::Core::Literal($authority)
+		)
+	);
+	$model->addStmt(
+		new RDF::Core::Statement(
+			$resource,
+			$resource->new( MOBY::RDF::Predicates::DC_PROTEGE->identifier ),
+			new RDF::Core::Literal($lsid)
+		)
+	);
+	$model->addStmt(
+		new RDF::Core::Statement(
+			$resource,
+			$resource->new( MOBY::RDF::Predicates::DC_PROTEGE->creator ),
+			new RDF::Core::Literal($email)
+		)
+	);
 
-		#		$model->addStmt(
-		#			new RDF::Core::Statement(
-		#				$resource,
-		#				$resource->new( MOBY::RDF::Predicates::RDF->type ),
-		#				new RDF::Core::Resource( MOBY::RDF::Predicates::OWL->Class )
-		#			)
-		#		);
+	# add subclassof, if applicable
+	do {
+		my $parent = new RDF::Core::Resource( $self->{uri}, $object );
 		$model->addStmt(
 			new RDF::Core::Statement(
 				$resource,
-				$resource->new( MOBY::RDF::Predicates::RDFS->label ),
-				new RDF::Core::Literal($subject)
+				$resource->new( MOBY::RDF::Predicates::RDFS->subClassOf ),
+				$parent
 			)
 		);
+	} if $relationship =~ m/.*\:isa$/;
+
+	# add hasa container relationships
+	do {
+		my $container =
+		  new RDF::Core::Resource( $self->{uri_comp},
+			$subject . "_" . CGI::escape(encode_base64("$articlename")) );
 		$model->addStmt(
 			new RDF::Core::Statement(
-				$resource,
-				$resource->new( MOBY::RDF::Predicates::RDFS->comment ),
-				new RDF::Core::Literal($description)
+				$container,
+				$container->new( MOBY::RDF::Predicates::RDF->type ),
+				new RDF::Core::Resource( $self->{uri}, $object )
 			)
 		);
 		$model->addStmt(
 			new RDF::Core::Statement(
 				$resource,
-				$resource->new( MOBY::RDF::Predicates::DC_PROTEGE->publisher ),
-				new RDF::Core::Literal($authority)
+				$resource->new( MOBY::RDF::Predicates::MOBY_PREDICATES->hasa ),
+				$container
 			)
 		);
 		$model->addStmt(
 			new RDF::Core::Statement(
-				$resource,
-				$resource->new( MOBY::RDF::Predicates::DC_PROTEGE->identifier ),
-				new RDF::Core::Literal($lsid)
+				$container,
+				$container->new(
+					MOBY::RDF::Predicates::MOBY_PREDICATES->articleName
+				),
+				new RDF::Core::Literal($articlename)
 			)
 		);
+		$self->_processISAs( $model, $object );
+
+	} if $relationship =~ m/.*\:hasa$/;
+
+	# add has container relationship
+	do {
+		my $container =
+		  new RDF::Core::Resource( $self->{uri_comp},
+			$subject . "_" .  CGI::escape (encode_base64("$articlename")));
 		$model->addStmt(
 			new RDF::Core::Statement(
-				$resource,
-				$resource->new( MOBY::RDF::Predicates::DC_PROTEGE->creator ),
-				new RDF::Core::Literal($email)
+				$container,
+				$container->new( MOBY::RDF::Predicates::RDF->type ),
+				new RDF::Core::Resource( $self->{uri}, $object )
 			)
 		);
 
-		# add subclassof, if applicable
-		do {
-			my $parent = new RDF::Core::Resource( $self->{uri}, $object );
-			$model->addStmt(
-				new RDF::Core::Statement(
-					$resource,
-					$resource->new( MOBY::RDF::Predicates::RDFS->subClassOf ),
-					$parent
-				)
-			);
-		} if $relationship =~ m/.*\:isa$/;
+		$model->addStmt(
+			new RDF::Core::Statement(
+				$resource,
+				$resource->new( MOBY::RDF::Predicates::MOBY_PREDICATES->has ),
+				$container
+			)
+		);
+		$model->addStmt(
+			new RDF::Core::Statement(
+				$container,
+				$container->new(
+					MOBY::RDF::Predicates::MOBY_PREDICATES->articleName
+				),
+				new RDF::Core::Literal($articlename)
+			)
+		);
+		$self->_processISAs( $model, $object );
 
-		# add hasa container relationships
-		do {
-			my $container = new RDF::Core::Resource( $self->{uri_comp}, $subject . "_" . $articlename );
-			$model->addStmt(
-				new RDF::Core::Statement(
-					$container, $container->new( MOBY::RDF::Predicates::RDF->type ),
-					new RDF::Core::Resource( $self->{uri}, $object )
-				)
-			);
-			$model->addStmt(
-				new RDF::Core::Statement(
-					$resource,
-					$resource->new(
-						MOBY::RDF::Predicates::MOBY_PREDICATES->hasa
-					),
-					$container
-				)
-			);
-			$model->addStmt(
-				new RDF::Core::Statement(
-					$container,
-					$container->new(
-						MOBY::RDF::Predicates::MOBY_PREDICATES->articleName
-					),
-					new RDF::Core::Literal($articlename)
-				)
-			);
-			$self->_processISAs($model, $object);
-			
-		} if $relationship =~ m/.*\:hasa$/;
-
-		# add has container relationship
-		do {
-			my $container = new RDF::Core::Resource( $self->{uri_comp}, $subject . "_" . $articlename );
-			$model->addStmt(
-				new RDF::Core::Statement(
-					$container, $container->new( MOBY::RDF::Predicates::RDF->type ),
-					new RDF::Core::Resource( $self->{uri}, $object )
-				)
-			);
-			
-			$model->addStmt(
-				new RDF::Core::Statement(
-					$resource,
-					$resource->new(
-						MOBY::RDF::Predicates::MOBY_PREDICATES->has
-					),
-					$container
-				)
-			);
-			$model->addStmt(
-				new RDF::Core::Statement(
-					$container,
-					$container->new(
-						MOBY::RDF::Predicates::MOBY_PREDICATES->articleName
-					),
-					new RDF::Core::Literal($articlename)
-				)
-			);
-			$self->_processISAs($model, $object);
-			
-		} if $relationship =~ m/.*\:has$/;
+	} if $relationship =~ m/.*\:has$/;
 }
 
 sub _processISAs {
 	my ( $self, $model, $term ) = @_;
 
 	my $termExists = 0;
-		
+
 	do {
 		my $CONF = MOBY::Config->new;
 		my $adap = $CONF->getDataAdaptor( source => "mobyobject" );
@@ -447,7 +467,11 @@
 			my $authority    = $$ref[6];
 			my $email        = $$ref[7];
 			my $resource = new RDF::Core::Resource( $self->{uri}, $subject );
-			$self->_foo($model, $resource, $subject, $relationship, $object, $articlename, $description, $lsid, $authority, $email);
+			$self->_processDatatype(
+				$model,     $resource,    $subject,     $relationship,
+				$object,    $articlename, $description, $lsid,
+				$authority, $email
+			);
 			do {
 				$term = $object;
 			} if $relationship =~ m/.*\:isa$/;
@@ -459,6 +483,5 @@
 	} while ( $term && $term ne '' );
 }
 
-
 1;
 __END__




More information about the MOBY-guts mailing list