Skip to content

Commit

Permalink
Merge pull request #43 from ncbo/develop
Browse files Browse the repository at this point in the history
Develop to master merge, release v5.33.4
  • Loading branch information
alexskr authored Nov 27, 2024
2 parents b6d50eb + 11838eb commit 1709cce
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 78 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ group :development do
end

# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'goo', github: 'ncbo/goo', branch: 'master'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'master'
gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'master'
gem 'goo', github: 'ncbo/goo', branch: 'develop'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'develop'
gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'develop'
12 changes: 6 additions & 6 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: 39f67ab7fae7675b6ff417ace0ab923e40ffcbcd
branch: master
revision: 35721855ba808517698d8b94eb38d4553001c4b6
branch: develop
specs:
goo (0.0.2)
addressable (~> 2.8)
Expand All @@ -16,8 +16,8 @@ GIT

GIT
remote: https://github.com/ncbo/ontologies_linked_data.git
revision: 0ce77f2781ac3353716407c22d8fc16d9bfd2c8f
branch: master
revision: 6389fa2052e06ff8e21c64fd1be0030beca4c828
branch: develop
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand All @@ -36,8 +36,8 @@ GIT

GIT
remote: https://github.com/ncbo/sparql-client.git
revision: e89c26aa96f184dbe9b52d51e04fb3d9ba998dbc
branch: master
revision: 1657f0dd69fd4b522d3549a6848670175f5e98cc
branch: develop
specs:
sparql-client (1.0.1)
json_pure (>= 1.4)
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ services:
retries: 10

mgrep-ut:
image: ontoportal/mgrep:0.0.2
image: ontoportal/mgrep:0.0.3
platform: linux/amd64
healthcheck:
test: ["CMD", "nc", "-z", "-v", "127.0.0.1", "55556"]
Expand Down
139 changes: 71 additions & 68 deletions test/test_annotator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,17 @@ def test_annotate
with_synonyms: true
})
direct = annotations
assert direct.length >= size && direct.length > 0
assert_operator 0, :<, direct.length
assert_operator size, :<, direct.length
found = 0
class_page.each do |cls|
if cls.prefLabel.length > 2
#TODO: This assertion may fail if the dictionary file on mgrep server does not contain the terms from the test ontologies
assert (direct.select { |x| x.annotatedClass.id.to_s == cls.id.to_s }).length > 0
assert_operator 0, :<, (direct.select { |x| x.annotatedClass.id.to_s == cls.id.to_s }).length, "expected to find #{cls.id}"
found += 1
end
end
assert found >= size
assert_operator size, :<=, found
end

# test for a specific class annotation
Expand All @@ -279,12 +280,12 @@ def test_annotate
with_synonyms: true
})

assert annotations.length == 1
assert annotations.first.annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Data_Storage"
assert annotations.first.annotations.length == 1
assert annotations.first.annotations.first[:from] == 1
assert annotations.first.annotations.first[:to] == term_text.length
assert text[annotations.first.annotations.first[:from] - 1, annotations.first.annotations.first[:to]] == term_text
assert_equal 1, annotations.length
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Data_Storage", annotations.first.annotatedClass.id.to_s
assert_equal 1, annotations.first.annotations.length
assert_equal 1, annotations.first.annotations.first[:from]
assert_equal term_text.length, annotations.first.annotations.first[:to]
assert_equal term_text, text[annotations.first.annotations.first[:from] - 1, annotations.first.annotations.first[:to]]

# check for a non-existent ontology
non_existent_ont = ["DOESNOTEXIST"]
Expand Down Expand Up @@ -370,14 +371,15 @@ def test_annotate_minsize_term
})
direct = annotations

