labimotion 1.4.0.rc1 → 1.4.0.rc3

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: 04e8244e35f9f07197148e331748e527451dae61be8352729f04b9e7be923e6f
4
- data.tar.gz: 334b4f9d71132b30884e522a38cc11e770048d20d8ff4e34bc0f60ddaf45d3df
3
+ metadata.gz: a0e43bc1bdccd36b76e3c357c88b148f6af58a422ac15967b51018ad68cc570c
4
+ data.tar.gz: bf7e9b0ea4e21736bd9a71cca94b32f02c3d2eed96a1188c07a97be3e11a25f4
5
5
  SHA512:
6
- metadata.gz: faf260b294017c7b504aa9eef458736d1076cd5f7198ba15b073f593bc5649d7c6bf892bf9deb3be449ee51ffb3b44b4936719eb1134353fdf9a4535f1d1f9ad
7
- data.tar.gz: 5ca488c82012a85bdf51b37c2210ce0a9171935b387a1e6cd31ac8008398be89539c43d1c5f42825834aa013f65b5ae31de14e25d745c505fc361f5e66b5e314
6
+ metadata.gz: b64d866c7f796c327b3a3f37b7ac5883a1e4ce8e604b0280dc3f47ea300ebbfb82251ea2e42ac2315377d24453f4323de13d10a6a6a85bd6fdf1f57671431d24
7
+ data.tar.gz: 90d185c4806b9e9f10ace66612bad2eb1e31d268a517890c01dd1304fcb53c1b42ef2433a2960d0da53e5c910c7fd8b526c6d4057845f394f663fd148d9e0e2b
@@ -23,7 +23,7 @@ module Labimotion
23
23
 
24
24
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_label'] = el.short_label if field['type'] == Labimotion::FieldType::DRAG_SAMPLE
25
25
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_tip'] = el.short_label if field['type'] == Labimotion::FieldType::DRAG_SAMPLE
26
- object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el.molecule_svg_file)
26
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el&.molecule_svg_file || 'nosvg')
27
27
  end
28
28
 
29
29
  field_tables = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::TABLE }
@@ -41,7 +41,7 @@ module Labimotion
41
41
  find_mol = Molecule.find_by(id: sub_value[col_id]['value']['el_id'])
42
42
  next unless find_mol.present?
43
43
 
44
- sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_mol.molecule_svg_file)
44
+ sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_mol.molecule_svg_file) if find_mol&.molecule_svg_file&.present?
45
45
  sub_value[col_id]['value']['el_inchikey'] = find_mol.inchikey
46
46
  sub_value[col_id]['value']['el_smiles'] = find_mol.cano_smiles
47
47
  sub_value[col_id]['value']['el_iupac'] = find_mol.iupac_name
@@ -47,7 +47,7 @@ module Labimotion
47
47
  el.short_label
48
48
  end
49
49
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] =
50
- field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el.molecule_svg_file)
50
+ field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el&.molecule_svg_file || 'nosvg')
51
51
  end
52
52
 
53
53
  field_tables = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::TABLE }
@@ -88,7 +88,7 @@ module Labimotion
88
88
 
89
89
  case obj
90
90
  when Labimotion::Prop::MOLECULE
91
- sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_obj.molecule_svg_file)
91
+ sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_obj.molecule_svg_file) if find_obj&.molecule_svg_file&.present?
92
92
  sub_value[col_id]['value']['el_inchikey'] = find_obj.inchikey
93
93
  sub_value[col_id]['value']['el_smiles'] = find_obj.cano_smiles
94
94
  sub_value[col_id]['value']['el_iupac'] = find_obj.iupac_name
@@ -20,7 +20,27 @@ module Labimotion
20
20
 
21
21
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_label'] = el.short_label if field['type'] == Labimotion::FieldType::DRAG_SAMPLE
22
22
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_tip'] = el.short_label if field['type'] == Labimotion::FieldType::DRAG_SAMPLE
23
- object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el.molecule_svg_file)
23
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el&.molecule_svg_file || 'nosvg')
24
+ end
25
+
26
+ field_sys_reactions = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::SYS_REACTION }
27
+ field_sys_reactions.each do |field|
28
+ idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
29
+ sid = field.dig('value', 'el_id')
30
+ next unless sid.present?
31
+
32
+ el = Reaction.find_by(id: sid)
33
+ if el.blank?
34
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_tip'] = 'ERROR'
35
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = ''
36
+ end
37
+
38
+ next unless el.present?
39
+ next unless object.properties.dig(Labimotion::Prop::LAYERS, key, Labimotion::Prop::FIELDS, idx, 'value').present?
40
+
41
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_label'] = el.short_label
42
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_tip'] = el.short_label
43
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = el.reaction_svg_file
24
44
  end
