labimotion 1.5.0.rc5 → 1.5.0.rc7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5793040329800aeaa72a6b597114ecd08ff86abbc1605ad857b2c2a6dbfb68ae
4
- data.tar.gz: 4fbe879e2477760252774d845d3d11ada757876ccc35ad8f941ed80497e25e80
3
+ metadata.gz: 933a7ef2942093d53c89df803dd802efeb4f0a0241193de7094d51c26fcfa8ff
4
+ data.tar.gz: 5792273bc537ccf951ee3c7ab5ef575f23079b63acc8ce3f2d923fb445181d26
5
5
  SHA512:
6
- metadata.gz: f01ebd2e1452d4ad4f0d3c51dac92effbf6457c83e161e54533a04f0ca3a5c7ec2b8c0ed97f551bd1f3b88187a7aa01d207d8e07299f170887a9819f8699166c
7
- data.tar.gz: f1b02f0cb7f5e810c9a4a08d03a2c8201a9897497dac5962b789c7a29af4ff36a8a846c6a413db7896a8b8b2e9f78c6eba839cb8c1d0629e562a0e7d51b95467
6
+ metadata.gz: 2b50364418e278a654814ef2afa8c29bf2c9a2a1d4d134fb690573e317676b2fe9cdfa2afbc5cce8d65a5317fcf45a7f7a427791c36b19cc3f4d85a043055048
7
+ data.tar.gz: 04a7949b73b943642f8c2e4e4541d4ee3695e27aded5fc447818c5bfaefd2ba8ced4626f9bd045eef9765fe75c7d5f42016f1afe2b202cd0454bcd5be89c94fe
@@ -12,5 +12,79 @@ module Labimotion
12
12
  def klass_label
13
13
  object&.dataset_klass&.label
14
14
  end
15
+
16
+
17
+ # def root_element
18
+ # object&.element&.root_element
19
+ # end
20
+
21
+ # def properties
22
+ # prop = object&.properties || {}
23
+ # prop[Labimotion::Prop::LAYERS].keys.each do |key|
24
+ # layer = prop[Labimotion::Prop::LAYERS][key] || {}
25
+ # return prop if layer.empty? || layer[Labimotion::Prop::FIELDS].nil?
26
+
27
+ # field_vocs = layer[Labimotion::Prop::FIELDS].select { |ss| ss['is_voc'] == true }
28
+ # field_vocs.each do |field|
29
+ # idx = prop[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
30
+ # next if idx.nil?
31
+
32
+ # case field['source']
33
+ # when Labimotion::Prop::ELEMENT
34
+ # if field['identifier'] == 'element.name'
35
+ # # byebug
36
+ # prop[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = root_element&.name
37
+ # # dic[field.identifier] = currentElement.name
38
+
39
+ # end
40
+ # when Labimotion::Prop::SEGMENT
41
+ # segs = root_element&.segments&.select { |ss| field['source_id'] == ss.segment_klass&.identifier }
42
+ # next if segs.empty? || field['layer_id'].blank? || field['field_id'].blank?
43
+
44
+ # seg = segs&.first
45
+ # seg_fields = seg.properties.dig(Labimotion::Prop::LAYERS, field['layer_id'], Labimotion::Prop::FIELDS).select { |ff| ff['field'] == field['field_id'] }
46
+ # seg_field = seg_fields&.first
47
+ # prop[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = seg_field['value']
48
+ # when Labimotion::Prop::DATASET
49
+ # # byebug
50
+ # dk = DatasetKlass.find_by(identifier: field["source_id"])
51
+ # dk["ols_term_id"]
52
+ # # byebug
53
+ # # sel_ana = root_element.analyses.select { |ana| ana.extended_metadata["kind"].split("|")&.first&.strip == dk["ols_term_id"] }
54
+ # anas = root_element.analyses.select { |ana| ana.extended_metadata["kind"].split("|")&.first&.strip == dk["ols_term_id"] }
55
+ # anas.each do |ana|
56
+ # cdss = ana.children
57
+ # cdss.each do |cds|
58
+ # next unless cds.dataset.present?
59
+ # ds_prop = cds.dataset.properties
60
+ # ds_fields = ds_prop.dig(Labimotion::Prop::LAYERS, field['layer_id'], Labimotion::Prop::FIELDS).select { |ff| ff['field'] == field['field_id'] }
61
+ # ds_field = ds_fields&.first
62
+ # # byebug
63
+ # if prop[Labimotion::Prop::LAYERS][key].present? && ds_field['value'].present?
64
+ # prop[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = ds_field['value']
65
+ # end
66
+ # end
67
+ # end
68
+
69
+ # # sel_ana.dataset
70
+ # # if root_element.analyses&.first&.extended_metadata["kind"].split("|")&.first&.strip == dk["ols_term_id"]
71
+ # # byebug
72
+ # # end
73
+ # # root_element.analyses.select { |ss| ss.dataset_klass_id == dk.id }
74
+ # end
75
+ # end
76
+
77
+ # # layer[Labimotion::Prop::FIELDS].each do |field|
78
+ # # end
79
+ # end
80
+
81
+ # # byebug
82
+ # # layers = properties['layers']
83
+
84
+ # # properties['vocabularies'].each_with_object({}) do |v, h|
85
+ # # h[v['name']] = v['value']
86
+ # # end
87
+ # prop
88
+ # end
15
89
  end
