pypath.inputs.uniprot.uniprot_query§
- pypath.inputs.uniprot.uniprot_query(*query, fields: str | Iterable[str] | None = None, **kwargs) dict[str, str] | dict[str, dict[str, str]] [source]§
Basic client for the UniProt REST API.
- Parameters:
query – Query elements: can be a ready query or its components, bypassing the processing in this function or performing only simple concatenation. Alternatively, it can be a nested structure of lists and dicts describing more complex queries. See the examples below.
fields – One or more UniProt field name. See details.
kwargs – Same as passing a dict to
query
.
- Details:
The query can be built in several ways: - Simple string or concatenation of strings:
query_builder(‘kinase AND organism_id:9606’) query_builder(‘kinase’, ‘organism_id:9606’) query_builder(‘kinase’, organism_id = 9606) The above 3 examples all return the same query: kinase AND organism_id:9606
The default operator within lists is OR and within dicts is AND: query_builder(organism = [9606, 10090, 10116]) organism_id:9606 OR organism_id:10090 OR organism_id:10116 query_builder({‘organism_id’: 9606, ‘reviewed’: True}) organism_id:9606 AND reviewed:true
These default operators can be changed by including the op key in dicts or including the operator with an underscore in lists: query_builder({‘length’: (500,), ‘mass’: (50000,), ‘op’: ‘OR’}) length:[500 TO *] OR mass:[50000 TO *] query_builder(lit_author = [‘Huang’, ‘Kovac’, ‘_AND’]) lit_author:Huang AND lit_author:Kovac
The nested structures translate into nested parentheses in the query: query_builder({‘organism_id’: [9606, 10090], ‘reviewed’: True}) (organism_id:9606 OR organism_id:10090) AND reviewed:true
Values are converted to strings, intervals can be provided as tuples: query_builder({‘length’: (100, None), ‘organism_id’: 9606}) length:[100 TO *] AND organism_id:9606
For a complete reference of the available parameters, see https://www.uniprot.org/help/query-fields and https://www.uniprot.org/help/text-search for additional syntax elements.
For the available fields refer to the
_FIELD_SYNONYMS
attribute of the UniprotQuery class or the UniProt website: https://www.uniprot.org/help/return_fields
- Returns:
A list of UniProt IDs if no fields were provided.
A dict of UniProt IDs and corresponding field values if exactly one field was provided.
A dict with field names as top level keys and dicts of the kind described in the previous point as values.