1- require_relative " ./test_ontology_common"
2- require " logger"
1+ require_relative ' ./test_ontology_common'
2+ require ' logger'
33
44class TestInstances < LinkedData ::TestOntologyCommon
55
6- PROP_TYPE = " http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
7- PROP_CLINICAL_MANIFESTATION = " http://www.owl-ontologies.com/OntologyXCT.owl#isClinicalManifestationOf"
8- PROP_OBSERVABLE_TRAIT = " http://www.owl-ontologies.com/OntologyXCT.owl#isObservableTraitof"
9- PROP_HAS_OCCURRENCE = " http://www.owl-ontologies.com/OntologyXCT.owl#hasOccurrenceIn"
6+ PROP_TYPE = RDF :: URI . new ' http://www.w3.org/1999/02/22-rdf-syntax-ns#type' . freeze
7+ PROP_CLINICAL_MANIFESTATION = RDF :: URI . new ' http://www.owl-ontologies.com/OntologyXCT.owl#isClinicalManifestationOf' . freeze
8+ PROP_OBSERVABLE_TRAIT = RDF :: URI . new ' http://www.owl-ontologies.com/OntologyXCT.owl#isObservableTraitof' . freeze
9+ PROP_HAS_OCCURRENCE = RDF :: URI . new ' http://www.owl-ontologies.com/OntologyXCT.owl#hasOccurrenceIn' . freeze
1010
1111 def self . before_suite
1212 LinkedData ::TestCase . backend_4s_delete
1313 end
1414
1515 def test_instance_counts_class
16- submission_parse ( " TESTINST" , " Testing instances" ,
17- " test/data/ontology_files/XCTontologyvtemp2_vvtemp2.zip" ,
16+ submission_parse ( ' TESTINST' , ' Testing instances' ,
17+ ' test/data/ontology_files/XCTontologyvtemp2_vvtemp2.zip' ,
1818 12 ,
19- masterFileName : " XCTontologyvtemp2/XCTontologyvtemp2.owl" ,
19+ masterFileName : ' XCTontologyvtemp2/XCTontologyvtemp2.owl' ,
2020 process_rdf : true , index_search : false ,
2121 run_metrics : false , reasoning : true )
2222 submission_id = LinkedData ::Models ::OntologySubmission . all . first . id
23- class_id = RDF ::URI . new ( " http://www.owl-ontologies.com/OntologyXCT.owl#ClinicalManifestation" )
23+ class_id = RDF ::URI . new ( ' http://www.owl-ontologies.com/OntologyXCT.owl#ClinicalManifestation' )
2424
2525 instances = LinkedData ::InstanceLoader . get_instances_by_class ( submission_id , class_id )
2626 assert_equal 385 , instances . length
@@ -30,82 +30,83 @@ def test_instance_counts_class
3030 end
3131
3232 def test_instance_counts_ontology
33- submission_parse ( " TESTINST" , " Testing instances" ,
34- " test/data/ontology_files/XCTontologyvtemp2_vvtemp2.zip" ,
33+ submission_parse ( ' TESTINST' , ' Testing instances' ,
34+ ' test/data/ontology_files/XCTontologyvtemp2_vvtemp2.zip' ,
3535 12 ,
36- masterFileName : " XCTontologyvtemp2/XCTontologyvtemp2.owl" ,
36+ masterFileName : ' XCTontologyvtemp2/XCTontologyvtemp2.owl' ,
3737 process_rdf : true , index_search : false ,
3838 run_metrics : false , reasoning : true )
3939 submission_id = LinkedData ::Models ::OntologySubmission . all . first . id
40- instances = LinkedData ::InstanceLoader . get_instances_by_ontology ( submission_id , 1 , 800 )
40+ instances = LinkedData ::InstanceLoader . get_instances_by_ontology ( submission_id , page_no : 1 , size : 800 )
4141 assert_equal 714 , instances . length
4242 end
4343
4444 def test_instance_labels
45- submission_parse ( " TESTINST" , " Testing instances" ,
46- " test/data/ontology_files/XCTontologyvtemp2_vvtemp2.zip" ,
45+ submission_parse ( ' TESTINST' , ' Testing instances' ,
46+ ' test/data/ontology_files/XCTontologyvtemp2_vvtemp2.zip' ,
4747 12 ,
48- masterFileName : " XCTontologyvtemp2/XCTontologyvtemp2.owl" ,
48+ masterFileName : ' XCTontologyvtemp2/XCTontologyvtemp2.owl' ,
4949 process_rdf : true , index_search : false ,
5050 run_metrics : false , reasoning : true )
5151 submission_id = LinkedData ::Models ::OntologySubmission . all . first . id
52- class_id = RDF ::URI . new ( " http://www.owl-ontologies.com/OntologyXCT.owl#ClinicalManifestation" )
52+ class_id = RDF ::URI . new ( ' http://www.owl-ontologies.com/OntologyXCT.owl#ClinicalManifestation' )
5353
54- instances = LinkedData ::InstanceLoader . get_instances_by_class ( submission_id , class_id )
54+ instances = LinkedData ::InstanceLoader . get_instances_by_class ( submission_id , class_id )
5555 instances . each do |inst |
5656 assert ( not inst . label . nil? )
5757 assert ( not inst . id . nil? )
5858 end
5959
6060 inst1 = instances . find { |inst | inst . id . to_s == 'http://www.owl-ontologies.com/OntologyXCT.owl#PresenceofAbnormalFacialShapeAt46' }
61- assert ( not inst1 . nil? )
61+ assert ! inst1 . nil?
6262 assert_equal 'PresenceofAbnormalFacialShapeAt46' , inst1 . label
6363
6464 inst2 = instances . find { |inst | inst . id . to_s == 'http://www.owl-ontologies.com/OntologyXCT.owl#PresenceofGaitDisturbanceAt50' }
65- assert ( not inst2 . nil? )
65+ assert ! inst2 . nil?
6666 assert_equal 'PresenceofGaitDisturbanceAt50' , inst2 . label
6767 end
6868
6969 def test_instance_properties
7070 known_properties = [ PROP_TYPE , PROP_CLINICAL_MANIFESTATION , PROP_OBSERVABLE_TRAIT , PROP_HAS_OCCURRENCE ]
7171
72- submission_parse ( " TESTINST" , " Testing instances" ,
73- " test/data/ontology_files/XCTontologyvtemp2_vvtemp2.zip" ,
72+ submission_parse ( ' TESTINST' , ' Testing instances' ,
73+ ' test/data/ontology_files/XCTontologyvtemp2_vvtemp2.zip' ,
7474 12 ,
75- masterFileName : " XCTontologyvtemp2/XCTontologyvtemp2.owl" ,
75+ masterFileName : ' XCTontologyvtemp2/XCTontologyvtemp2.owl' ,
7676 process_rdf : true , index_search : false ,
7777 run_metrics : false , reasoning : true )
7878 submission_id = LinkedData ::Models ::OntologySubmission . all . first . id
79- class_id = RDF ::URI . new ( " http://www.owl-ontologies.com/OntologyXCT.owl#ClinicalManifestation" )
79+ class_id = RDF ::URI . new ( ' http://www.owl-ontologies.com/OntologyXCT.owl#ClinicalManifestation' )
8080
8181 instances = LinkedData ::InstanceLoader . get_instances_by_class ( submission_id , class_id )
82- inst = instances . find { |inst | inst . id . to_s == 'http://www.owl-ontologies.com/OntologyXCT.owl#PresenceofThyroidNoduleAt46' }
82+ inst = instances . find { |inst | inst . id . to_s == 'http://www.owl-ontologies.com/OntologyXCT.owl#PresenceofThyroidNoduleAt46' }
8383 assert ( not inst . nil? )
8484 assert_equal 4 , inst . properties . length
8585 assert_equal known_properties . sort , inst . properties . keys . sort
8686
8787 props = inst . properties
8888
8989 known_types = [
90- " http://www.owl-ontologies.com/OntologyXCT.owl#ClinicalManifestation" ,
91- " http://www.w3.org/2002/07/owl#NamedIndividual"
90+ ' http://www.owl-ontologies.com/OntologyXCT.owl#ClinicalManifestation' ,
91+ ' http://www.w3.org/2002/07/owl#NamedIndividual'
9292 ]
93+
9394 types = props [ PROP_TYPE ] . map { |type | type . to_s }
9495 assert_equal 2 , types . length
9596 assert_equal known_types . sort , types . sort
9697
9798 manifestations = props [ PROP_CLINICAL_MANIFESTATION ]
9899 assert_equal 1 , manifestations . length
99- assert_equal " http://www.owl-ontologies.com/OntologyXCT.owl#Patient_11_1" , manifestations . first . to_s
100+ assert_equal ' http://www.owl-ontologies.com/OntologyXCT.owl#Patient_11_1' , manifestations . first . to_s
100101
101102 observables = props [ PROP_OBSERVABLE_TRAIT ]
102103 assert_equal 1 , observables . length
103- assert_equal " http://www.owl-ontologies.com/OntologyXCT.owl#PresenceofThyroidNodule" , observables . first . to_s
104+ assert_equal ' http://www.owl-ontologies.com/OntologyXCT.owl#PresenceofThyroidNodule' , observables . first . to_s
104105
105106 occurrences = props [ PROP_HAS_OCCURRENCE ]
106107 assert_equal 1 , occurrences . length
107108 assert ( occurrences . first . is_a? RDF ::Literal )
108- assert_equal "46" , occurrences . first . value
109+ assert_equal '46' , occurrences . first . value
109110 end
110111
111112end
0 commit comments