16
90
  end
@@ -7,27 +7,7 @@ module Labimotion
7
7
  # TODO: Refactor this method to something more readable/understandable
8
8
  def properties
9
9
  (object&.properties.is_a?(Hash) && object.properties[Labimotion::Prop::LAYERS]&.keys || []).each do |key|
10
- # layer = object.properties[key]
11
-
12
- # field_vocabularies = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['is_voc'] == true}
13
- # field_vocabularies.each do |field|
14
- # idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
15
- # if field['identifier'] == '7c30cd4f-aef4-433a-946e-d0f81f8918f1'
16
- # if properties['klass'] == 'Dataset'
17
- # container = object&.element_type.constantize.find_by(id: object&.element_id)
18
- # element = container.root.containable
19
- # if field['source'] == 'Segment'
20
- # byebug
21
- # segments = element.segments.joins(:segment_klass).find_by('segment_klasses.identifier = ?', field['source_id'])
22
- # seg_prop = segments.properties
23
- # fields = seg_prop[Labimotion::Prop::LAYERS][field['layer_id']][Labimotion::Prop::FIELDS].select { |ss| ss['field'] == field['field_id'] }
24
- # val = fields.first['value']
25
- # object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = val
26
- # end
27
- # end
28
- # # object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = Time.now.strftime('%d/%m/%Y %H:%M')
29
- # end
30
- # end
10
+
31
11
 
32
12
  field_sample_molecules = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_SAMPLE || ss['type'] == Labimotion::FieldType::DRAG_MOLECULE }
33
13
  field_sample_molecules.each do |field|
@@ -75,6 +55,53 @@ module Labimotion
75
55
  field_table_samples = field[Labimotion::Prop::SUBFIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_SAMPLE }
76
56
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx] = set_table(field, field_table_samples, Labimotion::Prop::SAMPLE) if field_table_samples.present?
77
57
  end
58
+
59
+ field_vocs = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['is_voc'] == true }
60
+ field_vocs.each do |field|
61
+ idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
62
+ next if idx.nil?
63
+
64
+ case object.class.name
65
+ when Labimotion::Prop::L_ELEMENT
66
+ root_element = object
67
+ when Labimotion::Prop::L_SEGMENT
68
+ root_element = object&.element
69
+ when Labimotion::Prop::L_DATASET
70
+ root_element = object&.element&.root_element
71
+ end
72
+
73
+ case field['source']
74
+ when Labimotion::Prop::ELEMENT
75
+ if field['identifier'] == 'element.name'
76
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = root_element&.name
77
+ end
78
+ when Labimotion::Prop::SEGMENT
79
+ segs = root_element&.segments&.select { |ss| field['source_id'] == ss.segment_klass&.identifier }
80
+ next if segs.empty? || field['layer_id'].blank? || field['field_id'].blank?
81
+
82
+ seg = segs&.first
83
+ seg_fields = seg.properties.dig(Labimotion::Prop::LAYERS, field['layer_id'], Labimotion::Prop::FIELDS).select { |ff| ff['field'] == field['field_id'] }
84
+ seg_field = seg_fields&.first
85
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = seg_field['value']
86
+ when Labimotion::Prop::DATASET
87
+ dk = DatasetKlass.find_by(identifier: field["source_id"])
88
+ dk["ols_term_id"]
89
+ anas = root_element.analyses.select { |ana| ana.extended_metadata["kind"].split("|")&.first&.strip == dk["ols_term_id"] }
90
+ anas.each do |ana|
91
+ cdss = ana.children
92
+ cdss.each do |cds|
93
+ next unless cds.dataset.present?
94
+
95
+ ds_prop = cds.dataset.properties
96
+ ds_fields = ds_prop.dig(Labimotion::Prop::LAYERS, field['layer_id'], Labimotion::Prop::FIELDS).select { |ff| ff['field'] == field['field_id'] }
97
+ ds_field = ds_fields&.first
98
+ if object.properties[Labimotion::Prop::LAYERS][key].present? && ds_field['value'].present?
99
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = ds_field['value']
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
78
105
  end
