From b883e6075bd76f979fbffdb768313665681315a0 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 19 Feb 2019 20:17:59 +0100 Subject: Only plot when a Picture object is there grConvert is not needed for plotting --- ChangeLog | 15 ++ R/chent.R | 1 + README.html | 303 +++++++++++++++++++++++++++++++++++++---- docs/reference/chent.html | 6 +- docs/reference/plot.chent.html | 2 +- inst/examples/caffeine.R | 2 +- inst/examples/octanol.R | 2 +- man/chent.Rd | 4 +- man/plot.chent.Rd | 2 +- test.log | 6 +- 10 files changed, 302 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index e371d83..569a151 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +commit 95a067f0ed8fb580cc3652acd4c7885eb000244a +Author: Johannes Ranke +Date: 2019-02-19 18:55:27 +0100 + + Skip plotting in examples if grConvert is missing + +commit 132bd73395033a95163080517b5a7c371cf512a2 +Author: Johannes Ranke +Date: 2019-02-19 18:17:38 +0100 + + Fix check for rdkit availability + + Also remove python-rdkit from the travis config as its version is too + old on travis (Ubuntu trusty) + commit aa80ce4f46f9ff1a2851ba9ba873a55a8f6ebc6d Author: Johannes Ranke Date: 2019-02-19 17:17:48 +0100 diff --git a/R/chent.R b/R/chent.R index 6a5abc7..c80cf06 100644 --- a/R/chent.R +++ b/R/chent.R @@ -463,6 +463,7 @@ draw_svg.chent = function(x, width = 300, height = 150, #' @example inst/examples/caffeine.R #' @export plot.chent = function(x, ...) { + if (is.null(x$Picture)) stop("No Picture object in chent, was RDKit available during creation?") grid.picture(x$Picture) } diff --git a/README.html b/README.html index a203447..f113586 100644 --- a/README.html +++ b/README.html @@ -4,24 +4,209 @@ - + - +README.utf8.md - + - - - - - - - + + + + + + + @@ -88,9 +275,15 @@ img { .tabbed-pane { padding-top: 12px; } +.html-widget { + margin-bottom: 20px; +} button.code-folding-btn:focus { outline: none; } +summary { + display: list-item; +} @@ -98,10 +291,71 @@ button.code-folding-btn:focus {
+ + + @@ -110,7 +364,6 @@ $(document).ready(function () { -
if (requireNamespace("grConvert")) { +#> [9] "caprylic alcohol" "n-Octyl alcohol"
if (!is.null(caffeine$Picture)) { plot(oct) -}
caffeine <- chent$new("caffeine")
#> PubChem:
#> https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/cids/JSON
#> https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/property/MolecularFormula,MolecularWeight,CanonicalSMILES,IsomericSMILES,InChI,InChIKey,IUPACName,XLogP,TPSA,Complexity,Charge,HBondDonorCount,HBondAcceptorCount/JSON
#> https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/synonyms/JSON
#> Trying to get chemical information from RDKit using PubChem_Canonical SMILES +}
#> Error in eval(expr, envir, enclos): Objekt 'caffeine' nicht gefunden
caffeine <- chent$new("caffeine")
#> PubChem:
#> https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/cids/JSON
#> https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/property/MolecularFormula,MolecularWeight,CanonicalSMILES,IsomericSMILES,InChI,InChIKey,IUPACName,XLogP,TPSA,Complexity,Charge,HBondDonorCount,HBondAcceptorCount/JSON
#> https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/synonyms/JSON
#> Trying to get chemical information from RDKit using PubChem_Canonical SMILES #> CN1C=NC2=C1C(=O)N(C(=O)N2C)C
#> Did not find chyaml file ./caffeine.yaml
print(caffeine)
#> <chent> #> Identifier $identifier caffeine #> InChI Key $inchikey RYYVLZVUVIJVGH-UHFFFAOYSA-N @@ -174,7 +174,7 @@ configured for use with PythonInR

#> [3] "58-08-2" "Guaranine" #> [5] "1,3,7-Trimethylxanthine" "Thein" #> [7] "Cafeina" "Methyltheobromine" -#> [9] "Koffein" "Mateina"
if (requireNamespace("grConvert")) { +#> [9] "Koffein" "Mateina"
if (!is.null(caffeine$Picture)) { plot(caffeine) }
diff --git a/docs/reference/plot.chent.html b/docs/reference/plot.chent.html index cc4d376..026c25f 100644 --- a/docs/reference/plot.chent.html +++ b/docs/reference/plot.chent.html @@ -141,7 +141,7 @@ #> [3] "58-08-2" "Guaranine" #> [5] "1,3,7-Trimethylxanthine" "Thein" #> [7] "Cafeina" "Methyltheobromine" -#> [9] "Koffein" "Mateina"
if (requireNamespace("grConvert")) { +#> [9] "Koffein" "Mateina"
if (!is.null(caffeine$Picture)) { plot(caffeine) }
diff --git a/inst/examples/caffeine.R b/inst/examples/caffeine.R index f5711f3..e886878 100644 --- a/inst/examples/caffeine.R +++ b/inst/examples/caffeine.R @@ -1,5 +1,5 @@ caffeine <- chent$new("caffeine") print(caffeine) -if (requireNamespace("grConvert")) { +if (!is.null(caffeine$Picture)) { plot(caffeine) } diff --git a/inst/examples/octanol.R b/inst/examples/octanol.R index b13d9ce..8818836 100644 --- a/inst/examples/octanol.R +++ b/inst/examples/octanol.R @@ -1,5 +1,5 @@ oct <- chent$new("1-octanol", smiles = "CCCCCCCCO") print(oct) -if (requireNamespace("grConvert")) { +if (!is.null(caffeine$Picture)) { plot(oct) } diff --git a/man/chent.Rd b/man/chent.Rd index a90a3b3..73cb728 100644 --- a/man/chent.Rd +++ b/man/chent.Rd @@ -55,12 +55,12 @@ configured for use with PythonInR} \examples{ oct <- chent$new("1-octanol", smiles = "CCCCCCCCO") print(oct) -if (requireNamespace("grConvert")) { +if (!is.null(caffeine$Picture)) { plot(oct) } caffeine <- chent$new("caffeine") print(caffeine) -if (requireNamespace("grConvert")) { +if (!is.null(caffeine$Picture)) { plot(caffeine) } } diff --git a/man/plot.chent.Rd b/man/plot.chent.Rd index a406533..f2850fa 100644 --- a/man/plot.chent.Rd +++ b/man/plot.chent.Rd @@ -17,7 +17,7 @@ Plot method for chent objects \examples{ caffeine <- chent$new("caffeine") print(caffeine) -if (requireNamespace("grConvert")) { +if (!is.null(caffeine$Picture)) { plot(caffeine) } } diff --git a/test.log b/test.log index 9062ecc..587b665 100644 --- a/test.log +++ b/test.log @@ -8,11 +8,11 @@ The following objects are masked from ‘package:devtools’: Testing chents ✔ | OK F W S | Context - ⠏ | 0 | Generation of chent objects ⠋ | 1 | Generation of chent objects ⠙ | 2 | Generation of chent objects ⠹ | 3 | Generation of chent objects ⠸ | 4 | Generation of chent objects ⠼ | 5 | Generation of chent objects ⠴ | 6 | Generation of chent objects ✔ | 6 | Generation of chent objects [2.8 s] - ⠏ | 0 | Generation of pai objects ⠋ | 1 | Generation of pai objects ⠙ | 2 | Generation of pai objects ⠹ | 3 | Generation of pai objects ⠸ | 4 | Generation of pai objects ⠼ | 5 | Generation of pai objects ⠴ | 6 | Generation of pai objects ⠦ | 7 | Generation of pai objects ⠧ | 8 | Generation of pai objects ⠇ | 9 | Generation of pai objects ✔ | 9 | Generation of pai objects [6.4 s] + ⠏ | 0 | Generation of chent objects ⠋ | 1 | Generation of chent objects ⠙ | 2 | Generation of chent objects ⠹ | 3 | Generation of chent objects ⠸ | 4 | Generation of chent objects ⠼ | 5 | Generation of chent objects ⠴ | 6 | Generation of chent objects ✔ | 6 | Generation of chent objects [5.3 s] + ⠏ | 0 | Generation of pai objects ⠋ | 1 | Generation of pai objects ⠙ | 2 | Generation of pai objects ⠹ | 3 | Generation of pai objects ⠸ | 4 | Generation of pai objects ⠼ | 5 | Generation of pai objects ⠴ | 6 | Generation of pai objects ⠦ | 7 | Generation of pai objects ⠧ | 8 | Generation of pai objects ⠇ | 9 | Generation of pai objects ✔ | 9 | Generation of pai objects [6.8 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 9.2 s +Duration: 12.1 s OK: 15 Failed: 0 -- cgit v1.2.1