Skip to content

Commit

Permalink
Document Updates (#18)
Browse files Browse the repository at this point in the history
* move from magrittr to base r

* fix imports and add url

* update docs and Description

* style pkgdown

* add orcid

* rename

* update depict for rxn check

* add rxn smiles test

* style pass

* update allowable classes

* add a get_svg_string function

* add icon

* update to use SVG strings directly

* use cat to get cleaner vignette

* fix imports and update example code

* remove rcdk

* update jovs

* update docs and description

* more CRAN compat

* update docs

---------

Co-authored-by: Zachary Charlop-Powers <zcpowers@Zacharys-MacBook-Air.local>
  • Loading branch information
zachcp and Zachary Charlop-Powers authored Mar 5, 2024
1 parent 5c2b5e0 commit 9402251
Show file tree
Hide file tree
Showing 26 changed files with 105 additions and 60 deletions.
6 changes: 2 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ Type: Package
Title: Draw Beautiful Molecular Structures
Version: 0.4.0
Authors@R: c(
person('Zachary', 'Charlop-Powers', ,'zach.charlop.powers@gmail.com',role=c('cre'),
person('Zachary', 'Charlop-Powers', ,'zach.charlop.powers@gmail.com',role=c('cre', 'aut'),
comment = c(ORCID = "0000-0001-8816-4680")))
Description: Generate images of molecules using the Depiction API of the 'Chemistry Development Kit'.
CDK's Depict Api
Description: Generate images of molecules using the Depiction API of the 'Chemistry Development Kit'.
License: LGPL
LazyData: TRUE
Depends:
rJava (>= 1.0-11),
rcdk (>= 3.7),
rcdklibs (>= 2.8)
Imports:
png
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ export(read_mol)
export(save_image)
export(set_size)
export(set_zoom)
import(rJava)
import(rcdklibs)
importFrom(png,readPNG)
3 changes: 2 additions & 1 deletion R/IO.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' @param generatecoords Optional. Default \code{TRUE}. Whether
#' to generate coordinates from the smiles
#' @param kekulise Optional. Boolean. Default \code{TRUE}
#' @return an IAtomContainer
#' @export
#'
parse_smiles <- function(smi, generatecoords = TRUE, kekulise = TRUE) {
Expand All @@ -31,7 +32,7 @@ parse_smiles <- function(smi, generatecoords = TRUE, kekulise = TRUE) {

#' read_mol
#'
#' Read a Molfile and return an AtomContainer
#' Read a Molfile and return an `AtomContainer`
#'
#' @param molfile Required. A filepath to a MOLfile.
#' @return an AtomContainer
Expand Down
22 changes: 14 additions & 8 deletions R/depict.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#'
#' create the CDK depiction object that can be manipulated
#'
#' @return DepictionGenerator
#' @seealso \url{https://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/depict/DepictionGenerator.html}
#' @export
depiction <- function() {
.jnew("org/openscience/cdk/depict/DepictionGenerator")
Expand All @@ -13,6 +15,7 @@ depiction <- function() {
#'
#' @param dg a CDK DepictionGenerator
#' @seealso \url{https://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/depict/DepictionGenerator.html}
#' @return DepictionGenerator
#' @export
color_atoms <- function(dg) {
if (!checkJavaClass(dg, "org/openscience/cdk/depict/DepictionGenerator")) {
Expand All @@ -24,6 +27,7 @@ color_atoms <- function(dg) {
#' outerglow
#'
#' @param dg a CDK Depiction Generator
#' @return DepictionGenerator
#' @seealso \url{https://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/depict/DepictionGenerator.html}
#' @export
outerglow <- function(dg) {
Expand All @@ -38,6 +42,7 @@ outerglow <- function(dg) {
#' @param dg a CDK Depiction Generator
#' @param width width (int)
#' @param height height (int)
#' @return DepictionGenerator
#' @seealso \url{https://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/depict/DepictionGenerator.html}
#' @export
set_size <- function(dg, width, height) {
Expand All @@ -51,6 +56,7 @@ set_size <- function(dg, width, height) {
#' add_title
#'
#' @param dg a CDK Depiction Generator
#' @return DepictionGenerator
#' @seealso \url{https://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/depict/DepictionGenerator.html}
#' @export
add_title <- function(dg) {
Expand All @@ -64,6 +70,7 @@ add_title <- function(dg) {
#' add terminal carbons
#'
#' @param dg a Depiction Generator
#' @return DepictionGenerator
#' @seealso \url{https://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/depict/DepictionGenerator.html}
#' @export
add_terminal_carbons <- function(dg) {
Expand All @@ -83,9 +90,8 @@ add_terminal_carbons <- function(dg) {
#'
#' @param dg Required. A DepictionGenerator
#' @param mol Required. An AtomContainer
#' @seealso \url{https://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/depict/DepictionGenerator.html}
#' @seealso \url{https://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/AtomContainer.html}
#'
#' @return A Depiction
#' @seealso \url{https://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/depict/Depiction.html}
#' @export
depict <- function(dg, mol) {
if (!checkJavaClass(dg, "org/openscience/cdk/depict/DepictionGenerator")) {
Expand Down Expand Up @@ -117,7 +123,7 @@ depict <- function(dg, mol) {
#' Highlight atoms
#'
#' @param dg Required. A Depiction Generator
#' @param highlights Required. A list of CDK IChemOjbects, usually atoms or bonds
#' @param atoms Required. A list of CDK IChemOjbects, usually atoms or bonds
#' @param color Required. A java.awt.Color
#' @export
highlight_atoms <- function(dg, atoms, color) {
Expand All @@ -129,20 +135,20 @@ highlight_atoms <- function(dg, atoms, color) {

#' save_image
#'
#' Highlight atoms
#' save image to disk
#'
#' @param molgrid Required. A MolGridDepiction. Usually obtained from
#' the \code{depict} function.
#' @param outfile Required. Filepath to the output
#' @export
save_image <- function(molgrid, filepath) {
save_image <- function(molgrid, outfile) {
if (!checkJavaClass(molgrid, c(
"org/openscience/cdk/depict/MolGridDepiction",
"org/openscience/cdk/depict/ReactionDepiction"
))) {
stop("highlight_atoms requires a Depiction Generator")
}
molgrid$writeTo(filepath)
molgrid$writeTo(outfile)
}

#' get_image
Expand All @@ -151,7 +157,6 @@ save_image <- function(molgrid, filepath) {
#'
#' @param molgrid Required. A MolGridDepiction. Usually obtained from
#' the \code{depict} function.
#' @param outfile Required. Filepath to the output
#' @importFrom png readPNG
#' @export
#'
Expand Down Expand Up @@ -208,6 +213,7 @@ get_svg_string <- function(molgrid) {
#'
#' @param dg a Depiction Generator
#' @param zoom Optional. Default \code{1}
#' @return DepictionGenerator
#' @export
#'
set_zoom <- function(dg, zoom = 1) {
Expand Down
4 changes: 2 additions & 2 deletions R/smarts.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#' return a named list of SMARTS
#' patterns for amino_acids
#'
#' @seealso \url{http://www.daylight.com/dayhtml/doc/theory/theory.smarts.html}
#' @seealso \url{http://www.daylight.com/dayhtml_tutorials/languages/smarts/index.html}
#' @seealso \url{https://www.daylight.com/dayhtml/doc/theory/theory.smarts.html}
#' @seealso \url{https://www.daylight.com/dayhtml_tutorials/languages/smarts/index.html}
#' @export
#'
#'
Expand Down
7 changes: 3 additions & 4 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @param jobj Required. A Java Object
#' @param klass Required. A string defining a java class
#' @return Boolean
#' @noRd
checkJavaClass <- function(jobj, klass) {
if (is.null(attr(jobj, 'jclass'))) stop("this is not a Java Object")

Expand All @@ -17,8 +18,6 @@ checkJavaClass <- function(jobj, klass) {
}




#' atomcontainer_list_to_jarray
#'
#'
Expand All @@ -27,10 +26,10 @@ checkJavaClass <- function(jobj, klass) {
#'
#' @export
#' @examples
#' \dontrun {
#' \dontrun{
#'
#' atmcontnrs <- purrr::map(
#' c("CCCCCC", "CCC1CCC1NC", "COCCOCCO")
#' c("CCCCCC", "CCC1CCC1NC", "COCCOCCO"),
#' parse_smiles)
#'
#' atomcontainer_list_to_jarray(atmcontnrs)
Expand Down
3 changes: 3 additions & 0 deletions man/add_terminal_carbons.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/add_title.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/amino_acids.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/atomcontainer_list_to_jarray.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions man/checkJavaClass.Rd

This file was deleted.

3 changes: 3 additions & 0 deletions man/color_atoms.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/depict-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions man/depict.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/depiction.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions man/get_image.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/highlight_atoms.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/outerglow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/parse_smiles.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/read_mol.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/save_image.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/set_size.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9402251

Please sign in to comment.