labimotion 1.5.0.rc6 → 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: 1a8123a3e71db321a6b3efef15ecce3cca9e287bce32a268b5447c25dd6ed55d
4
- data.tar.gz: 36b88fb09d16d5ac4bc2a8eeae2775d20c9197d871e48df5e6dacc34b2934e23
3
+ metadata.gz: 933a7ef2942093d53c89df803dd802efeb4f0a0241193de7094d51c26fcfa8ff
4
+ data.tar.gz: 5792273bc537ccf951ee3c7ab5ef575f23079b63acc8ce3f2d923fb445181d26
5
5
  SHA512:
6
- metadata.gz: 7695e71a516c3fba35fdae8cdb4d4b0081d4ca4da3802eb8703e43189a2dbbdbbe85413650a4d3699f262d9eeb92e6199f87a10a97a52aa7eb0927fab688e536
7
- data.tar.gz: cb9a7de785d9ddecd6d69d0be45b9323a08c5227cdf7c0e4ed1db2063aaa47b306045534d30a9c5daa5d8c83624b642418badea4810cc9e9fd49a35f6700a753
6
+ metadata.gz: 2b50364418e278a654814ef2afa8c29bf2c9a2a1d4d134fb690573e317676b2fe9cdfa2afbc5cce8d65a5317fcf45a7f7a427791c36b19cc3f4d85a043055048
7
+ data.tar.gz: 04a7949b73b943642f8c2e4e4541d4ee3695e27aded5fc447818c5bfaefd2ba8ced4626f9bd045eef9765fe75c7d5f42016f1afe2b202cd0454bcd5be89c94fe
@@ -14,53 +14,77 @@ module Labimotion
14
14
  end
15
15
 
16
16
 
17
- def root_element
18
- object&.element&.root_element
19
- end
17
+ # def root_element
18
+ # object&.element&.root_element
19
+ # end
20
20
 
21
- def properties
22
- properties = object&.properties || {}
23
- properties[Labimotion::Prop::LAYERS].keys.each do |key|
24
- layer = properties[Labimotion::Prop::LAYERS][key] || {}
25
- return properties if layer.empty? || layer[Labimotion::Prop::FIELDS].nil?
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
26
 
27
- field_vocs = layer[Labimotion::Prop::FIELDS].select { |ss| ss['is_voc'] == true }
28
- field_vocs.each do |field|
29
- idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
30
- next if idx.nil?
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
31
 
32
- case field['source']
33
- when Labimotion::Prop::ELEMENT
34
- if field['identifier'] == 'element.name'
35
- byebug
36
- properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = root_element&.name
37
- # dic[field.identifier] = currentElement.name
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
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?
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
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
- properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = seg_field['value']
48
- when Labimotion::Prop::DATASET
49
- byebug
50
- end
51
- end
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
52
68
 
53
- # layer[Labimotion::Prop::FIELDS].each do |field|
54
- # end
55
- end
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
56
76
 
57
- # byebug
58
- # layers = properties['layers']
77
+ # # layer[Labimotion::Prop::FIELDS].each do |field|
78
+ # # end
79
+ # end
59
80
 
60
- # properties['vocabularies'].each_with_object({}) do |v, h|
61
- # h[v['name']] = v['value']
62
- # end
63
- properties
64
- end
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
65
89
  end
66
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
@@ -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.rc6'
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.rc6
4
+ version: 1.5.0.rc7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chia-Lin Lin