25
45
 
26
46
  field_tables = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::TABLE }
@@ -49,7 +69,7 @@ module Labimotion
49
69
 
50
70
  case obj
51
71
  when Labimotion::Prop::MOLECULE
52
- sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_obj.molecule_svg_file)
72
+ sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_obj.molecule_svg_file) if find_obj&.molecule_svg_file&.present?
53
73
  sub_value[col_id]['value']['el_inchikey'] = find_obj.inchikey
54
74
  sub_value[col_id]['value']['el_smiles'] = find_obj.cano_smiles
55
75
  sub_value[col_id]['value']['el_iupac'] = find_obj.iupac_name
@@ -22,7 +22,7 @@ module Labimotion
22
22
 
23
23
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_label'] = el.short_label if field['type'] == Labimotion::FieldType::DRAG_SAMPLE
24
24
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_tip'] = el.short_label if field['type'] == Labimotion::FieldType::DRAG_SAMPLE
25
- object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el.molecule_svg_file)
25
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el&.molecule_svg_file || 'nosvg')
26
26
  end
27
27
 
28
28
  field_tables = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::TABLE }
@@ -40,7 +40,7 @@ module Labimotion
40
40
  find_mol = Molecule.find_by(id: sub_value[col_id]['value']['el_id'])
41
41
  next unless find_mol.present?
42
42
 
43
- sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_mol.molecule_svg_file)
43
+ sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_mol.molecule_svg_file) if find_mol&.molecule_svg_file&.present?
44
44
  sub_value[col_id]['value']['el_inchikey'] = find_mol.inchikey
45
45
  sub_value[col_id]['value']['el_smiles'] = find_mol.cano_smiles
46
46
  sub_value[col_id]['value']['el_iupac'] = find_mol.iupac_name
@@ -91,6 +91,20 @@ module Labimotion
91
91
  obj_final = OpenStruct.new(obj_os)
92
92
  field_obj[:structure] = Reporter::Docx::DiagramSample.new(obj: obj_final, format: 'png').generate
93
93
  end
94
+ when Labimotion::FieldType::SYS_REACTION
95
+ val = field.fetch('value', nil)
96
+ if val.present?
97
+ instance = Reaction.find_by(id: val['el_id'])
98
+ field_obj[:value] = val['el_label']
99
+ field_obj[:has_structure] = true
100
+ obj_os = Entities::ReactionReportEntity.new(
101
+ instance,
102
+ current_user: @current_user,
103
+ detail_levels: ElementDetailLevelCalculator.new(user: @current_user, element: instance).detail_levels,
104
+ ).serializable_hash
105
+ obj_final = OpenStruct.new(obj_os)
106
+ field_obj[:structure] = Reporter::Docx::DiagramReaction.new(obj: obj_final, format: 'png').generate
107
+ end
94
108
  when Labimotion::FieldType::DRAG_MOLECULE
95
109
  val = field.fetch('value', nil)
96
110
  if val.present?
@@ -20,6 +20,8 @@ module Labimotion
20
20
  case name
21
21
  when Labimotion::FieldType::DRAG_ELEMENT
22
22
  Labimotion::Prop::L_ELEMENT
23
+ when Labimotion::FieldType::SYS_REACTION
24
+ Labimotion::Prop::REACTION
23
25
  when Labimotion::FieldType::DRAG_SAMPLE
24
26
  Labimotion::Prop::SAMPLE
25
27
  when Labimotion::FieldType::DRAG_MOLECULE
@@ -167,6 +169,7 @@ module Labimotion
167
169
  properties[Labimotion::Prop::LAYERS].keys.each do |key|
168
170
  properties = set_seg_prop(properties, uuids, key, Labimotion::FieldType::DRAG_ELEMENT)
169
171
  properties = set_seg_prop(properties, uuids, key, Labimotion::FieldType::DRAG_SAMPLE)
172
+ properties = set_seg_prop(properties, uuids, key, Labimotion::FieldType::SYS_REACTION)
170
173
  end
