openbabel-heroku 2.3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -0
- data/ext/openbabel/extconf.rb +93 -0
- data/lib/openbabel.rb +4 -0
- data/lib/openbabel/version.rb +4 -0
- data/test/test_openbabel.rb +24 -0
- metadata +52 -0
data/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'mkmf'
|
3
|
+
require 'rbconfig'
|
4
|
+
$:.unshift File.expand_path('../../../lib', __FILE__)
|
5
|
+
require 'openbabel/version'
|
6
|
+
|
7
|
+
ob_num_ver = OpenBabel::VERSION
|
8
|
+
ob_ver = "openbabel-"+ob_num_ver
|
9
|
+
|
10
|
+
RUBY=File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
11
|
+
|
12
|
+
main_dir = File.expand_path(File.join(File.dirname(__FILE__),"..",".."))
|
13
|
+
src_dir = File.join main_dir, ob_ver
|
14
|
+
build_dir = File.join main_dir, "build"
|
15
|
+
install_dir = main_dir
|
16
|
+
install_lib_dir = File.join install_dir, "lib"
|
17
|
+
lib_dir = File.join main_dir, "lib", "openbabel"
|
18
|
+
ruby_src_dir = File.join src_dir, "scripts", "ruby"
|
19
|
+
cmake_dir = File.join main_dir, "cmake-2.8.11.2"
|
20
|
+
|
21
|
+
begin
|
22
|
+
nr_processors = `grep processor /proc/cpuinfo | wc -l` # speed up compilation, Linux only
|
23
|
+
rescue
|
24
|
+
nr_processors = 1
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
Dir.chdir main_dir do
|
29
|
+
FileUtils.rm_rf src_dir
|
30
|
+
system "curl -L 'http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz' | tar xz"
|
31
|
+
|
32
|
+
Dir.chdir cmake_dir do
|
33
|
+
system "./bootstrap"
|
34
|
+
system "make"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
Dir.chdir main_dir do
|
40
|
+
puts "Downloading OpenBabel sources"
|
41
|
+
system "curl -L -d use_mirror=netcologne 'http://downloads.sourceforge.net/project/openbabel/openbabel/#{ob_num_ver}/openbabel-#{ob_num_ver}.tar.gz' | tar xz"
|
42
|
+
system "sed -i -e 's/-Wl,-flat_namespace//;s/-flat_namespace//' #{File.join ruby_src_dir, "extconf.rb"}" # remove unrecognized compiler option
|
43
|
+
system "sed -i -e 's/Init_OpenBabel/Init_openbabel/g' #{File.join ruby_src_dir,"*cpp"}" # fix swig bindings
|
44
|
+
end
|
45
|
+
FileUtils.mkdir_p build_dir
|
46
|
+
FileUtils.mkdir_p install_dir
|
47
|
+
Dir.chdir build_dir do
|
48
|
+
puts "Configuring OpenBabel"
|
49
|
+
|
50
|
+
|
51
|
+
cmake = "#{cmake_dir}/bin/cmake #{src_dir} -DCMAKE_INSTALL_PREFIX=#{install_dir} -DBUILD_GUI=OFF -DENABLE_TESTS=OFF -DRUBY_BINDINGS=ON"
|
52
|
+
# set rpath for local installations
|
53
|
+
# http://www.cmake.org/Wiki/CMake_RPATH_handling
|
54
|
+
# http://vtk.1045678.n5.nabble.com/How-to-force-cmake-not-to-remove-install-rpath-td5721193.html
|
55
|
+
cmake += " -DCMAKE_INSTALL_RPATH:STRING=\"#{install_lib_dir}\"" unless have_library('openbabel')
|
56
|
+
system cmake
|
57
|
+
end
|
58
|
+
unless have_library('openbabel')
|
59
|
+
# local installation in gem directory
|
60
|
+
Dir.chdir build_dir do
|
61
|
+
puts "OpenBabel not installed. Compiling sources."
|
62
|
+
system "make -j#{nr_processors}"
|
63
|
+
system "make install"
|
64
|
+
ENV["PKG_CONFIG_PATH"] = File.dirname(File.expand_path(Dir["#{install_dir}/**/openbabel*pc"].first))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
# compile ruby bindings
|
68
|
+
puts "Compiling and installing OpenBabel Ruby bindings."
|
69
|
+
Dir.chdir ruby_src_dir do
|
70
|
+
# fix rpath
|
71
|
+
system "sed -i 's|with_ldflags.*$|with_ldflags(\"#\$LDFLAGS -dynamic -Wl,-rpath,#{install_lib_dir}\") do|' #{File.join(ruby_src_dir,'extconf.rb')}" unless have_library('openbabel')
|
72
|
+
# get include and lib from pkg-config
|
73
|
+
ob_include=`pkg-config openbabel-2.0 --cflags-only-I`.sub(/\s+/,'').sub(/-I/,'')
|
74
|
+
ob_lib=`pkg-config openbabel-2.0 --libs-only-L`.sub(/\s+/,'').sub(/-L/,'')
|
75
|
+
system "#{RUBY} extconf.rb --with-openbabel-include=#{ob_include} --with-openbabel-lib=#{ob_lib}"
|
76
|
+
system "make -j#{nr_processors}"
|
77
|
+
end
|
78
|
+
FileUtils.cp(ruby_src_dir+"/openbabel.#{RbConfig::CONFIG["DLEXT"]}", "./")
|
79
|
+
File.open('Makefile', 'w') do |makefile|
|
80
|
+
makefile.write <<"EOF"
|
81
|
+
.PHONY: openbabel.#{RbConfig::CONFIG["DLEXT"]}
|
82
|
+
openbabel.#{RbConfig::CONFIG["DLEXT"]}:
|
83
|
+
chmod 755 openbabel.#{RbConfig::CONFIG["DLEXT"]}
|
84
|
+
|
85
|
+
.PHONY: install
|
86
|
+
install:
|
87
|
+
mkdir -p #{lib_dir}
|
88
|
+
mv openbabel.#{RbConfig::CONFIG["DLEXT"]} #{lib_dir}
|
89
|
+
EOF
|
90
|
+
end
|
91
|
+
ensure
|
92
|
+
FileUtils.remove_entry_secure src_dir, build_dir
|
93
|
+
end
|
data/lib/openbabel.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
4
|
+
$:.unshift File.expand_path('../../ext', __FILE__)
|
5
|
+
require 'openbabel'
|
6
|
+
include OpenBabel
|
7
|
+
|
8
|
+
class OBTest < Test::Unit::TestCase
|
9
|
+
def test_obmol
|
10
|
+
# Code from http://goo.gl/9H1LZ
|
11
|
+
|
12
|
+
smi2mol = OBConversion.new
|
13
|
+
smi2mol.set_in_format("smi")
|
14
|
+
|
15
|
+
mol = OBMol.new
|
16
|
+
smi2mol.read_string(mol, 'CC(C)CCCC(C)C1CCC2C1(CCC3C2CC=C4C3(CCC(C4)O)C)C') # cholesterol, no chirality
|
17
|
+
mol.add_hydrogens
|
18
|
+
|
19
|
+
assert_equal(mol.num_atoms, 74)
|
20
|
+
assert_in_delta(mol.get_mol_wt, 386.65, 0.1)
|
21
|
+
assert_equal(mol.get_formula, "C27H46O")
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openbabel-heroku
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dominic Lütjohann
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-03 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: OpenBabel as a GEM
|
15
|
+
email:
|
16
|
+
executables: []
|
17
|
+
extensions:
|
18
|
+
- ext/openbabel/extconf.rb
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- Rakefile
|
22
|
+
- lib/openbabel.rb
|
23
|
+
- lib/openbabel/version.rb
|
24
|
+
- test/test_openbabel.rb
|
25
|
+
- ext/openbabel/extconf.rb
|
26
|
+
homepage: http://github.com/cominch/openbabel-heroku-gem
|
27
|
+
licenses:
|
28
|
+
- GPL-3
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 1.8.25
|
48
|
+
signing_key:
|
49
|
+
specification_version: 3
|
50
|
+
summary: OpenBabel!
|
51
|
+
test_files:
|
52
|
+
- test/test_openbabel.rb
|