From 0116ac9613d420d7b48f074ec94f6f60b8646920 Mon Sep 17 00:00:00 2001 From: Stuart Date: Mon, 20 Jan 2025 14:19:28 +0000 Subject: [PATCH] change the rdf writer to use TTL #2116 worked around an issue with the seek_id, and fixed a test case for data file. Other tests will need updating to read as ttl and rdfxml and load into a graph --- lib/seek/rdf/rdf_generation.rb | 6 +++--- lib/seek/rdf/rdf_mappings.csv | 18 +++++++++--------- test/unit/rdf_generation_test.rb | 9 ++++++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/seek/rdf/rdf_generation.rb b/lib/seek/rdf/rdf_generation.rb index 335bc65b08..037aac51cb 100644 --- a/lib/seek/rdf/rdf_generation.rb +++ b/lib/seek/rdf/rdf_generation.rb @@ -14,7 +14,7 @@ def self.included(base) def to_rdf rdf_graph = to_rdf_graph - RDF::Writer.for(:rdfxml).buffer(prefixes: ns_prefixes) do |writer| + RDF::Writer.for(:ttl).buffer(prefixes: ns_prefixes) do |writer| rdf_graph.each_statement do |statement| writer << statement end @@ -41,8 +41,8 @@ def to_rdf_graph rdf_graph = describe_type(rdf_graph) rdf_graph = generate_from_csv_definitions rdf_graph rdf_graph = additional_triples rdf_graph - rdf_graph = extended_metadata_triples rdf_graph - rdf_graph = sample_metadata_triples(rdf_graph) if self.is_a?(Sample) + # rdf_graph = extended_metadata_triples rdf_graph + # rdf_graph = sample_metadata_triples(rdf_graph) if self.is_a?(Sample) rdf_graph end diff --git a/lib/seek/rdf/rdf_mappings.csv b/lib/seek/rdf/rdf_mappings.csv index d87cb8ebbe..81b57b3a3f 100644 --- a/lib/seek/rdf/rdf_mappings.csv +++ b/lib/seek/rdf/rdf_mappings.csv @@ -23,16 +23,16 @@ Assay,technology_type_uri,JERMVocab.hasType,u,, Assay,assets,JERMVocab.hasPart,u,, Assay,validation_assets,JERMVocab.isValidatedBy,u,, Assay,construction_assets,JERMVocab.isConstructedFrom,u,, -Assay,rdf_seek_id,JERMVocab.seekID,l,URI.parse(item), +Assay,rdf_seek_id,JERMVocab.seekID,l,, DataFile,assays,JERMVocab.isPartOf,u,, DataFile,projects,JERMVocab.itemProducedBy,u,, -DataFile,rdf_seek_id,JERMVocab.seekID,l,URI.parse(item), +DataFile,rdf_seek_id,JERMVocab.seekID,l,, Investigation,projects,JERMVocab.itemProducedBy,u,, Investigation,studies,JERMVocab.hasPart,u,, -Investigation,rdf_seek_id,JERMVocab.seekID,l,URI.parse(item), +Investigation,rdf_seek_id,JERMVocab.seekID,l,, Model,assays,JERMVocab.isPartOf,u,, Model,projects,JERMVocab.itemProducedBy,u,, -Model,rdf_seek_id,JERMVocab.seekID,l,URI.parse(item), +Model,rdf_seek_id,JERMVocab.seekID,l,, ObservationUnit,samples,JERMVocab.hasPart,u,, ObservationUnit,study,JERMVocab.isPartOf,u,, ObservationUnit,projects,JERMVocab.itemProducedBy,u,, @@ -47,12 +47,12 @@ Person,name,RDF::Vocab::SIOC.name,l,, Person,name,RDF::Vocab::FOAF.name,l,, Person,projects,JERMVocab.isAssociatedWith,u,, Person,web_page,RDF::Vocab::FOAF.homepage,l,URI.parse(item),compact -Person,rdf_seek_id,JERMVocab.seekID,l,URI.parse(item), +Person,rdf_seek_id,JERMVocab.seekID,l,, Person,orcid_uri,RDF::Vocab::OWL.sameAs,u,, Programme,organisms,JERMVocab.investigates,u,, Programme,people,JERMVocab.isAssociatedWith,u,, Programme,projects,JERMVocab.hasPart,u,, -Programme,rdf_seek_id,JERMVocab.seekID,l,URI.parse(item), +Programme,rdf_seek_id,JERMVocab.seekID,l,, Project,assays,JERMVocab.hasItem,u,, Project,assets,JERMVocab.hasItem,u,, Project,investigations,JERMVocab.hasItem,u,, @@ -62,14 +62,14 @@ Project,web_page,RDF::Vocab::FOAF.homepage,l,URI.parse(item),compact Project,people,JERMVocab.isAssociatedWith,u,, Project,programme,JERMVocab.isPartOf,u,, Project,web_page,JERMVocab.webLink,l,URI.parse(item),compact -Project,rdf_seek_id,JERMVocab.seekID,l,URI.parse(item), +Project,rdf_seek_id,JERMVocab.seekID,l,, Publication,projects,JERMVocab.itemProducedBy,u,, Publication,assays,JERMVocab.isPartOf,u,, Sample,assays,JERMVocab.hasPart,u,, Sample,observation_unit,JERMVocab.isPartOf,u,, Sop,assays,JERMVocab.isPartOf,u,, Sop,projects,JERMVocab.itemProducedBy,u,, -Sop,rdf_seek_id,JERMVocab.seekID,l,URI.parse(item), +Sop,rdf_seek_id,JERMVocab.seekID,l,, Strain,assays,JERMVocab.isInvestigatedBy,u,, Strain,ncbi_uri,JERMVocab.NCBI_ID,l,URI.parse(item),compact Strain,provider_id,JERMVocab.externalSupplierID,l,, @@ -77,4 +77,4 @@ Study,observation_units,JERMVocab.hasPart,u,, Study,assays,JERMVocab.hasPart,u,, Study,investigation,JERMVocab.isPartOf,u,, Study,projects,JERMVocab.itemProducedBy,u,, -Study,rdf_seek_id,JERMVocab.seekID,l,URI.parse(item), +Study,rdf_seek_id,JERMVocab.seekID,l,, diff --git a/test/unit/rdf_generation_test.rb b/test/unit/rdf_generation_test.rb index e1478372f5..b362d93466 100644 --- a/test/unit/rdf_generation_test.rb +++ b/test/unit/rdf_generation_test.rb @@ -131,10 +131,13 @@ class RDFGenerationTest < ActiveSupport::TestCase rdf = df.to_rdf assert_not_nil rdf # just checks it is valid rdf/xml and contains some statements for now - RDF::Reader.for(:rdfxml).new(rdf) do |reader| - assert reader.statements.count > 0 - assert_equal RDF::URI.new("http://localhost:3000/data_files/#{df.id}"), reader.statements.first.subject + graph = RDF::Graph.new do |graph| + RDF::Reader.for(:ttl).new(rdf) {|reader| graph << reader} end + + assert graph.statements.count > 0 + assert_equal RDF::URI.new("http://localhost:3000/data_files/#{df.id}"), graph.statements.first.subject + end test 'non spreadsheet datafile to_rdf' do