171
174
  segment['properties'] = properties
172
175
  segment
@@ -183,6 +186,7 @@ module Labimotion
183
186
  properties = set_prop(properties, uuids, key, Labimotion::FieldType::DRAG_ELEMENT, &fetch_one)
184
187
  properties = set_prop(properties, uuids, key, Labimotion::FieldType::DRAG_MOLECULE, &fetch_one)
185
188
  properties = set_prop(properties, uuids, key, Labimotion::FieldType::DRAG_SAMPLE, &fetch_one)
189
+ properties = set_prop(properties, uuids, key, Labimotion::FieldType::SYS_REACTION, &fetch_one)
186
190
  properties, attachments = set_upload(instance, properties, attachments, uuids, key, Labimotion::FieldType::UPLOAD, &fetch_one)
187
191
  properties = set_table(properties, uuids, key, Labimotion::FieldType::TABLE, &fetch_one)
188
192
  end
@@ -11,13 +11,14 @@ module Labimotion
11
11
  WF_NEXT = 'wf-next'.freeze
12
12
  TEXT_FORMULA = 'text-formula'.freeze
13
13
  SYSTEM_DEFINED = 'system-defined'.freeze
14
+ SYS_REACTION = 'sys-reaction'.freeze
14
15
  DRAG = 'drag'.freeze
15
16
  DRAG_ELEMENT = 'drag_element'.freeze
16
17
  DRAG_MOLECULE = 'drag_molecule'.freeze
17
18
  DRAG_SAMPLE = 'drag_sample'.freeze
18
19
  DRAG_REACTION = 'drag_reaction'.freeze
19
20
  DRAG_MS = [DRAG_MOLECULE, DRAG_SAMPLE].freeze
20
- DRAG_ALL = [DRAG_ELEMENT, DRAG_MOLECULE, DRAG_SAMPLE, DRAG_REACTION].freeze
21
+ DRAG_ALL = [DRAG_ELEMENT, DRAG_MOLECULE, DRAG_SAMPLE, DRAG_REACTION, SYS_REACTION].freeze
21
22
  TABLE = 'table'.freeze
22
23
  UPLOAD = 'upload'.freeze
23
24
  TEXT = 'text'.freeze
@@ -24,7 +24,7 @@ module Labimotion
24
24
  value['el_id'] = molecule.id
25
25
  value['el_tip'] = "#{molecule.inchikey}@@#{molecule.cano_smiles}"
26
26
  value['el_label'] = molecule.iupac_name
27
- value['el_svg'] = File.join('/images', 'molecules', molecule.molecule_svg_file)
27
+ value['el_svg'] = File.join('/images', 'molecules', molecule&.molecule_svg_file) if molecule&.molecule_svg_file.present?
28
28
  value['el_inchikey'] = molecule.inchikey
29
29
  value['el_smiles'] = molecule.cano_smiles
30
30
  value['el_type'] = 'molecule' if value['el_type'].nil?
@@ -51,6 +51,21 @@ module Labimotion
51
51
  value
52
52
  end
53
53
 
54
+ def proc_assign_reaction(value, reaction)
55
+ return {} if reaction.nil?
56
+
57
+ value = {} if value.nil? || value.is_a?(String)
58
+ value['el_id'] = reaction.id
59
+ value['el_type'] = 'reaction' if value['el_type'].nil?
60
+ value['el_tip'] = reaction.short_label
61
+ value['el_label'] = reaction.short_label
62
+ value['el_svg'] = reaction.reaction_svg_file
63
+ value
64
+ rescue StandardError => e
65
+ Labimotion.log_exception(e)
66
+ value
67
+ end
68
+
54
69
  def proc_assign_element(value, element)
55
70
  return {} if element.nil?
56
71
 
@@ -136,6 +151,22 @@ module Labimotion
136
151
  end
137
152
  end
138
153
 
154
+ def self.proc_reaction(layer, key, data, instances, properties)
155
+ fields = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::SYS_REACTION }
156
+ fields.each do |field|
157
+ idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
158
+ id = field["value"] && field["value"]["el_id"] unless idx.nil?
159
+ reaction = instances.fetch(Labimotion::Prop::REACTION, nil)&.fetch(id, nil)
160
+ val = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']
161
+ val = proc_assign_reaction(val, reaction)
162
+ properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = val
163
+ end
164
+ properties
165
+ rescue StandardError => e
166
+ Labimotion.log_exception(e)
167
+ properties
168
+ end
169
+
139
170
  def self.proc_sample(layer, key, data, instances, properties)
