本家様 http://openbabel.org/wiki/Main_Page
各種分子フォーマットの変換ツールだと思ってたのですが、
構造式検索やら、構造最適化(エネルギー極小化計算)、配座解析な事もできるそうな。
記述子演算も可能で、、まぁーすごいです。
OpenBabel/win32
このOpenBabelをwindows向けにコンパイルして作る
OpenBabel/win64
x64の場合
Cartridge
このOpenBabelを検索エンジンとしてデータベース(MySQL)に組み込んで使ってみる
CartridgeWin
WindowsOSで使えるCartridgeを作ってみた(失敗)
v230
旧バージョン
OpenBabel-2.3.1 †
LinuxでOpenBabelアプリケーションのGUI版を作ってみる。
- 1. 環境整備
下準備として、ディスクトップ環境と開発環境をインストールします。CentOS6から構築の場合
[root@c3 src]# yum -y groupinstall Desktop "Development tools" "Japanese Support"
加えて下記のパッケージもインストールします。
[root@c3 src]# yum -y install cmake cairo-devel libjpeg-devel libtiff-devel \
gtk2-devel libSM-devel webkitgtk-devel gstreamer-devel
[root@c3 src]#
runレベルを5に変更します
[root@c3 src]# vi /etc/inittab
- id:3:initdefault:
+ id:5:initdefault:
[root@c3 src]# reboot
- 2. GUI向けのウィジットをインストール
wxWidgetsをインストールします
[root@c3 ~]# mkdir /opt/src; cd /opt/src
[root@c3 src]# wget http://downloads.sourceforge.net/project/wxwindows/2.8.12/wxWidgets-2.8.12.tar.bz2
[root@c3 src]# bzip2 -cd wxWidgets-2.8.12.tar.bz2 | tar xf -
[root@c3 src]# cd wxWidgets-2.8.12
[root@c3 wxWidgets-2.8.12]# ./configure --prefix=/opt/wxWidgets/2812
(中略)
Configured wxWidgets 2.8.12 for `x86_64-unknown-linux-gnu'
Which GUI toolkit should wxWidgets use? GTK+ 2
Should wxWidgets be compiled into single library? no
Should wxWidgets be compiled in debug mode? no
Should wxWidgets be linked as a shared library? yes
Should wxWidgets be compiled in Unicode mode? no
What level of wxWidgets compatibility should be enabled?
wxWidgets 2.4 no
wxWidgets 2.6 yes
Which libraries should wxWidgets use?
jpeg sys
png sys
regex sys
tiff sys
zlib sys
odbc no
expat builtin
libmspack no
sdl no
[root@c3 wxWidgets-2.8.12]# make; make install
[root@c3 wxWidgets-2.8.12]# cd /opt/wxWidgets; rm -f current; ln -s 2812 current
[root@c3 wxWidgets]# ls -l
合計 8
drwxr-xr-x 6 root root 4096 5月 2 01:22 2014 2812
drwxr-xr-x 6 root root 4096 5月 2 00:28 2014 300
lrwxrwxrwx 1 root root 4 5月 2 01:23 2014 current -> 2812
[root@c3 wxWidgets]#
[root@c3 wxWidgets]# echo /opt/wxWidgets/current/lib > /etc/ld.so.conf.d/wxWidgets.conf
[root@c3 wxWidgets]# ldconfig
*wxWidgets-3.0.0で行ってみたがopenbabelのコンパイル中にエラーが発生した。なので一世代前のwxWidgets-2.8.12を採用。こちらはopenbabelのコンパイルに成功
- 3. Eigen2
数値演算ライブラリ
[root@c3 ~]# cd /opt/src
[root@c3 src]# wget http://bitbucket.org/eigen/eigen/get/2.0.17.tar.bz2
[root@c3 src]# mv 2.0.17.tar.bz2 Eigen2-2.0.17.tar.bz2
[root@c3 src]# bzip2 -cd Eigen2-2.0.17.tar.bz2 | tar xf -
[root@c3 src]# mkdir Eigen2-build; cd Eigen2-build
[root@c3 Eigen2-build]# cmake ../eigen-eigen-b23437e61a07 -DCMAKE_INSTALL_PREFIX=/opt/eigen2
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Performing Test standard_math_library_linked_to_automatically
-- Performing Test standard_math_library_linked_to_automatically - Success
-- Standard libraries to link to explicitly: none
-- Performing Test has_wextra
-- Performing Test has_wextra - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/src/Eigen2-build
[root@c3 Eigen2-build]#
[root@c3 Eigen2-build]# make; make install
- 4. OpenBabel本体の構築/インストール
[root@c3 ~]# cd /opt/src
[root@c3 src]# wget http://downloads.sourceforge.net/project/openbabel/openbabel/2.3.1/openbabel-2.3.1.tar.gz
[root@c3 src]# gzip -cd openbabel-2.3.1.tar.gz | tar xf -
[root@c3 src]# mkdir openbabel-build; cd openbabel-build
[root@c3 openbabel-build]# cmake ../openbabel-2.3.1 -DCMAKE_INSTALL_PREFIX=/opt/openbabel-231 \
-DEIGEN2_INCLUDE_DIR=/opt/eigen2/include/eigen2 \
-DwxWidgets_CONFIG_EXECUTABLE=/opt/wxWidgets/current/bin/wx-config \
-DwxWidgets_wxrc_EXECUTABLE=/opt/wxWidgets/current/bin/wxrc
[root@c3 openbabel-build]#
[root@c3 openbabel-build]# make; make install
[root@c3 openbabel-build]# cd /opt; ln -s openbabel-231 openbabel
テスト
ディスクトップ画面でX端末を開き、/opt/openbabel/bin/obguiと入力すると、OpenBabelの画面が立ち上がる。

相変わらずの、、、、ちょっとはウィンドウサイズと連動してほしいものなのだが、、、
pybel †
pythonからOpenBabelを使用することができます。同様にRubyからも。
ここではpythonからOpenBabelを使用するpybelをインストールします。
pythonの開発環境をインストールして
[root@c3 ~]# yum -y install python-devel
それから
[root@c3 ~]# cd /opt/src/
[root@c3 src]# mkdir openbabel-build-pybel; cd openbabel-build-pybel
[root@c3 openbabel-build-pybel]#
[root@c3 openbabel-build-pybel]# cmake ../openbabel-2.3.1 \
-DCMAKE_INSTALL_PREFIX=/opt/openbabel-pybel-231 \
-DPYTHON_BINDINGS=ON \
-DEIGEN2_INCLUDE_DIR=/opt/eigen2/include/eigen2 \
-DPYTHON_INCLUDE_PATH=/usr/include/python2.6 \
-DPYTHON_LIBRARY=/usr/lib64/python2.6
(中略)
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/src/openbabel-build-pybel
[root@c3 openbabel-build-pybel]# make; make install
configureを再確認したければ、 cmake ../openbabel-2.3.1 -L と入力します
*別にGUI版のcmakeの際に、上記を加えても構わない。ここでは別物として扱っている。
テスト。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [root@c3 ~]# export LD_LIBRARY_PATH=/opt/openbabel-pybel-231/lib
[root@c3 ~]# export PYTHONPATH=/opt/openbabel-pybel-231/lib64/python2.6/site-packages
[root@c3 ~]# python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import pybel
>>> import openbabel
>>> mol = pybel.readstring( "smi", "C1CCCCC1C(=O)O")
>>> mol.draw( show=False, filename="cyclohexanecarboxylic_acid.png")
>>> quit()
[root@c3 ~]#
|
こんな絵が作れます。