Skip to content

Commit

Permalink
change the rdf writer to use TTL #2116
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stuzart committed Jan 22, 2025
1 parent 580464d commit 0116ac9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/seek/rdf/rdf_generation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
18 changes: 9 additions & 9 deletions lib/seek/rdf/rdf_mappings.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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,,
Expand All @@ -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,,
Expand All @@ -62,19 +62,19 @@ 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,,
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,,
9 changes: 6 additions & 3 deletions test/unit/rdf_generation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0116ac9

Please sign in to comment.