Note: the most recent version of this tutorial can be found here and a short overview slide show here.
ChemmineOB
provides an R interface to a subset of
cheminformatics functionalities implemented by the OpelBabel C++ project
(O’Boyle, Morley, and Hutchison 2008; O’Boyle et
al. 2011). OpenBabel is an open source cheminformatics toolbox
that includes utilities for structure format interconversions,
descriptor calculations, compound similarity searching and more.
ChemineOB
aims to make a subset of these utilities
available from within R. For non-developers, ChemineOB
is
primarily intended to be used from ChemmineR
(Cao et al. 2008; Backman, Cao, and Girke 2011; Wang et
al. 2013) as an add-on package rather than used directly.
To use the ChemmineOB
package on Linux or Mac, OpenBabel
2.3.0 or greater needs to be installed on a system. On Linux systems,
the OpenBabel header files are also required in order to compile
ChemmineOB
. The windows distribution will include its own
version of OpenBabel. The OpenBabel site (http://openbabel.org/wiki/Get_Open_Babel) provides
excellent instructions for installing the OpenBabel software on Mac or
Linux systems. The ChemmineR
and ChemmineOB
packages can be installed from within R with:
if (!requireNamespace("BiocManager", quietly=TRUE))
install.packages("BiocManager")
BiocManager::install(c("ChemmineR", "ChemmineOB"))
library("ChemmineR")
library("ChemmineOB")
If the installation fails on Linux, you may need to manually set the locations of the open babel libraries and header files. This is best done through configure flags. For example, at the command prompt do:
$ R CMD INSTALL --configure-args='--with-openbabel-include=... --with-openbabel-lib=...' <ChemmineOB package file>
where the ‘…’ are replaced by the relevant paths. See the README file for more details.
Some OpenBabel modules are not avaible through ChemmineOB on windows. These currently include “MACCS” and “InChi”.
Detailed instructions for using ChemmineOB
are provided
in the vignette of the ChemmineR
package instead of this
document. The main reason for consolidating the documentation in one
central document rather than distributing it across several vignettes is
that it helps minimizing duplications and inconsistencies. It also is
the more suitable format for providing a task-oriented description of
functionalities for users. To obtain an overview of the OpenBabel
utilities supported by ChemmineOB
, we recommend consulting
the OpenBabel Functions section of the ChemmineR
vignette. To open the ChemmineR
vignette from R, one can
use the following command.
ChemmineOB
now includes wrapper functions for all of
OpenBabel, as genereted by SWIG. We
still maintain our own set of functions to provide better integration
with R in general and ChemmineR
specifically.
If you are familiar with the Open Babel API, using the SWIG wrapper should be similar, once you know a few conventions used. You can look at the R code in this package to see examples of these.
OBConversion *x = new OBConversion(...)
in R you would have:
x = OBConversion(...)
x->AddOption(...)
we have:
OBConversion_AddOption(x,...)
stringp
function. The char* pointer can be accessed with
the cast
slot. The value can be retrieved from the
value
slot. For example:result = stringp()
OBDescriptor_GetStringValue(... , result$cast())
stringValue = result$value()
There are still many special cases however. The SWIG documentation can help, as well as browsing the generated R code in R/ChemmineOB.R.
R version 4.4.1 (2024-06-14) Platform: x86_64-pc-linux-gnu Running under: Ubuntu 24.04.1 LTS
Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
LC_TIME=en_US.UTF-8
[4] LC_COLLATE=C LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Etc/UTC tzcode source: system (glibc)
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] ChemmineOB_1.45.0 BiocStyle_2.33.1
loaded via a namespace (and not attached): [1] digest_0.6.37 R6_2.5.1
codetools_0.2-20 zlibbioc_1.51.2
[5] fastmap_1.2.0 xfun_0.48 maketools_1.3.1 cachem_1.1.0
[9] knitr_1.48 htmltools_0.5.8.1 rmarkdown_2.28 buildtools_1.0.0
[13] lifecycle_1.0.4 cli_3.6.3 sass_0.4.9 jquerylib_0.1.4
[17] compiler_4.4.1 sys_3.4.3 tools_4.4.1 evaluate_1.0.1
[21] bslib_0.8.0 yaml_2.3.10 BiocManager_1.30.25 jsonlite_1.8.9
[25] rlang_1.1.4
This software was developed with funding from the National Science Foundation: ABI-0957099, 2010-0520325 and IGERT-0504249.