chemomer 1.1.2.0 → 1.1.4.0

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: cb236931c3d386ec246032d9066286cf5b4b556e3f6014103c39beaa8b728e1f
4
- data.tar.gz: b2595709835c4b5fb85779535f62c53b3149de06071d0537f1630892ad839974
3
+ metadata.gz: 05d88fc3287c84e5301c6bc4b6fbc5fe06a6cc376c9de3583163c9cbc06a2778
4
+ data.tar.gz: e87d30f636285b37a29345ba28badbde0000b741c4364ab153136dcf4c6a4f5c
5
5
  SHA512:
6
- metadata.gz: c8d7b51fa8caf482c6d70b8df2960ad55a73ce4292b1bc720e85d384f4fe719d1a4309468a2fc6551330d20f99a3bdf120278360e48b1b15ffdca5afa173b00f
7
- data.tar.gz: 4c1e44efca972a213f90ac3ee50e1427ea5fa9a2cd17094555886e26eb511c68a43f006893f8b1f62b89a2671f4648b5d6abdf033f668045b5f56bce07e84b80
6
+ metadata.gz: 7749cc4df18b7e548485837812101c5889a9eeea7176778e768b4a15f24c1b2d79e8e6981aa79ea2731edeb491797abae8d1d52d3ebca1330c07e2fd16c14b68
7
+ data.tar.gz: 183d13e57a7e6f98039039c56f761d6f12f31bb3915ee10b71f8b73b46d615f3d8b3971e2a83df95b1871ae36958288a7ce62404d969a605257f53a0995c259c
@@ -9,7 +9,7 @@ env:
9
9
  # Hermetic CI: the engine ref and the oracle corpus ref are pinned,
10
10
  # never floating. Bump these lines deliberately with each engine
11
11
  # ride (the tag carries what changed).
12
- ENGINE_REF: v1.1.2
12
+ ENGINE_REF: v1.1.4
13
13
  CORPUS_REF: v0.3.41
14
14
 
15
15
  jobs:
@@ -144,6 +144,41 @@ module Chemomer
144
144
  raise Error, load_failure(e)
145
145
  end
146
146
 
147
+ # The ABI-v2 surface (chemomer 1.1.3+): the single-crossing RInChI
148
+ # record with the force-equilibrium option bit, and the SMILES
149
+ # reader. Attached on first use — a v1 cdylib keeps the v1 path.
150
+ def record(*names)
151
+ record_bindings[names] ||= attach_record(names)
152
+ end
153
+
154
+ def record_bindings
155
+ @record_bindings ||= {}
156
+ end
157
+
158
+ def attach_record(names)
159
+ guard_readable(names)
160
+ Module.new do
161
+ extend FFI::Library
162
+
163
+ ffi_lib(*names)
164
+ attach_function :chemomer_rinchi_record_from_rxn2, %i[string uint32], :pointer
165
+ attach_function :chemomer_from_smiles, %i[string], :pointer
166
+ attach_function :chemomer_string_free, %i[pointer], :void
167
+ attach_function :chemomer_last_error, [], :pointer
168
+
169
+ def self.last_error
170
+ pointer = chemomer_last_error
171
+ pointer.null? ? nil : pointer.read_string
172
+ end
173
+ end
174
+ rescue FFI::NotFoundError
175
+ raise Error,
176
+ "chemomer: the cdylib does not export the ABI-v2 symbols — " \
177
+ "the record/smiles surface needs chemomer 1.1.3+ (github.com/chemomer/chemomer)"
178
+ rescue LoadError => e
179
+ raise Error, load_failure(e)
180
+ end
181
+
147
182
  # An explicit CHEMOMER_LIB path is one candidate; a missing or
148
183
  # unreadable file deserves the direct message rather than the
149
184
  # loader's. The default soname list is searched by the loader
@@ -5,5 +5,5 @@ module Chemomer
5
5
  # chemomer-py): the chemomer engine release this gem wraps (0.1.0)
6
6
  # plus the gem's own runtime counter (1). An engine bump resets the
7
7
  # counter (0.2.0.1); a runtime-only fix increments it (0.1.0.2).
8
- VERSION = "1.1.2.0"
8
+ VERSION = "1.1.4.0"
9
9
  end
data/lib/chemomer.rb CHANGED
@@ -101,7 +101,32 @@ module Chemomer
101
101
  Rinchi.decode_table(call(bindings, :chemomer_rinchi_decode, rinchi, rauxinfo))
102
102
  end
103
103
 
104
- # The C ABI version of the attached cdylib (1 today).
104
+ # RXNfile → the identity record in one crossing, with the
105
+ # equilibrium option: { "rinchi" =>, "rauxinfo" =>, "rinchikey" =>,
106
+ # "longKey" =>, "webKey" => } — the five lines the v1 export needed
107
+ # five calls for. `force_equilibrium: true` derives the `/d` form
108
+ # and the equilibrium key shapes exactly as the oracle corpus's
109
+ # `forceEquilibrium` cases record. Needs an ABI-v2 cdylib
110
+ # (chemomer 1.1.3+).
111
+ def rinchi_record_from_rxn(rxnfile, force_equilibrium: false)
112
+ bindings = Bindings.record(*lib)
113
+ options = force_equilibrium ? 0x1 : 0x0
114
+ table = call(bindings, :chemomer_rinchi_record_from_rxn2, rxnfile, options)
115
+ keys = %w[rinchi rauxinfo rinchikey longKey webKey]
116
+ keys.zip(table.split("\n")).to_h
117
+ end
118
+
119
+ # SMILES → the derived identifier (the day-1 `smiles.parg` contract:
120
+ # chains, branches, ring closures, organic + bracket atoms, charges,
121
+ # isotopes, explicit H counts, aromatic markers). Needs an ABI-v2
122
+ # cdylib (chemomer 1.1.3+).
123
+ def from_smiles(smiles)
124
+ bindings = Bindings.record(*lib)
125
+ call(bindings, :chemomer_from_smiles, smiles)
126
+ end
127
+
128
+ # The C ABI version of the attached cdylib (2 today; v1 exports
129
+ # unchanged).
105
130
  def ffi_version
106
131
  Bindings.for(*lib).chemomer_ffi_version
107
132
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chemomer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2.0
4
+ version: 1.1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.