rdkit_chem 2019.03.3.1 → 2025.09.3.2

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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CMakeLists.txt +713 -0
  3. data/Code/CMakeLists.txt +44 -0
  4. data/Code/RubyWrappers/Abbreviations.i +19 -0
  5. data/Code/RubyWrappers/AddHs.i +34 -0
  6. data/Code/RubyWrappers/Atom.i +165 -0
  7. data/Code/RubyWrappers/AtomIterators.i +77 -0
  8. data/Code/RubyWrappers/AtomPairs.i +95 -0
  9. data/Code/RubyWrappers/AvalonLib.i +41 -0
  10. data/Code/RubyWrappers/BitOps.i +72 -0
  11. data/Code/RubyWrappers/Bond.i +87 -0
  12. data/Code/RubyWrappers/BondIterators.i +61 -0
  13. data/Code/RubyWrappers/CMakeLists.txt +67 -0
  14. data/Code/RubyWrappers/Canon.i +40 -0
  15. data/Code/RubyWrappers/ChemDraw.i +81 -0
  16. data/Code/RubyWrappers/ChemReactions.i +166 -0
  17. data/Code/RubyWrappers/ChemTransforms.i +126 -0
  18. data/Code/RubyWrappers/Conformer.i +69 -0
  19. data/Code/RubyWrappers/Descriptors.i +64 -0
  20. data/Code/RubyWrappers/Dict.i +45 -0
  21. data/Code/RubyWrappers/DistGeom.i +217 -0
  22. data/Code/RubyWrappers/DiversityPick.h +49 -0
  23. data/Code/RubyWrappers/DiversityPick.i +10 -0
  24. data/Code/RubyWrappers/ErrorGenerator.i +73 -0
  25. data/Code/RubyWrappers/ExplicitBitVect.i +76 -0
  26. data/Code/RubyWrappers/FMCS.i +63 -0
  27. data/Code/RubyWrappers/FilterCatalog.i +154 -0
  28. data/Code/RubyWrappers/Fingerprints.i +56 -0
  29. data/Code/RubyWrappers/ForceField.i +161 -0
  30. data/Code/RubyWrappers/GeneralizedSubstruct.i +38 -0
  31. data/Code/RubyWrappers/GenericRDKitException.h +27 -0
  32. data/Code/RubyWrappers/Inchi.i +38 -0
  33. data/Code/RubyWrappers/MolBundle.i +16 -0
  34. data/Code/RubyWrappers/MolDraw2D.i +117 -0
  35. data/Code/RubyWrappers/MolEnumerator.i +45 -0
  36. data/Code/RubyWrappers/MolHash.i +25 -0
  37. data/Code/RubyWrappers/MolOps.i +72 -0
  38. data/Code/RubyWrappers/MolStandardize.i +37 -0
  39. data/Code/RubyWrappers/MolSupplier.i +83 -0
  40. data/Code/RubyWrappers/MolTransforms.i +39 -0
  41. data/Code/RubyWrappers/MolWriters.i +41 -0
  42. data/Code/RubyWrappers/MonomerInfo.i +42 -0
  43. data/Code/RubyWrappers/MorganFingerprints.h +21 -0
  44. data/Code/RubyWrappers/MorganFingerprints.i +66 -0
  45. data/Code/RubyWrappers/PeriodicTable.i +44 -0
  46. data/Code/RubyWrappers/Queries.i +289 -0
  47. data/Code/RubyWrappers/QueryAtom.i +47 -0
  48. data/Code/RubyWrappers/QueryBond.i +47 -0
  49. data/Code/RubyWrappers/QueryOps.i +44 -0
  50. data/Code/RubyWrappers/RDKitExceptions.i +75 -0
  51. data/Code/RubyWrappers/RDLogger.i +74 -0
  52. data/Code/RubyWrappers/RDProps.i +44 -0
  53. data/Code/RubyWrappers/RGroupDecomposition.i +52 -0
  54. data/Code/RubyWrappers/ROMol.i +695 -0
  55. data/Code/RubyWrappers/RWMol.i +241 -0
  56. data/Code/RubyWrappers/RascalMCES.i +71 -0
  57. data/Code/RubyWrappers/ReactionFingerprints.i +37 -0
  58. data/Code/RubyWrappers/RingInfo.i +40 -0
  59. data/Code/RubyWrappers/Rings.i +40 -0
  60. data/Code/RubyWrappers/SanitException.i +100 -0
  61. data/Code/RubyWrappers/ScaffoldNetwork.i +28 -0
  62. data/Code/RubyWrappers/SmartsWrite.i +38 -0
  63. data/Code/RubyWrappers/SmilesParse.i +40 -0
  64. data/Code/RubyWrappers/SmilesWrite.i +42 -0
  65. data/Code/RubyWrappers/StereoGroup.i +16 -0
  66. data/Code/RubyWrappers/Streams.i +67 -0
  67. data/Code/RubyWrappers/Subgraphs.i +53 -0
  68. data/Code/RubyWrappers/Subset.i +75 -0
  69. data/Code/RubyWrappers/SubstanceGroup.i +91 -0
  70. data/Code/RubyWrappers/SubstructLibrary.i +80 -0
  71. data/Code/RubyWrappers/TautomerQuery.i +19 -0
  72. data/Code/RubyWrappers/Trajectory.i +34 -0
  73. data/Code/RubyWrappers/boost_tuple.i +64 -0
  74. data/Code/RubyWrappers/extend_std_vector.i +10 -0
  75. data/Code/RubyWrappers/gmwrapper/CMakeLists.txt +69 -0
  76. data/Code/RubyWrappers/gmwrapper/GraphMolRuby.i +431 -0
  77. data/Code/RubyWrappers/gmwrapper/std_list.i +65 -0
  78. data/Code/RubyWrappers/point.i +56 -0
  79. data/Code/RubyWrappers/transforms.i +60 -0
  80. data/Code/RubyWrappers/types.i +40 -0
  81. data/README.md +24 -0
  82. data/Rakefile +165 -4
  83. data/ext/rdkit_chem/CMakeLists.txt +69 -0
  84. data/ext/rdkit_chem/Makefile +5 -0
  85. data/ext/rdkit_chem/extconf.rb +47 -17
  86. data/lib/rdkit_chem/version.rb +2 -2
  87. data/lib/rdkit_chem.rb +31 -1
  88. data/test/test_rdkit_chem.rb +38 -10
  89. metadata +119 -13
