[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Thu Nov 20 19:35:46 UTC 2008


kawas
Thu Nov 20 14:35:46 EST 2008
Update of /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers
In directory dev.open-bio.org:/tmp/cvs-serv13269/Perl/MOBY-Server/lib/MOBY/RDF/Parsers

Modified Files:
	ServiceParser.pm 
Log Message:
*added the unit test parsing to this module
*added a warning telling users not to try and parse the whole service instance ontology
moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers ServiceParser.pm,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers/ServiceParser.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers/ServiceParser.pm	2008/11/20 17:02:24	1.1
+++ /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers/ServiceParser.pm	2008/11/20 19:35:46	1.2
@@ -61,6 +61,13 @@
 
 =cut
 
+=head1 WARNING
+
+Do not attempt to parse service instance RDF containing more than a few hundred services because the RDF is
+parsed and held in memory.
+
+=cut
+
 =head1 AUTHORS
 
  Edward Kawas (edward.kawas [at] gmail [dot] com)
@@ -228,43 +235,45 @@
 		$providedBy = [] unless @$providedBy;
 		$providedBy = $$providedBy[0]
 		  if ref($providedBy) eq 'ARRAY' and $$providedBy[0];
+		if ($providedBy) {
 
-		# set the authoritative
-		$val = $model->getObjects(
-								   $providedBy,
-								   new RDF::Core::Resource(
+			# set the authoritative
+			$val = $model->getObjects(
+									   $providedBy,
+									   new RDF::Core::Resource(
 													 MOBY::RDF::Predicates::FETA
 													   ->authoritative
-								   )
-		);
-		$val = "" unless $$val[0];
-		$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
-		$instance->authoritative(
+									   )
+			);
+			$val = "" unless $$val[0];
+			$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
+			$instance->authoritative(
 							 MOBY::RDF::Utils::trim($val) =~ m/true/i ? 1 : 0 );
 
-		# set the contact email
-		$val = $model->getObjects(
-								   $providedBy,
-								   new RDF::Core::Resource(
+			# set the contact email
+			$val = $model->getObjects(
+									   $providedBy,
+									   new RDF::Core::Resource(
 											   MOBY::RDF::Predicates::DC_PROTEGE
 												 ->creator
-								   )
-		);
-		$val = "" unless $$val[0];
-		$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
-		$instance->contactEmail( MOBY::RDF::Utils::trim($val) );
+									   )
+			);
+			$val = "" unless $$val[0];
+			$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
+			$instance->contactEmail( MOBY::RDF::Utils::trim($val) );
 
-		# set the authority uri
-		$val = $model->getObjects(
-								   $providedBy,
-								   new RDF::Core::Resource(
+			# set the authority uri
+			$val = $model->getObjects(
+									   $providedBy,
+									   new RDF::Core::Resource(
 											   MOBY::RDF::Predicates::DC_PROTEGE
 												 ->publisher
-								   )
-		);
-		$val = "" unless $$val[0];
-		$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
-		$instance->authority( MOBY::RDF::Utils::trim($val) );
+									   )
+			);
+			$val = "" unless $$val[0];
+			$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
+			$instance->authority( MOBY::RDF::Utils::trim($val) );
+		}
 
 		# no longer need the providedBy node
 		$providedBy = undef;
@@ -281,6 +290,9 @@
 		$hasOperation = $$hasOperation[0]
 		  if ref($hasOperation) eq 'ARRAY' and $$hasOperation[0];
 
+		# if this is missing ... what's the point?
+		next unless $hasOperation;
+
 		# process any inputs
 		my $inputs = $model->getObjects(
 								 $hasOperation,
@@ -454,6 +466,7 @@
 			}
 			elsif ( $val eq MOBY::RDF::Predicates::FETA->secondaryParameter ) {
 				my $param = MOBY::Client::SecondaryArticle->new;
+
 				# get the articlename
 				$val =
 				  $model->getObjects(
@@ -761,7 +774,72 @@
 		$performs = undef;
 
 		# process any unit test information
-		#TODO
+		my $unit_test =
+		  $model->getObjects(
+							  $hasOperation,
+							  new RDF::Core::Resource(
+										MOBY::RDF::Predicates::FETA->hasUnitTest
+							  )
+		  );
+		$unit_test = [] unless @$unit_test;
+		foreach my $ut (@$unit_test) {
+			my $unit = new MOBY::Client::MobyUnitTest;
+
+			# get example input
+			$val =
+			  $model->getObjects(
+								  $ut,
+								  new RDF::Core::Resource(
+									   MOBY::RDF::Predicates::FETA->exampleInput
+								  )
+			  );
+			$val = "" unless $$val[0];
+			$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
+			$unit->example_input( MOBY::RDF::Utils::trim($val) );
+
+			# get example output
+			$val =
+			  $model->getObjects(
+								  $ut,
+								  new RDF::Core::Resource(
+													 MOBY::RDF::Predicates::FETA
+													   ->validOutputXML
+								  )
+			  );
+			$val = "" unless $$val[0];
+			$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
+			$unit->expected_output( MOBY::RDF::Utils::trim($val) );
+
+			# get regex
+			$val =
+			  $model->getObjects(
+								  $ut,
+								  new RDF::Core::Resource(
+										 MOBY::RDF::Predicates::FETA->validREGEX
+								  )
+			  );
+			$val = "" unless $$val[0];
+			$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
+			$unit->regex( MOBY::RDF::Utils::trim($val) );
+
+			# get xpath
+			$val =
+			  $model->getObjects(
+								  $ut,
+								  new RDF::Core::Resource(
+										 MOBY::RDF::Predicates::FETA->validXPath
+								  )
+			  );
+			$val = "" unless $$val[0];
+			$val = $$val[0]->getValue if ref($val) eq 'ARRAY' and $$val[0];
+			$unit->xpath( MOBY::RDF::Utils::trim($val) );
+
+			# set the unit test in the service
+			$instance->unitTest($unit);
+
+			# should only be one ... so last;
+			last;
+		}
 
 		# this service is done ...
 		push @{$services}, $instance;




More information about the MOBY-guts mailing list