aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/chent.R24
-rw-r--r--test.log27
-rw-r--r--tests/testthat/test_chent.R2
3 files changed, 37 insertions, 16 deletions
diff --git a/R/chent.R b/R/chent.R
index 6f77582..91fc41b 100644
--- a/R/chent.R
+++ b/R/chent.R
@@ -195,19 +195,25 @@ chent <- R6Class("chent",
self$inchikey <- self$pubchem$InChIKey
attr(self$inchikey, "source") <- "pubchem"
} else {
- if (length(self$inchikey) > 1) {
- message("InChIKey ", self$inchikey, " retreived from ",
- attr(self$inchikey, "source"),
- " has length > 1, using PubChem InChIKey")
+ if (is.na(self$inchikey)) {
+ warning("Overwriting uninitialized InChIKey")
self$inchikey <- self$pubchem$InChIKey
attr(self$inchikey, "source") <- "pubchem"
} else {
- if (self$pubchem$InChIKey != self$inchikey) {
- message("InChiKey ", self$pubchem$InChIKey, " from PubChem record does not match\n",
- "InChiKey ", self$inchikey, " retreived from ",
- attr(self$inchikey, "source"))
+ if (length(self$inchikey) > 1) {
+ message("InChIKey ", self$inchikey, " retreived from ",
+ attr(self$inchikey, "source"),
+ " has length > 1, using PubChem InChIKey")
+ self$inchikey <- self$pubchem$InChIKey
+ attr(self$inchikey, "source") <- "pubchem"
} else {
- attr(self$inchikey, "source") <- c(attr(self$inchikey, "source"), "pubchem")
+ if (self$pubchem$InChIKey != self$inchikey) {
+ message("InChiKey ", self$pubchem$InChIKey, " from PubChem record does not match\n",
+ "InChiKey ", self$inchikey, " retreived from ",
+ attr(self$inchikey, "source"))
+ } else {
+ attr(self$inchikey, "source") <- c(attr(self$inchikey, "source"), "pubchem")
+ }
}
}
}
diff --git a/test.log b/test.log
index 9817e02..6c6325d 100644
--- a/test.log
+++ b/test.log
@@ -1,11 +1,26 @@
Loading required package: usethis
-ℹ Loading chents
ℹ Testing chents
-✔ | F W S OK | Context
-✔ | 6 | Generation of chent objects [3.3s]
-✔ | 8 | Generation of pai objects [8.1s]
+
+Attaching package: ‘testthat’
+
+The following object is masked from ‘package:devtools’:
+
+ test_file
+
+✔ | F W S OK | Context
+
+⠏ | 0 | chent
+⠏ | 0 | Generation of chent objects
+⠋ | 1 | Generation of chent objects
+⠸ | 4 | Generation of chent objects
+✔ | 7 | Generation of chent objects [4.9s]
+
+⠏ | 0 | pai
+⠏ | 0 | Generation of pai objects
+⠋ | 1 | Generation of pai objects
+✔ | 8 | Generation of pai objects [6.8s]
══ Results ═════════════════════════════════════════════════════════════════════
-Duration: 11.4 s
+Duration: 11.7 s
-[ FAIL 0 | WARN 0 | SKIP 0 | PASS 14 ]
+[ FAIL 0 | WARN 0 | SKIP 0 | PASS 15 ]
diff --git a/tests/testthat/test_chent.R b/tests/testthat/test_chent.R
index 4551cf7..7594640 100644
--- a/tests/testthat/test_chent.R
+++ b/tests/testthat/test_chent.R
@@ -15,7 +15,7 @@ test_that("We can generate a chent object from SMILES using RDKit", {
})
test_that("We can add information retrieved from PubChem via webchem", {
- oct$try_pubchem()
+ expect_warning(oct$try_pubchem(), "Overwriting uninitialized InChIKey")
expect_equivalent(round(oct$mw, 2), 130.23)
ik = "KBPLFHHGFOOTCA-UHFFFAOYSA-N"
attr(ik, "source") <- "pubchem"

Contact - Imprint