schrodinger.utils.ligfilter module

Support module for Ligfilter applications, including parsing functions, filtering criteria, constants, and setting up of the default composite SMARTS patterns.

The basic idea is to provide a set of criteria for filtering structures based on properties, function evaluation, or collections of SMARTS patterns. These criteria can be easily specified in an external file.

Examples of criteria definitons:

Molecular_weight < 300 A predefined criterion type i_qp_#amide >= 1 A property-based criterion Alcohols == 0 A SMARTS definition matching criterion s_sd_Asinex A check for the existence of a property
General terminology used in the documentation of this module:
  • SMARTS expression - a SMARTS string
  • DEFINITION - a named definition, which can be simple (i.e., just a SMARTS expression) or composite (including/excluding multiple definitions, whether simple or composite).
  • KEY - a definition name or predefined function (e.g., Num_atoms)
  • CRITERION - a filtering condition

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.utils.ligfilter.mysplit(thestr)

Special version of thestr.split()

The following string: “criteria<value” will be split into: [“criteria”, “<”, “value”]

Implemented so that spaces would not longer be required in criteria.

class schrodinger.utils.ligfilter.Criterion(name=None, compstr=None)

Bases: object

A base class for a structure matching criterion. Each instance will test a structure for some property and indicate whether it passes or not.

Attributes

type - The classification of the Criterion. Can be PREDEFINED,
PROPERTY, or SMARTS.
__init__(name=None, compstr=None)

Parameters

name - the name of the Criterion. See subclasses for meaning, as
it depends on the implementation.
compstr - a comparison string for evaluating the value of the
named property. Examples are ‘VALUE < 300’ or ‘VALUE >= 1’.

If name or compstr are not specified, parseLine() method should be used

If a PROPERTY Criterion has no operator or value, the Criterion is just the existence of the property in the tested structure.

The reason why comstr is one string instead of two values (operator and number) is in order to support implementation of Ev:50600 - Add the ability to create criteria with multiple (boolean) conditions

setCompStr(compstr)

Set the compstr attributes according to specified line Raises RuntimeError if the string is invalid

parseLine(line)
Parse a line of the form:
<name> (Property criterion only)
or:
<name> <oper> <value>
or:
<name> <oper> <value> AND/OR <oper> <value>

Set the name and compstr attributes from the parsed line; Raises RuntimeError if the string is invalid

__str__()

Return a standard string form of the Criterion suitable for filter files.

match_compstr(value)

Return True if the value matches self.compstr, False if not.

matches(st, addprops=False)

Return True if the structure ‘st’ matches the criterion, False if not. OVERWRITE this method in the subclass

st (Structure) - Structure object addprops (bool) - whether to add properties for each description

getvalue(st)

Return the value of this criterion in the structure ‘st’. OVERWRITE this method in the subclass

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.utils.ligfilter', '__doc__': '\n A base class for a structure matching criterion. Each instance will test\n a structure for some property and indicate whether it passes or not.\n\n Attributes\n\n type - The classification of the Criterion. Can be PREDEFINED,\n PROPERTY, or SMARTS.\n\n ', '__init__': <function Criterion.__init__>, 'setCompStr': <function Criterion.setCompStr>, 'parseLine': <function Criterion.parseLine>, '__str__': <function Criterion.__str__>, 'match_compstr': <function Criterion.match_compstr>, 'matches': <function Criterion.matches>, 'getvalue': <function Criterion.getvalue>, '__dict__': <attribute '__dict__' of 'Criterion' objects>, '__weakref__': <attribute '__weakref__' of 'Criterion' objects>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.utils.ligfilter'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

schrodinger.utils.ligfilter.Num_rings(st)

Return the number of rings in the structure ‘st’.

schrodinger.utils.ligfilter.Num_aromatic_rings(st)

Return the number of aromatic rings in the structure ‘st’.

schrodinger.utils.ligfilter.Num_aliphatic_rings(st)

Return the number of aliphatic rings in the structure ‘st’.

schrodinger.utils.ligfilter.Num_heteroaromatic_rings(st)

Return the number of aromatic rings containing heteroatoms (N, O, S) in the structure ‘st’.

schrodinger.utils.ligfilter.Num_rotatable_bonds(st)

Return the number of rotatable bonds in the structure ‘st’, as determined by structutils.analyze.get_num_rotatable_bonds().

schrodinger.utils.ligfilter.Num_atoms(st)

Return the number of atoms in the structure ‘st’.

schrodinger.utils.ligfilter.Num_heavy_atoms(st)

Return the number of non-hydrogen atoms in the structure

schrodinger.utils.ligfilter.Num_molecules(st)

Return number of molecules in the structure.

schrodinger.utils.ligfilter.Num_residues(st)

Return number of residues in the structure.

