pypath.inputs.uniprot.query_builder§

pypath.inputs.uniprot.query_builder(*query, **kwargs) str[source]§

Build a query for the UniProt web site and 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.

  • 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.

Returns:

A query that can be inserted into the UniProt search field.