Skip to content

Commit

Permalink
changes required to support ncbo/ontologies_linked_data#220
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorf committed Oct 19, 2024
1 parent 84febcf commit fd54ad2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'develop'
gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'develop'
gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'develop'
gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'develop'
gem 'goo', github: 'ncbo/goo', branch: 'develop'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'develop'
gem 'goo', github: 'ncbo/goo', branch: 'multilingual_preflabels'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'multilingual_preflabels'


group :development do
Expand Down
28 changes: 14 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/ncbo/goo.git
revision: 74a012eebb9433d031eb00df5abbe488cb8b4512
branch: develop
revision: d6b84e12d61317dbddc1b86cb1451acb37915369
branch: multilingual_preflabels
specs:
goo (0.0.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -56,8 +56,8 @@ GIT

GIT
remote: https://github.com/ncbo/ontologies_linked_data.git
revision: 812dd78f02b77c9c6d579b0febf1c2a42d513022
branch: develop
revision: dec2e789e808e5edea18ca015ee487ddbe02f288
branch: multilingual_preflabels
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand Down Expand Up @@ -176,7 +176,7 @@ GEM
google-cloud-core (1.7.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.2.0)
google-cloud-env (2.2.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.4.0)
google-protobuf (3.25.5-aarch64-linux)
Expand All @@ -189,23 +189,23 @@ GEM
grpc (~> 1.41)
googleapis-common-protos-types (1.16.0)
google-protobuf (>= 3.18, < 5.a)
googleauth (1.11.0)
googleauth (1.11.1)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.1)
jwt (>= 1.4, < 3.0)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
grpc (1.66.0-aarch64-linux)
grpc (1.67.0-aarch64-linux)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.66.0-arm64-darwin)
grpc (1.67.0-arm64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.66.0-x86_64-darwin)
grpc (1.67.0-x86_64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.66.0-x86_64-linux)
grpc (1.67.0-x86_64-linux)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
haml (5.2.2)
Expand All @@ -221,7 +221,7 @@ GEM
json-schema (2.8.1)
addressable (>= 2.4)
json_pure (2.7.2)
jwt (2.9.1)
jwt (2.9.3)
base64
kgio (2.11.4)
language_server-protocol (3.17.0.3)
Expand Down Expand Up @@ -250,7 +250,7 @@ GEM
net-http (0.4.1)
uri
net-http-persistent (2.9.4)
net-imap (0.4.16)
net-imap (0.4.17)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -328,7 +328,7 @@ GEM
rsolr (2.6.0)
builder (>= 2.1.2)
faraday (>= 0.9, < 3, != 2.0.0)
rubocop (1.66.1)
rubocop (1.67.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand Down Expand Up @@ -372,7 +372,7 @@ GEM
rack-test
sinatra (~> 1.4.0)
tilt (>= 1.3, < 3)
sshkit (1.23.1)
sshkit (1.23.2)
base64
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
Expand Down
39 changes: 26 additions & 13 deletions test/controllers/test_classes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def test_notation_lookup
assert response["@id"] == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Ontology_Development_and_Management"
end


def test_all_class_pages
ont = Ontology.find("TEST-ONT-0").include(:acronym).first

Expand All @@ -99,7 +98,7 @@ def test_all_class_pages
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
page_response["collection"].each do |item|
assert_instance_of String, item["prefLabel"]
assert_instance_of String, item["prefLabel"], item["@id"]
assert_instance_of String, item["@id"]
assert_instance_of Hash, item["@context"]
assert_instance_of Hash, item["links"]
Expand Down Expand Up @@ -131,6 +130,7 @@ def test_single_cls_all
ont = Ontology.find("TEST-ONT-0").include(:acronym).first
clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Electron_Microscope" ]

clss_ids.each do |cls_id|
escaped_cls= CGI.escape(cls_id)
call = "/ontologies/#{ont.acronym}/classes/#{escaped_cls}?include=all"
Expand All @@ -149,6 +149,7 @@ def test_single_cls_properties
ont = Ontology.find("TEST-ONT-0").include(:acronym).first
clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Electron_Microscope" ]

clss_ids.each do |cls_id|
escaped_cls= CGI.escape(cls_id)
call = "/ontologies/#{ont.acronym}/classes/#{escaped_cls}?include=properties"
Expand All @@ -163,7 +164,6 @@ def test_single_cls_properties

def test_single_cls
ont = Ontology.find("TEST-ONT-0").include(:acronym).first

clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Electron_Microscope" ]

Expand Down Expand Up @@ -208,7 +208,7 @@ def test_roots_for_cls
roots = MultiJson.load(last_response.body)
assert_equal 9, roots.length
roots.each do |r|
assert_instance_of String, r["prefLabel"]
assert_instance_of String, r["prefLabel"], r["@id"]
assert_instance_of String, r["@id"]
assert r.include?"hasChildren"
#By definition roots have no parents
Expand All @@ -221,7 +221,6 @@ def test_roots_for_cls
end

def test_classes_for_not_parsed_ontology

ont = Ontology.find("TEST-ONT-0").include(:acronym).first

#first submission was not parsed
Expand All @@ -232,7 +231,6 @@ def test_classes_for_not_parsed_ontology
end

def test_tree

ont = Ontology.find("TEST-ONT-0").include(:acronym).first

clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
Expand All @@ -251,7 +249,6 @@ def test_tree
end

def test_path_to_root_for_cls

ont = Ontology.find("TEST-ONT-0").include(:acronym).first
clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Electron_Microscope" ]
Expand All @@ -264,7 +261,6 @@ def test_path_to_root_for_cls
end

def test_ancestors_for_cls

ont = Ontology.find("TEST-ONT-0").include(:acronym).first
ancestors_data = {}
ancestors_data['http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction'] =[
Expand Down Expand Up @@ -454,7 +450,6 @@ def test_calls_not_found
end

def test_children_for_cls_round_trip

clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_and_Cellular_Data',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Microscope" ]

Expand Down Expand Up @@ -511,7 +506,7 @@ def test_class_page_with_metric_count
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
page_response["collection"].each do |item|
assert_instance_of String, item["prefLabel"]
assert_instance_of String, item["prefLabel"], item["@id"]
assert_instance_of String, item["@id"]
assert_instance_of Hash, item["@context"]
assert_instance_of Hash, item["links"]
Expand All @@ -536,22 +531,40 @@ def test_default_multilingual
sub = ont.latest_submission
sub.bring_remaining

get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Biospecimen_Management')}"
# rdfs:label is NOT present and the prefLabel is NOT defined for the ontology or portal language
sub.naturalLanguage = ['es']
sub.save
get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Community_Engagement')}"
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
# does not contain a value in english show the generated one
assert_equal 'Community_Engagement', page_response["prefLabel"]

# rdfs:label is present but NOT for either the ontology or portal language
get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Biospecimen_Management')}"
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
# does not contain a value in english show the generated one
assert_equal 'Biospecimen_Management', page_response["prefLabel"]

# prefLabel NOT present, rdfs:label is present but NOT for either the ontology or portal language
get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Gene_Therapy')}"
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
# does not contain a value in english show the generated one
assert_equal 'Gene_Therapy', page_response["prefLabel"]

# prefLabel is present in the ontology language
sub.naturalLanguage = ['fr']
sub.save

get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Biospecimen_Management')}"
assert last_response.ok?
page_response = MultiJson.load(last_response.body)

# show french value as specified in submission naturalLanguage
assert_equal 'Biospecimen Management', page_response["prefLabel"]

sub.naturalLanguage = []
sub.save
end

end

0 comments on commit fd54ad2

Please sign in to comment.