/chemdoodle

htmlwidgets for chemdoodle web components

Primary LanguageR

chemdoodle

This repo is for the creation of an HTMLWidget for visualizing moleules based on the ChemDoodle WebComponent library, the HTMLWidgets package, and the Chemistry Development Kit via rCDK. Warning: development in flux and liable to break until version 1.0!

Install

And the development version from GitHub with:

# install.packages("devtools")
# devtools::install_github("zachcp/chemdoodle")

Basic Viewer

library(chemdoodle)
chemdoodle_viewer("C1CCCCC1", width = 100, height = 100)

Transform Canvas

chemdoodle_transform("C1CCCCC1", width = 100, height = 100)

Slideshow Canvas

chemdoodle_slideshow(c("C1CCCCC1", "CNCNCNC1CCCCC1", "CN1C=NC2=C1C(=O)N(C(=O)N2C)C",
                       "CC1=C(C=C(C2=C1C(=C)OC2=O)OC)OC"), 200,200, bondscale=15)

Sketcher

The ChemDoodle Sketcher needs extra work for functionality. You can use drawMolecule() to create a seketcher and the molecule is captured as ChemDoodle JSON which can be converted to a CDK Atom and be passed around, converter or whatever. Currently round-tripping (putting the molecule back) doesn’t work because there are some issues around properly scaling the compound.

#experimetal/new features

# gets a molecule from the chemdoodle sketcher
moljson <- drawMolecule()

# processed the Molecule JSON to a CDK AtomContainer - this can be saved,
# written to Smiles etc.
mol <- processChemDoodleJson(moljson)

# convert to SMILES
smi <- toSmiles(mol)

# convert to InChi
inchi <- toInChi(mol)

# try sending a molecule to the sketcher (needs work)
drawMolecule(mol=mol)

Access the Sketcher as a ShinyApp

# you can also try a minimal shiny example
shiny::runApp(appDir = "examples/minimalshinyapp/")