From a5e851a5d81194bef25c3f3a32e355e5795cdde1 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 13 Mar 2026 13:19:36 +0100 Subject: Small improvements, see NEWS.md In the README, improve the scaling of the graphs --- NEWS.md | 4 +- R/chent.R | 4 +- README.md | 54 ++++++++++++--------- README.rmd | 35 +++++++------ docs/authors.html | 4 +- docs/authors.md | 4 +- docs/index.html | 30 ++++++------ docs/index.md | 40 ++++++++------- docs/llms.txt | 40 ++++++++------- docs/news/index.html | 3 +- docs/news/index.md | 4 +- .../reference/figures/README-unnamed-chunk-4-1.png | Bin 6346 -> 5369 bytes .../reference/figures/README-unnamed-chunk-5-1.png | Bin 7461 -> 6451 bytes docs/reference/ppp.html | 4 +- docs/search.json | 2 +- log/check.log | 10 ++-- man/figures/README-unnamed-chunk-4-1.png | Bin 6346 -> 15109 bytes man/figures/README-unnamed-chunk-5-1.png | Bin 7461 -> 39123 bytes 18 files changed, 135 insertions(+), 103 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6ec85a4..32fee8e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ ## version 0.4.1 -- R/chent.R: Improve print method for `pai` objects. +- Improve print method for `pai` objects +- `chent` plot method: Pass dots argument to `grid.picture()` as documented +- `chent` plot method: Use preferred SMILES. If PubChem information was retrieved, this will now be the SMILES including stereochemical information ## version 0.4.0 diff --git a/R/chent.R b/R/chent.R index 5302ef9..c118558 100644 --- a/R/chent.R +++ b/R/chent.R @@ -235,7 +235,7 @@ chent <- R6Class("chent", smiles_preferred, " SMILES\n", self$smiles[smiles_preferred]) self$rdkit <- list() - self$mol <- rdkit_module$Chem$MolFromSmiles(self$smiles[1]) + self$mol <- rdkit_module$Chem$MolFromSmiles(self$smiles[smiles_preferred]) self$rdkit$mw <- rdkit_module$Chem$Descriptors$MolWt(self$mol) if (!is.null(self$mw) && !is.na(self$mw)) { if (round(self$rdkit$mw, 1) != round(self$mw, 1)) { @@ -643,7 +643,7 @@ draw_svg.chent = function(x, width = 300, height = 150, #' } plot.chent = function(x, ...) { if (is.null(x$Picture)) stop("No Picture object in chent, was RDKit available during creation?") - grid.picture(x$Picture) + grid.picture(x$Picture, ...) } #' @title An R6 class for pesticidal active ingredients and associated data diff --git a/README.md b/README.md index 1bea80d..bbf4ae9 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,11 @@ status](https://jranke.r-universe.dev/badges/chents)](https://jranke.r-universe. [![Code coverage](https://img.shields.io/badge/coverage-jrwb.de-blue.svg)](https://pkgdown.jrwb.de/chents/coverage/coverage.html) -The R package **chents** provides some utilities for working with -chemical entities in R. +When working with data on chemical substances, we often need a reliable +link between the data and the chemical identity of the substances. The R +package **chents** provides a way to define and check the identity of +chemically defined substances (“chemical entities”) and to collect +related information. When first defining a chemical entity, some chemical information is retrieved from the [PubChem](https://pubchem.ncbi.nlm.nih.gov/) website @@ -20,8 +23,8 @@ using the [webchem](https://docs.ropensci.org/webchem/) package. ``` r library(chents) caffeine <- chent$new("caffeine") -#> Querying PubChem ... -#> Trying to get chemical information from RDKit using PubChem SMILES +#> Querying PubChem for name caffeine ... +#> Get chemical information from RDKit using PubChem SMILES #> CN1C=NC2=C1C(=O)N(C(=O)N2C)C ``` @@ -47,7 +50,7 @@ print(caffeine) #> [3] "Guaranine" "1,3,7-Trimethylxanthine" #> [5] "Methyltheobromine" "Theine" #> [7] "Thein" "Cafeina" -#> [9] "Koffein" "Mateina" +#> [9] "Caffein" "Cafipel" ``` There is a very simple plotting method for the chemical structure. @@ -58,41 +61,46 @@ plot(caffeine) ![](man/figures/README-unnamed-chunk-4-1.png) -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 -lambda <- pai$new("lambda-cyhalothrin") -#> Querying BCPC for lambda-cyhalothrin ... -#> Querying PubChem ... -#> Trying to get chemical information from RDKit using PubChem SMILES -#> CC1([C@@H]([C@@H]1C(=O)O[C@@H](C#N)C2=CC(=CC=C2)OC3=CC=CC=C3)/C=C(/C(F)(F)F)\Cl)C -#> RDKit mw is 449.856 -#> mw is 449.8 -plot(lambda) +delta <- pai$new("deltamethrin") +#> Querying BCPC for deltamethrin ... +#> Querying PubChem for inchikey OWZREIFADZCYQD-NSHGMRRFSA-N ... +#> Get chemical information from RDKit using PubChem SMILES +#> CC1([C@H]([C@H]1C(=O)O[C@H](C#N)C2=CC(=CC=C2)OC3=CC=CC=C3)C=C(Br)Br)C +plot(delta) ``` ![](man/figures/README-unnamed-chunk-5-1.png) +Additional information can be 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. However, this functionality is to be superseded by +a dedicated package, defining data for the environmental risk assessment +on chemicals, in particular on active ingredients of plant protection +products. + ## 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")) +``` r +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 +``` sh +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 @@ -105,4 +113,6 @@ 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") +``` r +Sys.setenv(RETICULATE_PYTHON="/usr/bin/python3") +``` diff --git a/README.rmd b/README.rmd index 4fe26ea..b88c22f 100644 --- a/README.rmd +++ b/README.rmd @@ -14,8 +14,12 @@ knitr::opts_chunk$set( [![R-Universe status](https://jranke.r-universe.dev/badges/chents)](https://jranke.r-universe.dev/chents) [![Code coverage](https://img.shields.io/badge/coverage-jrwb.de-blue.svg)](https://pkgdown.jrwb.de/chents/coverage/coverage.html) -The R package **chents** provides some utilities for working with chemical -entities in R. +When working with data on chemical substances, we often need a reliable link between +the data and the chemical identity of the substances. The R package **chents** +provides a way to define and check the identity of chemically defined substances +("chemical entities") and to collect related information. + + When first defining a chemical entity, some chemical information is retrieved from the [PubChem](https://pubchem.ncbi.nlm.nih.gov/) website using @@ -39,31 +43,33 @@ print(caffeine) There is a very simple plotting method for the chemical structure. -```{r fig.width = 2} +```{r fig.height = 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) +```{r fig.height = 3.5} +delta <- pai$new("deltamethrin") +plot(delta) ``` +Additional information can be 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. However, this functionality is to be superseded by a dedicated +package, defining data for the environmental risk assessment on chemicals, +in particular on active ingredients of plant protection products. + ## Installation You can conveniently install chents from the repository kindly made available by the R-Universe project: -``` +```{r, eval = FALSE} install.packages("chents", repos = c("https://jranke.r-universe.dev", "https://cran.r-project.org")) ``` @@ -71,9 +77,10 @@ install.packages("chents", In order to profit from the chemoinformatics, you need to install RDKit and its python bindings. On a Debian type Linux distribution, just use -``` +```{sh, eval = FALSE} 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. @@ -85,7 +92,7 @@ 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. -``` +```{r, eval = FALSE} Sys.setenv(RETICULATE_PYTHON="/usr/bin/python3") ``` diff --git a/docs/authors.html b/docs/authors.html index a11c70d..162162f 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -46,14 +46,14 @@

