Skip to contents

Get a single entry from UniProt. By default it fetches the webpage using format = "json" and outputs a list of information, but different formats are available from different databases. It is a wrapper for this UniProt API endpoint.

Usage

uniprot_single(
  id,
  database = "uniprotkb",
  format = "json",
  path = NULL,
  fields = NULL,
  isoform = NULL,
  verbosity = NULL,
  dry_run = FALSE
)

Arguments

id

string, entry ID. Form depends on database e.g. "P12345" for UniProtKB, "UPI0000128BBF" for UniParc, etc.

database

string, database to look up. Default is "uniprotkb". See the Databases section below for all available databases.

format

string, data format to fetch. Default is "json". Can be one of "tsv", "json", or "fasta".

path

string (optional), file path to save the results, e.g. "path/to/results.tsv".

fields

character (optional), fields (i.e. columns) of data to get. The fields available depends on the database used, see return_fields for all available fields.

isoform

logical (optional), should protein isoforms be included in the results? Not necessarily relevant for all formats and databases.

verbosity

integer (optional), how much information to print?

  • 0: no output

  • NULL (default): minimal output

  • 1: show request headers

  • 2: show request headers and bodies

  • 3: show request headers, bodies, and curl status messages

dry_run

logical, perform request with httr2::req_dry_run()? Requires the httpuv package to be installed. Default is FALSE.

Value

By default, returns an object whose type depends on format:

If path is specified, saves the results to the file path indicated, and returns NULL invisibly. If dry_run = TRUE, returns a list containing information about the request, including the request method, path, and headers.

Databases

The following databases are available to query:

See also

Other API wrapper functions: uniprot_map(), uniprot_search()

Examples

if (FALSE) {
  # Download the entry for human Cytochrome C
  res <- uniprot_single("P99999", format = "json")

  # Look at the structure of the resulting list
  str(res, max.level = 1)
}