yarrrml_template_builder 0.1.54

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,214 @@
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
+ File: README
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 = "README";
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="file_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</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-INSTRUCTIONS">INSTRUCTIONS</h1>
62
+
63
+ <pre class="code ruby"><code class="ruby"> $ bundle install
64
+
65
+ $ gem build
66
+
67
+ $ gem install yarrrml_template_builder-{VERSION}.gem
68
+ </code></pre>
69
+
70
+ <p>VERSION is some version that will appear in the filename of the gem.</p>
71
+
72
+ <h2 id="label-Execute+a+CDE+Transformation+from+CSV">Execute a CDE Transformation from CSV</h2>
73
+
74
+ <p>0) Default folder structure, relative to where you will run the transformation script:</p>
75
+
76
+ <pre class="code ruby"><code class="ruby"> .
77
+ ./data/ (this folder is mounted into sdmrdfizer - see step 1 below)
78
+ ./data/mydataX.csv (input csv files)
79
+ ./data/mydataY.csv...
80
+ ./data/triples/ (output FAIR data ends up here)
81
+ ./config/
82
+ ./config/***_yarrrml_template.yaml (*** is a one-word tag of the &quot;type&quot; of data, e.g. &quot;height&quot;)
83
+ </code></pre>
84
+
85
+ <p>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:</p>
86
+
87
+ <pre class="code ruby"><code class="ruby">```yaml
88
+ version: &quot;2.0&quot;
89
+ services:
90
+
91
+
92
+ yarrrml_transform:
93
+ image: markw/yarrrml-parser-ejp:latest
94
+ container_name: yarrrml_transform
95
+ ports:
96
+ - &quot;3000:3000&quot;
97
+ volumes:
98
+ - ./data:/data
99
+
100
+
101
+ rdfizer:
102
+ image: markw/sdmrdfizer_ejp:0.3.0
103
+ container_name: rdfizer
104
+ ports:
105
+ - &quot;4000:4000&quot;
106
+ volumes:
107
+ - ./data:/data
108
+ - ./config:/config
109
+ ```
110
+ </code></pre>
111
+
112
+ <p>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.</p>
113
+
114
+ <p>3) In the ./data folder, create a CSV file with the necessary headings for your desired transform.</p>
115
+
116
+ <p>4) Identify the “tag” of the YARRML template you want to use (e.g. &#39;height&#39; 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.</p>
117
+
118
+ <p>5) Execute the transformation: You can use <a href="run_me_to_test.rb">run_me_to_test.rb</a> by changing the tag described as datatype_tag parameter at YARRRML_Transform:</p>
119
+
120
+ <pre class="code ruby"><code class="ruby">```ruby
121
+ y = YARRRML_Transform.new(datafile: &quot;./data/myHeightData.csv&quot;, datatype_tag: &quot;height&quot;)
122
+ y.yarrrml_transform
123
+ y.make_fair_data # output goes to ./data/triples
124
+ ```
125
+ </code></pre>
126
+
127
+ <h2 id="label-Example+of+creating+a+template-3A">Example of creating a template:</h2>
128
+
129
+ <h3 id="label-General+Discussion-3A">General Discussion:</h3>
130
+
131
+ <p>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). <em>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.</em></p>
132
+
133
+ <p>personid_column and unique_id column are absolutely mandatory, and do not have a default.</p>
134
+
135
+ <p>There are three ways of representing a data column (or its default, if that column doesn&#39;t exist):</p>
136
+ <ul><li>
137
+ <p>You can specify the default value (these parameters are designated “xxxx” for example “process_type”.</p>
138
+ </li><li>
139
+ <p>You can specify the column header. These parameters are designated “xxxxxx_column” - for example &#39;process_type_column&#39;. Specifying “process_type_column” will override any value you provided in “process_type”</p>
140
+ </li><li>
141
+ <p>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.</p>
142
+ </li></ul>
143
+
144
+ <p>Almost all cases will allow any of those three methods (see detailed documentation for more)</p>
145
+
146
+ <p>“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…</p>
147
+
148
+ <p>With that said, here&#39;s what a template-building script looks like:</p>
149
+
150
+ <pre class="code ruby"><code class="ruby">require &quot;yarrrml-template-builder&quot;
151
+
152
+ # this is the header of the CSV we are going to transform
153
+ # &quot;pid,uniqid,qualityURI,qualityLabel,measurementURI,measurementLabel,processURI,processLabel,height,unitURI,unitLabel,date,comments&quot;
154
+
155
+ b = YARRRML_Template_Builder.new({
156
+ baseURI: &quot;http://marks.test/this/&quot;, # this should resolve to wherever you are going to serve the data from.
157
+ # RDF URLs become e.g. http://marks.test/this/individual_X_Y#patientRole
158
+ source_name: &quot;patient_height&quot;}
159
+ )
160
+
161
+ b.person_identifier_role_mappings({
162
+ personid_column: &quot;pid&quot;,
163
+ uniqueid_column: &quot;uniqid&quot;,
164
+ identifier_type: &quot;https://ejp-rd.eu/vocab/identifier&quot;,
165
+ person_type: &quot;https://ejp-rd.eu/vocab/Person&quot;,
166
+ person_role_tag: &quot;patientRole&quot;,
167
+ role_type: &#39;obo:OBI_0000093&#39;
168
+ role_label: &quot;Patient&quot;
169
+ })
170
+ b.role_in_process({
171
+ process_type_column: &quot;processURI&quot;,
172
+ process_tag: &quot;some_height_measuring_process&quot;,
173
+ process_label_column: &quot;processLabel&quot;,
174
+ process_start_column: &quot;date&quot;,
175
+ process_end_column: nil,
176
+ })
177
+
178
+ b.person_has_quality({
179
+ quality_type_column: &quot;qualityURI&quot;,
180
+ quality_tag: &quot;height_quality&quot;,
181
+ quality_label_column: &quot;qualityLabel&quot;,
182
+ })
183
+
184
+ b.process_hasoutput_output({
185
+ output_nature: &quot;quantitative&quot;,
186
+ output_type_column: &quot;measurementURI&quot;,
187
+ output_type_label_column: &quot;measurementLabel&quot;,
188
+ output_value_column: &quot;height&quot;,
189
+ output_value_datatype: &quot;xsd:float&quot;,
190
+ output_comments_column: &quot;comments&quot;,
191
+ })
192
+
193
+ b.output_has_unit({
194
+ output_unit_column: &quot;unitURI&quot;,
195
+ output_unit_label: &quot;unitLabel&quot;
196
+ })
197
+
198
+ puts b.generate
199
+ </code></pre>
200
+
201
+ <p>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 XXXXXX_yarrrml_template.yaml, and should live in the ./config folder. XXXXXX is the &#39;tag&#39; of the data type (e.g. &#39;height&#39;)</p>
202
+
203
+ <p>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.</p>
204
+ </div></div>
205
+
206
+ <div id="footer">
207
+ Generated on Sat Dec 18 09:07:59 2021 by
208
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
209
+ 0.9.26 (ruby-2.7.2).
210
+ </div>
211
+
212
+ </div>
213
+ </body>
214
+ </html>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+
53
+ </ul>
54
+ </div>
55
+ </body>
56
+ </html>
data/doc/frames.html ADDED
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.26</title>
6
+ </head>
7
+ <script type="text/javascript">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : 'index.html';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>
data/doc/index.html ADDED
@@ -0,0 +1,214 @@
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
+ File: README
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 = "README";
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</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-INSTRUCTIONS">INSTRUCTIONS</h1>
62
+
63
+ <pre class="code ruby"><code class="ruby"> $ bundle install
64
+
65
+ $ gem build
66
+
67
+ $ gem install yarrrml_template_builder-{VERSION}.gem
68
+ </code></pre>
69
+
70
+ <p>VERSION is some version that will appear in the filename of the gem.</p>
71
+
72
+ <h2 id="label-Execute+a+CDE+Transformation+from+CSV">Execute a CDE Transformation from CSV</h2>
73
+
74
+ <p>0) Default folder structure, relative to where you will run the transformation script:</p>
75
+
76
+ <pre class="code ruby"><code class="ruby"> .
77
+ ./data/ (this folder is mounted into sdmrdfizer - see step 1 below)
78
+ ./data/mydataX.csv (input csv files)
79
+ ./data/mydataY.csv...
80
+ ./data/triples/ (output FAIR data ends up here)
81
+ ./config/
82
+ ./config/***_yarrrml_template.yaml (*** is a one-word tag of the &quot;type&quot; of data, e.g. &quot;height&quot;)
83
+ </code></pre>
84
+
85
+ <p>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:</p>
86
+
87
+ <pre class="code ruby"><code class="ruby">```yaml
88
+ version: &quot;2.0&quot;
89
+ services:
90
+
91
+
92
+ yarrrml_transform:
93
+ image: markw/yarrrml-parser-ejp:latest
94
+ container_name: yarrrml_transform
95
+ ports:
96
+ - &quot;3000:3000&quot;
97
+ volumes:
98
+ - ./data:/data
99
+
100
+
101
+ rdfizer:
102
+ image: markw/sdmrdfizer_ejp:0.3.0
103
+ container_name: rdfizer
104
+ ports:
105
+ - &quot;4000:4000&quot;
106
+ volumes:
107
+ - ./data:/data
108
+ - ./config:/config
109
+ ```
110
+ </code></pre>
111
+
112
+ <p>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.</p>
113
+
114
+ <p>3) In the ./data folder, create a CSV file with the necessary headings for your desired transform.</p>
115
+
116
+ <p>4) Identify the “tag” of the YARRML template you want to use (e.g. &#39;height&#39; 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.</p>
117
+
118
+ <p>5) Execute the transformation: You can use <a href="run_me_to_test.rb">run_me_to_test.rb</a> by changing the tag described as datatype_tag parameter at YARRRML_Transform:</p>
119
+
120
+ <pre class="code ruby"><code class="ruby">```ruby
121
+ y = YARRRML_Transform.new(datafile: &quot;./data/myHeightData.csv&quot;, datatype_tag: &quot;height&quot;)
122
+ y.yarrrml_transform
123
+ y.make_fair_data # output goes to ./data/triples
124
+ ```
125
+ </code></pre>
126
+
127
+ <h2 id="label-Example+of+creating+a+template-3A">Example of creating a template:</h2>
128
+
129
+ <h3 id="label-General+Discussion-3A">General Discussion:</h3>
130
+
131
+ <p>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). <em>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.</em></p>
132
+
133
+ <p>personid_column and unique_id column are absolutely mandatory, and do not have a default.</p>
134
+
135
+ <p>There are three ways of representing a data column (or its default, if that column doesn&#39;t exist):</p>
136
+ <ul><li>
137
+ <p>You can specify the default value (these parameters are designated “xxxx” for example “process_type”.</p>
138
+ </li><li>
139
+ <p>You can specify the column header. These parameters are designated “xxxxxx_column” - for example &#39;process_type_column&#39;. Specifying “process_type_column” will override any value you provided in “process_type”</p>
140
+ </li><li>
141
+ <p>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.</p>
142
+ </li></ul>
143
+
144
+ <p>Almost all cases will allow any of those three methods (see detailed documentation for more)</p>
145
+
146
+ <p>“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…</p>
147
+
148
+ <p>With that said, here&#39;s what a template-building script looks like:</p>
149
+
150
+ <pre class="code ruby"><code class="ruby">require &quot;yarrrml-template-builder&quot;
151
+
152
+ # this is the header of the CSV we are going to transform
153
+ # &quot;pid,uniqid,qualityURI,qualityLabel,measurementURI,measurementLabel,processURI,processLabel,height,unitURI,unitLabel,date,comments&quot;
154
+
155
+ b = YARRRML_Template_Builder.new({
156
+ baseURI: &quot;http://marks.test/this/&quot;, # this should resolve to wherever you are going to serve the data from.
157
+ # RDF URLs become e.g. http://marks.test/this/individual_X_Y#patientRole
158
+ source_name: &quot;patient_height&quot;}
159
+ )
160
+
161
+ b.person_identifier_role_mappings({
162
+ personid_column: &quot;pid&quot;,
163
+ uniqueid_column: &quot;uniqid&quot;,
164
+ identifier_type: &quot;https://ejp-rd.eu/vocab/identifier&quot;,
165
+ person_type: &quot;https://ejp-rd.eu/vocab/Person&quot;,
166
+ person_role_tag: &quot;patientRole&quot;,
167
+ role_type: &#39;obo:OBI_0000093&#39;
168
+ role_label: &quot;Patient&quot;
169
+ })
170
+ b.role_in_process({
171
+ process_type_column: &quot;processURI&quot;,
172
+ process_tag: &quot;some_height_measuring_process&quot;,
173
+ process_label_column: &quot;processLabel&quot;,
174
+ process_start_column: &quot;date&quot;,
175
+ process_end_column: nil,
176
+ })
177
+
178
+ b.person_has_quality({
179
+ quality_type_column: &quot;qualityURI&quot;,
180
+ quality_tag: &quot;height_quality&quot;,
181
+ quality_label_column: &quot;qualityLabel&quot;,
182
+ })
183
+
184
+ b.process_hasoutput_output({
185
+ output_nature: &quot;quantitative&quot;,
186
+ output_type_column: &quot;measurementURI&quot;,
187
+ output_type_label_column: &quot;measurementLabel&quot;,
188
+ output_value_column: &quot;height&quot;,
189
+ output_value_datatype: &quot;xsd:float&quot;,
190
+ output_comments_column: &quot;comments&quot;,
191
+ })
192
+
193
+ b.output_has_unit({
194
+ output_unit_column: &quot;unitURI&quot;,
195
+ output_unit_label: &quot;unitLabel&quot;
196
+ })
197
+
198
+ puts b.generate
199
+ </code></pre>
200
+
201
+ <p>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 XXXXXX_yarrrml_template.yaml, and should live in the ./config folder. XXXXXX is the &#39;tag&#39; of the data type (e.g. &#39;height&#39;)</p>
202
+
203
+ <p>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.</p>
204
+ </div></div>
205
+
206
+ <div id="footer">
207
+ Generated on Sat Dec 18 09:07:59 2021 by
208
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
209
+ 0.9.26 (ruby-2.7.2).
210
+ </div>
211
+
212
+ </div>
213
+ </body>
214
+ </html>