rdkit_chem 2025.09.3.2 → 2025.09.3.3

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: eb84e9eb9b23425a697da1935d2a58fde15b5b184f9b0f0605340577f9296f16
4
- data.tar.gz: 3ba3ea75e71cf6f86d82008d297a6409494a09e152b7049077245eb641626eaf
3
+ metadata.gz: 72f1c22f156a06620110c1359f9539c406aa65e0192798ea9b5494883d807fdf
4
+ data.tar.gz: 4d0afc7baa75eb3af77519c140550336fe07d70e0981a32219aa9a0fa21bc98f
5
5
  SHA512:
6
- metadata.gz: f2001ea207f0a2e4484595d27ce3fe5f74d2e0acbf3b58caf204169a09b928542fccabf544a424653175af1e272b73378eaac81db962b26b8ff1ece82219bd43
7
- data.tar.gz: 5c859291de10e2a2355068b3d57619d7e56e3c248c607b3df413d46f4e9fd29437bfc5cc1914fbb70e2daa319da2889b790b2a205c6087a2ebdaf1faffcb6cdd
6
+ metadata.gz: 8d5b69b87e14806643044e1a414a326630517579bb7761e2d3740284dd6662620d6d598b4c7d4d5b2f7a6dc9a185069a347e8e4c38773f65ea651fa5d96f30cb
7
+ data.tar.gz: 959e83ad9e231ea1491b229a56919bccf3a7fec0cafc98a9651e3ecd8c7b5e78da0aaac171fef8fa299f17b52be2a8ea40fa2452b63a052a52445f835ba93f3e
@@ -45,9 +45,10 @@
45
45
  %newobject RDKit::MolOps::adjustQueryProperties;
46
46
 
47
47
  %ignore RDKit::MolOps::detectChemistryProblems;
48
- // Ignore all native sanitizeMol overloads - we provide a custom wrapper below
49
- %ignore RDKit::MolOps::sanitizeMol;
50
48
  %include <GraphMol/MolOps.h>
49
+ // Ignore only the 3-arg overload that uses reference parameters (incompatible with SWIG)
50
+ // This keeps the 1-arg sanitizeMol(RWMol &) available from the header
51
+ %ignore RDKit::MolOps::sanitizeMol(RWMol &,unsigned int &,unsigned int &);
51
52
  %template(BoolPair) std::pair<bool, bool>;
52
53
 
53
54
  %inline %{
@@ -189,9 +189,12 @@ unsigned int getDefaultPickleProperties();
189
189
  return res;
190
190
  }
191
191
 
192
- /* Used in the addConformer modifications described above */
193
- unsigned int RDKit::ROMol::addConf(RDKit::Conformer * ownedConf, bool assignId=false) {
194
- return self->addConformer(ownedConf, assignId);
192
+ /* Create a copy of the conformer before adding it to the molecule.
193
+ This avoids the double-free issue since Ruby owns the original and C++ owns the copy.
194
+ The original DISOWN approach doesn't work with shared_ptr wrappers. */
195
+ unsigned int RDKit::ROMol::addConf(RDKit::Conformer *conf, bool assignId=false) {
196
+ RDKit::Conformer *confCopy = new RDKit::Conformer(*conf);
197
+ return self->addConformer(confCopy, assignId);
195
198
  }
196
199
 
197
200
  std::string MolToSmiles(bool doIsomericSmiles=true, bool doKekule=false, int rootedAtAtom=-1, bool canonical=true,
@@ -1,4 +1,4 @@
1
1
  module RDKitChem
2
- VERSION = '2025.09.3'.freeze
3
- GEMVERSION = VERSION + '.2'
2
+ VERSION = "2025.09.3".freeze
3
+ GEMVERSION = VERSION + ".3"
4
4
  end
@@ -44,4 +44,41 @@ class RDKitTest < Test::Unit::TestCase
44
44
  assert_not_nil(rw_mol)
45
45
  assert_equal(28, rw_mol.get_num_atoms) # C27H46O has 28 heavy atoms (27 C + 1 O)
46
46
  end
47
+
48
+ def test_conformer_ownership
49
+ # Test that conformer ownership is properly transferred to the molecule.
50
+ # This verifies the DISOWN directive works - without it, Ruby GC and C++
51
+ # destructor both try to free the Conformer, causing a double-free segfault.
52
+ smiles = 'CCO' # ethanol
53
+ rw_mol = RDKitChem::RWMol.mol_from_smiles(smiles)
54
+
55
+ # Create a conformer with 3D coordinates
56
+ conf = RDKitChem::Conformer.new(rw_mol.get_num_atoms)
57
+ conf.set_atom_pos(0, RDKitChem::Point3D.new(0.0, 0.0, 0.0))
58
+ conf.set_atom_pos(1, RDKitChem::Point3D.new(1.5, 0.0, 0.0))
59
+ conf.set_atom_pos(2, RDKitChem::Point3D.new(2.0, 1.0, 0.0))
60
+
61
+ # Add conformer to molecule (ownership transfers to C++)
62
+ conf_id = rw_mol.addConf(conf, true)
63
+ assert(conf_id >= 0, "Conformer should be added successfully")
64
+
65
+ # Verify conformer was added
66
+ assert_equal(1, rw_mol.get_num_conformers)
67
+
68
+ # Access the conformer through the molecule
69
+ retrieved_conf = rw_mol.get_conformer(conf_id)
70
+ assert_not_nil(retrieved_conf)
71
+
72
+ # Verify coordinates
73
+ pos = retrieved_conf.get_atom_pos(0)
74
+ assert_in_delta(0.0, pos.x, 0.001)
75
+ assert_in_delta(0.0, pos.y, 0.001)
76
+ assert_in_delta(0.0, pos.z, 0.001)
77
+
78
+ # Force garbage collection to ensure no double-free occurs
79
+ GC.start
80
+
81
+ # The molecule should still be valid after GC
82
+ assert_equal(3, rw_mol.get_num_atoms)
83
+ end
47
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdkit_chem
3
3
  version: !ruby/object:Gem::Version
4
- version: 2025.09.3.2
4
+ version: 2025.09.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Nguyen