This function performs a request for data from the UniProt REST API, fetches the results using the stream endpoint, and saves them to a file or into memory.
You likely won't use this function directly, but rather one of the
wrapper functions: uniprot_map(), uniprot_search(), or uniprot_single().
Things to note:
The stream endpoint is expensive for the API to process. If this endpoint has too many requests a
429status error will occur. In this case usefetch_paged()or try again later.Up to 10,000,000 results can be fetched via stream. If you want to get more results you should use
fetch_paged(), or consider downloading some datasets from UniProt's FTP website.
Arguments
- req
httr2_requestobject, generated by e.g.httr2::request()oruniprot_request().- format
string, data format to fetch. Can be one of"tsv","json"or"fasta".- parse
logical, should the response body be parsed e.g. into adata.frameor should thehttr2_responseobject be returned instead? Default isTRUE. Does nothing ifpathis provided.- path
string(optional), file path to save the results, e.g."path/to/results.tsv". The file must not already exist, otherwise an error is thrown.- 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
Value
By default, returns an object whose type depends on format:
tsv:data.framejson:listfasta: Biostrings::AAStringSet (ornamed characterif Biostrings not installed)
If parse = FALSE, returns an httr2_response. If path is specified,
saves the parsed results to the file path indicated, and returns NULL
invisibly.
Examples
if (FALSE) {
req <- uniprot_request(
"https://rest.uniprot.org/uniref/stream",
query = "P99999",
format = "tsv",
fields = "id,name,count"
)
fetch_stream(req)
}