rdkit_chem 2019.03.3.1 → 2025.09.3.1
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/CMakeLists.txt +713 -0
- data/Code/CMakeLists.txt +44 -0
- data/Code/RubyWrappers/Abbreviations.i +19 -0
- data/Code/RubyWrappers/AddHs.i +34 -0
- data/Code/RubyWrappers/Atom.i +165 -0
- data/Code/RubyWrappers/AtomIterators.i +77 -0
- data/Code/RubyWrappers/AtomPairs.i +95 -0
- data/Code/RubyWrappers/AvalonLib.i +41 -0
- data/Code/RubyWrappers/BitOps.i +72 -0
- data/Code/RubyWrappers/Bond.i +87 -0
- data/Code/RubyWrappers/BondIterators.i +61 -0
- data/Code/RubyWrappers/CMakeLists.txt +67 -0
- data/Code/RubyWrappers/Canon.i +40 -0
- data/Code/RubyWrappers/ChemDraw.i +81 -0
- data/Code/RubyWrappers/ChemReactions.i +166 -0
- data/Code/RubyWrappers/ChemTransforms.i +126 -0
- data/Code/RubyWrappers/Conformer.i +69 -0
- data/Code/RubyWrappers/Descriptors.i +64 -0
- data/Code/RubyWrappers/Dict.i +45 -0
- data/Code/RubyWrappers/DistGeom.i +217 -0
- data/Code/RubyWrappers/DiversityPick.h +49 -0
- data/Code/RubyWrappers/DiversityPick.i +10 -0
- data/Code/RubyWrappers/ErrorGenerator.i +73 -0
- data/Code/RubyWrappers/ExplicitBitVect.i +76 -0
- data/Code/RubyWrappers/FMCS.i +63 -0
- data/Code/RubyWrappers/FilterCatalog.i +154 -0
- data/Code/RubyWrappers/Fingerprints.i +56 -0
- data/Code/RubyWrappers/ForceField.i +161 -0
- data/Code/RubyWrappers/GeneralizedSubstruct.i +38 -0
- data/Code/RubyWrappers/GenericRDKitException.h +27 -0
- data/Code/RubyWrappers/Inchi.i +38 -0
- data/Code/RubyWrappers/MolBundle.i +16 -0
- data/Code/RubyWrappers/MolDraw2D.i +117 -0
- data/Code/RubyWrappers/MolEnumerator.i +45 -0
- data/Code/RubyWrappers/MolHash.i +25 -0
- data/Code/RubyWrappers/MolOps.i +72 -0
- data/Code/RubyWrappers/MolStandardize.i +37 -0
- data/Code/RubyWrappers/MolSupplier.i +83 -0
- data/Code/RubyWrappers/MolTransforms.i +39 -0
- data/Code/RubyWrappers/MolWriters.i +41 -0
- data/Code/RubyWrappers/MonomerInfo.i +42 -0
- data/Code/RubyWrappers/MorganFingerprints.h +21 -0
- data/Code/RubyWrappers/MorganFingerprints.i +66 -0
- data/Code/RubyWrappers/PeriodicTable.i +44 -0
- data/Code/RubyWrappers/Queries.i +289 -0
- data/Code/RubyWrappers/QueryAtom.i +47 -0
- data/Code/RubyWrappers/QueryBond.i +47 -0
- data/Code/RubyWrappers/QueryOps.i +44 -0
- data/Code/RubyWrappers/RDKitExceptions.i +75 -0
- data/Code/RubyWrappers/RDLogger.i +74 -0
- data/Code/RubyWrappers/RDProps.i +44 -0
- data/Code/RubyWrappers/RGroupDecomposition.i +52 -0
- data/Code/RubyWrappers/ROMol.i +695 -0
- data/Code/RubyWrappers/RWMol.i +241 -0
- data/Code/RubyWrappers/RascalMCES.i +71 -0
- data/Code/RubyWrappers/ReactionFingerprints.i +37 -0
- data/Code/RubyWrappers/RingInfo.i +40 -0
- data/Code/RubyWrappers/Rings.i +40 -0
- data/Code/RubyWrappers/SanitException.i +100 -0
- data/Code/RubyWrappers/ScaffoldNetwork.i +28 -0
- data/Code/RubyWrappers/SmartsWrite.i +38 -0
- data/Code/RubyWrappers/SmilesParse.i +40 -0
- data/Code/RubyWrappers/SmilesWrite.i +42 -0
- data/Code/RubyWrappers/StereoGroup.i +16 -0
- data/Code/RubyWrappers/Streams.i +67 -0
- data/Code/RubyWrappers/Subgraphs.i +53 -0
- data/Code/RubyWrappers/Subset.i +75 -0
- data/Code/RubyWrappers/SubstanceGroup.i +91 -0
- data/Code/RubyWrappers/SubstructLibrary.i +80 -0
- data/Code/RubyWrappers/TautomerQuery.i +19 -0
- data/Code/RubyWrappers/Trajectory.i +34 -0
- data/Code/RubyWrappers/boost_tuple.i +64 -0
- data/Code/RubyWrappers/extend_std_vector.i +10 -0
- data/Code/RubyWrappers/gmwrapper/CMakeLists.txt +69 -0
- data/Code/RubyWrappers/gmwrapper/GraphMolRuby.i +431 -0
- data/Code/RubyWrappers/gmwrapper/std_list.i +65 -0
- data/Code/RubyWrappers/point.i +56 -0
- data/Code/RubyWrappers/transforms.i +60 -0
- data/Code/RubyWrappers/types.i +40 -0
- data/README.md +24 -0
- data/Rakefile +125 -4
- data/ext/rdkit_chem/CMakeLists.txt +69 -0
- data/ext/rdkit_chem/Makefile +5 -0
- data/ext/rdkit_chem/extconf.rb +47 -17
- data/lib/rdkit_chem/version.rb +1 -1
- data/lib/rdkit_chem.rb +31 -1
- data/test/test_rdkit_chem.rb +38 -10
- metadata +119 -13
data/Rakefile
CHANGED
|
@@ -1,9 +1,130 @@
|
|
|
1
|
-
|
|
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'
|
|
3
9
|
|
|
4
|
-
|
|
10
|
+
VERSION = RDKitChem::GEMVERSION
|
|
11
|
+
NATIVE_DIR = 'rdkit_chem/lib'
|
|
12
|
+
|
|
13
|
+
desc 'Run tests'
|
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
|
15
|
+
t.libs << 'lib'
|
|
5
16
|
t.libs << 'test'
|
|
17
|
+
t.pattern = 'test/**/*_test.rb,test/**/test_*.rb'
|
|
18
|
+
t.verbose = true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc 'Build source gem (requires compilation on install)'
|
|
22
|
+
task :build do
|
|
23
|
+
sh 'gem build rdkit_chem.gemspec'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc 'Build pre-compiled gem for current platform (x86_64-linux)'
|
|
27
|
+
task :build_native do
|
|
28
|
+
# Check that native libraries exist
|
|
29
|
+
unless File.exist?(File.join(NATIVE_DIR, 'RDKitChem.so'))
|
|
30
|
+
abort "ERROR: Native extension not found at #{NATIVE_DIR}/RDKitChem.so\n" \
|
|
31
|
+
"Run 'gem install rdkit_chem' first to compile, or build manually."
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Get Ruby version for directory structure
|
|
35
|
+
ruby_version = "#{RUBY_VERSION.split('.')[0..1].join('.')}.0"
|
|
36
|
+
target_dir = "lib/rdkit_chem/#{ruby_version}"
|
|
37
|
+
|
|
38
|
+
puts "Packaging pre-compiled gem for Ruby #{ruby_version}..."
|
|
39
|
+
|
|
40
|
+
# Create target directory
|
|
41
|
+
FileUtils.mkdir_p(target_dir)
|
|
42
|
+
|
|
43
|
+
# Copy native extension and all shared libraries
|
|
44
|
+
Dir.glob("#{NATIVE_DIR}/*.so*").each do |lib|
|
|
45
|
+
# Skip symlinks, copy only real files
|
|
46
|
+
next if File.symlink?(lib)
|
|
47
|
+
dest = File.join(target_dir, File.basename(lib))
|
|
48
|
+
FileUtils.cp(lib, dest, verbose: true)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Also copy symlinks (they're needed for library resolution)
|
|
52
|
+
# This includes both .so -> .so.1 and .so.1 -> .so.1.version symlinks
|
|
53
|
+
Dir.glob("#{NATIVE_DIR}/*.so*").each do |lib|
|
|
54
|
+
next unless File.symlink?(lib)
|
|
55
|
+
link_target = File.readlink(lib)
|
|
56
|
+
dest = File.join(target_dir, File.basename(lib))
|
|
57
|
+
FileUtils.rm_f(dest)
|
|
58
|
+
FileUtils.ln_s(link_target, dest, verbose: true)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Build the platform-specific gem
|
|
62
|
+
ENV['RDKIT_PRECOMPILED'] = '1'
|
|
63
|
+
sh 'gem build rdkit_chem.gemspec'
|
|
64
|
+
ENV.delete('RDKIT_PRECOMPILED')
|
|
65
|
+
|
|
66
|
+
# Clean up
|
|
67
|
+
FileUtils.rm_rf(target_dir)
|
|
68
|
+
|
|
69
|
+
puts "\nBuilt: rdkit_chem-#{VERSION}-#{Gem::Platform.local}.gem"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
desc 'Apply RPATH fix to existing native extension (no recompile needed)'
|
|
73
|
+
task :fix_rpath do
|
|
74
|
+
so_file = File.join(NATIVE_DIR, 'RDKitChem.so')
|
|
75
|
+
unless File.exist?(so_file)
|
|
76
|
+
abort "ERROR: #{so_file} not found"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Check if patchelf is available
|
|
80
|
+
unless system('which patchelf > /dev/null 2>&1')
|
|
81
|
+
abort "ERROR: patchelf not installed. Run: sudo apt install patchelf"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Fix RPATH on all shared libraries (including versioned ones like *.so.1.2026.03.1pre)
|
|
85
|
+
puts "Setting RPATH to $ORIGIN on all shared libraries..."
|
|
86
|
+
count = 0
|
|
87
|
+
Dir.glob("#{NATIVE_DIR}/*.so*").each do |lib|
|
|
88
|
+
next if File.symlink?(lib) # Skip symlinks
|
|
89
|
+
next if lib.end_with?('.a') # Skip static libraries
|
|
90
|
+
system("patchelf --set-rpath '$ORIGIN' '#{lib}' 2>/dev/null")
|
|
91
|
+
count += 1
|
|
92
|
+
end
|
|
93
|
+
puts "Fixed RPATH on #{count} libraries"
|
|
94
|
+
|
|
95
|
+
# Verify main extension
|
|
96
|
+
puts "\nVerifying RPATH on #{so_file}:"
|
|
97
|
+
sh "readelf -d #{so_file} | grep -E '(RPATH|RUNPATH)' || echo 'No RPATH found'"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
desc 'Test that native extension loads without LD_LIBRARY_PATH'
|
|
101
|
+
task :test_native do
|
|
102
|
+
so_dir = File.expand_path(NATIVE_DIR, __dir__)
|
|
103
|
+
puts "Testing native extension loading from #{so_dir}..."
|
|
104
|
+
|
|
105
|
+
# Test without LD_LIBRARY_PATH
|
|
106
|
+
result = system("ruby -I#{so_dir} -Ilib -e \"require 'rdkit_chem'; puts 'SUCCESS: RDKitChem loaded'\"")
|
|
107
|
+
|
|
108
|
+
if result
|
|
109
|
+
puts "\nNative extension loads correctly without LD_LIBRARY_PATH!"
|
|
110
|
+
else
|
|
111
|
+
puts "\nFAILED: Still requires LD_LIBRARY_PATH. Run 'rake fix_rpath' first."
|
|
112
|
+
exit 1
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
desc 'Install gem locally'
|
|
117
|
+
task :install => :build do
|
|
118
|
+
sh "gem install rdkit_chem-#{VERSION}.gem"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
desc 'Clean build artifacts'
|
|
122
|
+
task :clean do
|
|
123
|
+
FileUtils.rm_f(Dir.glob('*.gem'))
|
|
124
|
+
FileUtils.rm_rf('lib/rdkit_chem/3.0')
|
|
125
|
+
FileUtils.rm_rf('lib/rdkit_chem/3.1')
|
|
126
|
+
FileUtils.rm_rf('lib/rdkit_chem/3.2')
|
|
127
|
+
FileUtils.rm_rf('lib/rdkit_chem/3.3')
|
|
6
128
|
end
|
|
7
129
|
|
|
8
|
-
|
|
9
|
-
task :default => :test
|
|
130
|
+
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)
|
data/ext/rdkit_chem/extconf.rb
CHANGED
|
@@ -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
|
-
|
|
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 =
|
|
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} -
|
|
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=
|
|
38
|
-
'-
|
|
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
|
|
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'),
|
|
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
|
|
data/lib/rdkit_chem/version.rb
CHANGED
data/lib/rdkit_chem.rb
CHANGED
|
@@ -1,2 +1,32 @@
|
|
|
1
|
-
|
|
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'
|
data/test/test_rdkit_chem.rb
CHANGED
|
@@ -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
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
16
|
-
#
|
|
17
|
-
|
|
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:
|
|
4
|
+
version: 2025.09.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- An Nguyen
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
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
|
-
-
|
|
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:
|
|
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
|
-
|
|
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
|