pdbsearch.rcsb

pdbsearch.rcsb.apply_pagination(query, start, limit)[source]

Creates a query’s request_options and applies pagination information to it, or an instruction to get all data.

Parameters
  • query (dict) – the RCSB query object.

  • start (int) – the start location.

  • limit (int) – the number of results to return (or None to get everything)

pdbsearch.rcsb.apply_query(query, kwargs)[source]

Adds the query component to the overall query object. It uses whatever leftover keyword arguments are passed to the search function and uses these in a chain of AND queries.

Parameters
  • query (dict) – the RCSB query object.

  • kwargs (dict) – the keyword arguments passed to the search function.

pdbsearch.rcsb.apply_sort(query, sort)[source]

Applies sort terms to a query’s request_options.

Parameters
  • query (dict) – the RCSB query object.

  • sort – the sort term(s).

pdbsearch.rcsb.get_query_attribute(kwarg)[source]

Takes a proposed query property and modifies it as needed based on suffixes or shorthand.

Parameters

kwarg (str) – the keyword argument passed to the search function.

Return type

str

pdbsearch.rcsb.get_query_operator(kwarg, value)[source]

Takes a key-value pair passed to the search function and works out what operator should be used (equals, less than, within etc.).

Parameters
  • kwarg (str) – the keyword argument passed to the search function.

  • value – the search value.

Return type

str

pdbsearch.rcsb.get_query_parameters(property, value)[source]

Takes a key-value pair passed to the search function and turns it into a parameters dictionary representing that search criterion.

Parameters
  • property (str) – the keyword name.

  • value – the search value.

Return type

dict

pdbsearch.rcsb.search(start=0, limit=10, sort=None, **kwargs)[source]

Searches for PDB codes. You can choose how many to get and from what starting point.

Sort terms can either be formal RCSB attributes, or a shorthand such as ‘resolution’ or ‘code’. If you supply a list of terms, these will be applied in turn.

Parameters
  • start (int) – the start index (default 0).

  • limit (int) – how many codes to return (default 10).

  • sort – the sort term, or list of sort terms.

Return type

list

pdbsearch.rcsb.send_request(query)[source]

Sends a query dictionary to the RCSB search API. If a valid response is received, this will be returned in JSON format. Otherwise None will be returned.

Parameters

query (dict) – the query, formatted to RCSB specifications.

Return type

dict

pdbsearch.rcsb.sort_term_to_sort_dict(term)[source]

Converts a single string to a RCSB sort modifier. If a ‘-’ is on the front of the string, the search will be made ascending - otherwise it is descending.

The string should be one of the terms given at https://search.rcsb.org/search-attributes.html, or one of a few shorthands (see code).

Parameters

term (str) – the sort term.

Return type

dict