schrodinger.utils.ligfilter.Molecular_weight(st)

Return the total molecular weight of the structure ‘st’.

schrodinger.utils.ligfilter.Num_chiral_centers(st)

Return the number of chiral centers in the structure ‘st’, as determined by structutils.analyze.get_chiral_atoms().

schrodinger.utils.ligfilter.Total_charge(st)

Return the total formal charge of the structure ‘st’.

schrodinger.utils.ligfilter.Num_positive_atoms(st)

Return the number of positive atoms in the structure ‘st’.

schrodinger.utils.ligfilter.Num_negative_atoms(st)

Return the number of negative atoms in the structure ‘st’.

schrodinger.utils.ligfilter.Molecular_formula(st)
schrodinger.utils.ligfilter.Percent_helix(st)
schrodinger.utils.ligfilter.Percent_strand(st)
schrodinger.utils.ligfilter.Percent_loop(st)
class schrodinger.utils.ligfilter.PropertyCriterion(name=None, compstr=None)

Bases: schrodinger.utils.ligfilter.Criterion

A structure matching criterion that acts on the presence or value of a specific structure property.

If no comparison string is provided, the criterion will check for the presence of property ‘name’. Otherwise it will compare the value against the comparison string definition.

__init__(name=None, compstr=None)

Parameters

name - the name of the property being evaluated

compstr - the property comparison string to be used if present
currently in format “<operator> <value>”

If name or compstr are not specified, parseLine() method should be used

matches(st, addprops=False)

Return True if structure ‘st’ matches this criterion, False if not.

st (Structure) - Structure object addprops (bool) - ignored for property criterions

getvalue(st)

Return the value of the property for this structure. Returns None if the property does not exist.

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.utils.ligfilter', '__doc__': "\n A structure matching criterion that acts on the presence or value of a\n specific structure property.\n\n If no comparison string is provided, the criterion will check for the\n presence of property 'name'. Otherwise it will compare the value against\n the comparison string definition.\n\n ", '__init__': <function PropertyCriterion.__init__>, 'matches': <function PropertyCriterion.matches>, 'getvalue': <function PropertyCriterion.getvalue>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.utils.ligfilter'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__()

Return a standard string form of the Criterion suitable for filter files.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

match_compstr(value)

Return True if the value matches self.compstr, False if not.

parseLine(line)
Parse a line of the form:
<name> (Property criterion only)
or:
<name> <oper> <value>
or:
<name> <oper> <value> AND/OR <oper> <value>

Set the name and compstr attributes from the parsed line; Raises RuntimeError if the string is invalid

setCompStr(compstr)

Set the compstr attributes according to specified line Raises RuntimeError if the string is invalid

class schrodinger.utils.ligfilter.SmartsCriterion(definition, compstr=None)

Bases: schrodinger.utils.ligfilter.Criterion

A structure matching criterion that looks for a match to a Definition instance, which is comprised of a collection of SMARTS patterns.

