diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 0041cccfb..6a4b9a7ef 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -46,7 +46,7 @@ jobs: shell: Rscript {0} - name: Cache R packages - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ env.R_LIBS_USER }} key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} diff --git a/README.Rmd b/README.Rmd index ca9915271..d42e25223 100755 --- a/README.Rmd +++ b/README.Rmd @@ -11,7 +11,7 @@ knitr::opts_chunk$set( ) ``` -[![Build Status](https://api.travis-ci.org/CDK-R/cdkr.svg?branch=master)](https://travis-ci.org/CDK-R/cdkr) + [![CRAN Version](https://www.r-pkg.org/badges/version/rcdk?color=green)](https://cran.r-project.org/package=rcdk) [![CRAN 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) diff --git a/rcdk/.Rbuildignore b/rcdk/.Rbuildignore index 9620f7bb6..f23f3d5f5 100755 --- a/rcdk/.Rbuildignore +++ b/rcdk/.Rbuildignore @@ -6,3 +6,6 @@ ^pkgdown$ ^revdep$ README.Rmd +vignettes/Features_29.Rmd +^doc$ +^Meta$ diff --git a/rcdk/.gitignore b/rcdk/.gitignore index 3a8d2860f..607761ce7 100755 --- a/rcdk/.gitignore +++ b/rcdk/.gitignore @@ -5,4 +5,6 @@ revdep/ .Rhistory .Rproj *.Rmd -*.png \ No newline at end of file +*.png +/doc/ +/Meta/ diff --git a/rcdk/DESCRIPTION b/rcdk/DESCRIPTION index 85815618e..baecd60e2 100755 --- a/rcdk/DESCRIPTION +++ b/rcdk/DESCRIPTION @@ -1,14 +1,16 @@ Package: rcdk -Version: 3.9.0 -Date: 2024-03-02 +Version: 3.8.2 +Date: 2025-09-10 Title: Interface to the 'CDK' Libraries 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'), + 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"))) + person('Emma', 'Schymanski', ,'schymane@gmail.com', role=c('ctb'), + comment = c(ORCID = "0000-0001-6868-8145")), + person('Egon', 'Willighagen', ,'egon.willighagen@maastrichtuniversity.nl', role=c('ctb'), + comment = c(ORCID = "0000-0001-7542-0286"))) Depends: rcdklibs (>= 2.9) Imports: @@ -23,8 +25,7 @@ Suggests: RUnit, knitr, rmarkdown, - devtools, - depict + devtools License: LGPL URL: https://github.com/CDK-R/cdkr LazyLoad: yes @@ -35,7 +36,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.3.1 +RoxygenNote: 7.3.3 VignetteBuilder: knitr Encoding: UTF-8 -Remotes: CDK-R/depict + diff --git a/rcdk/NEWS.md b/rcdk/NEWS.md index 93b8833b6..fa4bf8ca0 100755 --- a/rcdk/NEWS.md +++ b/rcdk/NEWS.md @@ -1,6 +1,6 @@ -# rcdk 3.9.0 +# rcdk 3.8.2 -* Update rCDK to work with rcdklibs 2.9 +* Update rCDK to work with rcdklibs 2.11 # rcdk 3.8.0 diff --git a/rcdk/R/deprecated_functions.R b/rcdk/R/deprecated_functions.R index 4632ef0a9..2b340a522 100644 --- a/rcdk/R/deprecated_functions.R +++ b/rcdk/R/deprecated_functions.R @@ -1,20 +1,19 @@ ################################################################################ #' Deprecated functions in the rcdk package. -#' +#' #' These functions are provided for compatibility with older version of #' the phyloseq package. They may eventually be completely #' removed. -#' +#' #' @usage deprecated_rcdk_function(x, value, ...) #' @rdname rcdk-deprecated #' @name rcdk-deprecated #' @param x For assignment operators, the object that will undergo a replacement #' (object inside parenthesis). -#' @param value For assignment operators, the value to replace with +#' @param value For assignment operators, the value to replace with #' (the right side of the assignment). -#' @param ... For functions other than assignment operators, +#' @param ... For functions other than assignment operators, #' parameters to be passed to the modern version of the function (see table). -#' @docType package #' @export do.typing #' @aliases deprecated_rcdk_function do.typing #' @details @@ -24,4 +23,4 @@ #' deprecated_rcdk_function <- function(x, value, ...){return(NULL)} do.typing <- function(...){.Deprecated("set.atom.types", package="rcdk");return(set.atom.types(...))} -################################################################################ \ No newline at end of file +################################################################################ diff --git a/rcdk/R/fingerprint.R b/rcdk/R/fingerprint.R index a145987c2..d374f3ac0 100755 --- a/rcdk/R/fingerprint.R +++ b/rcdk/R/fingerprint.R @@ -1,8 +1,8 @@ #' Generate molecular fingerprints -#' +#' #' `get.fingerprint` returns a `fingerprint` object representing molecular fingerprint of #' the input molecule. -#' +#' #' @param molecule A \code{jobjRef} object to an \code{IAtomContaine} #' @param type The type of fingerprint. Possible values are: #' \itemize{ @@ -18,52 +18,50 @@ #' \item pubchem - 881 bit fingerprints defined by PubChem #' \item kr - 4860 bit fingerprint defined by Klekota and Roth #' \item shortestpath - A fingerprint based on the shortest paths between pairs of atoms and takes into account ring systems, charges etc. -#' \item signature - A feature,count type of fingerprint, similar in nature to circular fingerprints, but based on the signature +#' \item signature - A feature,count type of fingerprint, similar in nature to circular fingerprints, but based on the signature #' descriptor #' \item circular - An implementation of the ECFP6 (default) fingerprint. Other circular types can be chosen by modifying the \code{circular.type} parameter. #' \item substructure - Fingerprint based on list of SMARTS pattern. By default a set of functional groups is tested. #' } #' @param fp.mode The style of fingerprint. Specifying "`bit`" will return a binary fingerprint, -#' "`raw`" returns the the original representation (usually sequence of integers) and +#' "`raw`" returns the the original representation (usually sequence of integers) and #' "`count`" returns the fingerprint as a sequence of counts. #' @param depth The search depth. This argument is ignored for the #' `pubchem`, `maccs`, `kr` and `estate` fingerprints -#' @param size The final length of the fingerprint. -#' This argument is ignored for the `pubchem`, `maccs`, `kr`, `signature`, `circular` and +#' @param size The final length of the fingerprint. +#' This argument is ignored for the `pubchem`, `maccs`, `kr`, `signature`, `circular` and #' `estate` fingerprints #' @param substructure.pattern List of characters containing the SMARTS pattern to match. If the an empty list is provided (default) than the functional groups substructures (default in CDK) are used. #' @param circular.type Name of the circular fingerprint type that should be computed given as string. Possible values are: 'ECFP0', 'ECFP2', 'ECFP4', 'ECFP6' (default), 'FCFP0', 'FCFP2', 'FCFP4' and 'FCFP6'. #' @param verbose Verbose output if \code{TRUE} -#' @return an S4 object of class \code{\link{fingerprint-class}} or \code{\link{featvec-class}}, +#' @return an S4 object of class \code{\link[fingerprint]{fingerprint-class}} or \code{\link[fingerprint]{featvec-class}}, #' which can be manipulated with the fingerprint package. #' @export #' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com}) -#' @examples +#' @examples #' ## get some molecules -#' sp <- get.smiles.parser() -#' smiles <- c('CCC', 'CCN', 'CCN(C)(C)', 'c1ccccc1Cc1ccccc1','C1CCC1CC(CN(C)(C))CC(=O)CC') +#' smiles <- c('CCC', 'CCN') #' mols <- parse.smiles(smiles) -#' -#' ## get a single fingerprint using the standard -#' ## (hashed, path based) fingerprinter -#' fp <- get.fingerprint(mols[[1]]) -#' -#' ## get MACCS keys for all the molecules +#' +#' ## get a single fingerprint using MACCS (fast) +#' fp <- get.fingerprint(mols[[1]], type='maccs') +#' +#' ## get MACCS keys for both molecules #' fps <- lapply(mols, get.fingerprint, type='maccs') -#' +#' #' ## get Signature fingerprint #' ## feature, count fingerprinter #' fps <- lapply(mols, get.fingerprint, type='signature', fp.mode='raw') #' ## get Substructure fingerprint for functional group fragments #' fps <- lapply(mols, get.fingerprint, type='substructure') -#' +#' #' ## get Substructure count fingerprint for user defined fragments #' mol1 <- parse.smiles("c1ccccc1CCC")[[1]] #' smarts <- c("c1ccccc1", "[CX4H3][#6]", "[CX2]#[CX2]") #' fps <- get.fingerprint(mol1, type='substructure', fp.mode='count', #' substructure.pattern=smarts) -#' -#' ## get ECFP0 count fingerprints +#' +#' ## get ECFP0 count fingerprints #' mol2 <- parse.smiles("C1=CC=CC(=C1)CCCC2=CC=CC=C2")[[1]] #' fps <- get.fingerprint(mol2, type='circular', fp.mode='count', circular.type='ECFP0') get.fingerprint <- function(molecule, type = 'standard', fp.mode = 'bit', depth=6, size=1024, substructure.pattern=character(), circular.type = "ECFP6", verbose=FALSE) { @@ -75,17 +73,17 @@ get.fingerprint <- function(molecule, type = 'standard', fp.mode = 'bit', depth= mode(size) <- 'integer' mode(depth) <- 'integer' - + # Determine integer ID for the circular fingerprint given its desired type. - # This allows us to use also ECFP4, ... + # This allows us to use also ECFP4, ... if (type == 'circular') { - circular.type.id <- switch(circular.type, + circular.type.id <- switch(circular.type, ECFP0 = 1, ECFP2 = 2, ECFP4 = 3, ECFP6 = 4, FCFP0 = 5, FCFP2 = 6, FCFP4 = 7, FCFP6 = 8, NULL) - + if (is.null(circular.type.id)) stop(paste('Invalid circular fingerprint type: ', circular.type)) - + mode(circular.type.id) <- 'integer' } @@ -103,8 +101,8 @@ get.fingerprint <- function(molecule, type = 'standard', fp.mode = 'bit', depth= shortestpath = .jnew('org/openscience/cdk/fingerprint/ShortestPathFingerprinter', size), signature = .jnew('org/openscience/cdk/fingerprint/SignatureFingerprinter', depth), circular = .jnew('org/openscience/cdk/fingerprint/CircularFingerprinter', circular.type.id), - substructure = - if (length(substructure.pattern) == 0) + substructure = + if (length(substructure.pattern) == 0) # Loads the default group substructures { .jnew('org/openscience/cdk/fingerprint/SubstructureFingerprinter') } else @@ -125,11 +123,11 @@ get.fingerprint <- function(molecule, type = 'standard', fp.mode = 'bit', depth= } else if (fp.mode == 'count') { jfp <- .jcall(fingerprinter, "Lorg/openscience/cdk/fingerprint/ICountFingerprint;", - "getCountFingerprint", molecule, check=FALSE) + "getCountFingerprint", molecule, check=FALSE) } - + e <- .jgetEx() - if (.jcheck(silent=TRUE)) { + if (.jcheck(silent=TRUE)) { if (verbose) print(e) return(NULL) } @@ -139,7 +137,7 @@ get.fingerprint <- function(molecule, type = 'standard', fp.mode = 'bit', depth= if (fp.mode == 'bit') { bitset <- .jcall(jfp, "Ljava/util/BitSet;", "asBitSet") - + if (type == 'maccs') nbit <- 166 else if (type == 'estate') nbit <- 79 else if (type == 'pubchem') nbit <- 881 @@ -147,7 +145,7 @@ get.fingerprint <- function(molecule, type = 'standard', fp.mode = 'bit', depth= else if (type == 'substructure') nbit <- .jcall(fingerprinter, "I", "getSize") else if (type == 'circular') nbit <- .jcall(fingerprinter, "I", "getSize") else nbit <- size - + bitset <- .jcall(bitset, "S", "toString") s <- gsub('[{}]','', bitset) s <- strsplit(s, split=',')[[1]] @@ -166,7 +164,7 @@ get.fingerprint <- function(molecule, type = 'standard', fp.mode = 'bit', depth= tempkey <- .jsimplify(tempkey) } keys[[i]] <- tempkey - + } values <- list() diff --git a/rcdk/R/formula.R b/rcdk/R/formula.R index dfa58ac84..855de5011 100755 --- a/rcdk/R/formula.R +++ b/rcdk/R/formula.R @@ -528,7 +528,7 @@ generate.formula <- function(mass, #' @param tol The tolerance #' @return A \code{jobjRef} corresponding to an instance of \code{IsotopePatternSimilarity} #' @seealso \code{\link{compare.isotope.pattern}} -#' @references \url{http://cdk.github.io/cdk/1.5/docs/api/org/openscience/cdk/formula/IsotopePatternSimilarity.html} +#' @references \url{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/formula/IsotopePatternSimilarity.html} #' @author Miguel Rojas Cherto get.isotope.pattern.similarity <- function(tol = NULL) { ips <- .jnew("org/openscience/cdk/formula/IsotopePatternSimilarity") @@ -544,7 +544,7 @@ get.isotope.pattern.similarity <- function(tol = NULL) { #' #' @param minAbundance The minimum abundance #' @return A \code{jobjRef} corresponding to an instance of \code{IsotopePatternGenerator} -#' @references \url{http://cdk.github.io/cdk/1.5/docs/api/org/openscience/cdk/formula/IsotopePatternGenerator.html} +#' @references \url{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/formula/IsotopePatternGenerator.html} #' @author Miguel Rojas Cherto get.isotope.pattern.generator <- function(minAbundance = NULL) { if (is.null(minAbundance)) @@ -564,7 +564,7 @@ get.isotope.pattern.generator <- function(minAbundance = NULL) { #' @return A numeric value between 0 and 1 indicating the similarity between the two patterns #' @seealso \code{\link{get.isotope.pattern.similarity}} #' @export -#' @references \url{http://cdk.github.io/cdk/2.3/docs/api/org/openscience/cdk/formula/IsotopePatternSimilarity.html} +#' @references \url{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/formula/IsotopePatternSimilarity.html} #' @author Miguel Rojas Cherto compare.isotope.pattern <- function(iso1, iso2, ips = NULL) { cls <- unique(c(class(iso1), class(iso2))) diff --git a/rcdk/R/rcdk.R b/rcdk/R/rcdk.R index 50b1b4a0c..989733301 100755 --- a/rcdk/R/rcdk.R +++ b/rcdk/R/rcdk.R @@ -10,11 +10,11 @@ #' a builder object when directly working with the CDK API via #' `rJava`. #' -#' This method returns an instance of the \href{https://cdk.github.io/cdk/2.5/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder}. +#' This method returns an instance of the \href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder}. #' Note that this is a static object that is created at package load time, #' and the same instance is returned whenever this function is called. #' -#' @return An instance of \href{https://cdk.github.io/cdk/2.5/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder} +#' @return An instance of \href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder} #' @export #' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com}) get.chem.object.builder <- function() { diff --git a/rcdk/R/smiles.R b/rcdk/R/smiles.R index 995e8c1b7..6122d8298 100755 --- a/rcdk/R/smiles.R +++ b/rcdk/R/smiles.R @@ -2,11 +2,11 @@ #' #' The CDK supports a variety of customizations for SMILES generation including #' the use of lower case symbols for aromatic compounds to the use of the ChemAxon -#' \href{http://butane.chem.uiuc.edu/jsmoore/marvin/help/formats/cxsmiles-doc.html}{CxSmiles} +#' \href{https://docs.chemaxon.com/display/docs/formats_chemaxon-extended-smiles-and-smarts-cxsmiles-and-cxsmarts.md}{CxSmiles} #' format. Each 'flavor' is represented by an integer and multiple #' customizations are bitwise OR'ed. This method accepts the names of one or #' more customizations and returns the bitwise OR of them. -#' See \href{https://cdk.github.io/cdk/2.3/docs/api/index.html?org/openscience/cdk/smiles/SmiFlavor.html}{CDK documentation} +#' See \href{https://cdk.github.io/cdk/2.10/docs/api/index.html?org/openscience/cdk/smiles/SmiFlavor.html}{CDK documentation} #' for the list of flavors and what they mean. #' #' @param flavors A character vector of flavors. The default is \code{Generic} @@ -42,7 +42,7 @@ #' @md #' @return A numeric representing the bitwise `OR`` of the specified flavors #' @seealso \code{\link{get.smiles}} -#' @references \href{https://cdk.github.io/cdk/2.3/docs/api/index.html?org/openscience/cdk/smiles/SmiFlavor.html}{CDK documentation} +#' @references \href{https://cdk.github.io/cdk/2.10/docs/api/index.html?org/openscience/cdk/smiles/SmiFlavor.html}{CDK documentation} #' @examples #' m <- parse.smiles('C1C=CCC1N(C)c1ccccc1')[[1]] #' get.smiles(m) @@ -96,7 +96,7 @@ smiles.flavors <- function(flavors = c('Generic')) { #' The function will generate a SMILES representation of an #' `IAtomContainer` object. The default parameters of the CDK SMILES #' generator are used. This can mean that for large ring systems the -#' method may fail. See CDK \href{http://cdk.github.io/cdk/2.2/docs/api/org/openscience/cdk/smiles/SmilesGenerator.html}{Javadocs} +#' method may fail. See CDK \href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/smiles/SmilesGenerator.html}{Javadocs} #' for more information #' @param molecule The molecule to query. Should be a `jobjRef` representing an `IAtomContainer` #' @param flavor The type of SMILES to generate. See \code{\link{smiles.flavors}}. Default is `Generic` @@ -106,7 +106,7 @@ smiles.flavors <- function(flavors = c('Generic')) { #' @seealso \code{\link{parse.smiles}}, \code{\link{smiles.flavors}} #' @export #' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com}) -#' @references \href{http://cdk.github.io/cdk/2.2/docs/api/org/openscience/cdk/smiles/SmilesGenerator.html}{SmilesGenerator} +#' @references \href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/smiles/SmilesGenerator.html}{SmilesGenerator} #' @examples #' m <- parse.smiles('C1C=CCC1N(C)c1ccccc1')[[1]] #' get.smiles(m) @@ -127,7 +127,7 @@ get.smiles <- function(molecule, flavor = smiles.flavors(c('Generic')), smigen = #' to instantiate a new parser for each call #' #' @return A `jobjRef` object corresponding to the CDK -#' \href{http://cdk.github.io/cdk/2.2/docs/api/org/openscience/cdk/smiles/SmilesParser.html}{SmilesParser} class +#' \href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/smiles/SmilesParser.html}{SmilesParser} class #' @seealso \code{\link{get.smiles}}, \code{\link{parse.smiles}} #' @export #' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com}) diff --git a/rcdk/cran-comments.md b/rcdk/cran-comments.md index cd7560c9f..04c749215 100755 --- a/rcdk/cran-comments.md +++ b/rcdk/cran-comments.md @@ -1,5 +1,15 @@ ## General Comments -- submission of rcdk 3.8.1 -- fix to the SystemRequirements Field -- update CITATION file +- 3rd resubmission. Fixed the final URL issue. More long test avoidance on CRAN/linux +- 2nd resubmission. The URL issue seems to be related to CACHE; I've slimmed the Unit tests to fit in time. +- resubmission with a number of small URL fixes +- submission of rcdk 3.8.2 +- add Egon +- update links to fingerprint +- fix a few lints and tests + + +── R CMD check results ─────────────────────────────── rcdk 3.8.2 ──── +Duration: 25.5s + +0 errors ✔ | 0 warnings ✔ | 0 notes ✔ \ No newline at end of file diff --git a/rcdk/inst/unitTests/runit.fingerprints.R b/rcdk/inst/unitTests/runit.fingerprints.R index 91794630e..08f22e806 100755 --- a/rcdk/inst/unitTests/runit.fingerprints.R +++ b/rcdk/inst/unitTests/runit.fingerprints.R @@ -2,10 +2,18 @@ test.fp <- function() { mol <- parse.smiles("CCCCC")[[1]] fp <- get.fingerprint(mol, type='maccs') checkTrue(length(fp@bits) > 0) - fp <- get.fingerprint(mol, type='kr') - checkTrue(length(fp@bits) > 0) - fp <- get.fingerprint(mol, type='shortestpath') - checkTrue(length(fp@bits) > 0) + + # Skip slow tests during CRAN check (use multiple detection methods) + is_cran_check <- Sys.getenv("_R_CHECK_PACKAGE_NAME_", "") != "" || + Sys.getenv("_R_CHECK_TIMINGS_", "") != "" || + identical(Sys.getenv("NOT_CRAN"), "false") + + if (!is_cran_check) { + fp <- get.fingerprint(mol, type='kr') + checkTrue(length(fp@bits) > 0) + fp <- get.fingerprint(mol, type='shortestpath') + checkTrue(length(fp@bits) > 0) + } } # Substructure test are inspired by the test for the substructure fingerprints in CDK @@ -14,43 +22,43 @@ test.fp.substructures.binary <- function() { mol <- parse.smiles("c1ccccc1CCC")[[1]] fp <- get.fingerprint(mol, type="substructure", fp.mode="bit") fp_bits <- fingerprint::fp.to.matrix(list(fp)) - + checkEquals(length(fp), 307) checkEquals(fp_bits[1], 1) checkEquals(fp_bits[2], 1) checkEquals(fp_bits[274], 1) checkEquals(fp_bits[101], 0) - + # User defined patterns smarts <- c("c1ccccc1", "[CX4H3][#6]", "[CX2]#[CX2]") mol <- parse.smiles("c1ccccc1CCC")[[1]] - fp <- get.fingerprint(mol, type="substructure", fp.mode="bit", + fp <- get.fingerprint(mol, type="substructure", fp.mode="bit", substructure.pattern = smarts) fp_bits <- fingerprint::fp.to.matrix(list(fp)) - + checkEquals(length(fp), 3) checkEquals(length(fp@bits), 2) checkEquals(fp_bits[1], 1) checkEquals(fp_bits[2], 1) checkEquals(fp_bits[3], 0) - + mol <- parse.smiles("C=C=C")[[1]] - fp <- get.fingerprint(mol, type="substructure", fp.mode="bit", + fp <- get.fingerprint(mol, type="substructure", fp.mode="bit", substructure.pattern = smarts) fp_bits <- fingerprint::fp.to.matrix(list(fp)) - + checkEquals(length(fp), 3) checkEquals(length(fp@bits), 0) for (i_fp in 1:3) { checkEquals(fp_bits[i_fp], 0) } - + # Check for aromatic ring smarts <- "a:1:a:a:a:a:a1" mol <- parse.smiles("C1=CC=CC(=C1)CCCC2=CC=CC=C2")[[1]] set.atom.types(mol) do.aromaticity(mol) - fp <- get.fingerprint(mol, type="substructure", fp.mode="bit", + fp <- get.fingerprint(mol, type="substructure", fp.mode="bit", substructure.pattern = smarts) fp_bits <- fingerprint::fp.to.matrix(list(fp)) checkEquals(length(fp), 1) @@ -61,42 +69,41 @@ test.fp.substructures.count <- function() { # Default patterns: functional groups mol <- parse.smiles("c1ccccc1CCC")[[1]] fp <- get.fingerprint(mol, type="substructure", fp.mode="count") - + checkEquals(length(fp), 307) checkTrue(fingerprint::count(fp@features[[1]]) > 0) checkTrue(fingerprint::count(fp@features[[2]]) > 0) checkTrue(fingerprint::count(fp@features[[274]]) > 0) checkTrue(fingerprint::count(fp@features[[101]]) == 0) - + # User defined patterns smarts <- c("c1ccccc1", "[CX4H3][#6]", "[CX2]#[CX2]") mol <- parse.smiles("c1ccccc1CCC")[[1]] - fp <- get.fingerprint(mol, type="substructure", fp.mode="count", + fp <- get.fingerprint(mol, type="substructure", fp.mode="count", substructure.pattern = smarts) - + checkEquals(length(fp), 3) checkEquals(fingerprint::count(fp@features[[1]]), 1) checkEquals(fingerprint::count(fp@features[[2]]), 1) checkEquals(fingerprint::count(fp@features[[3]]), 0) - + mol <- parse.smiles("C=C=C")[[1]] - fp <- get.fingerprint(mol, type="substructure", fp.mode="count", + fp <- get.fingerprint(mol, type="substructure", fp.mode="count", substructure.pattern = smarts) - + checkEquals(length(fp), 3) for (i_fp in 1:3) { checkEquals(fingerprint::count(fp@features[[i_fp]]), 0) } - + # Check for aromatic ring smarts <- "a:1:a:a:a:a:a1" mol <- parse.smiles("C1=CC=CC(=C1)CCCC2=CC=CC=C2")[[1]] set.atom.types(mol) do.aromaticity(mol) - fp <- get.fingerprint(mol, type="substructure", fp.mode="count", + fp <- get.fingerprint(mol, type="substructure", fp.mode="count", substructure.pattern = smarts) - + checkEquals(length(fp), 1) checkEquals(fingerprint::count(fp@features[[1]]), 2) } - diff --git a/rcdk/inst/unitTests/runit.frags.R b/rcdk/inst/unitTests/runit.frags.R index 7652c84f1..48cbf4b3b 100755 --- a/rcdk/inst/unitTests/runit.frags.R +++ b/rcdk/inst/unitTests/runit.frags.R @@ -1,6 +1,6 @@ test.frag1 <- function() { m <- parse.smiles("c1(ccc(cc1C)CCC(C(CCC)C2C(C2)CC)C3C=C(C=C3)CC)C")[[1]] - do.aromaticity(m) + do.aromaticity(m) set.atom.types(m) f <- get.murcko.fragments(m, as.smiles=TRUE, min.frag.size = 6, single.framework = TRUE) checkEquals(length(f), 1) @@ -13,7 +13,7 @@ test.frag2 <- function() { ms <- parse.smiles(c('c1(ccc(cc1C)CCC(C(CCC)C2C(C2)CC)C3C=C(C=C3)CC)C', 'c1ccc(cc1)c2c(oc(n2)N(CCO)CCO)c3ccccc3', 'COc1ccc(cc1OCc2ccccc2)C(=S)N3CCOCC3')) - lapply(ms, do.aromaticity) + lapply(ms, do.aromaticity) lapply(ms, set.atom.types) f <- get.murcko.fragments(ms, as.smiles=TRUE, min.frag.size = 6, single.framework = TRUE) checkEquals(length(f), 3) @@ -26,11 +26,11 @@ test.frag3 <- function() { ms <- parse.smiles(c('c1(ccc(cc1C)CCC(C(CCC)C2C(C2)CC)C3C=C(C=C3)CC)C', 'c1ccc(cc1)c2c(oc(n2)N(CCO)CCO)c3ccccc3', 'COc1ccc(cc1OCc2ccccc2)C(=S)N3CCOCC3')) - lapply(ms, do.aromaticity) + lapply(ms, do.aromaticity) lapply(ms, set.atom.types) f <- get.murcko.fragments(ms, as.smiles=FALSE, min.frag.size = 6, single.framework = TRUE) checkEquals(length(f), 3) fworks <- unlist(lapply(f, function(x) unlist(lapply(x$frameworks, .jclass)))) - checkTrue(all(fworks == "org.openscience.cdk.silent.AtomContainer2")) + checkTrue(all(fworks %in% c("org.openscience.cdk.silent.AtomContainer", "org.openscience.cdk.silent.AtomContainer2"))) } diff --git a/rcdk/inst/unitTests/runit.match.R b/rcdk/inst/unitTests/runit.match.R index 42aee2636..b2cb12bf0 100755 --- a/rcdk/inst/unitTests/runit.match.R +++ b/rcdk/inst/unitTests/runit.match.R @@ -44,25 +44,25 @@ test.match4 <- function() test.mcs1 <- function() { mols <- parse.smiles(c("NCc1ccccc1OC(=N)CCN", "c1ccccc1OC(=N)")) lapply(mols, do.aromaticity) - lapply(mols, set.atom.types) + lapply(mols, set.atom.types) mcs <- get.mcs(mols[[1]], mols[[2]], TRUE) - checkEquals("org.openscience.cdk.silent.AtomContainer2", .jclass(mcs)) + checkTrue(.jclass(mcs) %in% c("org.openscience.cdk.silent.AtomContainer", "org.openscience.cdk.silent.AtomContainer2")) checkEquals(9, get.atom.count(mcs)) } test.mcs3 <- function() { mols <- parse.smiles(c("c1cccc(COC(=O)NC(CC(C)C)C(=O)NC(CCc2ccccc2)C(=O)COC)c1", "c1cccc(COC(=O)NC(CC(C)C)C(=O)NCC#N)c1")) lapply(mols, do.aromaticity) - lapply(mols, set.atom.types) + lapply(mols, set.atom.types) mcs <- get.mcs(mols[[1]], mols[[2]], TRUE) - checkEquals("org.openscience.cdk.silent.AtomContainer2", .jclass(mcs)) + checkTrue(.jclass(mcs) %in% c("org.openscience.cdk.silent.AtomContainer", "org.openscience.cdk.silent.AtomContainer2")) checkEquals(21, get.atom.count(mcs)) } test.mcs2 <- function() { mols <- parse.smiles(c("NCc1ccccc1OC(=N)CCN", "c1ccccc1OC(=N)")) lapply(mols, do.aromaticity) - lapply(mols, set.atom.types) + lapply(mols, set.atom.types) mcs <- get.mcs(mols[[1]], mols[[2]], FALSE) checkTrue(inherits(mcs, "matrix")) checkEquals(9, nrow(mcs)) diff --git a/rcdk/man/compare.isotope.pattern.Rd b/rcdk/man/compare.isotope.pattern.Rd index a31a2fb8a..5ab0fa995 100755 --- a/rcdk/man/compare.isotope.pattern.Rd +++ b/rcdk/man/compare.isotope.pattern.Rd @@ -20,7 +20,7 @@ A numeric value between 0 and 1 indicating the similarity between the two patter Computes a similarity score between two different isotope abundance patterns. } \references{ -\url{http://cdk.github.io/cdk/2.3/docs/api/org/openscience/cdk/formula/IsotopePatternSimilarity.html} +\url{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/formula/IsotopePatternSimilarity.html} } \seealso{ \code{\link{get.isotope.pattern.similarity}} diff --git a/rcdk/man/get.chem.object.builder.Rd b/rcdk/man/get.chem.object.builder.Rd index a0fa56510..832342812 100755 --- a/rcdk/man/get.chem.object.builder.Rd +++ b/rcdk/man/get.chem.object.builder.Rd @@ -7,7 +7,7 @@ get.chem.object.builder() } \value{ -An instance of \href{https://cdk.github.io/cdk/2.5/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder} +An instance of \href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder} } \description{ The CDK employs a builder design pattern to construct @@ -19,7 +19,7 @@ a builder object when directly working with the CDK API via `rJava`. } \details{ -This method returns an instance of the \href{https://cdk.github.io/cdk/2.5/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder}. +This method returns an instance of the \href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder}. Note that this is a static object that is created at package load time, and the same instance is returned whenever this function is called. } diff --git a/rcdk/man/get.fingerprint.Rd b/rcdk/man/get.fingerprint.Rd index e057889b3..f47ca2c01 100755 --- a/rcdk/man/get.fingerprint.Rd +++ b/rcdk/man/get.fingerprint.Rd @@ -32,21 +32,21 @@ atomic properties into account into account \item pubchem - 881 bit fingerprints defined by PubChem \item kr - 4860 bit fingerprint defined by Klekota and Roth \item shortestpath - A fingerprint based on the shortest paths between pairs of atoms and takes into account ring systems, charges etc. -\item signature - A feature,count type of fingerprint, similar in nature to circular fingerprints, but based on the signature +\item signature - A feature,count type of fingerprint, similar in nature to circular fingerprints, but based on the signature descriptor \item circular - An implementation of the ECFP6 (default) fingerprint. Other circular types can be chosen by modifying the \code{circular.type} parameter. \item substructure - Fingerprint based on list of SMARTS pattern. By default a set of functional groups is tested. }} \item{fp.mode}{The style of fingerprint. Specifying "`bit`" will return a binary fingerprint, -"`raw`" returns the the original representation (usually sequence of integers) and +"`raw`" returns the the original representation (usually sequence of integers) and "`count`" returns the fingerprint as a sequence of counts.} \item{depth}{The search depth. This argument is ignored for the `pubchem`, `maccs`, `kr` and `estate` fingerprints} -\item{size}{The final length of the fingerprint. -This argument is ignored for the `pubchem`, `maccs`, `kr`, `signature`, `circular` and +\item{size}{The final length of the fingerprint. +This argument is ignored for the `pubchem`, `maccs`, `kr`, `signature`, `circular` and `estate` fingerprints} \item{substructure.pattern}{List of characters containing the SMARTS pattern to match. If the an empty list is provided (default) than the functional groups substructures (default in CDK) are used.} @@ -56,7 +56,7 @@ This argument is ignored for the `pubchem`, `maccs`, `kr`, `signature`, `circula \item{verbose}{Verbose output if \code{TRUE}} } \value{ -an S4 object of class \code{\link{fingerprint-class}} or \code{\link{featvec-class}}, +an S4 object of class \code{\link[fingerprint]{fingerprint-class}} or \code{\link[fingerprint]{featvec-class}}, which can be manipulated with the fingerprint package. } \description{ @@ -65,15 +65,13 @@ the input molecule. } \examples{ ## get some molecules -sp <- get.smiles.parser() -smiles <- c('CCC', 'CCN', 'CCN(C)(C)', 'c1ccccc1Cc1ccccc1','C1CCC1CC(CN(C)(C))CC(=O)CC') +smiles <- c('CCC', 'CCN') mols <- parse.smiles(smiles) -## get a single fingerprint using the standard -## (hashed, path based) fingerprinter -fp <- get.fingerprint(mols[[1]]) +## get a single fingerprint using MACCS (fast) +fp <- get.fingerprint(mols[[1]], type='maccs') -## get MACCS keys for all the molecules +## get MACCS keys for both molecules fps <- lapply(mols, get.fingerprint, type='maccs') ## get Signature fingerprint @@ -88,7 +86,7 @@ smarts <- c("c1ccccc1", "[CX4H3][#6]", "[CX2]#[CX2]") fps <- get.fingerprint(mol1, type='substructure', fp.mode='count', substructure.pattern=smarts) -## get ECFP0 count fingerprints +## get ECFP0 count fingerprints mol2 <- parse.smiles("C1=CC=CC(=C1)CCCC2=CC=CC=C2")[[1]] fps <- get.fingerprint(mol2, type='circular', fp.mode='count', circular.type='ECFP0') } diff --git a/rcdk/man/get.isotope.pattern.generator.Rd b/rcdk/man/get.isotope.pattern.generator.Rd index 1cebfea6d..e645bd707 100755 --- a/rcdk/man/get.isotope.pattern.generator.Rd +++ b/rcdk/man/get.isotope.pattern.generator.Rd @@ -18,7 +18,7 @@ minimum abundance specified. This object can be used to generate all combinatori chemical isotopes given a structure. } \references{ -\url{http://cdk.github.io/cdk/1.5/docs/api/org/openscience/cdk/formula/IsotopePatternGenerator.html} +\url{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/formula/IsotopePatternGenerator.html} } \author{ Miguel Rojas Cherto diff --git a/rcdk/man/get.isotope.pattern.similarity.Rd b/rcdk/man/get.isotope.pattern.similarity.Rd index 2e45d6a01..b21e5859c 100755 --- a/rcdk/man/get.isotope.pattern.similarity.Rd +++ b/rcdk/man/get.isotope.pattern.similarity.Rd @@ -18,7 +18,7 @@ class which can be used to compute similarity scores between pairs of isotope abundance patterns. } \references{ -\url{http://cdk.github.io/cdk/1.5/docs/api/org/openscience/cdk/formula/IsotopePatternSimilarity.html} +\url{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/formula/IsotopePatternSimilarity.html} } \seealso{ \code{\link{compare.isotope.pattern}} diff --git a/rcdk/man/get.smiles.Rd b/rcdk/man/get.smiles.Rd index 73707ef94..f8fbc8349 100755 --- a/rcdk/man/get.smiles.Rd +++ b/rcdk/man/get.smiles.Rd @@ -21,7 +21,7 @@ A character string containing the generated SMILES The function will generate a SMILES representation of an `IAtomContainer` object. The default parameters of the CDK SMILES generator are used. This can mean that for large ring systems the -method may fail. See CDK \href{http://cdk.github.io/cdk/2.2/docs/api/org/openscience/cdk/smiles/SmilesGenerator.html}{Javadocs} +method may fail. See CDK \href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/smiles/SmilesGenerator.html}{Javadocs} for more information } \examples{ @@ -30,7 +30,7 @@ get.smiles(m) get.smiles(m, smiles.flavors(c('Generic','UseAromaticSymbols'))) } \references{ -\href{http://cdk.github.io/cdk/2.2/docs/api/org/openscience/cdk/smiles/SmilesGenerator.html}{SmilesGenerator} +\href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/smiles/SmilesGenerator.html}{SmilesGenerator} } \seealso{ \code{\link{parse.smiles}}, \code{\link{smiles.flavors}} diff --git a/rcdk/man/get.smiles.parser.Rd b/rcdk/man/get.smiles.parser.Rd index d72aef0bc..b8780aaee 100755 --- a/rcdk/man/get.smiles.parser.Rd +++ b/rcdk/man/get.smiles.parser.Rd @@ -8,7 +8,7 @@ get.smiles.parser() } \value{ A `jobjRef` object corresponding to the CDK -\href{http://cdk.github.io/cdk/2.2/docs/api/org/openscience/cdk/smiles/SmilesParser.html}{SmilesParser} class +\href{https://cdk.github.io/cdk/2.10/docs/api/org/openscience/cdk/smiles/SmilesParser.html}{SmilesParser} class } \description{ This function returns a reference to a SMILES parser diff --git a/rcdk/man/rcdk-deprecated.Rd b/rcdk/man/rcdk-deprecated.Rd index 565572b90..1dd9e4a0b 100644 --- a/rcdk/man/rcdk-deprecated.Rd +++ b/rcdk/man/rcdk-deprecated.Rd @@ -1,8 +1,6 @@ % Generated by roxygen2: do not edit by hand % 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} @@ -14,10 +12,10 @@ deprecated_rcdk_function(x, value, ...) \item{x}{For assignment operators, the object that will undergo a replacement (object inside parenthesis).} -\item{value}{For assignment operators, the value to replace with +\item{value}{For assignment operators, the value to replace with (the right side of the assignment).} -\item{...}{For functions other than assignment operators, +\item{...}{For functions other than assignment operators, parameters to be passed to the modern version of the function (see table).} } \description{ diff --git a/rcdk/man/smiles.flavors.Rd b/rcdk/man/smiles.flavors.Rd index 1a04ffbbd..a0cd49ad0 100755 --- a/rcdk/man/smiles.flavors.Rd +++ b/rcdk/man/smiles.flavors.Rd @@ -46,11 +46,11 @@ A numeric representing the bitwise `OR`` of the specified flavors \description{ The CDK supports a variety of customizations for SMILES generation including the use of lower case symbols for aromatic compounds to the use of the ChemAxon -\href{http://butane.chem.uiuc.edu/jsmoore/marvin/help/formats/cxsmiles-doc.html}{CxSmiles} +\href{https://docs.chemaxon.com/display/docs/formats_chemaxon-extended-smiles-and-smarts-cxsmiles-and-cxsmarts.md}{CxSmiles} format. Each 'flavor' is represented by an integer and multiple customizations are bitwise OR'ed. This method accepts the names of one or more customizations and returns the bitwise OR of them. -See \href{https://cdk.github.io/cdk/2.3/docs/api/index.html?org/openscience/cdk/smiles/SmiFlavor.html}{CDK documentation} +See \href{https://cdk.github.io/cdk/2.10/docs/api/index.html?org/openscience/cdk/smiles/SmiFlavor.html}{CDK documentation} for the list of flavors and what they mean. } \examples{ @@ -64,7 +64,7 @@ get.smiles(m,flavor = smiles.flavors(c("CxSmiles","UseAromaticSymbols"))) } \references{ -\href{https://cdk.github.io/cdk/2.3/docs/api/index.html?org/openscience/cdk/smiles/SmiFlavor.html}{CDK documentation} +\href{https://cdk.github.io/cdk/2.10/docs/api/index.html?org/openscience/cdk/smiles/SmiFlavor.html}{CDK documentation} } \seealso{ \code{\link{get.smiles}} diff --git a/rcdk/vignettes/Features_29.Rmd b/rcdk/vignettes/Features_29.Rmd index c2b2592c3..a2d4bf43e 100644 --- a/rcdk/vignettes/Features_29.Rmd +++ b/rcdk/vignettes/Features_29.Rmd @@ -2,9 +2,9 @@ title: "Features 2.9" author: "Zachary Charlop-Powers" date: "`r Sys.Date()`" -output: +output: rmarkdown::html_vignette: - toc: true + toc: true vignette: > %\VignetteIndexEntry{Features 2.9} %\VignetteEngine{knitr::rmarkdown} @@ -24,6 +24,13 @@ vignette: > https://github.com/cdk/cdk/pull/927 ```{r setup, message=FALSE} +# Install depict from GitHub if not available +if (!requireNamespace("depict", quietly = TRUE)) { + if (!requireNamespace("remotes", quietly = TRUE)) { + install.packages("remotes") + } + remotes::install_github("CDK-R/depict") +} library(rcdklibs) library(depict) @@ -58,7 +65,7 @@ rxn <- smiles_parser$parseReactionSmiles("[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][c # note `as.list` for (mol in as.list(ReactionManipulator$getAllAtomContainers(rxn))) { - abbreviations$apply(mol) + abbreviations$apply(mol) } rxn$setDirection(IReaction$Direction$NO_GO) @@ -73,7 +80,7 @@ to_svg(svg) 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) + abbreviations$apply(mol) } rxn$setDirection(IReaction$Direction$RETRO_SYNTHETIC) @@ -87,7 +94,7 @@ to_svg(svg) 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) + abbreviations$apply(mol) } rxn$setDirection(IReaction$Direction$BIDIRECTIONAL) @@ -101,7 +108,7 @@ rxn <- smiles_parser$parseReactionSmiles("c1c(Cl)cccc1[N-][N+]#N>>c1c(Cl)cccc1N= for (mol in as.list(ReactionManipulator$getAllAtomContainers(rxn))) { - abbreviations$apply(mol) + abbreviations$apply(mol) } rxn$setDirection(IReaction$Direction$RESONANCE) @@ -161,14 +168,13 @@ maygen$setFormula("C3Cl2H4") # 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/rcdk.Rmd b/rcdk/vignettes/rcdk.Rmd index 36696c435..f23f8014c 100644 --- a/rcdk/vignettes/rcdk.Rmd +++ b/rcdk/vignettes/rcdk.Rmd @@ -159,7 +159,7 @@ get.smiles(mols[[3]], smiles.flavors(c('UseAromaticSymbols'))) get.smiles(mols[[3]], smiles.flavors(c('Generic','CxSmiles'))) ``` -Using the [CxSmiles](http://butane.chem.uiuc.edu/jsmoore/marvin/help/formats/cxsmiles-doc.html) flavors allows the user to encode a variety of information in the SMILES string, such as 2D or 3D coordinates. +Using the [CxSmiles](https://docs.chemaxon.com/display/docs/formats_chemaxon-extended-smiles-and-smarts-cxsmiles-and-cxsmarts.md) flavors allows the user to encode a variety of information in the SMILES string, such as 2D or 3D coordinates. ```{r} m <- parse.smiles('CCC')[[1]]