diff --git a/README.md b/README.md index b76746b12..c322bd087 100755 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Version](https://www.r-pkg.org/badges/version/rcdk?color=green)](https://cran.r- Downloads](http://cranlogs.r-pkg.org/badges/grand-total/rcdk?color=green)](https://cran.r-project.org/package=rcdk) [![CRAN Downloads Monthyl](http://cranlogs.r-pkg.org/badges/last-month/rcdk?color=green)](https://cran.r-project.org/package=rcdk) +[![R-CMD-check](https://github.com/zachcp/cdkr/workflows/R-CMD-check/badge.svg)](https://github.com/zachcp/cdkr/actions) # rcdk: a chemistry library @@ -36,25 +37,23 @@ install_github("https://github.com/CDK-R/cdkr", subdir="rcdk") Information on building and devloping the CDKR package is available in teh Otherwise if you prefer the command line -``` - cd /tmp/ - git clone git@github.com:CDK-R/rcdklibs.git - R CMD INSTALL rcdklibs - git clone git@github.com:CDK-R/cdkr.git - cd cdkr/rcdkjar - ant clean jar - cd ../ - R CMD INSTALL rcdk -``` + cd /tmp/ + git clone git@github.com:CDK-R/rcdklibs.git + R CMD INSTALL rcdklibs + git clone git@github.com:CDK-R/cdkr.git + cd cdkr/rcdkjar + ant clean jar + cd ../ + R CMD INSTALL rcdk Before performing the install, you should have the following dependencies installed: - - rJava - - fingerprint - - png - - RUnit - - Java JDK \>= 1.8 +- rJava +- fingerprint +- png +- RUnit +- Java JDK \>= 1.8 For the png package, I have tested [png-0.1-7](http://www.rforge.net/png/files/) @@ -86,7 +85,7 @@ You can try the following: # set the java version R CMD javareconf # or .... sudo R CMD javareconf - + # re install fromfrom R install.packages('rJava', type="source") diff --git a/rcdk/.Rbuildignore b/rcdk/.Rbuildignore index 3b22b0642..9620f7bb6 100755 --- a/rcdk/.Rbuildignore +++ b/rcdk/.Rbuildignore @@ -4,4 +4,5 @@ ^_pkgdown\.yml$ ^docs$ ^pkgdown$ -^revdep$ \ No newline at end of file +^revdep$ +README.Rmd diff --git a/rcdk/.gitignore b/rcdk/.gitignore index 31d5365dc..3a8d2860f 100755 --- a/rcdk/.gitignore +++ b/rcdk/.gitignore @@ -1,2 +1,8 @@ inst/doc docs +revdep/ +.RData +.Rhistory +.Rproj +*.Rmd +*.png \ No newline at end of file diff --git a/rcdk/DESCRIPTION b/rcdk/DESCRIPTION index 1ce30d298..85815618e 100755 --- a/rcdk/DESCRIPTION +++ b/rcdk/DESCRIPTION @@ -1,12 +1,16 @@ Package: rcdk -Version: 3.8.1 -Date: 2023-06-25 +Version: 3.9.0 +Date: 2024-03-02 Title: Interface to the 'CDK' Libraries -Authors@R: c(person('Rajarshi', 'Guha', role=c('aut',"cph"), email='rajarshi.guha@gmail.com'), - person('Zachary', 'Charlop-Powers', role=c('cre'), email='zach.charlop.powers@gmail.com'), - person('Emma', 'Schymanski', role=c('ctb'), email='schymane@gmail.com')) +Authors@R: c( + person('Rajarshi', 'Guha', ,'rajarshi.guha@gmail.com', role=c('aut',"cph"), + comment = c(ORCID = "0000-0001-7403-8819")), + person('Zachary', 'Charlop-Powers', ,'zach.charlop.powers@gmail.com',role=c('cre'), + comment = c(ORCID = "0000-0001-8816-4680")), + person('Emma', 'Schymanski', ,'schymane@gmail.com', role=c('ctb'), + comment = c(ORCID = "0000-0001-6868-8145"))) Depends: - rcdklibs (>= 2.8) + rcdklibs (>= 2.9) Imports: fingerprint, rJava, @@ -19,8 +23,10 @@ Suggests: RUnit, knitr, rmarkdown, - devtools + devtools, + depict License: LGPL +URL: https://github.com/CDK-R/cdkr LazyLoad: yes LazyData: true SystemRequirements: Java (>= 8) @@ -29,6 +35,7 @@ Description: Allows the user to access functionality in the 'CDK', a Java framework for chemoinformatics. This allows the user to load molecules, evaluate fingerprints, calculate molecular descriptors and so on. In addition, the 'CDK' API allows the user to view structures in 2D. -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 VignetteBuilder: knitr Encoding: UTF-8 +Remotes: CDK-R/depict diff --git a/rcdk/NEWS.md b/rcdk/NEWS.md index 46f71cc9f..93b8833b6 100755 --- a/rcdk/NEWS.md +++ b/rcdk/NEWS.md @@ -1,3 +1,7 @@ +# rcdk 3.9.0 + +* Update rCDK to work with rcdklibs 2.9 + # rcdk 3.8.0 * Change DESCRIPTION in accordance with CRAN rules about JDKs diff --git a/rcdk/R/atoms.R b/rcdk/R/atoms.R index 8536aa052..fffdcacbd 100755 --- a/rcdk/R/atoms.R +++ b/rcdk/R/atoms.R @@ -53,7 +53,7 @@ #' length \code{2}. #' #' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com}) -#' @docType package +#' @aliases rcdk-package NULL ## An example of getting all the coordinates for a molecule diff --git a/rcdk/README.Rmd b/rcdk/README.Rmd new file mode 100644 index 000000000..c1a28e7d7 --- /dev/null +++ b/rcdk/README.Rmd @@ -0,0 +1,36 @@ +--- +output: github_document +--- + + + +```{r, echo = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/" +) +``` + +# rcdk + + +[![CRAN Status](https://www.r-pkg.org/badges/version/rcdk)](https://cran.r-project.org/package=rcdk){.rcdk-release} +[![R-CMD-check](https://github.com/CDK-R/rcdk/workflows/R-CMD-check/badge.svg)](https://github.com/CDK-R/cdkr/actions){.rcdk-devel} +[![Codecov test coverage](https://codecov.io/gh/r-lib/rcdk/branch/main/graph/badge.svg)](https://app.codecov.io/gh/CDK-R/cdkr?branch=main) + + +Allows the user to access functionality in the `CDK`, a Java framework for chemoinformatics. This allows the user to load molecules, evaluate fingerprints, calculate molecular descriptors and so on. In addition, the 'CDK' API allows the user to view structures in 2D. + + +## Installation + +::: .rcdk-release +```{r, eval = FALSE} +# Install released version from CRAN +install.packages("rcdk") +``` +::: + + + diff --git a/rcdk/man/Atoms.Rd b/rcdk/man/Atoms.Rd index e926fcbaf..39b754a2e 100755 --- a/rcdk/man/Atoms.Rd +++ b/rcdk/man/Atoms.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/atoms.R -\docType{package} \name{Atoms} \alias{Atoms} +\alias{rcdk-package} \title{Operations on Atoms} \description{ \code{\link{get.symbol}} returns the chemical symbol for an atom diff --git a/rcdk/man/figures/logo.png b/rcdk/man/figures/logo.png new file mode 100644 index 000000000..40018498c Binary files /dev/null and b/rcdk/man/figures/logo.png differ diff --git a/rcdk/man/rcdk-deprecated.Rd b/rcdk/man/rcdk-deprecated.Rd index 24a19b761..565572b90 100644 --- a/rcdk/man/rcdk-deprecated.Rd +++ b/rcdk/man/rcdk-deprecated.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/deprecated_functions.R \docType{package} \name{rcdk-deprecated} +\alias{-package} \alias{rcdk-deprecated} \alias{deprecated_rcdk_function} \alias{do.typing} diff --git a/rcdk/_pkgdown.yml b/rcdk/pkgdown/_pkgdown.yml similarity index 91% rename from rcdk/_pkgdown.yml rename to rcdk/pkgdown/_pkgdown.yml index 5d95417c2..18391b965 100644 --- a/rcdk/_pkgdown.yml +++ b/rcdk/pkgdown/_pkgdown.yml @@ -1,14 +1,24 @@ url: https://cdk-r.github.io/cdkr/ +home: + title: Interact with the Chemistry Development Kit + + template: bootstrap: 5 + bslib: + primary: "#0054AD" + border-radius: 0.5rem + btn-border-radius: 0.25rem + +development: + mode: auto reference: - title: rCDK Functions - - subtitle: rCDK Data and Docs desc: > Available Datasets or Documentation @@ -115,4 +125,4 @@ reference: contents: - cdk.version - cdkFormula-class - - rcdk-deprecated \ No newline at end of file + - rcdk-deprecated diff --git a/rcdk/pkgdown/favicon/apple-touch-icon-120x120.png b/rcdk/pkgdown/favicon/apple-touch-icon-120x120.png new file mode 100644 index 000000000..68637f867 Binary files /dev/null and b/rcdk/pkgdown/favicon/apple-touch-icon-120x120.png differ diff --git a/rcdk/pkgdown/favicon/apple-touch-icon-152x152.png b/rcdk/pkgdown/favicon/apple-touch-icon-152x152.png new file mode 100644 index 000000000..6d625ffcb Binary files /dev/null and b/rcdk/pkgdown/favicon/apple-touch-icon-152x152.png differ diff --git a/rcdk/pkgdown/favicon/apple-touch-icon-180x180.png b/rcdk/pkgdown/favicon/apple-touch-icon-180x180.png new file mode 100644 index 000000000..973064fc2 Binary files /dev/null and b/rcdk/pkgdown/favicon/apple-touch-icon-180x180.png differ diff --git a/rcdk/pkgdown/favicon/apple-touch-icon-60x60.png b/rcdk/pkgdown/favicon/apple-touch-icon-60x60.png new file mode 100644 index 000000000..d380c3e0e Binary files /dev/null and b/rcdk/pkgdown/favicon/apple-touch-icon-60x60.png differ diff --git a/rcdk/pkgdown/favicon/apple-touch-icon-76x76.png b/rcdk/pkgdown/favicon/apple-touch-icon-76x76.png new file mode 100644 index 000000000..09dfee252 Binary files /dev/null and b/rcdk/pkgdown/favicon/apple-touch-icon-76x76.png differ diff --git a/rcdk/pkgdown/favicon/apple-touch-icon.png b/rcdk/pkgdown/favicon/apple-touch-icon.png new file mode 100644 index 000000000..ee7f758ba Binary files /dev/null and b/rcdk/pkgdown/favicon/apple-touch-icon.png differ diff --git a/rcdk/pkgdown/favicon/favicon-16x16.png b/rcdk/pkgdown/favicon/favicon-16x16.png new file mode 100644 index 000000000..882491dff Binary files /dev/null and b/rcdk/pkgdown/favicon/favicon-16x16.png differ diff --git a/rcdk/pkgdown/favicon/favicon-32x32.png b/rcdk/pkgdown/favicon/favicon-32x32.png new file mode 100644 index 000000000..62121c509 Binary files /dev/null and b/rcdk/pkgdown/favicon/favicon-32x32.png differ diff --git a/rcdk/pkgdown/favicon/favicon.ico b/rcdk/pkgdown/favicon/favicon.ico new file mode 100644 index 000000000..1d5774f79 Binary files /dev/null and b/rcdk/pkgdown/favicon/favicon.ico differ diff --git a/rcdk/vignettes/Features_29.Rmd b/rcdk/vignettes/Features_29.Rmd new file mode 100644 index 000000000..c2b2592c3 --- /dev/null +++ b/rcdk/vignettes/Features_29.Rmd @@ -0,0 +1,174 @@ +--- +title: "Features 2.9" +author: "Zachary Charlop-Powers" +date: "`r Sys.Date()`" +output: + rmarkdown::html_vignette: + toc: true +vignette: > + %\VignetteIndexEntry{Features 2.9} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + +# CDK 2.9 Release Notes Vignettes + +[CDK 2.9 Release Notes](https://github.com/cdk/cdk/releases/tag/cdk-2.9) + +[rJava](https://rforge.net/rJava/docs/reference/index.html) + + +## RXN Arrows + +https://github.com/cdk/cdk/pull/927 + +```{r setup, message=FALSE} + +library(rcdklibs) +library(depict) + + +# Java Imports +sp <- J('org.openscience.cdk.smiles.SmilesParser') +silentchemobject <- J("org.openscience.cdk.silent.SilentChemObjectBuilder") +smiles_parser <- new(sp, silentchemobject$getInstance()) +ReactionManipulator <- J('org.openscience.cdk.tools.manipulator.ReactionManipulator') +IReaction <- J('org.openscience.cdk.interfaces.IReaction') +dg <- .jnew('org.openscience.cdk.depict.DepictionGenerator') + +to_svg <- function(grd) { + svg_str <- grd$toSvgStr() + svg_list <- strsplit(svg_str, "\n")[[1]] + paste(svg_list[3:length(svg_list)], collapse="\n") +} + + +abbreviations <- .jnew('org.openscience.cdk.depict.Abbreviations') +abbreviations$add("[Al+3].[Cl-].[Cl-].[Cl-] AlCl3") +abbreviations$add("ClCCl DCM") +abbreviations$setContractToSingleLabel(TRUE) + +``` + + +```{r results='asis'} + +rxn <- smiles_parser$parseReactionSmiles("[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][cH:13][cH:14][cH:15]1.[CH2:3]([CH2:4][C:5](=[O:6])Cl)[CH2:2][Cl:1]>[Al+3].[Cl-].[Cl-].[Cl-].C(Cl)Cl>[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][c:13]([cH:14][cH:15]1)[C:5](=[O:6])[CH2:4][CH2:3][CH2:2][Cl:1] |f:2.3.4.5| Friedel-Crafts acylation [3.10.1]") + +# note `as.list` +for (mol in as.list(ReactionManipulator$getAllAtomContainers(rxn))) { + abbreviations$apply(mol) +} + +rxn$setDirection(IReaction$Direction$NO_GO) +svg <- depiction() |> depict(rxn) +to_svg(svg) + +``` + + + +```{r results='asis'} +rxn <- smiles_parser$parseReactionSmiles("[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][cH:13][cH:14][cH:15]1.[CH2:3]([CH2:4][C:5](=[O:6])Cl)[CH2:2][Cl:1]>[Al+3].[Cl-].[Cl-].[Cl-].C(Cl)Cl>[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][c:13]([cH:14][cH:15]1)[C:5](=[O:6])[CH2:4][CH2:3][CH2:2][Cl:1] |f:2.3.4.5| Friedel-Crafts acylation [3.10.1]") + +for (mol in as.list(ReactionManipulator$getAllAtomContainers(rxn))) { + abbreviations$apply(mol) +} + +rxn$setDirection(IReaction$Direction$RETRO_SYNTHETIC) +svg <- depiction() |> depict(rxn) +to_svg(svg) + +``` + + +```{r results='asis'} +rxn <- smiles_parser$parseReactionSmiles("[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][cH:13][cH:14][cH:15]1.[CH2:3]([CH2:4][C:5](=[O:6])Cl)[CH2:2][Cl:1]>[Al+3].[Cl-].[Cl-].[Cl-].C(Cl)Cl>[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][c:13]([cH:14][cH:15]1)[C:5](=[O:6])[CH2:4][CH2:3][CH2:2][Cl:1] |f:2.3.4.5| Friedel-Crafts acylation [3.10.1]") + +for (mol in as.list(ReactionManipulator$getAllAtomContainers(rxn))) { + abbreviations$apply(mol) +} + +rxn$setDirection(IReaction$Direction$BIDIRECTIONAL) +svg <- depiction() |> depict(rxn) +to_svg(svg) + +``` + +```{r results='asis'} +rxn <- smiles_parser$parseReactionSmiles("c1c(Cl)cccc1[N-][N+]#N>>c1c(Cl)cccc1N=[N+]=[N-]") + + +for (mol in as.list(ReactionManipulator$getAllAtomContainers(rxn))) { + abbreviations$apply(mol) +} + +rxn$setDirection(IReaction$Direction$RESONANCE) +svg <- depiction() |> depict(rxn) +to_svg(svg) +``` + + + +## Multi-Step Smiles + +```java +SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); +IReactionSet rset = sp.parseReactionSetSmiles("[Pb]>>[Ag]>>[Au] lead-to-silver-to-gold"); +``` + +```{r results='asis'} + +multi_smiles <- "ClC1=NC=2N(C(=C1)N(CC3=CC=CC=C3)CC4=CC=CC=C4)N=CC2C(OCC)=O>C1(=CC(=CC(=N1)C)N)N2C[C@H](CCC2)O.O1CCOCC1.CC1(C2=C(C(=CC=C2)P(C3=CC=CC=C3)C4=CC=CC=C4)OC5=C(C=CC=C15)P(C6=CC=CC=C6)C7=CC=CC=C7)C.C=1C=CC(=CC1)\\C=C\\C(=O)\\C=C\\C2=CC=CC=C2.C=1C=CC(=CC1)\\C=C\\C(=O)\\C=C\\C2=CC=CC=C2.C=1C=CC(=CC1)\\C=C\\C(=O)\\C=C\\C2=CC=CC=C2.[Pd].[Pd].[Cs]OC(=O)O[Cs]>C1(=CC(=CC(=N1)C)NC2=NC=3N(C(=C2)N(CC4=CC=CC=C4)CC5=CC=CC=C5)N=CC3C(OCC)=O)N6C[C@H](CCC6)O>CO.C1CCOC1.O.O[Li]>C1(=CC(=CC(=N1)C)NC2=NC=3N(C(=C2)N(CC4=CC=CC=C4)CC5=CC=CC=C5)N=CC3C(O)=O)N6C[C@H](CCC6)O>CN(C)C(=[N+](C)C)ON1C2=C(C=CC=N2)N=N1.F[P-](F)(F)(F)(F)F.[NH4+].[Cl-].CN(C)C=O.CCN(C(C)C)C(C)C>C1(=CC(=CC(=N1)C)NC2=NC=3N(C(=C2)N(CC4=CC=CC=C4)CC5=CC=CC=C5)N=CC3C(N)=O)N6C[C@H](CCC6)O>>C1(=CC(=CC(=N1)C)NC2=NC=3N(C(=C2)N)N=CC3C(N)=O)N4C[C@H](CCC4)O |f:4.5.6.7.8,16.17,18.19| US20190241576A1" + +rxn_set <- smiles_parser$parseReactionSetSmiles(multi_smiles) +svg <- depiction() |> depict(rxn_set) +to_svg(svg) +``` + + +## Features 2.8 + +### Maygen + + + +```{r} + +maygen_cls <- J('org.openscience.cdk.structgen.maygen.Maygen') +#smioutout_cls <- J('org.openscience.cdk.structgen.maygen.SmiOutputConsumer') +silentchemobject <- J("org.openscience.cdk.silent.SilentChemObjectBuilder") +smigen_cls <- J('org.openscience.cdk.smiles.SmilesGenerator') +smigen <- .jnew('org.openscience.cdk.smiles.SmilesGenerator') +#IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); +#SmilesGenerator smigen = new SmilesGenerator(SmiFlavor.Default); + + +maygen <- new(maygen_cls, silentchemobject$getInstance()) +maygen$setFormula("C3Cl2H4") + + +# smigen$create() +# consumer +# maygen$setConsumer(mol) +# maygen$run() + + +# StringWriter sw = new StringWriter(); +# maygen.setConsumer(new SmiOutputConsumer(sw)); + +# StringWriter sw = new StringWriter(); +# SdfOutputConsumer consumer = new SdfOutputConsumer(sw); +# consumer.setCoordinates(true); + +# maygen.setConsumer(mol -> { +# try { +# System.out.println(smigen.create(mol)); +# } catch (CDKException ignore) { } +# }); +# +# int count = maygen.getCount(); // number of structures generated + +``` + diff --git a/rcdk/vignettes/using-rcdk.Rmd b/rcdk/vignettes/rcdk.Rmd old mode 100755 new mode 100644 similarity index 98% rename from rcdk/vignettes/using-rcdk.Rmd rename to rcdk/vignettes/rcdk.Rmd index 29b34f8a9..36696c435 --- a/rcdk/vignettes/using-rcdk.Rmd +++ b/rcdk/vignettes/rcdk.Rmd @@ -1,3 +1,17 @@ +--- +title: "Using the CDK from R" +author: "Rajarshi Guha" +date: "`r Sys.Date()`" +description: > + Learn how to get started with the basics of pkgdown. +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Using the CDK from R} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + --- title: "Using the CDK from R" author: "Rajarshi Guha"