Skip to content

Commit

Permalink
Merge branch 'develop' for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
dwinter committed May 2, 2019
2 parents a3b7e83 + 53b867b commit 5d552d7
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rentrez
Version: 1.2.1
Date: 2018-02-12
Version: 1.2.2
Date: 2019-05-02
Title: 'Entrez' in R
Authors@R: c(
person("David", "Winter", role=c("aut", "cre"),
Expand Down
11 changes: 11 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Version 1.2.2
------------------
Maintenance release containing a number of bug fixes.

* A fix #127 forces curl to use http/1.1, as NCBI produces errors when sing http/2
(thanks @hammer for bug report and fix)
* fix #131 stops pubmed records with reference sections production > 1
value for the 'pmid' field. Thanks @agbarnett for the report.
* Added clarification around the expectd input for `extract_from_esummary` to
the docs.

Version 1.2.1
------------------

Expand Down
17 changes: 17 additions & 0 deletions R/base.r
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ make_entrez_query <- function(util, config, interface=".fcgi?", by_id=FALSE, deb
return( list(uri = uri, args=args ) )
}

#Seemingly, NCBI moved to https but not http v2.0?
# (thatnks Jeff Hammerbacher for report/solution)
#
# if no httr::config was passed we will add one
if(is.null(config)){
config = httr::config(http_version = 2)
# otherwise add http version, checkign we aren't overwriting something
# passed in (seems unlikely, but worth checking?)
#
} else {
if ("http_version" %in% names(config$options)) {
warning("Over-writing httr config options for 'http_version', as NCBI servers require v1.1")
}
config$options$http_version <- 2
}


if(length(args$id) > 200){
response <- httr::POST(uri, body=args, config= config)
} else {
Expand Down
4 changes: 3 additions & 1 deletion R/entrez_summary.r
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ entrez_summary <- function(db, id=NULL, web_history=NULL,

#' Extract elements from a list of esummary records
#'@export
#'@param esummaries A list of esummary objects
#'@param esummaries Either an esummary or an esummary_list (as returned by
#' entrez_summary).
#'@param elements the names of the element to extract
#'@param simplify logical, if possible return a vector
#'@seealso \code{\link{entrez_summary}} for examples of this function in action.
#'@return List or vector containing requested elements
extract_from_esummary <- function(esummaries, elements, simplify=TRUE){
UseMethod("extract_from_esummary", esummaries)
Expand Down
4 changes: 2 additions & 2 deletions R/parse_pubmed_xml.r
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ parse_one_pubmed <- function(paper){
res$issue <- get_value(".//JournalIssue/Issue")
res$pages <- get_value(".//MedlinePgn")
res$key_words <- get_value(".//DescriptorName")
res$doi <- get_value(".//ArticleId[@IdType='doi']")
res$pmid <- get_value(".//ArticleId[@IdType='pubmed']")
res$doi <- get_value(".//PubmedData/ArticleIdList/ArticleId[@IdType='doi']")
res$pmid <- get_value(".//PubmedData/ArticleIdList/ArticleId[@IdType='pubmed']")
res$abstract <- get_value(".//AbstractText")

structure(res, class="pubmed_record", empty=FALSE)
Expand Down
6 changes: 5 additions & 1 deletion man/extract_from_esummary.Rd

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

3 changes: 2 additions & 1 deletion tests/testthat/test_net.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
context("Network")
test_that("The NCBI is contactable from this comptuter /",{
expect_true(!httr::http_error("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/"))
response <- httr::GET("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi")
expect_lt(response$status_code, 400)
})
10 changes: 10 additions & 0 deletions tests/testthat/test_parse.r
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ parsed_raw <- parse_pubmed_xml(raw_rec)
parsed_rec <- parse_pubmed_xml(xml_rec)
parsed_multi <- parse_pubmed_xml(multi_rec)

multi_pmid_eg <- parse_pubmed_xml(
entrez_fetch(db="pubmed", id='29743284', rettype="xml")
)

test_that("pubmed file parsers work",{
expect_that(raw_rec, is_a("character"))

Expand All @@ -27,6 +31,12 @@ test_that("pubmed file parsers work",{
# re-introduced there will be 25 authors in each record and this will fail
expect_that(length(parsed_multi[[1]]$authors), equals(1))

# Bug #131 related to extracting all PMIDs from a pubmed xml that contained
# references, not just the one true pm od teh artcle. Testing we don't
# regress

expect_that(length(multi_pmid_eg$pmid), equals(1))

})

test_that("we can print pubmed records", {
Expand Down

0 comments on commit 5d552d7

Please sign in to comment.