assert direct.length >= size && direct.length > 0
assert_operator 0, :<, direct.length
assert_operator size, :<, direct.length
found = 0
filter_out_next = []
must_be_next = []
class_page.each do |cls|
if cls.prefLabel.length > 2
#TODO: This assertion may fail if the dictionary file on mgrep server does not contain the terms from the test ontologies
assert (direct.select { |x| x.annotatedClass.id.to_s == cls.id.to_s }).length > 0
assert_operator 0, :<, (direct.select { |x| x.annotatedClass.id.to_s == cls.id.to_s }).length
found += 1
if cls.prefLabel.length < 10
filter_out_next << cls
Expand All @@ -403,12 +405,13 @@ def test_annotate_minsize_term

direct = annotations
filter_out_next.each do |cls|
assert (direct.select { |x| x.annotatedClass.id.to_s == cls.id.to_s }).length == 0
assert_equal 0, (direct.select { |x| x.annotatedClass.id.to_s == cls.id.to_s }).length
end
must_be_next.each do |cls|
assert (direct.select { |x| x.annotatedClass.id.to_s == cls.id.to_s }).length > 0
assert_operator 0, :<, (direct.select { |x| x.annotatedClass.id.to_s == cls.id.to_s }).length
end
assert must_be_next.length > 0 && filter_out_next.length > 0
assert_operator 0, :<, must_be_next.length
assert_operator 0, :<, filter_out_next.length
end

def test_annotate_stop_words
Expand All @@ -430,7 +433,7 @@ def test_annotate_stop_words
"http://purl.obolibrary.org/obo/MCBCC_0000296#Deletion"]

not_show.each do |cls|
assert (annotations.select { |x| x.annotatedClass.id.to_s == cls }).length > 0
assert_operator 0, :<, (annotations.select { |x| x.annotatedClass.id.to_s == cls }).length
end

#annotation should not show up
Expand All @@ -449,7 +452,7 @@ def test_annotate_stop_words
})

not_show.each do |cls|
assert (annotations.select { |x| x.annotatedClass.id.to_s == cls }).length == 0
assert_equal 0, (annotations.select { |x| x.annotatedClass.id.to_s == cls }).length
end

#empty array must annotate all
Expand All @@ -468,7 +471,7 @@ def test_annotate_stop_words
})

not_show.each do |cls|
assert (annotations.select { |x| x.annotatedClass.id.to_s == cls }).length > 0
assert_operator 0, :<, (annotations.select { |x| x.annotatedClass.id.to_s == cls }).length
end
end

Expand All @@ -477,16 +480,16 @@ def test_annotate_hierarchy
text = "Aggregate Human Data Aggregate Human Data"
annotator = Annotator::Models::NcboAnnotator.new
annotations = annotator.annotate(text)
assert annotations.length == 1
assert annotations.first.annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Aggregate_Human_Data"
assert annotations.first.annotatedClass.submission.ontology.acronym == "BROTEST-0"
assert annotations.first.annotations.length == 2
assert annotations.first.annotations.first[:from] = 1
assert annotations.first.annotations.first[:to] = 1+("Aggregate Human Data".length)
assert annotations.first.annotations[1][:from] = 2 + ("Aggregate Human Data".length)
assert text[annotations.first.annotations.first[:from]-1,annotations.first.annotations.first[:to]-1] == "Aggregate Human Data"
assert annotations.first.annotations[1][:to] == (1 + ("Aggregate Human Data".length)) + ("Aggregate Human Data".length)
assert text[annotations.first.annotations[1][:from]-1,annotations.first.annotations[1][:to]-1] == "Aggregate Human Data"
assert_equal 1, annotations.length
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Aggregate_Human_Data", annotations.first.annotatedClass.id.to_s
assert_equal "BROTEST-0", annotations.first.annotatedClass.submission.ontology.acronym
assert_equal 2, annotations.first.annotations.length
assert_equal 1, annotations.first.annotations.first[:from]
assert_equal "Aggregate Human Data".length, annotations.first.annotations.first[:to]
assert_equal 2 + ("Aggregate Human Data".length), annotations.first.annotations[1][:from]
assert_equal "Aggregate Human Data", text[annotations.first.annotations.first[:from]-1,annotations.first.annotations.first[:to]]
assert_equal (1 + ("Aggregate Human Data".length)) + ("Aggregate Human Data".length), annotations.first.annotations[1][:to]
assert_equal "Aggregate Human Data", text[annotations.first.annotations[1][:from]-1,annotations.first.annotations[1][:to]-1]
annotations = annotator.annotate(text, {
ontologies: [],
semantic_types: [],
Expand All @@ -499,16 +502,16 @@ def test_annotate_hierarchy
with_synonyms: true
})

