diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2019-02-19 23:19:31 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2019-02-19 23:19:31 +0100 |
commit | bfa20a8c262580e38d30cfa95e75d1b01b568d07 (patch) | |
tree | d316e76f437662eb193736af2b12bbf223db6e72 | |
parent | a7e2c2008699b590325ccd848562881251676faf (diff) |
Use rsvg instead of grConvert
as grConvert is not on CRAN
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | DESCRIPTION | 5 | ||||
-rw-r--r-- | NAMESPACE | 1 | ||||
-rw-r--r-- | R/chent.R | 39 | ||||
-rw-r--r-- | docs/authors.html | 2 | ||||
-rw-r--r-- | docs/index.html | 2 | ||||
-rw-r--r-- | docs/reference/chent.html | 4 | ||||
-rw-r--r-- | docs/reference/draw_svg.chent.html | 2 | ||||
-rw-r--r-- | docs/reference/index.html | 2 | ||||
-rw-r--r-- | docs/reference/pai.html | 2 | ||||
-rw-r--r-- | docs/reference/plot.chent.html | 2 | ||||
-rw-r--r-- | docs/reference/pp.html | 2 | ||||
-rw-r--r-- | docs/reference/print.chent.html | 2 | ||||
-rw-r--r-- | docs/reference/print.pai.html | 2 |
14 files changed, 33 insertions, 36 deletions
@@ -1,4 +1,4 @@ -commit 433f66e88d96aaf745116b97d7fdaa6ce2abde30 +commit a7e2c2008699b590325ccd848562881251676faf Author: Johannes Ranke <jranke@uni-bremen.de> Date: 2019-02-19 20:46:18 +0100 diff --git a/DESCRIPTION b/DESCRIPTION index f45a6c3..451e6c5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: chents Type: Package Title: Chemical Entities as R Objects -Version: 0.2-6 +Version: 0.2-7 Date: 2019-02-19 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de")) @@ -15,13 +15,12 @@ Imports: webchem, R6, yaml, + rsvg, grImport Suggests: knitr, testthat, PythonInR, - grConvert -Remotes: sjp/grConvert License: GPL LazyLoad: yes LazyData: yes @@ -11,6 +11,7 @@ importFrom(R6,R6Class) importFrom(grImport,PostScriptTrace) importFrom(grImport,grid.picture) importFrom(grImport,readPicture) +importFrom(rsvg,rsvg_ps) importFrom(utils,head) importFrom(webchem,cid_compinfo) importFrom(webchem,get_cid) @@ -28,6 +28,7 @@ #' @importFrom webchem get_cid cid_compinfo #' @importFrom grImport PostScriptTrace readPicture #' @importFrom yaml yaml.load_file +#' @importFrom rsvg rsvg_ps #' @field identifier The identifier that was used to initiate the object, with attribute 'source' #' @field inchikey InChI Key, with attribute 'source' #' @field smiles SMILES code, with attribute 'source' @@ -193,26 +194,22 @@ chent <- R6Class("chent", PythonInR::pyExec("d2d.DrawMolecule(mol)") PythonInR::pyExec("d2d.FinishDrawing()") self$svg <- PythonInR::pyGet("d2d.GetDrawingText()") - - if (!requireNamespace("grConvert")) { - stop("grConvert is not available, self$Picture will not be created") - } else { - # Convert to PostScript, remembering size properties - svgfile <- tempfile(fileext = ".svg") - writeLines(self$svg, svgfile) - psfile <- tempfile(fileext = ".ps") - suppressMessages(grConvert::convertPicture(svgfile, psfile)) - ps_font_line <- grep("Tm$", readLines(psfile), value = TRUE)[1] - ps_font_size <- gsub(" .*$", "", ps_font_line) - self$Pict_font_size = as.numeric(ps_font_size) - - # Read in to create Picture - xmlfile <- tempfile(fileext = ".xml") - PostScriptTrace(psfile, outfilename = xmlfile) - unlink(paste0("capture", basename(psfile))) - self$Picture <- readPicture(xmlfile) - unlink(c(xmlfile, psfile, svgfile)) - } + svgfile <- tempfile(fileext = ".svg") + psfile <- tempfile(fileext = ".ps") + writeLines(self$svg, svgfile) + rsvg::rsvg_ps(svgfile, psfile) + + # Get size properties useful for plotting + ps_font_line <- grep("Tm$", readLines(psfile), value = TRUE)[1] + ps_font_size <- gsub(" .*$", "", ps_font_line) + self$Pict_font_size = as.numeric(ps_font_size) + + # Read in to create Picture + xmlfile <- tempfile(fileext = ".xml") + PostScriptTrace(psfile, outfilename = xmlfile) + unlink(paste0("capture", basename(psfile))) + self$Picture <- readPicture(xmlfile) + unlink(c(xmlfile, psfile, svgfile)) }, get_chyaml = function(repo = c("wd", "local", "web"), chyaml = paste0(URLencode(self$identifier), ".yaml")) { @@ -610,7 +607,7 @@ rdkit_available <- function() PythonInR::pyConnect() } sink(tempfile()) - try_rdkit <- try(PythonInR::pyImport("Chem", from = "rdkit"), + try_rdkit <- try(PythonInR::pyImport("Chem", from = "rdkit"), silent = TRUE) sink() if (inherits(try_rdkit, "try-error")) { diff --git a/docs/authors.html b/docs/authors.html index 5ac526d..3274797 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -60,7 +60,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> diff --git a/docs/index.html b/docs/index.html index f463fe0..6d69e3f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -35,7 +35,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> diff --git a/docs/reference/chent.html b/docs/reference/chent.html index 369b0a0..3d0928c 100644 --- a/docs/reference/chent.html +++ b/docs/reference/chent.html @@ -65,7 +65,7 @@ python bindings are installed and configured for use with PythonInR." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> @@ -149,7 +149,7 @@ configured for use with PythonInR</p></dd> <pre class="examples"><div class='input'><span class='no'>oct</span> <span class='kw'><-</span> <span class='no'>chent</span>$<span class='fu'>new</span>(<span class='st'>"1-octanol"</span>, <span class='kw'>smiles</span> <span class='kw'>=</span> <span class='st'>"CCCCCCCCO"</span>)</div><div class='output co'>#> <span class='message'>PubChem:</span></div><div class='output co'>#> <span class='message'>https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/cids/JSON</span></div><div class='output co'>#> <span class='message'>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</span></div><div class='output co'>#> <span class='message'>https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/synonyms/JSON</span></div><div class='output co'>#> <span class='message'></span> #> <span class='message'>Initialize Python Version 2.7.13 (default, Sep 26 2018, 18:42:22) </span> #> <span class='message'>[GCC 6.3.0 20170516]</span></div><div class='output co'>#> <span class='message'>Trying to get chemical information from RDKit using User SMILES</span> -#> <span class='message'>CCCCCCCCO</span></div><div class='output co'>#> <span class='message'>Lade nötigen Namensraum: grConvert</span></div><div class='output co'>#> <span class='message'>Did not find chyaml file ./1-octanol.yaml</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/print'>print</a></span>(<span class='no'>oct</span>)</div><div class='output co'>#> <chent> +#> <span class='message'>CCCCCCCCO</span></div><div class='output co'>#> <span class='message'>Did not find chyaml file ./1-octanol.yaml</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/print'>print</a></span>(<span class='no'>oct</span>)</div><div class='output co'>#> <chent> #> Identifier $identifier 1-octanol #> InChI Key $inchikey KBPLFHHGFOOTCA-UHFFFAOYSA-N #> SMILES string $smiles: diff --git a/docs/reference/draw_svg.chent.html b/docs/reference/draw_svg.chent.html index 54fec7c..582aa0c 100644 --- a/docs/reference/draw_svg.chent.html +++ b/docs/reference/draw_svg.chent.html @@ -63,7 +63,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> diff --git a/docs/reference/index.html b/docs/reference/index.html index e05a1c4..f08563c 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -60,7 +60,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> diff --git a/docs/reference/pai.html b/docs/reference/pai.html index d90bcc9..e240e11 100644 --- a/docs/reference/pai.html +++ b/docs/reference/pai.html @@ -64,7 +64,7 @@ Additional chemical information is retrieved from the internet if available." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> diff --git a/docs/reference/plot.chent.html b/docs/reference/plot.chent.html index 026c25f..fddd2e8 100644 --- a/docs/reference/plot.chent.html +++ b/docs/reference/plot.chent.html @@ -63,7 +63,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> diff --git a/docs/reference/pp.html b/docs/reference/pp.html index 8dbed29..aa660cb 100644 --- a/docs/reference/pp.html +++ b/docs/reference/pp.html @@ -63,7 +63,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> diff --git a/docs/reference/print.chent.html b/docs/reference/print.chent.html index 8ab91bc..8f0dd0d 100644 --- a/docs/reference/print.chent.html +++ b/docs/reference/print.chent.html @@ -63,7 +63,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> diff --git a/docs/reference/print.pai.html b/docs/reference/print.pai.html index 7f8c6f3..add2687 100644 --- a/docs/reference/print.pai.html +++ b/docs/reference/print.pai.html @@ -63,7 +63,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">chents</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.7</span> </span> </div> |