schrodinger.ui.qt.filter_dialog_dir.filter_core module

A simple, JSON-serializable property-based filter used by the filter_dialog module and compatible backends.

class schrodinger.ui.qt.filter_dialog_dir.filter_core.Criterion(prop, limiter, checked=True)

Bases: object

Object representing a single criteria of a filter. It consists of a property name and a “limiter”, which is a filter string for str types, a range of values for int/real types and True or False value for boolean types.

__init__(prop, limiter, checked=True)

Initialize criterion.

Parameters:
  • prop (str) – name of property used in this criterion
  • limiter (str or bool or Tuple) – criterion limiting values: True or False if property is boolen, str if property is string and tuple that contains min and max values if property is numerical.
  • checked (bool) – indicates whether this criterion is ‘checked’. True by default
valueMatches(value)

Return True if the given value matches the criteria; False otherwise.

Parameters:value (str or None) – Value to test
class schrodinger.ui.qt.filter_dialog_dir.filter_core.Filter(name, criteria=None)

Bases: object

A filter objects is made up of a name and a list of criteria.

__init__(name, criteria=None)
Parameters:
  • name (str) – Filter name
  • criteria (list of Criterion) – List of criteria to filter by
doPropsMatch(lig_props)

Returns True if the given dict of property names/values matches all criteria; returns False if at least one criteria doesn’t match.

serialize()

Encode the criteria from this filter into a JSON string.

classmethod fromJSON(json_str)

Create a Filter instance from the given JSON string.

Parameters:json_str (str or None) – JSON string specifying the filtering criteria. If None an empty filter is returned.
classmethod fromFile(filename)

Create a Filter instance from a file (may be None).

Parameters:filename (str or NoneType) – name of JSON file specifying the filtering criteria. If None, an empty filter is returned.
Return type:Filter
toFile(filename)

Write filter object to JSON file.

Parameters:filename (str) – name of JSON file, where filter object will be stored.
isChecked()

Checks whether any criterion is toggled on.

Returns:True if any criterion is toggled ‘on’ and False otherwise.
Return type:bool