Skip to content

Commit

Permalink
Document commonly used optional arguments
Browse files Browse the repository at this point in the history
Functions that take take `id` or `web_history` now
have those arguments documented and provided in the signature
(so they are tab-completable).

Functions that use `...` for API calls ahve link to API docs

This closes #48
  • Loading branch information
dwinter committed Jul 12, 2015
1 parent 612a280 commit 28d5e71
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 29 deletions.
4 changes: 3 additions & 1 deletion R/entrez_fetch.r
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
#'@param web_history A web_history object
#'@param rettype character Format in which to get data (eg, fasta, xml...)
#'@param retmode character Mode in which to receive data, defaults to 'text'
#'@param \dots character Additional terms to add to the request
#'@param config vector configuration options passed to httr::GET
#'@param \dots character Additional terms to add to the request, see NCBI
#'documentation linked to in referenes for a complete list
#'@references \url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_EFetch_}
#'@param parsed boolean should entrez_fetch attempt to parse the resulting
#' file. Only works with rettype="xml" at present
#'@seealso \code{\link[httr]{config}} for available configs
Expand Down
5 changes: 3 additions & 2 deletions R/entrez_link.r
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
#' \item prlinks. As 'llinks' but returns only the primary external link for
#' each ID.
#'}
#'@param \dots character Additional terms to add to the request
#'@param \dots character Additional terms to add to the request, see NCBI
#'documentation linked to in referenes for a complete list
#'@param config vector configuration options passed to httr::GET
#'@seealso \code{\link[httr]{config}} for available configs
#'@seealso \code{entrez_db_links}
#'@return An elink object containing the data defined by the \code{cmd} argument
#'@return file XMLInternalDocument xml file resulting from search, parsed with
#'\code{\link{xmlTreeParse}}
#'@references http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ELink_
#'@references \url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ELink_}
#'@importFrom XML xmlToList
#' @examples
#' \donttest{
Expand Down
13 changes: 7 additions & 6 deletions R/entrez_post.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
#'@param id vector with unique ID(s) for reacods in database \code{db}.
#'@param web_history A web_history object. Can be used to add to additional
#' identifiers to an existing web environment on the NCBI
#'@param \dots character Additional terms to add to the request
#'@param \dots character Additional terms to add to the request, see NCBI
#'documentation linked to in referenes for a complete list
#'@param config vector configuration options passed to httr::GET
#'@references \url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_EPost_}
#'@seealso \code{\link[httr]{config}} for available configs
#'@importFrom XML xmlTreeParse
#' @examples
#'\dontrun{
#' so_many_snails <- entrez_search(db="nuccore",
#' "Gastropoda[Organism] AND COI[Gene]", retmax=200)
#' upload <- entrez_post(db="nuccore", id=so_many_snails$ids)
#' cookie <- upload$WebEnv
#' first <- entrez_fetch(db="nuccore", rettype="fasta", WebEnv=cookie,
#' query_key=upload$QueryKey, retmax=10)
#' second <- entrez_fetch(db="nuccore", file_format="fasta", WebEnv=cookie,
#' query_key=upload$QueryKey, retstart=10, retmax=10)
#' first <- entrez_fetch(db="nuccore", rettype="fasta", web_history=upload,
#' retmax=10)
#' second <- entrez_fetch(db="nuccore", file_format="fasta", web_history=upload,
#' retstart=10, retmax=10)
#'}

entrez_post <- function(db, id=NULL, web_history=NULL, config=NULL, ...){
Expand Down
8 changes: 5 additions & 3 deletions R/entrez_search.r
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#' later calls to the NCBI
#'@param retmode character One of json (default) or xml. This will make no
#' difference in most cases.
#'@param \dots character Additional terms to add to the request, see NCBI
#'documentation linked to in referenes for a complete list
#'@param config vector configuration options passed to httr::GET
#'@param \dots character Additional terms to add to the request
#'@seealso \code{\link[httr]{config}} for available configs
#'@seealso \code{\link{entrez_db_searchable}} to get a set of search fields that
#' can be used in \code{term} for any base
Expand All @@ -24,10 +25,11 @@
#'\code{\link[XML]{xmlTreeParse}} or, if \code{retmode} was set to json a list
#' resulting from the returned JSON file being parsed with
#' \code{\link[jsonlite]{fromJSON}}.
#' @examples
#'@references \url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ESearch_}
#'@examples
#' \dontrun{
#' query <- "Gastropoda[Organism] AND COI[Gene]"
#' web_env_search <- entrez_search(db="nuccore", query, usehistory="y")
#' web_env_search <- entrez_search(db="nuccore", query, use_history=TRUE)
#' cookie <- web_env_search$WebEnv
#' qk <- web_env_search$QueryKey
#' snail_coi <- entrez_fetch(db = "nuccore", WebEnv = cookie, query_key = qk,
Expand Down
6 changes: 3 additions & 3 deletions R/entrez_summary.r
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#'@param web_history A web_history object
#'@param always_return_list logical, return a list of esummary objects even
#'when only one ID is provided.
#'@param \dots character Additional terms to add to the request. Requires either
#' id (unique id(s) for records in a given database) or WebEnv (a character
#' containing a cookie created by a previous entrez query).
#'@param \dots character Additional terms to add to the request, see NCBI
#'documentation linked to in referenes for a complete list
#'@param config vector configuration options passed to \code{httr::GET}
#'@param version either 1.0 or 2.0 see above for description
#'@references \url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ESummary_}
#'@seealso \code{\link[httr]{config}} for available configs
#'@seealso \code{\link{extract_from_esummary}} which can be used to extract
#'elements from a list of esummary records
Expand Down
6 changes: 5 additions & 1 deletion man/entrez_fetch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ file. Only works with rettype="xml" at present}