140
171
  fields = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_SAMPLE }
141
172
  fields.each do |field|
@@ -149,7 +180,7 @@ module Labimotion
149
180
  properties
150
181
  rescue StandardError => e
151
182
  Labimotion.log_exception(e)
152
- raise
183
+ properties
153
184
  end
154
185
 
155
186
  def self.proc_element(layer, key, data, instances, properties, elements)
@@ -169,7 +200,7 @@ module Labimotion
169
200
  properties
170
201
  rescue StandardError => e
171
202
  Labimotion.log_exception(e)
172
- raise
203
+ properties
173
204
  end
174
205
 
175
206
  def self.proc_upload(layer, key, data, instances, attachments, element)
@@ -221,7 +252,7 @@ module Labimotion
221
252
  properties
222
253
  rescue StandardError => e
223
254
  Labimotion.log_exception(e)
224
- raise
255
+ properties
225
256
  end
226
257
 
227
258
 
@@ -237,7 +268,7 @@ module Labimotion
237
268
  properties
238
269
  rescue StandardError => e
239
270
  Labimotion.log_exception(e)
240
- raise
271
+ properties
241
272
  end
242
273
 
243
274
  def self.properties_handler(data, instances, attachments, elmenet, elements)
@@ -246,6 +277,7 @@ module Labimotion
246
277
  layer = properties[Labimotion::Prop::LAYERS][key]
247
278
  properties = proc_molecule(layer, key, data, properties)
248
279
  properties = proc_upload(layer, key, data, instances, attachments, elmenet)
280
+ properties = proc_reaction(layer, key, data, instances, properties)
249
281
  properties = proc_sample(layer, key, data, instances, properties)
250
282
  properties = proc_element(layer, key, data, instances, properties, elements) # unless elements.nil?
251
283
  properties = proc_table(layer, key, data, instances, properties)
@@ -253,7 +285,7 @@ module Labimotion
253
285
  properties
254
286
  rescue StandardError => e
255
287
  Labimotion.log_exception(e)
256
- raise
288
+ properties
257
289
  end
258
290
 
259
291
  def self.process_ai(data, instances)
@@ -272,7 +304,7 @@ module Labimotion
272
304
  end
273
305
  rescue StandardError => e
274
306
  Labimotion.log_exception(e)
275
- raise
307
+ properties
276
308
  end
277
309
 
278
310
  def self.create_segment_klass(sk_obj, segment_klass, element_klass, current_user_id)
@@ -13,7 +13,7 @@ module Labimotion
13
13
 
14
14
  case obj
15
15
  when Labimotion::Prop::MOLECULE
16
- sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_obj.molecule_svg_file)
16
+ sub_value[col_id]['value']['el_svg'] = File.join('/images', 'molecules', find_obj.molecule_svg_file) if find_obj&.molecule_svg_file&.present?
17
17
  sub_value[col_id]['value']['el_inchikey'] = find_obj.inchikey
18
18
  sub_value[col_id]['value']['el_smiles'] = find_obj.cano_smiles
19
19
  sub_value[col_id]['value']['el_iupac'] = find_obj.iupac_name
@@ -56,7 +56,7 @@ module Labimotion
56
56
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_tip'] = el.short_label if %w[drag_sample].include?(field['type'])
57
57
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_tip'] = "#{el.element_klass&.label}@@#{el.name}" if %w[drag_element].include?(field['type'])
58
58
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['icon_name'] = el.element_klass&.icon_name || '' if %w[drag_element].include?(field['type'])
59
- object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el.molecule_svg_file) if Labimotion::FieldType::DRAG_MS.include?(field['type'])
59
+ object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el&.molecule_svg_file || 'nosvg') if Labimotion::FieldType::DRAG_MS.include?(field['type'])
60
60
  object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_decoupled'] = el.decoupled if %w[drag_sample].include?(field['type'])
61
61
  end
62
62
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
- VERSION = '1.4.0.rc1'
5
+ VERSION = '1.4.0.rc3'
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.4.0.rc1
4
+ version: 1.4.0.rc3
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-05-16 00:00:00.000000000 Z
12
+ date: 2024-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails