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

Class Filter

object --+
         |
        Filter
Known Subclasses:

Base class for filtering structures. The specific filters to use are determined by the SingleFilter objects passed to .append(), or by the file read with readFile().

Instance Methods [hide private]
 
__init__(self, filters=None, filename=None, **kwds)
Create a filter object, optionally with a source for the filter conditions.
 
readFileName(self, filename, **kwds)
Add filter conditions given a filename.
 
readFile(self, fh)
Add filter conditions given a file-like object.
 
append(self, filter)
Add a filter the PropFilter object.
bool
checkStructure(self, st_or_mol, max_violations=0)
Return True if st_or_mol passes the filters; False otherwise.
 
filter(self, structures, **kwds)
A generator that returns only the structures from 'structures' that pass the filter conditions.
cls._mol_class
_adaptStructure(self, st_or_mol)
Convert st_or_mol to the class specified by cls._mol_class by calling the cls._mol_adapter function.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _mol_adapter = None
hash(x)
  _mol_class = None
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filters=None, filename=None, **kwds)
(Constructor)

 

Create a filter object, optionally with a source for the filter conditions.

Parameters:
  • kwds - additional keywords to pass to readFile or readFileName
  • filters (iterable of str)
  • filename (str)
Overrides: object.__init__

readFileName(self, filename, **kwds)

 

Add filter conditions given a filename.

Parameters:
  • kwds - additional keywords to pass to readFile
  • filename (str)

readFile(self, fh)

 

Add filter conditions given a file-like object. Not implemented in the base class.

Parameters:
  • fh (iterable of str)

append(self, filter)

 

Add a filter the PropFilter object.

Parameters:
  • expr (SingleFilter)

checkStructure(self, st_or_mol, max_violations=0)

 

Return True if st_or_mol passes the filters; False otherwise.

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

filter(self, structures, **kwds)

 

A generator that returns only the structures from 'structures' that pass the filter conditions.

Parameters:
  • structures (iterable of Structure or Mol)

_adaptStructure(self, st_or_mol)

 

Convert st_or_mol to the class specified by cls._mol_class by calling the cls._mol_adapter function. Does nothing if the object is already and instance of _mol_class or there is no _mol_adapter.

This function is called by checkStructure before doing the actual checking of the filters.

Parameters:
  • st_or_mol (Mol or Structure)
Returns: cls._mol_class