aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2019-02-19 23:19:31 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2019-02-19 23:19:31 +0100
commitbfa20a8c262580e38d30cfa95e75d1b01b568d07 (patch)
treed316e76f437662eb193736af2b12bbf223db6e72
parenta7e2c2008699b590325ccd848562881251676faf (diff)
Use rsvg instead of grConvert
as grConvert is not on CRAN
-rw-r--r--ChangeLog2
-rw-r--r--DESCRIPTION5
-rw-r--r--NAMESPACE1
-rw-r--r--R/chent.R39
-rw-r--r--docs/authors.html2
-rw-r--r--docs/index.html2
-rw-r--r--docs/reference/chent.html4
-rw-r--r--docs/reference/draw_svg.chent.html2
-rw-r--r--docs/reference/index.html2
-rw-r--r--docs/reference/pai.html2
-rw-r--r--docs/reference/plot.chent.html2
-rw-r--r--docs/reference/pp.html2
-rw-r--r--docs/reference/print.chent.html2
-rw-r--r--docs/reference/print.pai.html2
14 files changed, 33 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index 31a1fcc..31c099d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/NAMESPACE b/NAMESPACE
index 987a658..e6ced73 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -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)
diff --git a/R/chent.R b/R/chent.R
index c80cf06..f6a8b09 100644
--- a/R/chent.R
+++ b/R/chent.R
@@ -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'>&lt;-</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'>#&gt; <span class='message'>PubChem:</span></div><div class='output co'>#&gt; <span class='message'>https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/cids/JSON</span></div><div class='output co'>#&gt; <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'>#&gt; <span class='message'>https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/synonyms/JSON</span></div><div class='output co'>#&gt; <span class='message'></span>
#&gt; <span class='message'>Initialize Python Version 2.7.13 (default, Sep 26 2018, 18:42:22) </span>
#&gt; <span class='message'>[GCC 6.3.0 20170516]</span></div><div class='output co'>#&gt; <span class='message'>Trying to get chemical information from RDKit using User SMILES</span>
-#&gt; <span class='message'>CCCCCCCCO</span></div><div class='output co'>#&gt; <span class='message'>Lade nötigen Namensraum: grConvert</span></div><div class='output co'>#&gt; <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'>#&gt; &lt;chent&gt;
+#&gt; <span class='message'>CCCCCCCCO</span></div><div class='output co'>#&gt; <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'>#&gt; &lt;chent&gt;
#&gt; Identifier $identifier 1-octanol
#&gt; InChI Key $inchikey KBPLFHHGFOOTCA-UHFFFAOYSA-N
#&gt; 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>

Contact - Imprint