data/Rakefile CHANGED
@@ -1,9 +1,170 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
2
3
  require 'rake/testtask'
4
+ require 'fileutils'
5
+
6
+ # Load version
7
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
8
+ require 'rdkit_chem/version'
9
+
10
+ VERSION = RDKitChem::GEMVERSION
11
+ NATIVE_DIR = 'rdkit_chem/lib'
3
12
 
4
- Rake::TestTask.new do |t|
13
+ # System libraries that need to be bundled for portability
14
+ BUNDLED_SYSTEM_LIBS = %w[
15
+ libboost_serialization.so*
16
+ libboost_iostreams.so*
17
+ ].freeze
18
+
19
+ desc 'Run tests'
20
+ Rake::TestTask.new(:test) do |t|
21
+ t.libs << 'lib'
5
22
  t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb,test/**/test_*.rb'
24
+ t.verbose = true
25
+ end
26
+
27
+ desc 'Build source gem (requires compilation on install)'
28
+ task :build do
29
+ sh 'gem build rdkit_chem.gemspec'
30
+ end
31
+
32
+ desc 'Build pre-compiled gem for current platform (x86_64-linux)'
33
+ task :build_native do
34
+ # Check that native libraries exist
35
+ unless File.exist?(File.join(NATIVE_DIR, 'RDKitChem.so'))
36
+ abort "ERROR: Native extension not found at #{NATIVE_DIR}/RDKitChem.so\n" \
37
+ "Run 'gem install rdkit_chem' first to compile, or build manually."
38
+ end
39
+
40
+ # Get Ruby version for directory structure
41
+ ruby_version = "#{RUBY_VERSION.split('.')[0..1].join('.')}.0"
42
+ target_dir = "lib/rdkit_chem/#{ruby_version}"
43
+
44
+ puts "Packaging pre-compiled gem for Ruby #{ruby_version}..."
45
+
46
+ # Create target directory
47
+ FileUtils.mkdir_p(target_dir)
48
+
49
+ # Copy native extension and all shared libraries
50
+ Dir.glob("#{NATIVE_DIR}/*.so*").each do |lib|
51
+ # Skip symlinks, copy only real files
52
+ next if File.symlink?(lib)
53
+ dest = File.join(target_dir, File.basename(lib))
54
+ FileUtils.cp(lib, dest, verbose: true)
55
+ end
56
+
57
+ # Also copy symlinks (they're needed for library resolution)
58
+ # This includes both .so -> .so.1 and .so.1 -> .so.1.version symlinks
59
+ Dir.glob("#{NATIVE_DIR}/*.so*").each do |lib|
60
+ next unless File.symlink?(lib)
61
+ link_target = File.readlink(lib)
62
+ dest = File.join(target_dir, File.basename(lib))
63
+ FileUtils.rm_f(dest)
64
+ FileUtils.ln_s(link_target, dest, verbose: true)
65
+ end
66
+
67
+ # Build the platform-specific gem
68
+ ENV['RDKIT_PRECOMPILED'] = '1'
69
+ sh 'gem build rdkit_chem.gemspec'
70
+ ENV.delete('RDKIT_PRECOMPILED')
71
+
72
+ # Clean up
73
+ FileUtils.rm_rf(target_dir)
74
+
75
+ puts "\nBuilt: rdkit_chem-#{VERSION}-#{Gem::Platform.local}.gem"
76
+ end
77
+
78
+ desc 'Bundle system libraries (Boost) into native directory'
79
+ task :bundle_system_libs do
80
+ so_file = File.join(NATIVE_DIR, 'RDKitChem.so')
81
+ unless File.exist?(so_file)
82
+ abort "ERROR: #{so_file} not found"
83
+ end
84
+
85
+ puts "Finding and bundling system library dependencies..."
86
+
87
+ # Find library paths using ldd
88
+ ldd_output = `ldd #{so_file} 2>/dev/null`
89
+
90
+ BUNDLED_SYSTEM_LIBS.each do |lib_pattern|
91
+ lib_name = lib_pattern.gsub('*', '')
92
+ # Extract actual library path from ldd output
93
+ match = ldd_output.match(/#{Regexp.escape(lib_name)}[^\s]* => ([^\s]+)/)
94
+ if match
95
+ src_path = match[1]
96
+ if File.exist?(src_path)
97
+ dest = File.join(NATIVE_DIR, File.basename(src_path))
98
+ unless File.exist?(dest)
99
+ FileUtils.cp(src_path, dest, verbose: true)
100
+ else
101
+ puts "Already exists: #{dest}"
102
+ end
103
+ end
104
+ else
105
+ puts "WARNING: Could not find #{lib_pattern} in ldd output"
106
+ end
107
+ end
108
+
109
+ puts "Done bundling system libraries."
110
+ end
111
+
112
+ desc 'Apply RPATH fix to existing native extension (no recompile needed)'
113
+ task :fix_rpath do
114
+ so_file = File.join(NATIVE_DIR, 'RDKitChem.so')
115
+ unless File.exist?(so_file)
116
+ abort "ERROR: #{so_file} not found"
117
+ end
118
+
119
+ # Check if patchelf is available
120
+ unless system('which patchelf > /dev/null 2>&1')
121
+ abort "ERROR: patchelf not installed. Run: sudo apt install patchelf"
122
+ end
123
+
124
+ # Fix RPATH on all shared libraries (including versioned ones like *.so.1.2026.03.1pre)
125
+ puts "Setting RPATH to $ORIGIN on all shared libraries..."
126
+ count = 0
127
+ Dir.glob("#{NATIVE_DIR}/*.so*").each do |lib|
128
+ next if File.symlink?(lib) # Skip symlinks
129
+ next if lib.end_with?('.a') # Skip static libraries
130
+ system("patchelf --set-rpath '$ORIGIN' '#{lib}' 2>/dev/null")
131
+ count += 1
132
+ end
133
+ puts "Fixed RPATH on #{count} libraries"
134
+
135
+ # Verify main extension
136
+ puts "\nVerifying RPATH on #{so_file}:"
137
+ sh "readelf -d #{so_file} | grep -E '(RPATH|RUNPATH)' || echo 'No RPATH found'"
138
+ end
139
+
140
+ desc 'Test that native extension loads without LD_LIBRARY_PATH'
141
+ task :test_native do
142
+ so_dir = File.expand_path(NATIVE_DIR, __dir__)
143
+ puts "Testing native extension loading from #{so_dir}..."
144
+
145
+ # Test without LD_LIBRARY_PATH
146
+ result = system("ruby -I#{so_dir} -Ilib -e \"require 'rdkit_chem'; puts 'SUCCESS: RDKitChem loaded'\"")
147
+
148
+ if result
149
+ puts "\nNative extension loads correctly without LD_LIBRARY_PATH!"
150
+ else
151
+ puts "\nFAILED: Still requires LD_LIBRARY_PATH. Run 'rake fix_rpath' first."
152
+ exit 1
153
+ end
154
+ end
155
+
156
+ desc 'Install gem locally'
157
+ task :install => :build do
158
+ sh "gem install rdkit_chem-#{VERSION}.gem"
159
+ end
160
+
161
+ desc 'Clean build artifacts'
162
+ task :clean do
163
+ FileUtils.rm_f(Dir.glob('*.gem'))
164
+ FileUtils.rm_rf('lib/rdkit_chem/3.0')
165
+ FileUtils.rm_rf('lib/rdkit_chem/3.1')
166
+ FileUtils.rm_rf('lib/rdkit_chem/3.2')
167
+ FileUtils.rm_rf('lib/rdkit_chem/3.3')
6
168
  end
7
169
 
8
- desc "Run tests"
9
- task :default => :test
170
+ task default: :test
@@ -0,0 +1,69 @@
1
+ cmake_minimum_required(VERSION 3.8)
2
+
3
+ # Apple: Don't modify install_name when touching RPATH.
4
+ if(POLICY CMP0068)
5
+ cmake_policy(SET CMP0068 NEW)
6
+ endif()
7
+ # target_sources: use absolute path for INTERFACE_SOURCES.
8
+ if(POLICY CMP0076)
9
+ cmake_policy(SET CMP0076 NEW)
10
+ endif()
11
+ # SWIG: use standard target name.
12
+ if(POLICY CMP0078)
13
+ cmake_policy(SET CMP0078 NEW)
14
+ endif()
15
+ # SWIG: use SWIG_MODULE_NAME property.
16
+ if(POLICY CMP0086)
17
+ cmake_policy(SET CMP0086 NEW)
18
+ endif()
19
+
20
+ project (GraphMolRuby)
21
+
22
+ include_directories( ${RDKit_ExternalDir} )
23
+
24
+ find_package(Ruby REQUIRED)
25
+
26
+ INCLUDE_DIRECTORIES(${RDKit_INCLUDE_DIR} ${RUBY_INCLUDE_PATH})
27
+
28
+ SET_SOURCE_FILES_PROPERTIES(GraphMolRuby.i PROPERTIES CPLUSPLUS ON )
29
+
30
+ SET(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_SOURCE_DIR}/swig_ruby )
31
+
32
+ if(RDK_BUILD_INCHI_SUPPORT)
33
+ SET(CMAKE_SWIG_FLAGS "-DRDK_BUILD_INCHI_SUPPORT" ${CMAKE_SWIG_FLAGS} )
34
+ endif()
35
+ if(RDK_BUILD_AVALON_SUPPORT)
36
+ SET(CMAKE_SWIG_FLAGS "-DRDK_BUILD_AVALON_SUPPORT" ${CMAKE_SWIG_FLAGS} )
37
+ endif()
38
+ if(RDK_USE_BOOST_IOSTREAMS)
39
+ SET(CMAKE_SWIG_FLAGS "-DRDK_USE_BOOST_IOSTREAMS" ${CMAKE_SWIG_FLAGS} )
40
+ endif()
41
+
42
+ FILE(GLOB SWIG_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/../*.i")
43
+
44
+ # we added all source files, now remove the ones that we're not supporting in this build:
45
+ if(NOT RDK_BUILD_AVALON_SUPPORT)
46
+ LIST(REMOVE_ITEM SWIG_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/../AvalonLib.i")
47
+ endif()
48
+
49
+ if(NOT RDK_BUILD_INCHI_SUPPORT)
50
+ LIST(REMOVE_ITEM SWIG_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/../Inchi.i")
51
+ endif()
52
+
53
+ SET(SWIG_MODULE_RDKitChem_EXTRA_DEPS ${SWIG_SRC_FILES} )
54
+ SET(CMAKE_SWIG_FLAGS -small -naturalvar -autorename)
55
+
56
+ SWIG_ADD_LIBRARY(RDKitChem TYPE MODULE LANGUAGE ruby SOURCES GraphMolRuby.i)
57
+
58
+ # it doesnt seem like the threading libs should need to be here, but
59
+ # as of Oct 2012 using boost 1.51 under at least ubuntu 12.04 we get a
60
+ # link error if they aren't there.
61
+ SWIG_LINK_LIBRARIES(RDKitChem
62
+ ${RDKit_Wrapper_Libs}
63
+ ${Boost_SERIALIZATION_LIBRARY}
64
+ ${RDKit_THREAD_LIBS})
65
+
66
+ MESSAGE("serial: ${Boost_SERIALIZATION_LIBRARY}")
67
+ MESSAGE("THREAD: ${RDKit_THREAD_LIBS}")
68
+
69
+ INSTALL(TARGETS RDKitChem LIBRARY DESTINATION lib)
@@ -0,0 +1,5 @@
1
+ all:
2
+ true
3
+
4
+ install:
5
+ true
@@ -1,16 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fileutils'
2
4
  require 'rbconfig'
3
5
  require 'mkmf'
4
6
 
5
- main_dir = File.expand_path(File.join(File.dirname(__FILE__),"..",".."))
6
-
7
- # install OpenBabel
8
-
9
- rdkit_dir = File.join main_dir, 'rdkit'
7
+ main_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
8
+ rdkit_dir = File.join(main_dir, 'rdkit')
9
+ install_dir = File.join(main_dir, 'rdkit_chem')
10
10
  src_dir = rdkit_dir
11
-
12
- build_dir = File.join src_dir, 'build'
13
- install_dir = rdkit_dir
11
+ build_dir = File.join(src_dir, 'build')
14
12
 
15
13
  begin
16
14
  nr_processors = `getconf _NPROCESSORS_ONLN`.to_i # should be POSIX compatible
@@ -22,32 +20,64 @@ FileUtils.mkdir_p rdkit_dir
22
20
  Dir.chdir main_dir do
23
21
  FileUtils.rm_rf src_dir
24
22
  puts 'Downloading RDKit sources'
25
- git = "git clone https://github.com/CamAnNguyen/rdkit.git \
26
- --branch 'ruby-binding'"
23
+ git = 'git clone https://github.com/rdkit/rdkit.git'
27
24
  system git
28
25
  end
29
26
 
27
+ Dir.chdir(src_dir) do
28
+ checkout = 'git checkout c2e48f41d88ddc15c6e1f818d1c4ced70b7f20d1'
29
+ system checkout
30
+ end
31
+
32
+ FileUtils.cp_r(
33
+ File.join(main_dir, 'Code'),
34
+ File.join(rdkit_dir),
35
+ remove_destination: true
36
+ )
37
+
38
+ FileUtils.cp_r(
39
+ File.join(main_dir, 'CMakeLists.txt'),
40
+ File.join(rdkit_dir),
41
+ remove_destination: true
42
+ )
43
+
44
+ host_os = RbConfig::CONFIG['host_os']
45
+ is_linux = host_os =~ /linux/
46
+ is_mac = host_os =~ /darwin/
47
+ ld_path = ''
48
+
49
+ if is_linux || is_mac
50
+ ld_string = is_linux ? 'LD_LIBRARY_PATH' : 'DYLD_LIBRARY_PATH'
51
+ ld_path = "#{ld_string}=#{install_dir}/lib"
52
+ env_ld = ENV[ld_string] || ''
53
+
54
+ ld_path += ":#{env_ld}" unless env_ld.empty?
55
+ end
56
+
30
57
  FileUtils.mkdir_p build_dir
31
- FileUtils.mkdir_p install_dir
32
58
  Dir.chdir build_dir do
33
59
  puts 'Configuring RDKit'
34
60
 
35
- cmake = "cmake #{src_dir} -DCMAKE_INSTALL_PREFIX=#{install_dir} " \
61
+ cmake = "#{ld_path} cmake #{src_dir} -DRDK_INSTALL_INTREE=OFF " \
62
+ "-DCMAKE_INSTALL_PREFIX=#{install_dir} " \
36
63
  '-DCMAKE_BUILD_TYPE=Release -DRDK_BUILD_PYTHON_WRAPPERS=OFF ' \
37
- '-DRDK_BUILD_SWIG_WRAPPERS=ON -DRDK_BUILD_INCHI_SUPPORT=ON ' \
38
- '-DBOOST_ROOT=/usr/include/'
64
+ '-DRDK_BUILD_SWIG_WRAPPERS=ON -DRDK_BUILD_INCHI_SUPPORT=OFF ' \
65
+ '-DBoost_NO_BOOST_CMAKE=ON'
39
66
  system cmake
40
67
  end
41
68
 
42
69
  # local installation in gem directory
43
70
  Dir.chdir build_dir do
44
71
  puts 'Compiling RDKit sources.'
45
- system "make -j#{nr_processors}"
46
- system 'make install'
72
+ system "#{ld_path} make -j#{nr_processors}"
73
+ system "#{ld_path} make install"
47
74
  end
48
75
 
76
+ # Remove compiled file, free spaces
77
+ FileUtils.remove_dir(rdkit_dir)
78
+
49
79
  # create a fake Makefile
50
- File.open(File.join(File.dirname(__FILE__), 'Makefile'), "w+") do |makefile|
80
+ File.open(File.join(File.dirname(__FILE__), 'Makefile'), 'w+') do |makefile|
51
81
  makefile.puts "all:\n\ttrue\n\ninstall:\n\ttrue\n"
52
82
  end
53
83
 
@@ -1,4 +1,4 @@
1
1
  module RDKitChem
2
- VERSION = '2019.03.3'.freeze
3
- GEMVERSION = VERSION + '.1'
2
+ VERSION = '2025.09.3'.freeze
3
+ GEMVERSION = VERSION + '.2'
4
4
  end
data/lib/rdkit_chem.rb CHANGED
@@ -1,2 +1,32 @@
1
- require_relative '../rdkit/Code/lib/RDKitChem'
1
+ # frozen_string_literal: true
2
+
2
3
  require 'rdkit_chem/version'
4
+
5
+ # Try to load the native extension from multiple possible locations:
6
+ # 1. Pre-compiled gem: lib/rdkit_chem/<ruby_version>/RDKitChem.so
7
+ # 2. Source-compiled gem: rdkit_chem/lib/RDKitChem.so (legacy location)
8
+
9
+ def find_rdkit_native_extension
10
+ ruby_version = "#{RUBY_VERSION.split('.')[0..1].join('.')}.0"
11
+
12
+ # Location 1: Pre-compiled gem (platform-specific)
13
+ precompiled_path = File.expand_path("rdkit_chem/#{ruby_version}", __dir__)
14
+ if File.directory?(precompiled_path)
15
+ return precompiled_path
16
+ end
17
+
18
+ # Location 2: Source-compiled gem (legacy rdkit_chem/lib/)
19
+ source_compiled_path = File.expand_path('../rdkit_chem/lib', __dir__)
20
+ if File.exist?(File.join(source_compiled_path, 'RDKitChem.so')) ||
21
+ File.exist?(File.join(source_compiled_path, 'RDKitChem.bundle'))
22
+ return source_compiled_path
23
+ end
24
+
25
+ raise LoadError, "Cannot find RDKitChem native extension. " \
26
+ "Searched in:\n - #{precompiled_path}\n - #{source_compiled_path}"
27
+ end
28
+
29
+ native_path = find_rdkit_native_extension
30
+ $LOAD_PATH.unshift(native_path) unless $LOAD_PATH.include?(native_path)
31
+
32
+ require 'RDKitChem'
@@ -1,19 +1,47 @@
1
1
  require 'test/unit'
2
2
 
3
3
  require 'rdkit_chem'
4
- include RDKit
5
4
 
6
5
  class RDKitTest < Test::Unit::TestCase
7
- def test_ROMol
8
- # smi2mol = OBConversion.new
9
- # smi2mol.set_in_format("smi")
6
+ def test_mol_from_smiles
7
+ smiles = 'CCO' # ethanol
8
+ rw_mol = RDKitChem::RWMol.mol_from_smiles(smiles)
9
+ assert_not_nil(rw_mol)
10
+ assert_equal(3, rw_mol.get_num_atoms)
11
+ end
12
+
13
+ def test_mol_to_mol_block
14
+ smiles = 'CCO' # ethanol
15
+ rw_mol = RDKitChem::RWMol.mol_from_smiles(smiles)
16
+ mdl = rw_mol.mol_to_mol_block(true, -1, false)
17
+ assert_not_nil(mdl)
18
+ assert(mdl.include?('V2000') || mdl.include?('V3000'))
19
+ end
20
+
21
+ def test_mol_from_mol_block
22
+ smiles = 'c1ccccc1' # benzene
23
+ rw_mol = RDKitChem::RWMol.mol_from_smiles(smiles)
24
+ mdl = rw_mol.mol_to_mol_block(true, -1, false)
10
25
 
11
- # mol = OBMol.new
12
- # smi2mol.read_string(mol, 'CC(C)CCCC(C)C1CCC2C1(CCC3C2CC=C4C3(CCC(C4)O)C)C') # cholesterol, no chirality
13
- # mol.add_hydrogens
26
+ # Round-trip: mol block back to molecule
27
+ mol_from_block = RDKitChem::RWMol.mol_from_mol_block(mdl)
28
+ assert_not_nil(mol_from_block)
29
+ assert_equal(6, mol_from_block.get_num_atoms)
30
+ end
31
+
32
+ def test_mol_to_smiles
33
+ smiles = 'CCO'
34
+ rw_mol = RDKitChem::RWMol.mol_from_smiles(smiles)
35
+ output_smiles = RDKitChem.mol_to_smiles(rw_mol)
36
+ assert_not_nil(output_smiles)
37
+ assert_equal('CCO', output_smiles)
38
+ end
14
39
 
15
- # assert_equal(mol.num_atoms, 74)
16
- # assert_in_delta(mol.get_mol_wt, 386.65, 0.1)
17
- # assert_equal(mol.get_formula, "C27H46O")
40
+ def test_cholesterol
41
+ # Cholesterol without chirality
42
+ smiles = 'CC(C)CCCC(C)C1CCC2C1(CCC3C2CC=C4C3(CCC(C4)O)C)C'
43
+ rw_mol = RDKitChem::RWMol.mol_from_smiles(smiles)
44
+ assert_not_nil(rw_mol)
45
+ assert_equal(28, rw_mol.get_num_atoms) # C27H46O has 28 heavy atoms (27 C + 1 O)
18
46
  end
19
47
  end
metadata CHANGED
@@ -1,33 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdkit_chem
3
3
  version: !ruby/object:Gem::Version
4
- version: 2019.03.3.1
4
+ version: 2025.09.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Nguyen
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2019-07-15 00:00:00.000000000 Z
12
- dependencies: []
13
- description: RDKit as a GEM
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rake
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '13.0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '13.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: test-unit
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ description: Ruby bindings for RDKit cheminformatics library
14
41
  email:
15
- - annguyen@kit.edu
42
+ - caman.nguyenthanh@gmail.com
16
43
  executables: []
17
44
  extensions:
18
45
  - ext/rdkit_chem/extconf.rb
19
46
  extra_rdoc_files: []
20
47
  files:
48
+ - CMakeLists.txt
49
+ - Code/CMakeLists.txt
50
+ - Code/RubyWrappers/Abbreviations.i
51
+ - Code/RubyWrappers/AddHs.i
52
+ - Code/RubyWrappers/Atom.i
53
+ - Code/RubyWrappers/AtomIterators.i
54
+ - Code/RubyWrappers/AtomPairs.i
55
+ - Code/RubyWrappers/AvalonLib.i
56
+ - Code/RubyWrappers/BitOps.i
57
+ - Code/RubyWrappers/Bond.i
58
+ - Code/RubyWrappers/BondIterators.i
59
+ - Code/RubyWrappers/CMakeLists.txt
60
+ - Code/RubyWrappers/Canon.i
61
+ - Code/RubyWrappers/ChemDraw.i
62
+ - Code/RubyWrappers/ChemReactions.i
63
+ - Code/RubyWrappers/ChemTransforms.i
64
+ - Code/RubyWrappers/Conformer.i
65
+ - Code/RubyWrappers/Descriptors.i
66
+ - Code/RubyWrappers/Dict.i
67
+ - Code/RubyWrappers/DistGeom.i
68
+ - Code/RubyWrappers/DiversityPick.h
69
+ - Code/RubyWrappers/DiversityPick.i
70
+ - Code/RubyWrappers/ErrorGenerator.i
71
+ - Code/RubyWrappers/ExplicitBitVect.i
72
+ - Code/RubyWrappers/FMCS.i
73
+ - Code/RubyWrappers/FilterCatalog.i
74
+ - Code/RubyWrappers/Fingerprints.i
75
+ - Code/RubyWrappers/ForceField.i
76
+ - Code/RubyWrappers/GeneralizedSubstruct.i
77
+ - Code/RubyWrappers/GenericRDKitException.h
78
+ - Code/RubyWrappers/Inchi.i
79
+ - Code/RubyWrappers/MolBundle.i
80
+ - Code/RubyWrappers/MolDraw2D.i
81
+ - Code/RubyWrappers/MolEnumerator.i
82
+ - Code/RubyWrappers/MolHash.i
83
+ - Code/RubyWrappers/MolOps.i
84
+ - Code/RubyWrappers/MolStandardize.i
85
+ - Code/RubyWrappers/MolSupplier.i
86
+ - Code/RubyWrappers/MolTransforms.i
87
+ - Code/RubyWrappers/MolWriters.i
88
+ - Code/RubyWrappers/MonomerInfo.i
89
+ - Code/RubyWrappers/MorganFingerprints.h
90
+ - Code/RubyWrappers/MorganFingerprints.i
91
+ - Code/RubyWrappers/PeriodicTable.i
92
+ - Code/RubyWrappers/Queries.i
93
+ - Code/RubyWrappers/QueryAtom.i
94
+ - Code/RubyWrappers/QueryBond.i
95
+ - Code/RubyWrappers/QueryOps.i
96
+ - Code/RubyWrappers/RDKitExceptions.i
97
+ - Code/RubyWrappers/RDLogger.i
98
+ - Code/RubyWrappers/RDProps.i
99
+ - Code/RubyWrappers/RGroupDecomposition.i
100
+ - Code/RubyWrappers/ROMol.i
101
+ - Code/RubyWrappers/RWMol.i
102
+ - Code/RubyWrappers/RascalMCES.i
103
+ - Code/RubyWrappers/ReactionFingerprints.i
104
+ - Code/RubyWrappers/RingInfo.i
105
+ - Code/RubyWrappers/Rings.i
106
+ - Code/RubyWrappers/SanitException.i
107
+ - Code/RubyWrappers/ScaffoldNetwork.i
108
+ - Code/RubyWrappers/SmartsWrite.i
109
+ - Code/RubyWrappers/SmilesParse.i
110
+ - Code/RubyWrappers/SmilesWrite.i
111
+ - Code/RubyWrappers/StereoGroup.i
112
+ - Code/RubyWrappers/Streams.i
113
+ - Code/RubyWrappers/Subgraphs.i
114
+ - Code/RubyWrappers/Subset.i
115
+ - Code/RubyWrappers/SubstanceGroup.i
116
+ - Code/RubyWrappers/SubstructLibrary.i
117
+ - Code/RubyWrappers/TautomerQuery.i
118
+ - Code/RubyWrappers/Trajectory.i
119
+ - Code/RubyWrappers/boost_tuple.i
120
+ - Code/RubyWrappers/extend_std_vector.i
121
+ - Code/RubyWrappers/gmwrapper/CMakeLists.txt
122
+ - Code/RubyWrappers/gmwrapper/GraphMolRuby.i
123
+ - Code/RubyWrappers/gmwrapper/std_list.i
124
+ - Code/RubyWrappers/point.i
125
+ - Code/RubyWrappers/transforms.i
126
+ - Code/RubyWrappers/types.i
127
+ - README.md
21
128
  - Rakefile
129
+ - ext/rdkit_chem/CMakeLists.txt
130
+ - ext/rdkit_chem/Makefile
22
131
  - ext/rdkit_chem/extconf.rb
23
132
  - lib/rdkit_chem.rb
24
133
  - lib/rdkit_chem/version.rb
25
134
  - test/test_rdkit_chem.rb
26
135
  homepage: https://github.com/CamAnNguyen/rdkit-chem
27
136
  licenses:
28
- - BSD
137
+ - BSD-3-Clause
29
138
  metadata: {}
30
- post_install_message:
31
139
  rdoc_options: []
32
140
  require_paths:
33
141
  - lib
@@ -35,17 +143,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
35
143
  requirements:
36
144
  - - ">="
37
145
  - !ruby/object:Gem::Version
38
- version: '0'
146
+ version: 2.7.0
39
147
  required_rubygems_version: !ruby/object:Gem::Requirement
40
148
  requirements:
41
149
  - - ">="
42
150
  - !ruby/object:Gem::Version
43
151
  version: '0'
44
152
  requirements: []
45
- rubyforge_project:
46
- rubygems_version: 2.7.9
47
- signing_key:
153
+ rubygems_version: 4.0.1
48
154
  specification_version: 4
49
- summary: Ruby gem for RDKit !
155
+ summary: Ruby gem for RDKit
50
156
  test_files:
51
157
  - test/test_rdkit_chem.rb