Class: YARRRML_Template_Builder
- Inherits:
-
Object
- Object
- YARRRML_Template_Builder
- Defined in:
- lib/yarrrml_template_builder/yarrrml_template_builder.rb
Constant Summary collapse
- SIO =
{ "entity" => ["http://semanticscience.org/resource/SIO_000000", "http://semanticscience.org/resource/entity"], "day" => ["http://semanticscience.org/resource/SIO_000430", "http://semanticscience.org/resource/day"], "has-attribute" => ["http://semanticscience.org/resource/SIO_000008", "http://semanticscience.org/resource/has-attribute"], "has-measurement-value" => ["http://semanticscience.org/resource/SIO_000216", "http://semanticscience.org/resource/has-measurement-value"], "has-quality" => ["http://semanticscience.org/resource/SIO_000217", "http://semanticscience.org/resource/has-quality"], "has-unit" => ["http://semanticscience.org/resource/SIO_000221", "http://semanticscience.org/resource/has-unit"], "has-value" => ["http://semanticscience.org/resource/SIO_000300", "http://semanticscience.org/resource/has-value"], "has-part" => ["http://semanticscience.org/resource/SIO_000028", "http://semanticscience.org/resource/has-part"], "has-role" => ["http://semanticscience.org/resource/SIO_000228", "http://semanticscience.org/resource/has-role"], "has-agent" => ["http://semanticscience.org/resource/SIO_000139", "http://semanticscience.org/resource/has-agent"], "has-target" => ["http://semanticscience.org/resource/SIO_000291", "http://semanticscience.org/resource/has-target"], "is-participant-in" => ["http://semanticscience.org/resource/SIO_000062", "http://semanticscience.org/resource/is-participant-in"], "is-about" => ["http://semanticscience.org/resource/SIO_000332", "http://semanticscience.org/resource/is-about"], "has-output" => ["http://semanticscience.org/resource/SIO_000229", "http://semanticscience.org/resource/has-output"], "denotes" => ["http://semanticscience.org/resource/SIO_000020", "http://semanticscience.org/resource/denotes"], "is-realized-in" => ["http://semanticscience.org/resource/SIO_000356", "http://semanticscience.org/resource/is-realized-in"], "is-causally-related-to" => ["http://semanticscience.org/resource/SIO_000294", "http://semanticscience.org/resource/is-causally-related-to"], "is-causally-related-from" => ["http://semanticscience.org/resource/SIO_000352", "http://semanticscience.org/resource/is-causally-related-from"], "is-specified-by" => ["http://semanticscience.org/resource/SIO_000339", "http://semanticscience.org/resource/is-specified-by"], "has-component-part" => ["http://semanticscience.org/resource/SIO_000369", "http://semanticscience.org/resource/has-component-part"], # predicates # for processs "has-start-time" => ["http://semanticscience.org/resource/SIO_000680", "http://semanticscience.org/resource/has-start-time"], "exists-at" => ["http://semanticscience.org/resource/SIO_000687", "http://semanticscience.org/resource/exists-at"], "has-end-time" => ["http://semanticscience.org/resource/SIO_000681", "http://semanticscience.org/resource/has-end-time"], "has-time-boundary" => ["http://semanticscience.org/resource/SIO_000679", "http://semanticscience.org/resource/has-time-boundary"], # for information artifact "measured-at" => ["http://semanticscience.org/resource/SIO_000793", "http://semanticscience.org/resource/measured-at"], # objects "start-time" => ["http://semanticscience.org/resource/SIO_000669", "http://semanticscience.org/resource/start-time"], "end-time" => ["http://semanticscience.org/resource/SIO_000670", "http://semanticscience.org/resource/end-time"], "start-date" => ["http://semanticscience.org/resource/SIO_000031", "http://semanticscience.org/resource/start-date"], "end-date" => ["http://semanticscience.org/resource/SIO_000032", "http://semanticscience.org/resource/end-date"], "time-instant" => ["http://semanticscience.org/resource/SIO_000418", "http://semanticscience.org/resource/time-instant"], # "is-component-part-of" => ["http://semanticscience.org/resource/SIO_000313", "http://semanticscience.org/resource/is-component-part-of"], "drug" => ["http://semanticscience.org/resource/SIO_010038", "http://semanticscience.org/resource/drug"], "specialized-object" => ["http://semanticscience.org/resource/SIO_001353", "http://semanticscience.org/resource/specialized-object"], "object" => ["http://semanticscience.org/resource/SIO_000776", "http://semanticscience.org/resource/object"], "is-base-for" => ["http://semanticscience.org/resource/SIO_000642", "http://semanticscience.org/resource/is-base-for"], "has-concretization" => ["http://semanticscience.org/resource/SIO_000213", "http://semanticscience.org/resource/has-concretization"], "realizable-entity" => ["http://semanticscience.org/resource/SIO_000340", "http://semanticscience.org/resource/realizable-entity"], "information-content-entity" => ["http://semanticscience.org/resource/SIO_000015", "http://semanticscience.org/resource/information-content-entity"], "measurement-value" => ["http://semanticscience.org/resource/SIO_000070", "http://semanticscience.org/resource/measurement-value"], "refers-to" => ["http://semanticscience.org/resource/SIO_000628", "http://semanticscience.org/resource/refers-to"], "has-input" => ["http://semanticscience.org/resource/SIO_000230", "http://semanticscience.org/resource/has-input"], "person" => ["http://semanticscience.org/resource/SIO_000498", "http://semanticscience.org/resource/person"], "identifier" => ["http://semanticscience.org/resource/SIO_000115", "http://semanticscience.org/resource/identifier"], "role" => ["http://semanticscience.org/resource/SIO_000016", "http://semanticscience.org/resource/role"], "process" => ["http://semanticscience.org/resource/SIO_000006", "http://semanticscience.org/resource/process"], "attribute" => ["http://semanticscience.org/resource/SIO_000614", "http://semanticscience.org/resource/attribute"], "conforms-to" => ["https://semanticscience.org/resource/CHEMINF_000047", "http://semanticscience.org/resource/conforms-to"], }
Instance Attribute Summary collapse
-
#baseURI ⇒ Object
Returns the value of attribute baseURI.
-
#mappings ⇒ Object
Returns the value of attribute mappings.
-
#prefix_map ⇒ Object
Returns the value of attribute prefix_map.
-
#sio_verbose ⇒ Object
Returns the value of attribute sio_verbose.
-
#source_tag ⇒ Object
Returns the value of attribute source_tag.
-
#sources_module ⇒ Object
Returns the value of attribute sources_module.
Instance Method Summary collapse
-
#add_prefixes(params = {}) ⇒ Hash
adds new Prefixes to the prefix map.
-
#build_attribute(params) ⇒ Object
creates the build attribute clauses.
-
#entity_has_component(params) ⇒ Object
creates the entity has component entity portion of the CDE.
-
#entity_identifier_role_mappings(params = {}) ⇒ Object
creates an entity/identifier/role set of clauses.
-
#generate ⇒ YAML
Generate the YARRRML Template.
- #get_root_url(uniq) ⇒ Object
-
#get_uniq_id ⇒ Object
creates a time-based locally-unique identifier.
-
#initialize(params = {}) ⇒ YARRRML_Template_BuilderII
constructor
all params are passed as a hash, and retrieved by params.fetch(paramName).
-
#input_output_refers_to(params) ⇒ Object
creates the input output refers to portion of the CDE.
-
#mapping_clause(name, source, s, pots) ⇒ String
creates a single clause of the YARRRML (one subject, [p, o; p,o;.…] mapping).
-
#output_has_unit(params) ⇒ Object
creates the output_has_unit portion of the CDE.
-
#person_identifier_role_mappings(params = {}) ⇒ Object
creates the person/identifier/role portion of the CDE.
-
#process_caused_by(params) ⇒ Object
creates the process caused by.
-
#process_has_agent(params) ⇒ Object
Parameters passed as a hash.
-
#process_has_annotations(params) ⇒ Object
creates the process has annotations portion of the CDE.
-
#process_has_attribute(params) ⇒ Object
creates the process has_attribute.
-
#process_has_input(params) ⇒ Object
NEED AN INPUT REFERS TO HERE>>>>>>.
-
#process_has_part(params) ⇒ Object
creates the process_has_part portion of the CDE.
-
#process_has_target(params) ⇒ Object
creates the process has target portion of the CDE.
-
#process_hasoutput_output(params) ⇒ Object
creates the process_hasoutput_output portion of the CDE.
-
#process_is_specified_by(params) ⇒ Object
creates the process is specified by portion of the CDE.
-
#role_in_process(params) ⇒ Object
creates the role_in_process portion of the CDE.
Constructor Details
#initialize(params = {}) ⇒ YARRRML_Template_BuilderII
all params are passed as a hash, and retrieved by params.fetch(paramName)
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 85 def initialize(params = {}) # get a name from the "new" call, or set a default @baseURI = params.fetch(:baseURI, "|||BASE|||") @sio_verbose = params.fetch(:sio_verbose, 0) abort "must have a baseURI parameter" unless self.baseURI @mappings = [] @source_tag = params.fetch(:source_tag, nil) abort "must have a source_name parameter" unless self.source_tag @prefix_map = { "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs" => "http://www.w3.org/2000/01/rdf-schema#", "ex" => "https://ejp-rd.eu/ids/", "obo" => "http://purl.obolibrary.org/obo/", "sio" => "http://semanticscience.org/resource/", "vocab" => "https://ejp-rd.eu/vocab/", "pico" => "https://data.cochrane.org/ontologies/pico/", "ndfrt" => "http://purl.bioontology.org/ontology/NDFRT/", "edam" => "http://purl.bioontology.org/ontology/EDAM/", "ordo" => "http://www.orpha.net/ORDO/", } self.add_prefixes(prefixesHash: {"this" => self.baseURI}) sources_module() end |
Instance Attribute Details
#baseURI ⇒ Object
Returns the value of attribute baseURI.
10 11 12 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 10 def baseURI @baseURI end |
#mappings ⇒ Object
Returns the value of attribute mappings.
14 15 16 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 14 def mappings @mappings end |
#prefix_map ⇒ Object
Returns the value of attribute prefix_map.
9 10 11 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 9 def prefix_map @prefix_map end |
#sio_verbose ⇒ Object
Returns the value of attribute sio_verbose.
11 12 13 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 11 def sio_verbose @sio_verbose end |
#source_tag ⇒ Object
Returns the value of attribute source_tag.
12 13 14 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 12 def source_tag @source_tag end |
#sources_module ⇒ Object
Returns the value of attribute sources_module.
13 14 15 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 13 def sources_module @sources_module end |
Instance Method Details
#add_prefixes(params = {}) ⇒ Hash
adds new Prefixes to the prefix map
Parameters passed as the value to the key :prefixesHash
131 132 133 134 135 136 137 138 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 131 def add_prefixes(params = {}) prefixesHash = params.fetch(:prefixesHash, {}) $stderr.puts prefixesHash @prefix_map.merge!(prefixesHash) return self.prefix_map end |
#build_attribute(params) ⇒ Object
creates the build attribute clauses
Parameters passed as a hash.
TODO: Allow any existing node to be a cause…
912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 912 def build_attribute(params) attribute_tag = params.fetch(:attribute_tag, nil) # some one-word name attribute_type = params.fetch(:attribute_type, nil) attribute_label = params.fetch(:attribute_label, nil) attribute_label_column = params.fetch(:attribute_label_column, nil) attribute_type_column = params.fetch(:attribute_type_column, nil) attribute_value_column = params.fetch(:attribute_value_column, nil) attribute_value_unit_column = params.fetch(:attribute_value_unit_column, nil) attribute_value_unit_label_column = params.fetch(:attribute_value_unit_label_column, nil) make_unique_process = params.fetch(:make_unique_process, true) root_url = get_root_url(make_unique_process) attribute_type = attribute_type_column ? "$(#{attribute_type_column})":attribute_type attribute_label = attribute_label_column ? "$(#{attribute_label_column})":attribute_label attribute_value_unit_column = "$(#{attribute_value_unit_column})" if attribute_value_unit_column attribute_value_unit_label_column = "$(#{attribute_value_unit_label_column})" if attribute_value_unit_label_column abort "must specify the attribute_tag" unless attribute_tag abort "must specify the attribute_type" unless (attribute_type or attribute_type_column) abort "must specify both a unit column and a unit label column" if (attribute_value_unit_column and !(attribute_value_unit_label_column)) @mappings << mapping_clause( "attribute_#{attribute_tag}_annotation", ["#{source_tag}-source"], root_url + "#attribute_#{attribute_tag}", [ ["rdf:type",SIO["attribute"][self.sio_verbose], "iri"], ["rdf:type",attribute_type, "iri"], ] ) if attribute_value_column @mappings << mapping_clause( "attribute_#{attribute_tag}_measurement", ["#{source_tag}-source"], root_url + "#attribute_#{attribute_tag}", [[SIO["has-measurement-value"][self.sio_verbose], root_url + "#measurement_of_attribute_#{attribute_tag}", "iri"]] ) @mappings << mapping_clause( "attribute_#{attribute_tag}_measurement_value", ["#{source_tag}-source"], root_url + "#measurement_of_attribute_#{attribute_tag}", [[SIO["has-measurement-value"][self.sio_verbose], root_url + "#measurementvalue_of_attribute_#{attribute_tag}", "iri"]] ) @mappings << mapping_clause( "attribute_#{attribute_tag}_measurement_value_value", ["#{source_tag}-source"], root_url + "#measurementvalue_of_attribute_#{attribute_tag}", [ [SIO["has-value"][self.sio_verbose], "$(#{attribute_value_column})", "xsd:string"], ["rdf:type", SIO["information-content-entity"][self.sio_verbose], "iri"], ] ) end if attribute_label @mappings << mapping_clause( "attribute_#{attribute_tag}_measurement_value_label", ["#{source_tag}-source"], root_url + "#measurementvalue_of_attribute_#{attribute_tag}", [["rdfs:label", attribute_label]] ) end if attribute_value_unit_column @mappings << mapping_clause( "attribute_#{attribute_tag}_measurement_value_unit_node", ["#{source_tag}-source"], root_url + "#measurementvalue_of_attribute_#{attribute_tag}", [ [SIO["has-unit"][self.sio_verbose], root_url + "#measurementvalue_unit_of_attribute_#{attribute_tag}", "iri"], ] ) @mappings << mapping_clause( "attribute_#{attribute_tag}_measurement_value_unit_node_type", ["#{source_tag}-source"], root_url + "#measurementvalue_unit_of_attribute_#{attribute_tag}", [ ["rdf:type", "#{attribute_value_unit_column}", "iri"], ["rdfs:label", "#{attribute_value_unit_label_column}"], ] ) end end |
#entity_has_component(params) ⇒ Object
creates the entity has component entity portion of the CDE
Parameters passed as a hash
TODO make it possible to explicitly compose entities from other modelled entities (part entity id column)
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 1445 def entity_has_component(params) parent_entityid_column = params.fetch(:parent_entityid_column, 'pid') parent_entity_tag = params.fetch(:part_entity_tag, "thisPerson") part_entity_tag = params.fetch(:part_entity_tag, nil) part_type = params.fetch(:part_type, nil) part_type_column = params.fetch(:part_type_column, nil) part_type = part_type_column ? "$(#{part_type_column})":part_type abort "cannot create entity has component without both a part type and part tag" unless (part_type && part_entity_tag) #uniqid = get_uniq_id @mappings << mapping_clause( "parent_entity_has_part_#{part_entity_tag}", ["#{source_tag}-source"], "this:individual_#{parent_entity_tag}_$(#{parent_entityid_column})#Entity", [[SIO["has-component-part"][self.sio_verbose], "this:individual_#{part_entity_tag}#componentEntity" , "iri"]] ) @mappings << mapping_clause( "parent_entity_has_part_#{part_entity_tag}", ["#{source_tag}-source"], "this:individual_#{part_entity_tag}#componentEntity", [['rdf:type', part_type , "iri"]] ) end |
#entity_identifier_role_mappings(params = {}) ⇒ Object
creates an entity/identifier/role set of clauses
Parameters passed as a hash
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 250 def entity_identifier_role_mappings(params = {}) @entityid_column = params.fetch(:entityid_column, 'pid') @uniqueid_column = params.fetch(:uniqueid_column, 'uniqid') identifier_type = params.fetch(:identifier_type, SIO["identifier"][self.sio_verbose]) identifier_type_column = params.fetch(:identifier_type_column, nil) entity_tag = params.fetch(:entity_tag, 'thisEntity') entity_type = params.fetch(:entity_type, SIO["specialized-object"][self.sio_verbose]) entity_type_column = params.fetch(:entity_type_column, nil) entity_label = params.fetch(:entity_label, nil) entity_label_column = params.fetch(:entity_label_column, nil) entity_role_tag = params.fetch(:entity_role_tag, 'thisRole') role_type = params.fetch(:role_type, 'obo:OBI_0000093') # patient role_type_column = params.fetch(:role_type_column, nil) # role_label = params.fetch(:role_label, 'Some Role') # patient role_label_column = params.fetch(:role_label_column, nil) # identifier_type = identifier_type_column ? "$(#{identifier_type_column})":identifier_type entity_type = entity_type_column ? "$(#{entity_type_column})":entity_type role_type = role_type_column ? "$(#{role_type_column})":role_type role_label = role_label_column ? "$(#{role_label_column})":role_label entity_label = entity_label_column ? "$(#{entity_label_column})":entity_label abort "You MUST have a @entityid_column and a @uniqueid_column to use this library. Sorry!" unless @entityid_column and @uniqueid_column @mappings << mapping_clause( "identifier_has_value_for_#{entity_tag}_#{entity_role_tag}", ["#{source_tag}-source"], "this:individual_#{entity_tag}_$(#{@entityid_column})#ID", [[SIO["has-value"][self.sio_verbose], "$(#{@entityid_column})", "xsd:string"]] ) @mappings << mapping_clause( "identifier_denotes_role_#{entity_role_tag}", ["#{source_tag}-source"], "this:individual_#{entity_tag}_$(#{@entityid_column})#ID", [ ["a", "#{identifier_type}", "iri"], ["a", SIO["identifier"][self.sio_verbose], "iri"], [SIO["denotes"][self.sio_verbose], "this:individual_#{entity_tag}_$(#{@entityid_column})_$(#{@uniqueid_column})##{entity_role_tag}", "iri"], ] ) @mappings << mapping_clause( "entity_has_role_#{entity_role_tag}", ["#{source_tag}-source"], "this:individual_#{entity_tag}_$(#{@entityid_column})#Entity", [ ["a", "#{entity_type}", "iri"], ["a", SIO["object"][self.sio_verbose], "iri"], [SIO["has-role"][self.sio_verbose], "this:individual_#{entity_tag}_$(#{@entityid_column})_$(#{@uniqueid_column})##{entity_role_tag}", "iri"], ] ) @mappings << mapping_clause( "#{entity_role_tag}_annotation", ["#{source_tag}-source"], "this:individual_#{entity_tag}_$(#{@entityid_column})_$(#{@uniqueid_column})##{entity_role_tag}", [ ["a", "#{role_type}", "iri"], ["a", SIO["role"][self.sio_verbose], "iri"], ["rdfs:label", " Role: #{role_label}", "xsd:string"], ] ) if entity_label @mappings << mapping_clause( "#{entity_role_tag}_entity_label_annotation", ["#{source_tag}-source"], "this:individual_#{entity_tag}_$(#{@entityid_column})#Entity", [ ["rdfs:label", " Role: #{entity_label}", "xsd:string"], ] ) end end |
#generate ⇒ YAML
Generate the YARRRML Template
No input parameters
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 147 def generate output = Hash.new output["prefixes"] = @prefix_map output["sources"] = @sources_module clauses = Hash.new self.mappings.each {|m| clauses.merge!(m)}#; $stderr.puts m; $stderr.puts "CLAUSES: #{clauses}\n\n"} output["mappings"] = clauses #$stderr.puts output.inspect return YAML::dump(output) end |
#get_root_url(uniq) ⇒ Object
222 223 224 225 226 227 228 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 222 def get_root_url(uniq) if uniq "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})_process" else "this:individual_$(#{@personid_column})_process" end end |
#get_uniq_id ⇒ Object
creates a time-based locally-unique identifier
1478 1479 1480 1481 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 1478 def get_uniq_id return Time.now.to_f.to_s.gsub("\.", "") end |
#input_output_refers_to(params) ⇒ Object
creates the input output refers to portion of the CDE
Parameters passed as a hash
1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 1302 def input_output_refers_to(params) entityid_column = params.fetch(:entityid_column, 'pid') inout_process_tag = params.fetch(:inout_process_tag, 'unidentifiedProcess') refers_to_tag = params.fetch(:refers_to_tag, nil) inout_refers_to = params.fetch(:inout_refers_to, nil) inout_refers_to_label = params.fetch(:inout_refers_to_label, nil) inout_refers_to_column = params.fetch(:inout_refers_to_column, nil) inout_refers_to_label_column = params.fetch(:inout_refers_to_label_column, nil ) inout_refers_to_uri_column = params.fetch(:inout_refers_to_uri_column, nil ) is_attribute = params.fetch(:is_attribute, true ) entity_tag = params.fetch(:entity_tag, "thisPerson" ) base_types = params.fetch(:base_types, [] ) refers_to = inout_refers_to_column ? "$(#{inout_refers_to_column})":inout_refers_to refers_to_label = inout_refers_to_label_column ? "$(#{inout_refers_to_label_column})":inout_refers_to_label abort "must specify in_out_process_tag" unless inout_process_tag abort "must specify refers_to_tag" unless refers_to_tag abort "must have an entity tag" unless entity_tag #$stderr.puts "is an attribute #{is_attribute}" attribute_node_uri = inout_refers_to_uri_column ? "$(#{inout_refers_to_uri_column})":"this:individual_#{entity_tag}_$(#{entityid_column})_$(#{@uniqueid_column})##{refers_to_tag}_TypedAttributeNode" types = [] types << ["rdf:type", SIO["attribute"][self.sio_verbose], "iri"] if is_attribute # add base type if its an attribute types << ["rdf:type", refers_to, "iri"] base_types.each do |b| types << ["rdf:type", b, "iri"] end @mappings << mapping_clause( "inout_from_process_#{inout_process_tag}_refers_to_concepts", ["#{source_tag}-source"], "this:individual_#{entity_tag}_$(#{entityid_column})_$(#{@uniqueid_column})#process_#{inout_process_tag}_Output", [ [SIO["refers-to"][self.sio_verbose], attribute_node_uri, "iri"] ] ) if is_attribute @mappings << mapping_clause( "has_attribute_of_inout_from_process_#{inout_process_tag}", ["#{source_tag}-source"], "this:individual_#{entity_tag}_$(#{entityid_column})#Entity", [ [SIO["has-attribute"][self.sio_verbose], attribute_node_uri, "iri"] ] ) end @mappings << mapping_clause( "inout_from_process_#{inout_process_tag}_refers_to_concept_#{refers_to_tag}_type", ["#{source_tag}-source"], attribute_node_uri, types ) if refers_to_label @mappings << mapping_clause( "inout_from_process_#{inout_process_tag}_refers_to_concept_#{refers_to_tag}_label", ["#{source_tag}-source"], attribute_node_uri, [ ["rdfs:label", "Attribute Type: #{refers_to_label}" ] ] ) end end |
#mapping_clause(name, source, s, pots) ⇒ String
creates a single clause of the YARRRML (one subject, [p, o; p,o;.…] mapping)
DO NOT use this externally! I will eventually make it private...
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 193 def mapping_clause(name, source, s, pots) pos = [] pots.each do |pot| #$stderr.puts pot.class (pred, obj, type) = pot #$stderr.puts "#{pred} #{obj} #{type}" typetag = "type" typetag = "datatype" unless type == 'iri' type = "xsd:string" unless type pos << { "predicates" => pred, "objects" => { "value" => obj, typetag => type} } end mappingclause = { name => { "sources" => source, "s" => s, "po" => pos } } return mappingclause end |
#output_has_unit(params) ⇒ Object
creates the output_has_unit portion of the CDE
Parameters passed as a hash
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 1391 def output_has_unit(params) process_tag = params.fetch(:inout_process_tag, 'unidentifiedProcess') output_unit = params.fetch(:output_unit, nil) # URI output_unit_column = params.fetch(:output_unit_column, nil) # URI output_unit_label = params.fetch(:output_unit_label, nil) output_unit_label_column = params.fetch(:output_unit_label_column, nil) output_unit = output_unit_column ? "$(#{output_unit_column})":output_unit output_unit_label = output_unit_label_column ? "$(#{output_unit_label_column})":output_unit_label if output_unit @mappings << mapping_clause( "process_#{process_tag}_Output_hasunit_unit", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_tag}_Output", [[SIO["has-unit"][self.sio_verbose], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_tag}_Output_unit", "iri"]] ) @mappings << mapping_clause( "process_#{process_tag}_Output_unit_annotation", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_tag}_Output_unit", [["rdf:type",output_unit, "iri"]] ) end if output_unit and output_unit_label @mappings << mapping_clause( "process_#{process_tag}_Output_unit_label_annotation", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_tag}_Output_unit", [["rdfs:label",output_unit_label,"xsd:string"] ] ) end end |
#person_identifier_role_mappings(params = {}) ⇒ Object
creates the person/identifier/role portion of the CDE
Parameters passed as a hash. this is a specification of the entity-identifier-role method, with Patient defaults
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 347 def person_identifier_role_mappings(params = {}) @personid_column = params.fetch(:personid_column, 'pid') uniqueid_column = params.fetch(:uniqueid_column, 'uniqid') identifier_type = params.fetch(:identifier_type, SIO["identifier"][self.sio_verbose]) identifier_type_column = params.fetch(:identifier_type_column, nil) person_type = params.fetch(:person_type, SIO["person"][self.sio_verbose]) person_tag = params.fetch(:person_tag, 'thisPerson') person_type_column = params.fetch(:person_type_column, nil) person_role_tag = params.fetch(:person_role_tag, 'thisRole') role_type = params.fetch(:role_type, 'obo:OBI_0000093') # patient role_type_column = params.fetch(:role_type_column, nil) # role_label = params.fetch(:role_label, 'Patient Role') # patient role_label_column = params.fetch(:role_label_column, nil) # person_label = params.fetch(:person_label, nil) # patient person_label_column = params.fetch(:person_label_column, nil) # self.entity_identifier_role_mappings({ entityid_column: @personid_column, uniqueid_column: uniqueid_column, identifier_type: identifier_type, identifier_type_column: identifier_type_column, entity_tag: person_tag, entity_type: person_type, entity_type_column: person_type_column, entity_role_tag: person_role_tag, role_type: role_type, role_type_column: role_type_column, role_label: role_label, role_label_column: role_label_column, entity_label: person_label, entity_label_column: person_label_column, }) end |
#process_caused_by(params) ⇒ Object
creates the process caused by
Parameters passed as a hash. there can be only one cause!
TODO: Allow any existing node to be a cause…
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 835 def process_caused_by(params) process_with_cause_tag = params.fetch(:process_with_cause_tag, nil) # some one-word name cause_type = params.fetch(:cause_type, nil) cause_type_column = params.fetch(:cause_type_column, nil) make_unique_process = params.fetch(:make_unique_process, true) root_url = get_root_url(make_unique_process) cause_type = cause_type_column ? "$(#{cause_type_column})":cause_type abort "must specify the process_with_cause_tag" unless process_with_cause_tag abort "must specify the cause type" unless (cause_type or cause_type_column) @mappings << mapping_clause( "process_#{process_with_cause_tag}_has_cause", ["#{source_tag}-source"], root_url + "#process_#{process_with_cause_tag}", [[SIO["is-causally-related-from"][self.sio_verbose], root_url + "#cause_of_process_#{process_with_cause_tag}", "iri"]] ) @mappings << mapping_clause( "process_#{process_with_cause_tag}_has_cause_annotation", ["#{source_tag}-source"], root_url + "#cause_of_process_#{process_with_cause_tag}", [ ["rdf:type",SIO["entity"][self.sio_verbose], "iri"], ["rdf:type",cause_type, "iri"], ] ) end |
#process_has_agent(params) ⇒ Object
Parameters passed as a hash
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 606 def process_has_agent(params) process_tag = params.fetch(:process_tag, "thisprocess") entityid_column = params.fetch(:entityid_column, "pid") entity_tag = params.fetch(:entity_tag, "thisEntity") make_unique_process = params.fetch(:make_unique_process, true) root_url = get_root_url(make_unique_process) @mappings << mapping_clause( "process_has_agent_#{entity_tag}", ["#{source_tag}-source"], root_url + "##{process_tag}", [[SIO['has-agent'][self.sio_verbose], "this:individual_#{entity_tag}_$(#{entityid_column})#Entity" , 'iri']] ) end |
#process_has_annotations(params) ⇒ Object
creates the process has annotations portion of the CDE
Parameters passed as a hash
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 536 def process_has_annotations(params) process_tag = params.fetch(:process_tag, "thisprocess") process_annotations_columns = params.fetch(:process_annotations_columns, []) process_annotations = params.fetch(:process_annotations, []) make_unique_process = params.fetch(:make_unique_process, true) root_url = get_root_url(make_unique_process) if !process_annotations_columns.empty? process_annotations_columns.each do |predicate, value, datatype| case when datatype =~ /iri/ datatype = "iri" when datatype =~ /^xsd\:/ datatype = datatype when datatype datatype = "$(#{datatype})" # its a column header else datatype = "xsd:string" end if predicate =~ /https?\:\/\// predicate = predicate else predicate = "$(#{predicate})" # if the predicate looks like a URI, assume that it is, rather than a colulmn header end next unless predicate and value uniqid = get_uniq_id @mappings << mapping_clause( "#{uniqid}_process_custom_annotation", ["#{source_tag}-source"], root_url + "#process_#{process_tag}", [[predicate, "$(#{value})", datatype]] ) end elsif !process_annotations.empty? process_annotations.each do |predicate, value, datatype| datatype = "xsd:string" unless datatype # otherwise make it default next unless predicate and value uniqid = get_uniq_id @mappings << mapping_clause( "#{uniqid}_process_custom_annotation", ["#{source_tag}-source"], root_url + "#process_#{process_tag}", [[predicate, value, datatype]] ) end end end |
#process_has_attribute(params) ⇒ Object
creates the process has_attribute
Parameters passed as a hash. there can be only one cause!
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 875 def process_has_attribute(params) process_with_attribute_tag = params.fetch(:process_with_attribute_tag, nil) # some one-word name attribute_tag = params.fetch(:attribute_tag, nil) # some one-word name make_unique_process = params.fetch(:make_unique_process, true) root_url = get_root_url(make_unique_process) abort "must specify the process_with_attribute_tag" unless process_with_attribute_tag abort "must specify the attribute_tag" unless (attribute_tag) @mappings << mapping_clause( "process_#{process_with_attribute_tag}_has_attribute_#{attribute_tag}", ["#{source_tag}-source"], root_url + "#process_#{process_with_attribute_tag}", [[SIO["has-attribute"][self.sio_verbose], root_url + "#attribute_#{attribute_tag}", "iri"]] ) end |
#process_has_input(params) ⇒ Object
NEED AN INPUT REFERS TO HERE>>>>>>
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 1026 def process_has_input(params) process_with_input_tag = params.fetch(:process_with_input_tag, "thisprocess") # some one-word name input_is_output_of_process_tag = params.fetch(:input_is_output_of_process_tag, 'unidentifiedProcess') # some one-word name input_type = params.fetch(:input_type, SIO["information-content-entity"][self.sio_verbose]) # some one-word name input_type_tag = params.fetch(:input_type_tag, "thisInput") # some one-word name input_type_column = params.fetch(:input_type_column, nil) # some one-word name input_type_label = params.fetch(:input_type_label, "information content entity") # some one-word name input_type_label_column = params.fetch(:input_type_label_column, nil) # some one-word name input_has_value = params.fetch(:input_has_value, nil) # some one-word name input_has_value_column = params.fetch(:input_has_value_column, nil) # some one-word name input_has_value_datatype = params.fetch(:input_has_value_datatype, "xsd:string") # some one-word name input_has_value_datatype_column = params.fetch(:input_has_value_datatype_column, nil) # some one-word name make_unique_process = params.fetch(:make_unique_process, true) root_url = get_root_url(make_unique_process) abort "must specify the process_with_input_tag (the identifier of the process that receives the input) before you can use the process_has_input function" unless process_with_input_tag input_type = input_type_column ? "$(#{input_type_column})":input_type input_label = input_type_label_column ? "$(#{input_type_label_column})":input_type_label input_value = input_has_value_column ? "$(#{input_has_value_column})":input_has_value input_value_datatype = input_has_value_datatype_column ? "$(#{input_has_value_datatype_column})":input_has_value_datatype @mappings << mapping_clause( "process_#{process_with_input_tag}_has_input_#{input_type_tag}", ["#{source_tag}-source"], root_url + "#process_#{process_with_input_tag}", [[SIO["has-input"][self.sio_verbose],"this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{input_is_output_of_process_tag}_Output", "iri"]] ) @mappings << mapping_clause( "process_#{process_with_input_tag}_has_input_#{input_type_tag}_annotation", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{input_is_output_of_process_tag}_Output", [ ["rdf:type",SIO["information-content-entity"][self.sio_verbose], "iri"], ["rdf:type","#{input_type}", "iri"], ["rdfs:label","Process Input: #{input_label} - Type: #{input_type_tag}", "xsd:string"], ] ) if input_value @mappings << mapping_clause( "input_#{input_type_tag}_has_value", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{input_is_output_of_process_tag}_Output", [[SIO["has-value"][self.sio_verbose],"#{input_value}", "#{input_value_datatype}"]] ) end # TODO: need to allow units here too! ...one day... end |
#process_has_part(params) ⇒ Object
creates the process_has_part portion of the CDE
Parameters passed as a hash
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 639 def process_has_part(params) parent_process_tag = params.fetch(:parent_process_tag, nil) part_process_tag = params.fetch(:part_process_tag, nil) part_process_type = params.fetch(:part_process_type, nil) part_process_type_column = params.fetch(:part_process_type_column, nil) parent_unique_process = params.fetch(:parent_unique_process, true) part_unique_process = params.fetch(:part_unique_process, true) parent_root_url = get_root_url(parent_unique_process) part_root_url = get_root_url(part_unique_process) part_process_type = part_process_type_column ? "$(#{part_process_type_column})":part_process_type abort "cannot create part relationship unless both parent and child processes have a tag" unless (parent_process_tag && part_process_tag) #uniqid = get_uniq_id @mappings << mapping_clause( "process_#{parent_process_tag}_has_part_#{part_process_tag}", ["#{source_tag}-source"], parent_root_url + "#process_#{parent_process_tag}", [ [SIO["has-part"][self.sio_verbose], part_root_url + "#process_#{part_process_tag}" , "iri"], ] ) @mappings << mapping_clause( "process_#{part_process_tag}_process_has_type", ["#{source_tag}-source"], parent_root_url + "#process_#{part_process_tag}", [ ["rdf:type", SIO["process"][self.sio_verbose], "iri"], ] ) if part_process_type @mappings << mapping_clause( "process_#{part_process_tag}_process_has_specific_type", ["#{source_tag}-source"], parent_root_url + "#process_#{part_process_tag}", [ ["rdf:type", part_process_type, "iri"], ] ) end end |
#process_has_target(params) ⇒ Object
creates the process has target portion of the CDE
Parameters passed as a hash
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 701 def process_has_target(params) process_with_target_tag = params.fetch(:process_with_target_tag, "thisprocess") # some one-word name target_type_tag = params.fetch(:target_type_tag, "thisTarget") # some one-word name target_type = params.fetch(:target_type, SIO["information-content-entity"][self.sio_verbose]) # some one-word name target_type_column = params.fetch(:target_type_column, nil) # some one-word name target_type_label = params.fetch(:target_type_label, "information content entity") # some one-word name target_type_label_column = params.fetch(:target_type_label_column, nil) # some one-word name make_unique_process = params.fetch(:make_unique_process, true) root_url = get_root_url(make_unique_process) abort "must specify the process_with_target_tag (the identifier of the process that has the input) before you can use the process_has_target function" unless process_with_target_tag target_type = target_type_column ? "$(#{target_type_column})":target_type target_label = target_type_label_column ? "$(#{target_type_label_column})":target_type_label @mappings << mapping_clause( "process_#{process_with_target_tag}_has_target_#{target_type_tag}", ["#{source_tag}-source"], root_url + "#process_#{process_with_target_tag}", [[SIO["has-target"][self.sio_verbose],"this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_target_tag}_Target", "iri"]] ) @mappings << mapping_clause( "process_#{process_with_target_tag}_has_target_#{target_type_tag}_annotation", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_target_tag}_Target", [ ["rdf:type",SIO["information-content-entity"][self.sio_verbose], "iri"], ["rdf:type","#{target_type}", "iri"], ["rdfs:label","Process Target: #{target_label}", "xsd:string"], ] ) end |
#process_hasoutput_output(params) ⇒ Object
creates the process_hasoutput_output portion of the CDE
TODO allow multiple outputs
Parameters passed as a hash
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 1110 def process_hasoutput_output(params) process_with_output_tag = params.fetch(:process_with_output_tag, "thisprocess") # some one-word name output_value = params.fetch(:output_value, nil) output_value_column = params.fetch(:output_value_column, nil) output_type = params.fetch(:output_type, SIO["information-content-entity"][self.sio_verbose]) output_type_column = params.fetch(:output_type_column, nil) output_type_label = params.fetch(:output_type_label, "measurement-value") output_type_label_column = params.fetch(:output_type_label_column, nil) output_value_datatype = params.fetch(:output_value_datatype, "xsd:string") output_value_datatype_column = params.fetch(:output_value_datatype_column, nil) output_comments_column = params.fetch(:output_comments_column, nil) output_start_column = params.fetch(:output_start_column, nil) output_end_column = params.fetch(:output_end_column, nil) output_timeinstant_column = params.fetch(:output_timeinstant_column, nil) output_measured_at_column = params.fetch(:output_measured_at_column, nil) output_annotations = params.fetch(:output_annotations, []) #output_annotations_columns = params.fetch(:output_annotations_columns, []) make_unique_process = params.fetch(:make_unique_process, true) output_value = output_value_column ? "$(#{output_value_column})":output_value output_type = output_type_column ? "$(#{output_type_column})":output_type output_type_label = output_type_label_column ? "$(#{output_type_label_column})":output_type_label output_value_datatype = output_value_datatype_column ? "$(#{output_value_datatype_column})":output_value_datatype root_url = get_root_url(make_unique_process) #return unless output_value @mappings << mapping_clause( "process_#{process_with_output_tag}_process_has_output", ["#{source_tag}-source"], root_url + "#process_#{process_with_output_tag}", [[SIO["has-output"][self.sio_verbose], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", "iri"]] ) @mappings << mapping_clause( "process_#{process_with_output_tag}_Output_annotation", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", [["rdf:type",SIO["information-content-entity"][self.sio_verbose], "iri"]] ) if output_type @mappings << mapping_clause( "process_#{process_with_output_tag}_Output_type_annotation", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", [["rdf:type",output_type, "iri"]] ) end if output_type_label @mappings << mapping_clause( "process_#{process_with_output_tag}_Output_type_label_annotation", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", [["rdfs:label","Output Type: #{output_type_label}", "xsd:string"]] ) end if output_value @mappings << mapping_clause( "process_#{process_with_output_tag}_Output_value_annotation", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", [[SIO["has-value"][self.sio_verbose],output_value, output_value_datatype]] ) end if output_comments_column @mappings << mapping_clause( "process_#{process_with_output_tag}_Output_value_comments", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", [["rdfs:comment","$(#{output_comments_column})", "xsd:string"]] ) end if output_measured_at_column @mappings << mapping_clause( "process_#{process_with_output_tag}_output_measured_at_timeinstant", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", [ [SIO["measured-at"][self.sio_verbose], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output_measured_at", "iri"], ] ) @mappings << mapping_clause( "process_#{process_with_output_tag}_output_measured_at_timeinstant_value", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output_measured_at", [ [SIO["has-value"][self.sio_verbose], "$(#{output_timeinstant_column})", "xsd:date"], ["rdf:type", SIO["time-instant"][self.sio_verbose], "iri"], ] ) end if output_start_column # start and end will be attributes of the information object @mappings << mapping_clause( "process_#{process_with_output_tag}_output_has_start_atribute", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", [ # need to add the start column into this URI so that, if it is empty, the attribute will not be created at all by SDMRDFizer [SIO["has-attribute"][self.sio_verbose], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output_start_attribute_$(#{output_start_column})", "iri"], ] ) @mappings << mapping_clause( "process_#{process_with_output_tag}_output_has_start_attribute_value", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output_start_attribute_$(#{output_start_column})", [ [SIO["has-value"][self.sio_verbose], "$(#{output_start_column})", "xsd:date"], ["rdf:type", SIO["start-date"][self.sio_verbose], "iri"], ] ) end if output_end_column # start and end will be attributes of the information object @mappings << mapping_clause( "process_#{process_with_output_tag}_output_has_end_atribute", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", [ # need to add the start column into this URI so that, if it is empty, the attribute will not be created at all by SDMRDFizer [SIO["has-attribute"][self.sio_verbose], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output_end_attribute_$(#{output_end_column})", "iri"], ] ) @mappings << mapping_clause( "process_#{process_with_output_tag}_output_has_end_attribute_value", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output_end_attribute_$(#{output_end_column})", [ [SIO["has-value"][self.sio_verbose], "$(#{output_end_column})", "xsd:date"], ["rdf:type", SIO["end-date"][self.sio_verbose], "iri"], ] ) end output_annotations.each do |pred, value, dtype| datatype = "xsd:string" predicate = "" if dtype and dtype =~ /\S+\:\S+/ # URI or qname datatype = dtype elsif dtype datatype = "$(#{datatype})" # make it the column reference if it exists, but isn't a uri end if pred and pred =~ /\S+\:\S+/ # URI or qname predicate = pred else predicate = "$(#{pred})" # make it the column reference if it exists, but isn't a uri end next unless predicate and value uniqid = get_uniq_id @mappings << mapping_clause( "#{uniqid}_output_custom_annotation", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})#process_#{process_with_output_tag}_Output", [["$(#{predicate})", "$(#{value})", datatype]] ) end end |
#process_is_specified_by(params) ⇒ Object
creates the process is specified by portion of the CDE
Parameters passed as a hash
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 761 def process_is_specified_by(params) process_with_protocol_tag = params.fetch(:process_with_protocol_tag, "thisprocess") # some one-word name protocol_type_tag = params.fetch(:protocol_type_tag, "thisProtocoltype") # some one-word name process_type = params.fetch(:processs_type, SIO["process"][self.sio_verbose]) # process_type_column = params.fetch(:protocol_type_column, nil) # process_type_label = params.fetch(:protocol_type_label, "Process") process_type_label_column = params.fetch(:protocol_type_label_column, nil) protocol_uri = params.fetch(:protocol_uri, nil) # Protocol protocol_uri_column = params.fetch(:protocol_uri_column, nil) protocol_label = params.fetch(:protocol_uri, nil) # Protocol protocol_label_column = params.fetch(:protocol_uri_column, nil) protocol_type = params.fetch(:protocol_type, "http://purl.obolibrary.org/obo/NCIT_C42651") # Protocol protocol_type_column = params.fetch(:protocol_type_column, nil) make_unique_process = params.fetch(:make_unique_process, true) root_url = get_root_url(make_unique_process) abort "must specify the process_with_target_tag and the protocol type tag (the identifier of the process that has the input) before you can use the process_has_target function" unless (process_with_protocol_tag and protocol_type_tag) process_type = process_type_column ? "$(#{process_type_column})":process_type process_type_label = process_type_label_column ? "$(#{process_type_label_column})":process_type_label protocol_uri = protocol_uri_column ? "$(#{protocol_uri_column})":protocol_uri protocol_label = protocol_label_column ? "$(#{protocol_label_column})":protocol_label protocol_type = protocol_type_column ? "$(#{protocol_type_column})":protocol_type abort "must specify either a default protocol URI, or a column of protocol URIs" unless protocol_uri @mappings << mapping_clause( "#{process_with_protocol_tag}_specified_by_#{protocol_type_tag}_specifictype_annotation", ["#{source_tag}-source"], root_url + "##{process_with_protocol_tag}", [ ["rdf:type","#{process_type}", "iri"], ["rdfs:label","Protocol: #{process_type_label}", "xsd:string"], ] ) @mappings << mapping_clause( "#{process_with_protocol_tag}_specified_by_#{protocol_type_tag}", ["#{source_tag}-source"], root_url + "##{process_with_protocol_tag}", [[SIO["is-specified-by"][self.sio_verbose], protocol_uri, "iri"]] ) @mappings << mapping_clause( "#{process_with_protocol_tag}_specified_by_#{protocol_type_tag}_annotation", ["#{source_tag}-source"], protocol_uri, [ ["rdf:type",SIO["information-content-entity"][self.sio_verbose], "iri"], ["rdf:type","http://purl.obolibrary.org/obo/NCIT_C42651", "iri"], # Protocol ["rdf:type","#{protocol_type}", "iri"], ["rdfs:label","Protocol: #{protocol_label}", "xsd:string"], ] ) end |
#role_in_process(params) ⇒ Object
creates the role_in_process portion of the CDE
Parameters passed as a hash
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
# File 'lib/yarrrml_template_builder/yarrrml_template_builder.rb', line 405 def role_in_process(params) person_role_tag = params.fetch(:person_role_tag, 'thisRole') entity_role_tag = params.fetch(:person_role_tag, nil) process_type = params.fetch(:process_type, SIO["process"][self.sio_verbose]) process_type_column = params.fetch(:process_type_column, nil) process_tag = params.fetch(:process_tag, 'thisprocess') # some one-word name process_label = params.fetch(:process_label, 'Process') process_label_column = params.fetch(:process_label_column, nil) process_start_column = params.fetch(:process_start_column, nil) process_end_column = params.fetch(:process_end_column, nil) process_duration_column = params.fetch(:process_end_column, nil) make_unique_process = params.fetch(:make_unique_process, true) process_type = process_type_column ? "$(#{process_type_column})":process_type process_label = process_label_column ? "$(#{process_label_column})":process_label person_role_tag = entity_role_tag if entity_role_tag root_url = get_root_url(make_unique_process) @mappings << mapping_clause( "#{person_role_tag}_realized_#{process_tag}", ["#{source_tag}-source"], "this:individual_$(#{@personid_column})_$(#{@uniqueid_column})##{person_role_tag}", [ [SIO["is-realized-in"][self.sio_verbose], root_url + "#process_#{process_tag}","iri"] ] ) @mappings << mapping_clause( "process_#{process_tag}_process_annotation", ["#{source_tag}-source"], root_url + "#process_#{process_tag}", [ ["rdf:type",SIO["process"][self.sio_verbose], "iri"], ["rdf:type","#{process_type}", "iri"], ["rdfs:label","Process: #{process_label}", "xsd:string"], ] ) if process_start_column @mappings << mapping_clause( "process_#{process_tag}_process_annotation_start", ["#{source_tag}-source"], root_url + "#process_#{process_tag}", [[SIO["has-start-time"][self.sio_verbose], root_url + "#process_#{process_tag}_startdate_#{process_start_column}", "iri"]] ) @mappings << mapping_clause( "process_#{process_tag}_process_annotation_start_value", ["#{source_tag}-source"], root_url + "#process_#{process_tag}_startdate_$(#{process_start_column})", [ [SIO["has-value"][self.sio_verbose], "$(#{process_start_column})", "xsd:date"], ["rdf:type", SIO["start-date"][self.sio_verbose], "iri"], ["rdfs:label", "Start Date: $(#{process_start_column})"], ] ) # now create the MIRROR (!!!!) end time, if one is not provided unless process_end_column @mappings << mapping_clause( "process_#{process_tag}_process_annotation_end", ["#{source_tag}-source"], root_url + "#process_#{process_tag}", [[SIO["has-end-time"][self.sio_verbose], root_url + "#process_#{process_tag}_enddate_#{process_start_column}", "iri"]] ) @mappings << mapping_clause( "process_#{process_tag}_process_annotation_end_value", ["#{source_tag}-source"], root_url + "#process_#{process_tag}_enddate_$(#{process_start_column})", [ [SIO["has-value"][self.sio_verbose], "$(#{process_start_column})", "xsd:date"], ["rdf:type", SIO["end-date"][self.sio_verbose], "iri"], ["rdfs:label", "End Date: $(#{process_start_column})"], ] ) end end if process_end_column @mappings << mapping_clause( "process_#{process_tag}_process_annotation_end", ["#{source_tag}-source"], root_url + "#process_#{process_tag}", [[SIO["has-end-time"][self.sio_verbose], root_url + "#process_#{process_tag}_enddate_#{process_end_column}", "iri"]] ) @mappings << mapping_clause( "process_#{process_tag}_process_annotation_end_value", ["#{source_tag}-source"], root_url + "#process_#{process_tag}_enddate_#{process_end_column}", [ [SIO["has-value"][self.sio_verbose], "$(#{process_end_column})", "xsd:date"], ["rdf:type", SIO["end-date"][self.sio_verbose], "iri"], ["rdfs:label", "End Date: $(#{process_end_column})"], ] ) end if process_duration_column @mappings << mapping_clause( "#{process_tag}_process_annotation_duration", ["#{source_tag}-source"], root_url + "##{process_tag}", [[SIO["exists-at"][self.sio_verbose], root_url + "##{process_tag}_exists_at_#{process_duration_column}", "iri"]] ) @mappings << mapping_clause( "#{process_tag}_process_annotation_duration_value", ["#{source_tag}-source"], root_url + "##{process_tag}_exists_at_#{process_duration_column}", [ [SIO["has-value"][self.sio_verbose], "$(#{process_duration_column})"], ["rdf:type", SIO["day"][self.sio_verbose], "iri"], ["rdfs:label", "Duration: $(#{process_duration_column}) days"], ] ) end end |