For example, for the Definition ‘TwoCarbons’ that matches against the SMARTS patterns [#6][#6], the comparison string

TwoCarbons < 40

will match if there are less than 40 carbon-carbon bonds in the structure.

__init__(definition, compstr=None)

Parameters

definition - a Definition instance, specifying the SMARTS
pattern(s) to be included and excluded
compstr - the comparison string to be used.
Currently equal to “<operator> <value>” Used by the expand() method

If compstr are not specified, parseLine() method should be used

matches(st, addprops=False)

Return True if structure ‘st’ matches this criterion, False if not.

Current matching behavior is to count the number of matches in the definition.includes() list, that do not have any overlapping atoms with matches in the definition.excludes() list.

st (Structure) - Structure object addprops (bool) - whether to add properties for each description

getvalue(st)

Return the number of times that definition.includes() patterns match the structure but do not overlap with any definition.excludes() patterns.

expand(definitions)

Generate a new SmartsCriterion from the current one in which the definition.includes() and definition.excludes() are expanded from the definitions list.

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.utils.ligfilter', '__doc__': "\n A structure matching criterion that looks for a match to a Definition\n instance, which is comprised of a collection of SMARTS patterns.\n\n For example, for the Definition 'TwoCarbons' that matches against the\n SMARTS patterns [#6][#6], the comparison string\n\n TwoCarbons < 40\n\n will match if there are less than 40 carbon-carbon bonds in the\n structure.\n\n ", '__init__': <function SmartsCriterion.__init__>, '_count_occurances': <function SmartsCriterion._count_occurances>, 'matches': <function SmartsCriterion.matches>, 'getvalue': <function SmartsCriterion.getvalue>, 'expand': <function SmartsCriterion.expand>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.utils.ligfilter'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__()

Return a standard string form of the Criterion suitable for filter files.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

match_compstr(value)

Return True if the value matches self.compstr, False if not.

parseLine(line)
Parse a line of the form:
<name> (Property criterion only)
or:
<name> <oper> <value>
or:
<name> <oper> <value> AND/OR <oper> <value>

Set the name and compstr attributes from the parsed line; Raises RuntimeError if the string is invalid

setCompStr(compstr)

Set the compstr attributes according to specified line Raises RuntimeError if the string is invalid

class schrodinger.utils.ligfilter.PredefinedCriterion(name=None, compstr=None)

Bases: schrodinger.utils.ligfilter.Criterion

A structure matching criterion that acts on the value of a predefined function applied to the structure.

Currently available functions are:
Num_rings Num_aromatic_rings Num_aliphatic_rings Num_heteroaromatic_rings Num_rotatable_bonds Num_atoms Molecular_weight Num_chiral_centers Total_charge Num_positive_atoms Num_negative_atoms
For example, one definition parseable from the external file is:
Num_rings == 0
__init__(name=None, compstr=None)

Parameters

name - the name of the function to use. Allowed values are those
in ligfilter.PREDEFINED_KEYS.
compstr - the comparison string to evaluate the result of the
predefined function against
matches(st, addprops=False)

Return True if structure ‘st’ matches this criterion, False if not.

st (Structure) - Structure object addprops (bool) - whether to add properties for each description

getvalue(st)

Return the value of the predefined function applied to ‘st’.

For example, return the number of rings, or number of rotatable bonds.

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.utils.ligfilter', '__doc__': '\n A structure matching criterion that acts on the value of a predefined\n function applied to the structure.\n\n Currently available functions are:\n Num_rings\n Num_aromatic_rings\n Num_aliphatic_rings\n Num_heteroaromatic_rings\n Num_rotatable_bonds\n Num_atoms\n Molecular_weight\n Num_chiral_centers\n Total_charge\n Num_positive_atoms\n Num_negative_atoms\n\n For example, one definition parseable from the external file is:\n Num_rings == 0\n\n ', '__init__': <function PredefinedCriterion.__init__>, 'matches': <function PredefinedCriterion.matches>, 'getvalue': <function PredefinedCriterion.getvalue>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.utils.ligfilter'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__()

Return a standard string form of the Criterion suitable for filter files.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

match_compstr(value)

Return True if the value matches self.compstr, False if not.

parseLine(line)
Parse a line of the form:
<name> (Property criterion only)
or:
<name> <oper> <value>
or:
<name> <oper> <value> AND/OR <oper> <value>

Set the name and compstr attributes from the parsed line; Raises RuntimeError if the string is invalid

setCompStr(compstr)

Set the compstr attributes according to specified line Raises RuntimeError if the string is invalid

class schrodinger.utils.ligfilter.AslCriterion(asl)

Bases: schrodinger.utils.ligfilter.Criterion

This criterion considers a Structure as matching if the stored ASL expresson match returns at least one atom.

__init__(asl)
Parameters
asl - the ASL expression string.
matches(st, addprops=False)

Return True if structure ‘st’ matches this ASL criterion, False if not.

st (Structure) - Structure object addprops (bool) - whether to add properties for each description

getvalue(st)

Return True if the structure ‘st’ matches this ASL. Flase otherwise.

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.utils.ligfilter', '__doc__': '\n This criterion considers a Structure as matching if the stored\n ASL expresson match returns at least one atom.\n ', '__init__': <function AslCriterion.__init__>, 'matches': <function AslCriterion.matches>, 'getvalue': <function AslCriterion.getvalue>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.utils.ligfilter'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__()

Return a standard string form of the Criterion suitable for filter files.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

match_compstr(value)

Return True if the value matches self.compstr, False if not.

parseLine(line)
Parse a line of the form:
<name> (Property criterion only)
or:
<name> <oper> <value>
or:
<name> <oper> <value> AND/OR <oper> <value>

Set the name and compstr attributes from the parsed line; Raises RuntimeError if the string is invalid

setCompStr(compstr)

Set the compstr attributes according to specified line Raises RuntimeError if the string is invalid

class schrodinger.utils.ligfilter.Definition(name, includes=[], excludes=[], group=None)

Bases: object

A class that defines a collection of SMARTS patterns for matching against. The includes() method returns a list of those patterns that should be matched, and the excludes() method returns those that shouldn’t.

__init__(name, includes=[], excludes=[], group=None)

Parameters

includes - a list of SMARTS patterns to count

excludes - a list of SMARTS patterns that can be used to exclude
matches in the includes list
group - name of the group that this definition is part of
(optional). See Ev:50599
addKey(key, positive=True)

Add the SMARTS pattern ‘key’ to the list of desired matches (includes) if ‘positive’ is True, and to the list of unwanted matches (excludes) if ‘positive’ is False.

removeKey(key)

Remove the SMARTS pattern ‘key’ from the wanted or unwanted matches list.

includes()

Return a list of wanted matches.

excludes()

Return a list of unwanted matches.

expand(definitions)

Generate a new Definition from the current one in which the includes and excludes are expanded from the provided ‘definitions’ dictionary.

__str__()

Return a standard string form of the Definition suitable for filter/keys files.

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.utils.ligfilter', '__doc__': "\n A class that defines a collection of SMARTS patterns for matching\n against. The includes() method returns a list of those patterns that\n should be matched, and the excludes() method returns those that\n shouldn't.\n ", '__init__': <function Definition.__init__>, 'addKey': <function Definition.addKey>, 'removeKey': <function Definition.removeKey>, 'includes': <function Definition.includes>, 'excludes': <function Definition.excludes>, '_expandIncludes': <function Definition._expandIncludes>, '_expandExcludes': <function Definition._expandExcludes>, 'expand': <function Definition.expand>, '__str__': <function Definition.__str__>, '__dict__': <attribute '__dict__' of 'Definition' objects>, '__weakref__': <attribute '__weakref__' of 'Definition' objects>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.utils.ligfilter'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

class schrodinger.utils.ligfilter.CriterionParser(definitions_dict=None)

Bases: object

A class for parsing a general property or predefined matching criterion.

__init__(definitions_dict=None)

Initialize self. See help(type(self)) for accurate signature.

error(err)

Print the error and exit.

expression_error(msg)

Print an error about an invalid expression and exit.

parse(line, line_num=None)

Create a Criterion object from a string. The method expects an input line of the form

<name>

…or…

<name> <operator> <value>

The first form is valid only for property criteria.

If the instance has a ‘definitions_dict’, definition criteria will be checked against it for validity.

Returns a Criterion.

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.utils.ligfilter', '__doc__': '\n A class for parsing a general property or predefined matching criterion.\n ', '__init__': <function CriterionParser.__init__>, 'error': <function CriterionParser.error>, 'expression_error': <function CriterionParser.expression_error>, 'parse': <function CriterionParser.parse>, '__dict__': <attribute '__dict__' of 'CriterionParser' objects>, '__weakref__': <attribute '__weakref__' of 'CriterionParser' objects>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.utils.ligfilter'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

class schrodinger.utils.ligfilter.DefinitionParser

Bases: object

A class for parsing a (possibly multi-line) specification of a Definition.

__init__()

Initialize self. See help(type(self)) for accurate signature.

error(err)

Print an error and exit.

parse(lines, line_num=None, group=None)

Return a Definition from a list of lines. No expansion of definitions is done.

General pattern of the specification is

DEFINE <name> <SMARTS pattern>

or

DEFINE <name>
(+ include_definition)* (- exclude_definition)*

Where the asterisk indicates zero or more of each of the include and exclude definitions.

Options:
line_num - current line of the file being parsed (for error handling) group - name of the definition group (or None, if there is no group)
__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.utils.ligfilter', '__doc__': '\n A class for parsing a (possibly multi-line) specification of a\n Definition.\n\n ', '__init__': <function DefinitionParser.__init__>, 'error': <function DefinitionParser.error>, 'parse': <function DefinitionParser.parse>, '__dict__': <attribute '__dict__' of 'DefinitionParser' objects>, '__weakref__': <attribute '__weakref__' of 'DefinitionParser' objects>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.utils.ligfilter'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

schrodinger.utils.ligfilter.read_keys(fh, validate=False, validdefinitions=None)

Generate lists of Definitions and Criteria from an iterator ‘fh’ that returns a line at a time of the Definition and Criteria specification. For example, this iterator can be an open file or a list of strings.

If ‘validate’ is True, definition names in criteria will be checked against known Definitions, including those previously read from ‘fh’ and passed in via ‘validdefinitions’. No expansion of Definitions is done.

Return a tuple of (Definition list, Criterion list).

schrodinger.utils.ligfilter.get_default_criterion_parser()

Returns a CriterionParser with default definitions

schrodinger.utils.ligfilter.generate_criterion(condition, cp=None)

Ev:55805 Returns a Criterion object for a specified condition string. Condition string may be something like: “Num_atoms < 100”

The returned criterion can be then used as follows:

if criterion.matches(st):
<do>

Optionally a CriterionParser (cp) may be specified; otherwise default definitions will be used.

schrodinger.utils.ligfilter.st_matches_criteria(st, criteria_list, match_any=False, addprops=False)

If the specified structure matches the criteria, returns None. If does not match, then a string is returned, explaining the reason.

match_any - if True, st is considers to match if it matches at least
one criteria; otherwise all criteria must be matched.

addprops - if True, properties for each descriptor is added to st.