Ranke J (2026). chents: Chemical Entities as R Objects. -R package version 0.4.1, https://pkgdown.jrwb.de/chents. +R package version 0.4.1, https://pkgdown.jrwb.de/chents/.

@Manual{,
   title = {chents: Chemical Entities as R Objects},
   author = {Johannes Ranke},
   year = {2026},
   note = {R package version 0.4.1},
-  url = {https://pkgdown.jrwb.de/chents},
+  url = {https://pkgdown.jrwb.de/chents/},
 }
diff --git a/docs/authors.md b/docs/authors.md index e297afa..ff9ca2d 100644 --- a/docs/authors.md +++ b/docs/authors.md @@ -10,12 +10,12 @@ Source: [`DESCRIPTION`](https://github.com/jranke/chents/blob/HEAD/DESCRIPTION) Ranke J (2026). *chents: Chemical Entities as R Objects*. R package -version 0.4.1, . +version 0.4.1, . @Manual{, title = {chents: Chemical Entities as R Objects}, author = {Johannes Ranke}, year = {2026}, note = {R package version 0.4.1}, - url = {https://pkgdown.jrwb.de/chents}, + url = {https://pkgdown.jrwb.de/chents/}, } diff --git a/docs/index.html b/docs/index.html index 6623b75..aec7d06 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,13 +50,13 @@

Online documentation R-Universe status Code coverage

-

The R package chents provides some utilities for working with chemical entities in R.

+

When working with data on chemical substances, we often need a reliable link between the data and the chemical identity of the substances. The R package chents provides a way to define and check the identity of chemically defined substances (“chemical entities”) and to collect related information.

When first defining a chemical entity, some chemical information is retrieved from the PubChem website using the webchem package.

-library(chents)
+library(chents)
 caffeine <- chent$new("caffeine")
-#> Querying PubChem ...
-#> Trying to get chemical information from RDKit using PubChem SMILES
+#> Querying PubChem for name caffeine ...
+#> Get chemical information from RDKit using PubChem SMILES
 #> CN1C=NC2=C1C(=O)N(C(=O)N2C)C

If Python and RDKit (> 2015.03) are installed and configured for use with the reticulate package, some additional chemical information including a 2D graph are computed.

The print method gives an overview of the information that was collected.

@@ -74,38 +74,40 @@ #> [3] "Guaranine" "1,3,7-Trimethylxanthine" #> [5] "Methyltheobromine" "Theine" #> [7] "Thein" "Cafeina" -#> [9] "Koffein" "Mateina"
+#> [9] "Caffein" "Cafipel"

There is a very simple plotting method for the chemical structure.

 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 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 first.

 lambda <- pai$new("lambda-cyhalothrin")
 #> Querying BCPC for lambda-cyhalothrin ...
-#> Querying PubChem ...
-#> Trying to get chemical information from RDKit using PubChem SMILES
+#> Querying PubChem for name lambda-cyhalothrin ...
+#> Get chemical information from RDKit using PubChem SMILES
 #> CC1([C@@H]([C@@H]1C(=O)O[C@@H](C#N)C2=CC(=CC=C2)OC3=CC=CC=C3)/C=C(/C(F)(F)F)\Cl)C
-#> RDKit mw is 449.856
-#> mw is 449.8
+#> Warning in self$get_rdkit(template = template): RDKit mw is 449.856 while mw is
+#> 449.8
 plot(lambda)

+

Additional information can be read from a local .yaml file. This information can be leveraged e.g. by the PEC_soil function of the ‘pfm’ package. However, this functionality is to be superseded by a dedicated package, defining data for the environmental risk assessment on chemicals, in particular on active ingredients of plant protection products.

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"))
+
+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
+
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")
+
+Sys.setenv(RETICULATE_PYTHON="/usr/bin/python3")