yarrrml_template_builder 0.1.54

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f0efff24594547c1099ffa16cf88504e2c518a34e819cc9494c9237ad4a6dede
4
+ data.tar.gz: 614587381f1744f21e50cdcee3b9c30be566e092f832238a4d10af050152812a
5
+ SHA512:
6
+ metadata.gz: 16fe5dd7fe9a7b1765d174252660968f8082fa07b969389cd1b81d9e61167a36470ebc056166808d01e25fb6fc988ce535ea5f2aa4fb119cac17c794e79d794a
7
+ data.tar.gz: 3c16f51f7778322090733723c41aaea31e0a9e6db8ae3997d607bbf0122d33a5c430a1e9f3facb0f340a3721a38341a919356063799747029b6aafab9319440b
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Changelog.md ADDED
@@ -0,0 +1 @@
1
+ Start
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in yarrrml_template_builder.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ yarrrml_template_builder (0.1.54)
5
+ rest-client (~> 2.1.0)
6
+ yaml (~> 0.1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ domain_name (0.5.20190701)
12
+ unf (>= 0.0.5, < 1.0.0)
13
+ http-accept (1.7.0)
14
+ http-cookie (1.0.5)
15
+ domain_name (~> 0.5)
16
+ mime-types (3.4.1)
17
+ mime-types-data (~> 3.2015)
18
+ mime-types-data (3.2022.0105)
19
+ netrc (0.11.0)
20
+ rake (13.0.6)
21
+ rest-client (2.1.0)
22
+ http-accept (>= 1.7.0, < 2.0)
23
+ http-cookie (>= 1.0.2, < 2.0)
24
+ mime-types (>= 1.16, < 4.0)
25
+ netrc (~> 0.8)
26
+ unf (0.1.4)
27
+ unf_ext
28
+ unf_ext (0.0.8.2)
29
+ yaml (0.1.1)
30
+
31
+ PLATFORMS
32
+ x86_64-linux
33
+
34
+ DEPENDENCIES
35
+ rake (~> 13.0)
36
+ yarrrml_template_builder!
37
+
38
+ BUNDLED WITH
39
+ 2.3.12
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Mark Wilkinson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # INSTRUCTIONS
2
+ $ bundle install
3
+
4
+ $ gem build
5
+
6
+ $ gem install yarrrml_template_builder-{VERSION}.gem
7
+
8
+ VERSION is some version that will appear in the filename of the gem.
9
+
10
+ ## Execute a CDE Transformation from CSV
11
+
12
+ 0) Default folder structure, relative to where you will run the transformation script:
13
+
14
+ .
15
+ ./data/ (this folder is mounted into sdmrdfizer - see step 1 below)
16
+ ./data/mydataX.csv (input csv files)
17
+ ./data/mydataY.csv...
18
+ ./data/triples/ (output FAIR data ends up here)
19
+ ./config/
20
+ ./config/***_yarrrml_template.yaml (*** is a one-word tag of the "type" of data, e.g. "height")
21
+
22
+ 1) Need to have sdmrdfizer and yarrrml-parser services running ./data mounted as /data and ./config as /config. You can use docker-compose to run both services:
23
+
24
+ ```yaml
25
+ version: "2.0"
26
+ services:
27
+
28
+
29
+ yarrrml_transform:
30
+ image: markw/yarrrml-parser-ejp:latest
31
+ container_name: yarrrml_transform
32
+ ports:
33
+ - "3000:3000"
34
+ volumes:
35
+ - ./data:/data
36
+
37
+
38
+ rdfizer:
39
+ image: markw/sdmrdfizer_ejp:0.3.0
40
+ container_name: rdfizer
41
+ ports:
42
+ - "4000:4000"
43
+ volumes:
44
+ - ./data:/data
45
+ - ./config:/config
46
+ ```
47
+
48
+ 2) Create your template by running build_xxx_template or select the appropriate YARRRML template (in the ./config folder, e.g. "height_yarrrml_template.yaml"). See "example of creating a template" below if you need to create one from-scratch.
49
+
50
+ 3) In the ./data folder, create a CSV file with the necessary headings for your desired transform.
51
+
52
+ 4) Identify the "tag" of the YARRML template you want to use (e.g. 'height' for "height_yarrrml_template.yaml"). This tag is used to coordinate between many of the components during the automation steps, so it must match exactly with the "tag" portion of the template name.
53
+
54
+ 5) Execute the transformation: You can use [run_me_to_test.rb](run_me_to_test.rb) by changing the tag described as datatype_tag parameter at YARRRML_Transform:
55
+
56
+ ```ruby
57
+ y = YARRRML_Transform.new(datafile: "./data/myHeightData.csv", datatype_tag: "height")
58
+ y.yarrrml_transform
59
+ y.make_fair_data # output goes to ./data/triples
60
+ ```
61
+
62
+
63
+
64
+
65
+ ## Example of creating a template:
66
+
67
+ ### General Discussion:
68
+ The objective of the library is to make it easy to generate a YARRRML template that matches your situation. There is a fair amount of flexibility in what parameters are used, which are optional, and which have defaults (SIO-compliant). *NOTE: What comes out of the yarrrml_template_builder is NOT a complete YARRRML file! It has place-holders for the source filename and reference formulation. you add those when calling the yarrrml_transform library.*
69
+
70
+ personid_column and unique_id column are absolutely mandatory, and do not have a default.
71
+
72
+ There are three ways of representing a data column (or its default, if that column doesn't exist):
73
+
74
+ * You can specify the default value (these parameters are designated "xxxx" for example "process_type".
75
+ * You can specify the column header. These parameters are designated "xxxxxx_column" - for example 'process_type_column'. Specifying "process_type_column" will override any value you provided in "process_type"
76
+ * You can specify nothing, in which case the internal defaults will be used (based on the "base" type for that node in SIO. Some data is allowed to be nil, and those nodes will not be created.
77
+
78
+ Almost all cases will allow any of those three methods (see detailed documentation for more)
79
+
80
+ "tags" are used for creating human-readable section names in the output YARRRML. They may not contain spaces or other odd characters... letters and underscores are fine. This is not currently sanity-checked, so...
81
+
82
+ With that said, here's what a template-building script looks like:
83
+
84
+ require "yarrrml-template-builder"
85
+
86
+ # this is the header of the CSV we are going to transform
87
+ # "pid,uniqid,qualityURI,qualityLabel,measurementURI,measurementLabel,processURI,processLabel,height,unitURI,unitLabel,date,comments"
88
+
89
+ b = YARRRML_Template_Builder.new({
90
+ baseURI: "http://marks.test/this/", # this should resolve to wherever you are going to serve the data from.
91
+ # RDF URLs become e.g. http://marks.test/this/individual_X_Y#patientRole
92
+ source_name: "patient_height"}
93
+ )
94
+
95
+ b.person_identifier_role_mappings({
96
+ personid_column: "pid",
97
+ uniqueid_column: "uniqid",
98
+ identifier_type: "https://ejp-rd.eu/vocab/identifier",
99
+ person_type: "https://ejp-rd.eu/vocab/Person",
100
+ person_role_tag: "patientRole",
101
+ role_type: 'obo:OBI_0000093'
102
+ role_label: "Patient"
103
+ })
104
+ b.role_in_process({
105
+ process_type_column: "processURI",
106
+ process_tag: "some_height_measuring_process",
107
+ process_label_column: "processLabel",
108
+ process_start_column: "date",
109
+ process_end_column: nil,
110
+ })
111
+
112
+ b.person_has_quality({
113
+ quality_type_column: "qualityURI",
114
+ quality_tag: "height_quality",
115
+ quality_label_column: "qualityLabel",
116
+ })
117
+
118
+ b.process_hasoutput_output({
119
+ output_nature: "quantitative",
120
+ output_type_column: "measurementURI",
121
+ output_type_label_column: "measurementLabel",
122
+ output_value_column: "height",
123
+ output_value_datatype: "xsd:float",
124
+ output_comments_column: "comments",
125
+ })
126
+
127
+ b.output_has_unit({
128
+ output_unit_column: "unitURI",
129
+ output_unit_label: "unitLabel"
130
+ })
131
+
132
+ puts b.generate
133
+
134
+
135
+ Note that this will output the template to STDOUT, so capture it to a file. For everything else to work "correctly" that file should be named
136
+ XXXXXX_yarrrml_template.yaml, and should live in the ./config folder. XXXXXX is the 'tag' of the data type (e.g. 'height')
137
+
138
+
139
+ The "run_me_to_test.rb" script will run as a demo - using the demo height data in the ./data folder, and the template that is created by the code above. Output will appear in the ./data/triples folder.
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "yarrrml_template_builder"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,190 @@
1
+ ---
2
+ prefixes:
3
+ rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
4
+ rdfs: http://www.w3.org/2000/01/rdf-schema#
5
+ ex: http://ejp-rd.eu/ids/
6
+ obo: http://purl.obolibrary.org/obo/
7
+ sio: https://semanticscience.org/resource/
8
+ vocab: https://ejp-rd.eu/vocab/
9
+ pico: http://data.cochrane.org/ontologies/pico/
10
+ ndfrt: http://purl.bioontology.org/ontology/NDFRT/
11
+ this: http://marks.test/this/
12
+ sources:
13
+ patient_height_experimental-source:
14
+ access: "|||DATA|||"
15
+ referenceFormulation: "|||FORMULATION|||"
16
+ iterator: "$"
17
+ mappings:
18
+ identifier_has_value:
19
+ sources:
20
+ - patient_height_experimental-source
21
+ s: this:individual_$(pid)_$(uniqid)#ID
22
+ po:
23
+ - predicates: sio:has-value
24
+ objects:
25
+ value: "$(pid)"
26
+ datatype: xsd:string
27
+ identifier_denotes:
28
+ sources:
29
+ - patient_height_experimental-source
30
+ s: this:individual_$(pid)_$(uniqid)#ID
31
+ po:
32
+ - predicates: a
33
+ objects:
34
+ value: https://ejp-rd.eu/vocab/identifier
35
+ type: iri
36
+ - predicates: sio:denotes
37
+ objects:
38
+ value: this:individual_$(pid)_$(uniqid)#thisRole
39
+ type: iri
40
+ person_has_role:
41
+ sources:
42
+ - patient_height_experimental-source
43
+ s: this:individual_$(pid)#Person
44
+ po:
45
+ - predicates: a
46
+ objects:
47
+ value: https://ejp-rd.eu/vocab/Person
48
+ type: iri
49
+ - predicates: sio:has-role
50
+ objects:
51
+ value: this:individual_$(pid)_$(uniqid)#thisRole
52
+ type: iri
53
+ thisRole_annotation:
54
+ sources:
55
+ - patient_height_experimental-source
56
+ s: this:individual_$(pid)_$(uniqid)#thisRole
57
+ po:
58
+ - predicates: a
59
+ objects:
60
+ value: obo:OBI_0000093
61
+ type: iri
62
+ - predicates: rdfs:label
63
+ objects:
64
+ value: Patient
65
+ datatype: xsd:string
66
+ thisRole_realized_some_height_measuring_process:
67
+ sources:
68
+ - patient_height_experimental-source
69
+ s: this:individual_$(pid)_$(uniqid)#thisRole
70
+ po:
71
+ - predicates: sio:is-realized-in
72
+ objects:
73
+ value: this:individual_$(pid)_$(uniqid)#some_height_measuring_process
74
+ type: iri
75
+ some_height_measuring_process_process_annotation:
76
+ sources:
77
+ - patient_height_experimental-source
78
+ s: this:individual_$(pid)_$(uniqid)#some_height_measuring_process
79
+ po:
80
+ - predicates: rdf:type
81
+ objects:
82
+ value: "$(processURI)"
83
+ type: iri
84
+ - predicates: rdfs:label
85
+ objects:
86
+ value: "$(processLabel)"
87
+ datatype: xsd:string
88
+ some_height_measuring_process_process_annotation_start:
89
+ sources:
90
+ - patient_height_experimental-source
91
+ s: this:individual_$(pid)_$(uniqid)#some_height_measuring_process
92
+ po:
93
+ - predicates: sio:start-time
94
+ objects:
95
+ value: "$(date)"
96
+ datatype: xsd:dateTime
97
+ person_has_height_quality_quality:
98
+ sources:
99
+ - patient_height_experimental-source
100
+ s: this:individual_$(pid)#Person
101
+ po:
102
+ - predicates: sio:has-quality
103
+ objects:
104
+ value: this:individual__$(pid)_$(uniqid)#height_quality
105
+ type: iri
106
+ height_quality_quality_annotation:
107
+ sources:
108
+ - patient_height_experimental-source
109
+ s: this:individual__$(pid)_$(uniqid)#height_quality
110
+ po:
111
+ - predicates: rdf:type
112
+ objects:
113
+ value: "$(qualityURI)"
114
+ type: iri
115
+ - predicates: rdfs:label
116
+ objects:
117
+ value: "$(qualityLabel)"
118
+ datatype: xsd:string
119
+ some_height_measuring_process_process_has_output:
120
+ sources:
121
+ - patient_height_experimental-source
122
+ s: this:individual_$(pid)_$(uniqid)#some_height_measuring_process
123
+ po:
124
+ - predicates: sio:has-output
125
+ objects:
126
+ value: this:individual__$(pid)_$(uniqid)#some_height_measuring_process_Output
127
+ type: iri
128
+ some_height_measuring_process_Output_annotation:
129
+ sources:
130
+ - patient_height_experimental-source
131
+ s: this:individual__$(pid)_$(uniqid)#some_height_measuring_process_Output
132
+ po:
133
+ - predicates: rdf:type
134
+ objects:
135
+ value: sio:measurement-value
136
+ type: iri
137
+ some_height_measuring_process_Output_type_annotation:
138
+ sources:
139
+ - patient_height_experimental-source
140
+ s: this:individual__$(pid)_$(uniqid)#some_height_measuring_process_Output
141
+ po:
142
+ - predicates: rdf:type
143
+ objects:
144
+ value: "$(measurementURI)"
145
+ type: iri
146
+ some_height_measuring_process_Output_type_label_annotation:
147
+ sources:
148
+ - patient_height_experimental-source
149
+ s: this:individual__$(pid)_$(uniqid)#some_height_measuring_process_Output
150
+ po:
151
+ - predicates: rdfs:label
152
+ objects:
153
+ value: "$(measurementLabel)"
154
+ datatype: xsd:string
155
+ some_height_measuring_process_Output_value_annotation:
156
+ sources:
157
+ - patient_height_experimental-source
158
+ s: this:individual__$(pid)_$(uniqid)#some_height_measuring_process_Output
159
+ po:
160
+ - predicates: sio:has-value
161
+ objects:
162
+ value: "$(height)"
163
+ datatype: xsd:float
164
+ some_height_measuring_process_Output_value_comments:
165
+ sources:
166
+ - patient_height_experimental-source
167
+ s: this:individual__$(pid)_$(uniqid)#some_height_measuring_process_Output
168
+ po:
169
+ - predicates: rdfs:comment
170
+ objects:
171
+ value: "$(comments)"
172
+ datatype: xsd:string
173
+ some_height_measuring_process_Output_hasunit_unit:
174
+ sources:
175
+ - patient_height_experimental-source
176
+ s: this:individual__$(pid)_$(uniqid)#some_height_measuring_process_Output
177
+ po:
178
+ - predicates: sio:has-unit
179
+ objects:
180
+ value: this:individual__$(pid)_$(uniqid)#some_height_measuring_process_Output_unit
181
+ type: iri
182
+ some_height_measuring_process_Output_unit_annotation:
183
+ sources:
184
+ - patient_height_experimental-source
185
+ s: this:individual__$(pid)_$(uniqid)#some_height_measuring_process_Output_unit
186
+ po:
187
+ - predicates: rdfs:label
188
+ objects:
189
+ value: "$(unitLabel)"
190
+ datatype: xsd:string
data/data/height.csv ADDED
@@ -0,0 +1,2 @@
1
+ pid,uniqid,qualityURI,qualityLabel,measurementURI,measurementLabel,processURI,processLabel,height,unitLabel,date,comments
2
+ 12345,abcde,http://purl.obolibrary.org/obo/PATO_0000119,Height quality (PATO),http://www.ebi.ac.uk/efo/EFO_0004339,body height (EFO),http://purl.obolibrary.org/obo/VT_0004370,ulnar length (VT),23,cm,2019-02-28T00:00:00.000Z,Notes: Height measurement type (default http://www.ebi.ac.uk/efo/EFO_0004339) may be estimated by ulnar length (recorded as ulnar length trait - http://purl.obolibrary.org/obo/VT_0004370 - and ulnar length measurement type - (http://purl.obolibrary.org/obo/CMO_0000440)
@@ -0,0 +1,121 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: YARRRMLTemplateBuilder
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "YARRRMLTemplateBuilder";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (Y)</a> &raquo;
40
+
41
+
42
+ <span class="title">YARRRMLTemplateBuilder</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: YARRRMLTemplateBuilder
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/yarrrml_template_builder/version.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+
87
+
88
+ <h2>
89
+ Constant Summary
90
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
91
+ </h2>
92
+
93
+ <dl class="constants">
94
+
95
+ <dt id="VERSION-constant" class="">VERSION =
96
+
97
+ </dt>
98
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.47</span><span class='tstring_end'>&quot;</span></span></pre></dd>
99
+
100
+ </dl>
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ </div>
112
+
113
+ <div id="footer">
114
+ Generated on Sat Dec 18 09:07:59 2021 by
115
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
116
+ 0.9.26 (ruby-2.7.2).
117
+ </div>
118
+
119
+ </div>
120
+ </body>
121
+ </html>