assert annotations.length == 1
assert annotations.first.annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Aggregate_Human_Data"
assert annotations.first.annotatedClass.submission.ontology.acronym == "BROTEST-0"
assert annotations.first.annotations.length == 2
assert annotations.first.annotations.first[:from] = 1
assert annotations.first.annotations.first[:to] = 1+("Aggregate Human Data".length)
assert_equal 1, annotations.length
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Aggregate_Human_Data", annotations.first.annotatedClass.id.to_s
assert_equal "BROTEST-0", annotations.first.annotatedClass.submission.ontology.acronym
assert_equal 2, annotations.first.annotations.length
assert_equal 1, annotations.first.annotations.first[:from]
assert_equal "Aggregate Human Data".length, annotations.first.annotations.first[:to]

assert annotations.first.hierarchy.length == 1
assert annotations.first.hierarchy.first.annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Clinical_Care_Data"
assert annotations.first.hierarchy.first.distance == 1
assert_equal 1, annotations.first.hierarchy.length
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Clinical_Care_Data", annotations.first.hierarchy.first.annotatedClass.id.to_s
assert_equal 1, annotations.first.hierarchy.first.distance
annotations = annotator.annotate(text, {
ontologies: [],
semantic_types: [],
Expand All @@ -521,13 +524,13 @@ def test_annotate_hierarchy
with_synonyms: true
})

assert annotations.first.hierarchy.length == 3
assert annotations.first.hierarchy.first.annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Clinical_Care_Data"
assert annotations.first.hierarchy.first.distance == 1
assert annotations.first.hierarchy[1].annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Data_Resource"
assert annotations.first.hierarchy[1].distance == 2
assert annotations.first.hierarchy[2].annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Information_Resource"
assert annotations.first.hierarchy[2].distance == 3
assert_equal 3, annotations.first.hierarchy.length
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Clinical_Care_Data", annotations.first.hierarchy.first.annotatedClass.id.to_s
assert_equal 1, annotations.first.hierarchy.first.distance
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Data_Resource", annotations.first.hierarchy[1].annotatedClass.id.to_s
assert_equal 2, annotations.first.hierarchy[1].distance
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Information_Resource", annotations.first.hierarchy[2].annotatedClass.id.to_s
assert_equal 3, annotations.first.hierarchy[2].distance
end

def test_annotate_hierachy_terms_multiple
Expand All @@ -546,56 +549,56 @@ def test_annotate_hierachy_terms_multiple
with_synonyms: true
})

assert annotations[0].annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Aggregate_Human_Data"
assert annotations[0].annotations.length == 3
assert annotations[0].hierarchy.length == 4
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Aggregate_Human_Data", annotations[0].annotatedClass.id.to_s
assert_equal 3, annotations[0].annotations.length
assert_equal 4, annotations[0].hierarchy.length
hhh = annotations[0].hierarchy.sort {|x| x.distance }.map { |x| x.annotatedClass.id.to_s }
hhh.sort!

assert hhh == [
assert_equal [
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Resource",
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Information_Resource",
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Clinical_Care_Data",
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Data_Resource"
].sort
].sort, hhh

assert annotations[1].annotatedClass.id.to_s == "http://purl.obolibrary.org/obo/MCBCC_0000288#ChromosomalMutation"
assert annotations[1].annotations.length == 2
assert_equal "http://purl.obolibrary.org/obo/MCBCC_0000288#ChromosomalMutation", annotations[1].annotatedClass.id.to_s
assert_equal 2, annotations[1].annotations.length
hhh = annotations[1].hierarchy.sort {|x| x.distance }.map { |x| x.annotatedClass.id.to_s }
hhh == ["http://purl.obolibrary.org/obo/MCBCC_0000287#GeneticVariation"]
assert_equal ["http://purl.obolibrary.org/obo/MCBCC_0000287#GeneticVariation"], hhh