79
106
  object.properties
80
107
  end
@@ -10,5 +10,6 @@ module Labimotion
10
10
  object.segment_klass.label
11
11
  end
12
12
 
13
+
13
14
  end
14
15
  end
@@ -17,7 +17,21 @@ module Labimotion
17
17
  # end
18
18
 
19
19
  expose :voc do |obj|
20
- (obj[:properties] && obj[:properties]['voc']) || {}
20
+ ## byebug
21
+ voc = (obj[:properties] && obj[:properties]['voc']) || {}
22
+
23
+ case voc['source']
24
+ when Labimotion::Prop::ELEMENT
25
+ if voc['identifier'] == 'element.name'
26
+ # byebug
27
+ # voc['source_name'] = ElementKlass.find_by(identifier: voc['source_id'])&.name
28
+ end
29
+ when Labimotion::Prop::SEGMENT
30
+ voc['source_name'] = SegmentKlass.find_by(identifier: voc['source_id'])&.label
31
+ when Labimotion::Prop::DATASET
32
+ voc['source_name'] = DatasetKlass.find_by(identifier: voc['source_id'])&.label
33
+ end
34
+ voc
21
35
  end
22
36
  expose :ontology do |obj|
23
37
  (obj[:properties] && obj[:properties]['ontology']) || {}
@@ -5,8 +5,20 @@
5
5
  "name": "Solvent",
6
6
  "label": "NMR Solvent",
7
7
  "field_type": "text",
8
- "opid": 7,
8
+ "opid": 0,
9
9
  "term_id": "NMR:1000330",
10
+ "ontology": {
11
+ "id": "nmrcv:class:http://nmrML.org/nmrCV#NMR:1000330",
12
+ "iri": "http://nmrML.org/nmrCV#NMR:1000330",
13
+ "short_form": "NMR:1000330",
14
+ "label": "NMR solvent",
15
+ "description": [
16
+ "Use Chebi entities here."
17
+ ],
18
+ "ontology_name": "nmrcv",
19
+ "ontology_prefix": "NMRCV",
20
+ "type": "class"
21
+ },
10
22
  "source": "Standard"
11
23
  },
12
24
  {
@@ -17,6 +29,18 @@
17
29
  "field_type": "text",
18
30
  "opid": 0,
19
31
  "term_id": "NMR:1400025",
32
+ "ontology": {
33
+ "id": "nmrcv:class:http://nmrML.org/nmrCV#NMR:1400025",
34
+ "iri": "http://nmrML.org/nmrCV#NMR:1400025",
35
+ "short_form": "NMR:1400025",
36
+ "label": "sample temperature in magnet",
37
+ "description": [
38
+ "def: The temperature of an NMR sample whilst in the magnet of an NMR instrument."
39
+ ],
40
+ "ontology_name": "nmrcv",
41
+ "ontology_prefix": "NMRCV",
42
+ "type": "class"
43
+ },
20
44
  "source": "Standard"
21
45
  }
22
46
  ]
@@ -28,7 +28,7 @@ module Labimotion
28
28
  fields = seg_prop[Labimotion::Prop::LAYERS][field['layer_id']][Labimotion::Prop::FIELDS].select { |ss| ss['field'] == field['field_id'] }
29
29
  val = fields.first['value']
30
30
  when 'Dataset'
31
- byebug
31
+ # byebug
32
32
  end
33
33
  # case field['identifier']
34
34
  # when 'dateTime.now'
@@ -2,5 +2,5 @@
2
2
 
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
- VERSION = '1.5.0.rc5'
5
+ VERSION = '1.5.0.rc7'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: labimotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.rc5
4
+ version: 1.5.0.rc7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chia-Lin Lin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-10-04 00:00:00.000000000 Z
12
+ date: 2024-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails