Package schrodinger :: Package structutils :: Module filter
[hide private]
[frames] | no frames]

Module filter


Functions and classes for filtering structure files based on properties or
SMARTS patterns. Supports filter files in the formats used by propfilter and
canvasSearch, respectively. The filter classes support both Structure and Mol
objects.

Simple example:

    prop_filter = PropFilter(filename='filters.txt')
    reader = StructureReader('structs.maegz'):
    for st in prop_filter.filter(reader):
        # st matches; do something with it

    smarts_filter = SmartsFilter(filename='filters.cflt')
    for st in smarts_filter.filter(reader):
        # st matches; do something with it

Copyright Schrodinger, LLC. All rights reserved.

Classes [hide private]
  SingleFilter
Base class for single filters.
  Filter
Base class for filtering structures.
  SinglePropFilter
Check if a structure satisfies an expression testing a single property.
  PropFilter
Check if a structure satisfies a given list of conditions.
  SingleSmartsFilter
Check if a structure matches a SMARTS pattern a given number of times.
  SmartsFilter
Check if a structure satisfies a given list of SMARTS filters.
Functions [hide private]
 
_op_action(t)
 
_and_action(t)
 
_or_action(t)
 
_push_first(t)
 
_term_action(t)
pyparsing.ParserElement
_get_filter_parser()
Return a parser for propfilter expressions.
bool
_has_prop(st_or_mol, propname)
Check whether a structure has a property.
float or str or int or bool
_get_prop(st_or_mol, propname)
Return the value of a property from a structure, which may either be a Structure or a Mol.
list
parse_filter_expression(s, verbose=False)
Given a filter expression, return a list of instructions for a stack-based machine.
Variables [hide private]
  logger = log.get_output_logger("schrodinger.analysis.reaction")
  OPERATORS = {'!=': <built-in function ne>, '!~': <function <la...
  _last_op = None
hash(x)
  _instructions = []
  _pp_parser = None
hash(x)
  __package__ = 'schrodinger.structutils'
Function Details [hide private]

_has_prop(st_or_mol, propname)

 

Check whether a structure has a property.

Parameters:
  • propname (str)
  • st_or_mol (Structure or Mol)
Returns: bool

_get_prop(st_or_mol, propname)

 

Return the value of a property from a structure, which may either be a Structure or a Mol. For the latter, values that look like numbers are returned as floats and anything else as strings.

Parameters:
  • propname (str)
  • st_or_mol (Structure or Mol)
Returns: float or str or int or bool

parse_filter_expression(s, verbose=False)

 

Given a filter expression, return a list of instructions for a stack-based machine.

The first instruction is a property name. The others are tuples of an operator optionally followed by a value to be compared against the property value. When the tuple only has an operator, it is applied to two values popped from the result stack. For example, "r_i_glide_gscore < -5 > -6' produces ['r_i_glide_gscore', ('<', '-5'), ('>', '-6'), ('AND',)].

Parameters:
  • s (str)
Returns: list

Variables Details [hide private]

OPERATORS

Value:
{'!=': <built-in function ne>,
 '!~': <function <lambda> at 0x7f1a1c998668>,
 '<': <built-in function lt>,
 '<=': <built-in function le>,
 '==': <built-in function eq>,
 '>': <built-in function gt>,
 '>=': <built-in function ge>,
 'AND': <built-in function and_>,
...