Skip to content

Commit

Permalink
version 0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mobreza authored and cran-robot committed Sep 2, 2019
1 parent d6e427f commit f4791e6
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 45 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,5 +1,5 @@
Package: genesysr
Version: 0.9.1
Version: 0.9.2
Title: Genesys PGR Client
Description: Access data on plant genetic resources from genebanks around the world published on Genesys (<https://www.genesys-pgr.org>).
Your use of data is subject to terms and conditions available at <https://www.genesys-pgr.org/content/legal/terms>.
Expand All @@ -10,15 +10,15 @@ Maintainer: Matija Obreza <matija.obreza@croptrust.org>
Depends: R (>= 3.1.0)
Imports: httr, jsonlite
License: Apache License 2.0
RoxygenNote: 6.0.1
RoxygenNote: 6.1.1
URL: https://gitlab.croptrust.org/genesys-pgr/genesysr
BugReports: https://gitlab.croptrust.org/genesys-pgr/genesysr/issues
Suggests: knitr, rmarkdown
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2018-06-12 19:12:29 UTC; mobreza
Packaged: 2019-09-02 09:32:51 UTC; mobreza
Author: Global Crop Diversity Trust [cph],
Matija Obreza [aut, cre],
Nora Castaneda [ctb]
Repository: CRAN
Date/Publication: 2018-06-14 19:24:54 UTC
Date/Publication: 2019-09-02 15:20:02 UTC
29 changes: 17 additions & 12 deletions MD5
@@ -1,25 +1,30 @@
a86defb48d4d5b6930386bf4709d9833 *DESCRIPTION
b79f7b6b1bb4ee7f122d15e2dc5c09cd *DESCRIPTION
95e36a55ec470fcfdd38b16d4fe61245 *NAMESPACE
3d49656b4c304602fa0bbe2e22627d29 *NEWS.md
e3fc67b971ebed3dbaecdd817078bf93 *R/api-client.R
aafaf7b9f67fc8451ef3640c80485443 *R/filters.R
3e34da3f556f9b453bb93da2503a2dcf *NEWS.md
6f8999f55812e6b15ff82a19d734adc6 *R/api-client.R
6867b32775e64efe5bd34b29363324a4 *R/filters.R
73128a079eef5a8f628ec1e17158304c *R/genesys.R
7e0493a9e4c33ae5be92580b72ccd46f *README.md
ea3b12fe2a55e424552ab1e32780fbee *build/vignette.rds
bf6557dda1549bec046340a92c9292f2 *inst/doc/tutorial.Rmd
db1df546d28bfd7e25a2f871ecc24c05 *inst/doc/tutorial.html
a6cd114243bc980b433d12c648844fc2 *README.md
89e54575a73d1df3d124692c6aee6c17 *build/vignette.rds
446d14ec0ec67ebe43439dd2eebe93b3 *inst/doc/tutorial.Rmd
f65491305d51068c3c4688c53c0edc6b *inst/doc/tutorial.html
a59a638d633133520d47af9af3e8556f *man/api_url.Rd
3c89e0e5581c109333bd2c32c8affd80 *man/authorization.Rd
b977ae83784900d75d756d2946920d63 *man/client_login.Rd
614d434792f634e542f152dd7ec7ec8f *man/dot-MAX_ALLOWED_PAGES.Rd
1a9125f6ae1a357530bfb1253beba86c *man/dot-check_auth.Rd
8c2e55f11a4626ad66c77d73ff319642 *man/dot-fetch_accessions_page.Rd
0012e14aa882077b9aac609b77704593 *man/dot-onLoad.Rd
c546c4641530df70c79f983290e95879 *man/dot-post.Rd
a4e2f7a68c9b341c04a80b23844ae3f0 *man/fetch_accessions.Rd
2db62806b45ddc904228f7dad30cb932 *man/filter_DOI.Rd
1a26ce7d5cd01e2375640e029940359f *man/filter_ORIGCTY.Rd
f5e9d08ec3ee48022daea3ba8491c9b8 *man/filter_SAMPSTAT.Rd
991994b8a7a65b025e6b161b4a25c5c1 *man/mcpd_filter.Rd
2ba6fb516ae56d6124cb4b514ebf6b4e *man/me.Rd
8a6fbe344291d152f27e1329998747d7 *man/print_setup.Rd
1ea2a1c45d29721ff4961042e87ed1cc *man/setup.Rd
cf8ee093227e205ff3f6677a2d410588 *man/setup_production.Rd
88d5cc71d196bc775a7bf85aa83ab6ca *man/setup_sandbox.Rd
f562d7cc9ec22b8e692370d584361330 *man/setup.Rd
a5d181cf2b629e0fd4d28356bd185422 *man/setup_production.Rd
5c09b4337f8f2c69dad1d9c47427ef08 *man/setup_sandbox.Rd
8e92387d911827f80c26ef8ce7ee7a9e *man/user_login.Rd
bf6557dda1549bec046340a92c9292f2 *vignettes/tutorial.Rmd
446d14ec0ec67ebe43439dd2eebe93b3 *vignettes/tutorial.Rmd
3 changes: 3 additions & 0 deletions NEWS.md
@@ -1,3 +1,6 @@
# August 2019

Updated for API at api.genesys-pgr.org

# June 2018

Expand Down
15 changes: 9 additions & 6 deletions R/api-client.R
Expand Up @@ -14,32 +14,35 @@

.genesysEnv <- new.env(parent = emptyenv())

#' Configure package defaults
#' Configure package defaults on load
#'
#' @param libname Library name
#' @param pkgname Package name
.onLoad <- function(libname, pkgname) {
setup_production()
}

#' Setup for Genesys Production
#'
#' Use the Genesys R Client with <https://www.genesys-pgr.org> requiring \code{\link{user_login}}
#' Use the Genesys R Client with <https://api.genesys-pgr.org> requiring \code{\link{user_login}}
#'
#' @export
setup_production <- function() {
setup(server = "https://www.genesys-pgr.org", client_id = "oHgJR.NjcdJAIB175gBDbuLEK3@www.genesys-pgr.org", client_secret = "public")
setup(server = "https://api.genesys-pgr.org", client_id = "oHgJR.NjcdJAIB175gBDbuLEK3@www.genesys-pgr.org", client_secret = "public")
}

#' Setup for Genesys Sandbox
#'
#' Use the Genesys R Client with <https://sandbox.genesys-pgr.org> requiring \code{\link{user_login}}
#' Use the Genesys R Client with <https://api.sandbox.genesys-pgr.org> requiring \code{\link{user_login}}
#'
#' @export
setup_sandbox <- function() {
setup(server = "https://sandbox.genesys-pgr.org", client_id = "cCS6e.BAn9u2WkhIwgxBLxOVqZ@sandbox.genesys-pgr.org", client_secret = NULL)
setup(server = "https://api.sandbox.genesys-pgr.org", client_id = "cCS6e.BAn9u2WkhIwgxBLxOVqZ@sandbox.genesys-pgr.org", client_secret = NULL)
}

#' Configure the Genesys environment
#'
#' @param server Server base URL (e.g. "https://www.genesys-pgr.org" or "https://sandbox.genesys-pgr.org")
#' @param server Server base URL (e.g. "https://api.genesys-pgr.org" or "https://api.sandbox.genesys-pgr.org")
#' @param client_id OAuth client ID
#' @param client_secret OAuth client secret
#'
Expand Down
24 changes: 24 additions & 0 deletions R/filters.R
Expand Up @@ -12,6 +12,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.


MCPD <- list(
SAMPSTAT = list("Wild" = list(100, "Natural" = 110, "Semi-natural/wild"=120, "Semi-natural/sown"=130),
"Weedy" = 200,
"Traditional cultivar/landrace" = 300,
"Breeding/research material"= list(400, "Breeder's line"=410,"Synthetic population"=411,"Hybrid"=412,"Founder stock/base population"=413,"Inbred line (parent of hybrid cultivar)"=414,"Segregating population"=415,"Clonal selection"=416,"Genetic stock"=420,"Mutant (e.g. induced/insertion mutant, tilling population)"=421,"Cytogenetic stock (e.g. chromosome addition/substitution, aneuploids, amphiploids)"=422,"Other genetic stocks (e.g. mapping populations)"=423),
"Advanced or improved cultivar (conventional breeding methods)"=500,
"GMO (by genetic engineering)"=600,
"Other (elaborate in REMARKS field)"=999),
STORAGE = list("Seed collection"=list(10,"Short term"=11,"Medium term"=12,"Long term"=13),
"Field collection"=20,
"In vitro collection"=30,
"Cryopreserved collection"=40,
"DNA collection"=50,
"Other (elaborate in REMARKS field)"=99),
COLLSRC = list("Wild habitat"=list(10,"Forest or woodland"=11,"Shrubland"=12,"Grassland"=13,"Desert or tundra"=14,"Aquatic habitat"=15),
"Farm or cultivated habitat"=list(20,"Field"=21,"Orchard"=22,"Backyard, kitchen or home garden (urban, peri-urban or rural)"=23,"Fallow land"=24,"Pasture"=25,"Farm store"=26,"Threshing floor"=27,"Park"=28),
"Market or shop"=30,
"Institute, Experimental station, Research organization, Genebank"=40,
"Seed company"=50,
"Weedy, disturbed or ruderal habitat"=list(60,"Roadside"=61,"Field margin"=62),
"Other (Elaborate in REMARKS field)"=99)
)

#' Make or adjust filter using MCPD terminology
#'
#' See FAO/Bioversity Multi-Crop Passport Descriptors.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -51,7 +51,7 @@ Accessing Genesys **without user interaction** requires that a client is registe
```R
# Setup
library('genesysr')
genesysr::setup(server = "https://www.genesys-pgr.org",
genesysr::setup(server = "https://api.genesys-pgr.org",
client_id = "someId.....@www.genesys-pgr.org",
client_secret = "your-private-secret")

Expand Down
Binary file modified build/vignette.rds
Binary file not shown.
7 changes: 4 additions & 3 deletions inst/doc/tutorial.Rmd
Expand Up @@ -16,6 +16,7 @@ Querying Genesys PGR
maintained *ex situ* in national, regional and international genebanks around the world.

**genesysr** uses the [Genesys API](https://www.genesys-pgr.org/doc/0/apis) to query Genesys data.
The API is accessible at https://api.genesys-pgr.org.

Accessing data with **genesysr** is similar to downloading data in CSV or Excel format and loading
it into R.
Expand All @@ -28,7 +29,7 @@ The database is queried by providing a `filter` (see Filters below):

```
## Setup: use Genesys Sandbox environment
# genesysr::setup_sandbox()
# genesysr::setup_sandbox()
# genesysr::setup_production() # This is initialized by default when loading genesysr
# Open a browser: login to Genesys and authorize access
Expand All @@ -44,7 +45,7 @@ itc <- fetch_accessions(list(institute.code = c('BEL084')))
some <- fetch_accessions(list(institute.code = c('BEL084','COL003')))
```

**genesysr** provides utility functions to create `filter` objects using [Multi-Crop Passport Descriptors (MCPD)](https://www.genesys-pgr.org/doc/0/basics#mcpd) definitions:
**genesysr** provides utility functions to create `filter` objects using [Multi-Crop Passport Descriptors (MCPD)](https://www.genesys-pgr.org/documentation/basics) definitions:

```
# Retrieve data by country of origin (MCPD)
Expand All @@ -63,7 +64,7 @@ musa.flatten <- musa.flatten %>% map_df(bind_rows)

# Filters

The records returned by Genesys match all filters provided (*AND* operation), while individual filters
The records returned by Genesys match all filters provided (*AND* operation), while individual filters
allow for specifying multiple criteria (*OR* operation):

```r
Expand Down
53 changes: 40 additions & 13 deletions inst/doc/tutorial.html
Expand Up @@ -7,22 +7,23 @@
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />

<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="author" content="Nora Castaneda &amp; Matija Obreza" />

<meta name="date" content="2018-06-12" />
<meta name="date" content="2019-09-02" />

<title>genesysr Tutorial</title>



<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
<style type="text/css" data-origin="pandoc">
a.sourceLine { display: inline-block; line-height: 1.25; }
a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
a.sourceLine:empty { height: 1.2em; position: absolute; }
a.sourceLine:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode { white-space: pre; position: relative; }
div.sourceCode { margin: 1em 0; }
Expand All @@ -35,13 +36,11 @@
a.sourceLine { text-indent: -1em; padding-left: 1em; }
}
pre.numberSource a.sourceLine
{ position: relative; }
pre.numberSource a.sourceLine:empty
{ position: absolute; }
{ position: relative; left: -4em; }
pre.numberSource a.sourceLine::before
{ content: attr(data-line-number);
position: absolute; left: -5em; text-align: right; vertical-align: baseline;
border: none; pointer-events: all;
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; pointer-events: all; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
Expand Down Expand Up @@ -83,7 +82,29 @@
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */

</style>
<script>
// apply pandoc div.sourceCode style to pre.sourceCode instead
(function() {
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
for (var j = 0; j < rules.length; j++) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue;
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' && rule.style.backgroundColor === '') continue;
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>



Expand Down Expand Up @@ -271,6 +292,9 @@
code > span.fu { color: #900; font-weight: bold; } code > span.er { color: #a61717; background-color: #e3d2d2; }
</style>




</head>

<body>
Expand All @@ -279,22 +303,22 @@


<h1 class="title toc-ignore">genesysr Tutorial</h1>
<h4 class="author"><em>Nora Castaneda &amp; Matija Obreza</em></h4>
<h4 class="date"><em>2018-06-12</em></h4>
<h4 class="author">Nora Castaneda &amp; Matija Obreza</h4>
<h4 class="date">2019-09-02</h4>



<div id="querying-genesys-pgr" class="section level1">
<h1>Querying Genesys PGR</h1>
<p><a href="https://www.genesys-pgr.org">Genesys PGR</a> is the global database on plant genetic resources maintained <em>ex situ</em> in national, regional and international genebanks around the world.</p>
<p><strong>genesysr</strong> uses the <a href="https://www.genesys-pgr.org/doc/0/apis">Genesys API</a> to query Genesys data.</p>
<p><strong>genesysr</strong> uses the <a href="https://www.genesys-pgr.org/doc/0/apis">Genesys API</a> to query Genesys data. The API is accessible at <a href="https://api.genesys-pgr.org" class="uri">https://api.genesys-pgr.org</a>.</p>
<p>Accessing data with <strong>genesysr</strong> is similar to downloading data in CSV or Excel format and loading it into R.</p>
<div id="for-the-impatient" class="section level2">
<h2>For the impatient</h2>
<p>Accession passport data is retrieved with the <code>fetch_accessions</code> function.</p>
<p>The database is queried by providing a <code>filter</code> (see Filters below):</p>
<pre><code>## Setup: use Genesys Sandbox environment
# genesysr::setup_sandbox()
# genesysr::setup_sandbox()
# genesysr::setup_production() # This is initialized by default when loading genesysr

# Open a browser: login to Genesys and authorize access
Expand All @@ -308,7 +332,7 @@ <h2>For the impatient</h2>

# Retrieve all accession data for the Musa International Transit Center, Bioversity International (BEL084) and the International Center for Tropical Agriculture (COL003)
some &lt;- fetch_accessions(list(institute.code = c('BEL084','COL003')))</code></pre>
<p><strong>genesysr</strong> provides utility functions to create <code>filter</code> objects using <a href="https://www.genesys-pgr.org/doc/0/basics#mcpd">Multi-Crop Passport Descriptors (MCPD)</a> definitions:</p>
<p><strong>genesysr</strong> provides utility functions to create <code>filter</code> objects using <a href="https://www.genesys-pgr.org/documentation/basics">Multi-Crop Passport Descriptors (MCPD)</a> definitions:</p>
<pre><code># Retrieve data by country of origin (MCPD)
fetch_accessions(mcpd_filter(ORIGCTY = c(&quot;DEU&quot;, &quot;SVN&quot;)))</code></pre>
</div>
Expand Down Expand Up @@ -392,6 +416,9 @@ <h1>Step-by-step example</h1>



<!-- code folding -->


<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
Expand Down
14 changes: 14 additions & 0 deletions man/dot-MAX_ALLOWED_PAGES.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/dot-check_auth.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions man/dot-fetch_accessions_page.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f4791e6

Please sign in to comment.