1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  | 
<!-- README.md is generated from README.rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-"
)
```
# chents
[](https://pkgdown.jrwb.de/chents/)
[](https://jranke.r-universe.dev/chents)
[](https://pkgdown.jrwb.de/chents/coverage/coverage.html)
The R package **chents** provides some utilities for working with chemical
entities in R.
When first defining a chemical entity, some chemical information
is retrieved from the [PubChem](https://pubchem.ncbi.nlm.nih.gov/) website using
the [webchem](https://docs.ropensci.org/webchem/) package.
```{r}
library(chents)
caffeine <- chent$new("caffeine")
```
If Python and [RDKit](https://rdkit.org) (> 2015.03) are installed and
configured for use with  the
[reticulate](https://rstudio.github.io/reticulate/) package, some
additional chemical information including a 2D graph are computed.
The print method gives an overview of the information that was collected.
```{r}
print(caffeine)
```
There is a very simple plotting method for the chemical structure.
```{r fig.width = 2}
plot(caffeine)
```
Additional information can be (but is rarely ever) read from a local .yaml
file. This information can be leveraged e.g. by the
[PEC_soil](https://pkgdown.jrwb.de/pfm/reference/PEC_soil.html) function of the
'pfm' package.
If you have a so-called ISO common name of a pesticide active ingredient, you
can use the 'pai' class derived from the 'chent' class, which starts with querying
the [BCPC compendium](http://www.bcpcpesticidecompendium.org/) first.
```{r fig.width = 2}
lambda <- pai$new("lambda-cyhalothrin")
plot(lambda)
```
## Installation
You can conveniently install chents from the repository kindly made available by the
R-Universe project:
```
install.packages("chents",
  repos = c("https://jranke.r-universe.dev", "https://cran.r-project.org"))
```
In order to profit from the chemoinformatics, you need to install RDKit and its
python bindings. On a Debian type Linux distribution, just use
```
sudo apt install python3-rdkit
```
If you use this package on Windows or MacOS, I would be happy to include
installation instructions here if you share them with me, e.g. via a Pull
Request.
## Configuration of the Python version to use
On Debian type Linux distributions, you can use the following line in your
global or project specific `.Rprofile` file to tell the `reticulate` package to
use the system Python version that will find the RDKit installed in the system
location.
```
Sys.setenv(RETICULATE_PYTHON="/usr/bin/python3")
```
  |