Skip to content

Commit

Permalink
Merge branch 'master' into release_1_0_0
Browse files Browse the repository at this point in the history
  • Loading branch information
dwinter committed Sep 16, 2015
2 parents f48a104 + 3e28144 commit 7d00904
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Generated by roxygen2 (4.1.1): do not edit by hand

S3method(as.data.frame,eInfoList)
S3method(extract_from_esummary,esummary)
S3method(extract_from_esummary,esummary_list)
S3method(print,eInfoEntry)
S3method(print,eInfoLink)
S3method(print,eInfoSearch)
Expand Down
13 changes: 12 additions & 1 deletion R/entrez_summary.r
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,18 @@ entrez_summary <- function(db, id=NULL, web_history=NULL,
#'@param simplify logical, if possible return a vector
#'@return List or vector containing requested elements
extract_from_esummary <- function(esummaries, elements, simplify=TRUE){
fxn <- if (simplify & length(elements) == 1) "[[" else "["
UseMethod("extract_from_esummary", esummaries)
}

#'@export
extract_from_esummary.esummary <- function(esummaries, elements, simplify=TRUE){
fxn <- if(simplify & length(elements)==1) `[[` else `[`
fxn(esummaries, elements)
}

#'@export
extract_from_esummary.esummary_list <- function(esummaries, elements, simplify=TRUE){
fxn <- if (simplify & length(elements) == 1) `[[` else `[`
sapply(esummaries, fxn, elements, simplify=simplify)
}

Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ output:
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
comment = "#"
)
knitr::opts_knit$set(upload.fun = knitr::imgur_upload, base.url = NULL)
Expand Down Expand Up @@ -80,7 +80,7 @@ Now, what sorts of data are available from other NCBI database for this paper?

```{r links}
hox_data <- entrez_link(db="all", id=hox_pmid, dbfrom="pubmed")
hox_data
hox_data$links
```

Each of the character vectors in this object contain unique IDS for records in
Expand All @@ -92,7 +92,7 @@ In this case we'll get the protein sequences as genbank files, using '
`entrez_fetch`:

```{r proteins}
hox_proteins <- entrez_fetch(db="protein", id=hox_data$pubmed_protein, rettype="gb")
hox_proteins <- entrez_fetch(db="protein", id=hox_data$links$pubmed_protein, rettype="gb")
```

###Retrieving datasets associated a particular organism.
Expand Down
9 changes: 5 additions & 4 deletions man/linkout_urls.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
linkout_urls(elink)
}
\arguments{
\item{elink:}{elink object (returned by entrez_link) containing Urls}

\item{list}{of character vectors, one per ID each containing of urls for that
ID.}
\item{elink}{elink object (returned by entrez_link) containing Urls}
}
\value{
list of character vectors, one per ID each containing of urls for that
ID.
}
\description{
Extract urls from an elink object
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test_summary.r
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ test_that("We can extract elements from esummary object", {

})

test_that("We can extract elements from a single esummary", {
expect_that(extract_from_esummary(pop_summ_xml[[1]], c("Title", "TaxId")), is_a("list"))
expect_that(extract_from_esummary(pop_summ_xml[[1]], "Gi"), is_a("integer"))
expect_that(extract_from_esummary(pop_summ_xml[[1]], "Gi", FALSE), is_a("list"))
})

test_that("We can get a list of one element if we ask for it", {
expect_that(entrez_summary(db="popset", id=307075396, always_return_list=TRUE), is_a("list"))
expect_that(entrez_summary(db="popset", id=307075396), is_a("esummary"))
Expand Down

0 comments on commit 7d00904

Please sign in to comment.