assert annotations[2].annotatedClass.id.to_s == "http://purl.obolibrary.org/obo/MCBCC_0000289#ChromosomalDeletion"
assert annotations[2].annotations.length == 1
assert_equal "http://purl.obolibrary.org/obo/MCBCC_0000289#ChromosomalDeletion", annotations[2].annotatedClass.id.to_s
assert_equal 1, annotations[2].annotations.length
hhh = annotations[2].hierarchy.sort {|x| x.distance }.map { |x| x.annotatedClass.id.to_s }
assert hhh == ["http://purl.obolibrary.org/obo/MCBCC_0000287#GeneticVariation",
"http://purl.obolibrary.org/obo/MCBCC_0000288#ChromosomalMutation"]

assert annotations[3].annotatedClass.id.to_s == "http://purl.obolibrary.org/obo/MCBCC_0000296#Deletion"
assert_equal "http://purl.obolibrary.org/obo/MCBCC_0000296#Deletion", annotations[3].annotatedClass.id.to_s
hhh = annotations[3].hierarchy.sort {|x| x.distance }.map { |x| x.annotatedClass.id.to_s }
assert hhh = ["http://purl.obolibrary.org/obo/MCBCC_0000287#GeneticVariation",
"http://purl.obolibrary.org/obo/MCBCC_0000295#GeneMutation"]
assert_equal ["http://purl.obolibrary.org/obo/MCBCC_0000287#GeneticVariation",
"http://purl.obolibrary.org/obo/MCBCC_0000295#GeneMutation"], hhh

assert annotations[4].annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Data_Resource"
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Data_Resource", annotations[4].annotatedClass.id.to_s
hhh = annotations[4].hierarchy.sort {|x| x.distance }.map { |x| x.annotatedClass.id.to_s }
assert hhh == ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Resource",
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Information_Resource"]
assert_equal ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Resource",
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Information_Resource"], hhh

assert annotations[5].annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Resource"
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Resource", annotations[5].annotatedClass.id.to_s
hhh = annotations[5].hierarchy.sort {|x| x.distance }.map { |x| x.annotatedClass.id.to_s }
assert hhh == [] #root
assert_empty hhh

assert annotations[6].annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Federal_Funding_Resource"
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Federal_Funding_Resource", annotations[6].annotatedClass.id.to_s
hhh = annotations[6].hierarchy.sort {|x| x.distance }.map { |x| x.annotatedClass.id.to_s }
assert hhh == ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Resource",
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Funding_Resource"]
assert_equal ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Resource",
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Funding_Resource"], hhh

assert annotations[7].annotatedClass.id.to_s == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Funding_Resource"
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Funding_Resource", annotations[7].annotatedClass.id.to_s
hhh = annotations[7].hierarchy.sort {|x| x.distance }.map { |x| x.annotatedClass.id.to_s }
assert hhh == ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Resource" ]
assert_equal ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Resource" ], hhh

assert annotations[8].annotatedClass.id.to_s == "http://purl.obolibrary.org/obo/MCBCC_0000275#ReceptorAntagonists"
assert_equal "http://purl.obolibrary.org/obo/MCBCC_0000275#ReceptorAntagonists", annotations[8].annotatedClass.id.to_s
hhh = annotations[8].hierarchy.sort {|x| x.distance }.map { |x| x.annotatedClass.id.to_s }
assert hhh == ["http://purl.obolibrary.org/obo/MCBCC_0000256#ChemicalsAndDrugs"]
assert_equal ["http://purl.obolibrary.org/obo/MCBCC_0000256#ChemicalsAndDrugs"], hhh

end

Expand Down

0 comments on commit 1709cce

Please sign in to comment.