\item{config}{vector configuration options passed to httr::GET}

\item{\dots}{character Additional terms to add to the request}
\item{\dots}{character Additional terms to add to the request, see NCBI
documentation linked to in referenes for a complete list}
}
\value{
character string containing the file created
Expand All @@ -40,6 +41,9 @@ katipo <- "Latrodectus katipo[Organism]"
katipo_search <- entrez_search(db="nuccore", term=katipo)
kaitpo_seqs <- entrez_fetch(db="nuccore", id=katipo_search$ids, rettype="fasta")
}
\references{
\url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_EFetch_}
}
\seealso{
\code{\link[httr]{config}} for available configs
}
Expand Down
5 changes: 3 additions & 2 deletions man/entrez_link.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ to discover databases that might have linked information (see examples).}

\item{config}{vector configuration options passed to httr::GET}

\item{\dots}{character Additional terms to add to the request}
\item{\dots}{character Additional terms to add to the request, see NCBI
documentation linked to in referenes for a complete list}
}
\value{
An elink object containing the data defined by the \code{cmd} argument
Expand All @@ -61,7 +62,7 @@ set for the \code{cmd} argument. Printing the returned object lists the names
}
}
\references{
http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ELink_
\url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ELink_}
}
\seealso{
\code{\link[httr]{config}} for available configs
Expand Down
15 changes: 9 additions & 6 deletions man/entrez_post.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ identifiers to an existing web environment on the NCBI}

\item{config}{vector configuration options passed to httr::GET}

\item{\dots}{character Additional terms to add to the request}
\item{\dots}{character Additional terms to add to the request, see NCBI
documentation linked to in referenes for a complete list}
}
\description{
Post IDs to Eutils for later use
Expand All @@ -26,13 +27,15 @@ Post IDs to Eutils for later use
so_many_snails <- entrez_search(db="nuccore",
"Gastropoda[Organism] AND COI[Gene]", retmax=200)
upload <- entrez_post(db="nuccore", id=so_many_snails$ids)
cookie <- upload$WebEnv
first <- entrez_fetch(db="nuccore", rettype="fasta", WebEnv=cookie,
query_key=upload$QueryKey, retmax=10)
second <- entrez_fetch(db="nuccore", file_format="fasta", WebEnv=cookie,
query_key=upload$QueryKey, retstart=10, retmax=10)
first <- entrez_fetch(db="nuccore", rettype="fasta", web_history=upload,
retmax=10)
second <- entrez_fetch(db="nuccore", file_format="fasta", web_history=upload,
retstart=10, retmax=10)
}
}
\references{
\url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_EPost_}
}
\seealso{
\code{\link[httr]{config}} for available configs
}
Expand Down
8 changes: 6 additions & 2 deletions man/entrez_search.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ difference in most cases.}
\item{use_history}{locgical Return a web_history object for use in
later calls to the NCBI}

\item{\dots}{character Additional terms to add to the request}
\item{\dots}{character Additional terms to add to the request, see NCBI
documentation linked to in referenes for a complete list}
}
\value{
ids integer Unique IDS returned by the search
Expand All @@ -45,7 +46,7 @@ a database name, then retrieves the XML document created by that query.
\examples{
\dontrun{
query <- "Gastropoda[Organism] AND COI[Gene]"
web_env_search <- entrez_search(db="nuccore", query, usehistory="y")
web_env_search <- entrez_search(db="nuccore", query, use_history=TRUE)
cookie <- web_env_search$WebEnv
qk <- web_env_search$QueryKey
snail_coi <- entrez_fetch(db = "nuccore", WebEnv = cookie, query_key = qk,
Expand All @@ -62,6 +63,9 @@ tax_fields$RANK
entrez_search(db="taxonomy", term="Drosophila & Genus[RANK]")
}
}
\references{
\url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ESearch_}
}
\seealso{
\code{\link[httr]{config}} for available configs

Expand Down
8 changes: 5 additions & 3 deletions man/entrez_summary.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ when only one ID is provided.}

\item{config}{vector configuration options passed to \code{httr::GET}}

\item{\dots}{character Additional terms to add to the request. Requires either
id (unique id(s) for records in a given database) or WebEnv (a character
containing a cookie created by a previous entrez query).}
\item{\dots}{character Additional terms to add to the request, see NCBI
documentation linked to in referenes for a complete list}
}
\value{
A list of esummary records (if multiple IDs are passed and
Expand Down Expand Up @@ -59,6 +58,9 @@ pop_ids = c("307082412", "307075396", "307075338", "307075274")
extract_from_esummary(cv, "trait_set")[1:2]
extract_from_esummary(cv, "gene_sort")
}
\references{
\url{http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ESummary_}
}
\seealso{
\code{\link[httr]{config}} for available configs

Expand Down

0 comments on commit 28d5e71

Please sign in to comment.