labimotion 2.0.0.rc2 → 2.0.0.rc8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,236 @@
1
+ {
2
+ "CHMO:0000025": {
3
+ "index": ["A", "B", "C", "D", "Q2", "Q3", "G", "H", "Q4", "Q5", "K", "L", "Q6", "N", "O", "P", "Q7", "R", "S", "T", "U", "V", "W", "X", "Q8", "Q9", "Q10"],
4
+ "mapper": {
5
+ "A": {
6
+ "sources": ["inchikey"]
7
+ },
8
+ "B": {
9
+ "sources": ["molfile"]
10
+ },
11
+ "C": {
12
+ "sources": ["concentration"]
13
+ },
14
+ "D": {
15
+ "sources": ["redox"],
16
+ "separator": ","
17
+ },
18
+ "G": {
19
+ "sources": ["solvent_volume"]
20
+ },
21
+ "H": {
22
+ "sources": ["elect_inchikey"]
23
+ },
24
+ "K": {
25
+ "sources": ["elect_concentration"]
26
+ },
27
+ "L": {
28
+ "sources": ["reference_internal"]
29
+ },
30
+ "N": {
31
+ "sources": ["scan_rate"]
32
+ },
33
+ "O": {
34
+ "sources": ["scan_number"]
35
+ },
36
+ "P": {
37
+ "sources": ["voltage_limit_one", "voltage_limit_two"],
38
+ "separator": ","
39
+ },
40
+ "R": {
41
+ "sources": ["atmosphere"]
42
+ },
43
+ "S": {
44
+ "sources": ["temperature"]
45
+ },
46
+ "T": {
47
+ "sources": ["condition"]
48
+ },
49
+ "U": {
50
+ "sources": ["we"]
51
+ },
52
+ "V": {
53
+ "sources": ["we_area"]
54
+ },
55
+ "W": {
56
+ "sources": ["ce"]
57
+ },
58
+ "X": {
59
+ "sources": ["re"]
60
+ },
61
+ "Q2": {
62
+ "sources": ["solvent"]
63
+ },
64
+ "Q3": {
65
+ "sources": ["solvent_molfile"]
66
+ },
67
+ "Q4": {
68
+ "sources": ["elect_molfile"]
69
+ },
70
+ "Q5": {
71
+ "sources": ["elect_purity"]
72
+ },
73
+ "Q6": {
74
+ "sources": ["reference_internal_compound_molfile"]
75
+ },
76
+ "Q7": {
77
+ "sources": ["scan_direction"],
78
+ "separator": ","
79
+ },
80
+ "Q8": {
81
+ "sources": ["details"],
82
+ "separator": ","
83
+ },
84
+ "Q9": {
85
+ "sources": ["includes"],
86
+ "separator": ","
87
+ },
88
+ "Q10": {
89
+ "sources": ["base_page"],
90
+ "separator": ","
91
+ }
92
+ },
93
+ "source": {
94
+ "concentration": {
95
+ "title": "Analyte concentration [mM]",
96
+ "param": "sample_preparation.concentration",
97
+ "type": "dataset"
98
+ },
99
+ "temperature": {
100
+ "title": "Temperature [°C]",
101
+ "param": "set.temperature",
102
+ "type": "dataset"
103
+ },
104
+ "condition": {
105
+ "title": "Condition",
106
+ "param": "set.conditions",
107
+ "type": "dataset"
108
+ },
109
+ "scan_rate": {
110
+ "title": "Scan rate [mV/s]",
111
+ "param": "meas.scan_rate",
112
+ "type": "dataset"
113
+ },
114
+ "atmosphere": {
115
+ "title": "Gas",
116
+ "param": "set.atmosphere",
117
+ "type": "dataset"
118
+ },
119
+ "scan_number": {
120
+ "title": "Scan number",
121
+ "param": "meas.cycles",
122
+ "type": "dataset"
123
+ },
124
+ "we": {
125
+ "title": "Working electrode",
126
+ "param": "electrodes.working",
127
+ "type": "dataset"
128
+ },
129
+ "we_area": {
130
+ "title": "Working electrode surface area",
131
+ "param": "electrodes.working_area",
132
+ "type": "dataset"
133
+ },
134
+ "ce": {
135
+ "title": "Counter electrode",
136
+ "param": "electrodes.counter",
137
+ "type": "dataset"
138
+ },
139
+ "re": {
140
+ "title": "Reference electrode",
141
+ "param": "electrodes.reference",
142
+ "type": "dataset"
143
+ },
144
+ "voltage_limit_one": {
145
+ "title": "Potential window",
146
+ "param": "meas.voltage_limit_one",
147
+ "type": "dataset"
148
+ },
149
+ "voltage_limit_two": {
150
+ "title": "Potential window",
151
+ "param": "meas.voltage_limit_two",
152
+ "type": "dataset"
153
+ },
154
+ "reference_internal": {
155
+ "title": "Internal reference compound_inchikey",
156
+ "param": "meas.reference_internal",
157
+ "type": "dataset"
158
+ },
159
+ "elect_inchikey": {
160
+ "title": "Electrolyte_inchikey",
161
+ "param": "sample_preparation.salt",
162
+ "type": "dataset"
163
+ },
164
+ "elect_concentration": {
165
+ "title": "Electrolyte concentration [M]",
166
+ "param": "sample_preparation.concentration_salt",
167
+ "type": "dataset"
168
+ },
169
+ "solvent": {
170
+ "title": "Solvent A_inchikey",
171
+ "param": "sample_preparation.solvent",
172
+ "type": "dataset"
173
+ },
174
+ "solvent_volume": {
175
+ "title": "Solvent volume [ml]",
176
+ "param": "sample_preparation.amount_sol",
177
+ "type": "dataset"
178
+ },
179
+ "solvent_molfile": {
180
+ "title": "Solvent A_molfile",
181
+ "param": "n/a",
182
+ "type": "string"
183
+ },
184
+ "scan_direction": {
185
+ "title": "Scan direction",
186
+ "param": "n/a",
187
+ "type": "string"
188
+ },
189
+ "reference_internal_compound_molfile": {
190
+ "title": "Internal reference compound_molfile",
191
+ "param": "n/a",
192
+ "type": "string"
193
+ },
194
+ "elect_purity": {
195
+ "title": "Electrolyte purity [%]",
196
+ "param": "n/a",
197
+ "type": "string"
198
+ },
199
+ "redox": {
200
+ "title": "Redox-Potential",
201
+ "param": 6,
202
+ "type": "spc"
203
+ },
204
+ "elect_molfile": {
205
+ "title": "Electrolyte_inchikey",
206
+ "param": "n/a",
207
+ "type": "string"
208
+ },
209
+ "inchikey": {
210
+ "title": "Analyte_inchikey",
211
+ "param": "inchikey",
212
+ "type": "molecule"
213
+ },
214
+ "molfile": {
215
+ "title": "Analyte_molfile",
216
+ "param": "molfile",
217
+ "type": "sample"
218
+ },
219
+ "details": {
220
+ "title": "Details",
221
+ "param": "n/a",
222
+ "type": "string"
223
+ },
224
+ "includes": {
225
+ "title": "Included",
226
+ "param": "n/a",
227
+ "type": "string"
228
+ },
229
+ "base_page": {
230
+ "title": "BasePageName",
231
+ "param": "n/a",
232
+ "type": "string"
233
+ }
234
+ }
235
+ }
236
+ }
@@ -0,0 +1,78 @@
1
+ {
2
+ "sourceMap": {
3
+ "sourceSelector": [
4
+ "parm",
5
+ "acqus",
6
+ "procs"
7
+ ],
8
+ "acqus": {
9
+ "file": "acqus",
10
+ "parameters": [
11
+ "DATE",
12
+ "D1",
13
+ "INSTRUM",
14
+ "NS",
15
+ "NUC1",
16
+ "NUC2",
17
+ "PROBHD",
18
+ "PULPROG",
19
+ "SFO1",
20
+ "SFO2",
21
+ "SOLVENT",
22
+ "SW",
23
+ "TD",
24
+ "TE",
25
+ "TITLE"
26
+ ]
27
+ },
28
+ "procs": {
29
+ "file": "pdata/1/procs",
30
+ "parameters": [
31
+ "SI",
32
+ "SF",
33
+ "WDW",
34
+ "LB",
35
+ "GB"
36
+ ]
37
+ },
38
+ "parm": {
39
+ "file": "pdata/1/parm.txt",
40
+ "parameters": [
41
+ "Date_",
42
+ "Time",
43
+ "INSTRUM",
44
+ "PROBHD",
45
+ "SOLVENT",
46
+ "TE",
47
+ "NS",
48
+ "PULPROG",
49
+ "TD",
50
+ "D1",
51
+ "SF",
52
+ "SFO1",
53
+ "SFO2",
54
+ "NUC1",
55
+ "NUC2"
56
+ ]
57
+ },
58
+ "parameters": {
59
+ "DATE": "general.date",
60
+ "D1": "set.done",
61
+ "INSTRUM": "instrument.instrument",
62
+ "NS": "set.ns",
63
+ "NUC1": "set.nucone",
64
+ "NUC2": "set.nuctwo",
65
+ "SF": "set.sf",
66
+ "SFO1": "set.sfoone",
67
+ "SFO2": "set.sfotwo",
68
+ "PROBHD": "equipment.probehead",
69
+ "PULPROG": "set.PULPROG",
70
+ "SOLVENT": "sample_preparation.solvent",
71
+ "TD": "set.td",
72
+ "TE": "set.temperature",
73
+ "TITLE": "software.Name",
74
+ "Version": "software.Version",
75
+ "Time": "general.time"
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'labimotion/utils/utils'
4
+ require 'labimotion/version'
5
+
6
+ module Labimotion
7
+ class DatasetBuilder
8
+ def self.build(container, content)
9
+ return unless valid_input?(container, content)
10
+
11
+ create_dataset_with_metadata(container, content)
12
+ end
13
+
14
+ private
15
+
16
+ def self.valid_input?(container, content)
17
+ container.present? &&
18
+ content.present? &&
19
+ content[:ols].present? &&
20
+ content[:metadata].present?
21
+ end
22
+
23
+ def self.create_dataset_with_metadata(container, content)
24
+ klass = find_dataset_klass(content[:ols])
25
+ return unless klass
26
+
27
+ dataset = create_dataset(container, klass)
28
+ build_result(dataset, content)
29
+ end
30
+
31
+ def self.find_dataset_klass(ols_term_id)
32
+ Labimotion::DatasetKlass.find_by(ols_term_id: ols_term_id)
33
+ end
34
+
35
+ def self.create_dataset(container, klass)
36
+ uuid = SecureRandom.uuid
37
+ props = prepare_properties(klass, uuid)
38
+
39
+ Labimotion::Dataset.create!(
40
+ uuid: uuid,
41
+ dataset_klass_id: klass.id,
42
+ element_type: 'Container',
43
+ element_id: container.id,
44
+ properties: props,
45
+ properties_release: klass.properties_release,
46
+ klass_uuid: klass.uuid
47
+ )
48
+ end
49
+
50
+ def self.prepare_properties(klass, uuid)
51
+ props = klass.properties_release
52
+ props['uuid'] = uuid
53
+ props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
54
+ props['klass'] = 'Dataset'
55
+ props
56
+ end
57
+
58
+ def self.build_result(dataset, content)
59
+ {
60
+ dataset: dataset,
61
+ metadata: content[:metadata],
62
+ ols: content[:ols],
63
+ parameters: content[:parameters]
64
+ }
65
+ end
66
+
67
+ private_class_method :valid_input?, :create_dataset_with_metadata, :find_dataset_klass, :create_dataset,
68
+ :prepare_properties, :build_result
69
+ end
70
+ end