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 +4 -4
- data/Code/RubyWrappers/MolOps.i +3 -2
- data/Code/RubyWrappers/ROMol.i +6 -3
- data/lib/rdkit_chem/version.rb +2 -2
- data/test/test_rdkit_chem.rb +37 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72f1c22f156a06620110c1359f9539c406aa65e0192798ea9b5494883d807fdf
|
|
4
|
+
data.tar.gz: 4d0afc7baa75eb3af77519c140550336fe07d70e0981a32219aa9a0fa21bc98f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8d5b69b87e14806643044e1a414a326630517579bb7761e2d3740284dd6662620d6d598b4c7d4d5b2f7a6dc9a185069a347e8e4c38773f65ea651fa5d96f30cb
|
|
7
|
+
data.tar.gz: 959e83ad9e231ea1491b229a56919bccf3a7fec0cafc98a9651e3ecd8c7b5e78da0aaac171fef8fa299f17b52be2a8ea40fa2452b63a052a52445f835ba93f3e
|
data/Code/RubyWrappers/MolOps.i
CHANGED
|
@@ -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 %{
|
data/Code/RubyWrappers/ROMol.i
CHANGED
|
@@ -189,9 +189,12 @@ unsigned int getDefaultPickleProperties();
|
|
|
189
189
|
return res;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
/*
|
|
193
|
-
|
|
194
|
-
|
|
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,
|
data/lib/rdkit_chem/version.rb
CHANGED
data/test/test_rdkit_chem.rb
CHANGED
|
@@ -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
|