schrodinger.structutils.smilesfilter module¶
A group of functions and classes to help filtering structure files on unique SMILES strings.
Copyright Schrodinger, LLC. All rights reserved.
-
schrodinger.structutils.smilesfilter.
remove_dupes
(smiles_generator, struct_iterator, put_unique, put_dupes=None, error_handler=None, reporter=None)¶ Process structures from the provided structure iterator ‘struct_iterator’ using the ‘smiles_generator’ to compute unique SMILES strings. Unique structures are passed to the ‘put_unique’ callback and duplicates to ‘put_dupes’ (if provided).
Parameters: - struct_iterator (iterator return Structure objects) – Any iterator returning Structure objects (such as a StructureReader) will work.
- put_dupes (callable) – These functions will be called with (structure, SMILES string) arguments in the appropriate situation.
- error_handler (callable) – A callable that takes (index, structure, exception) for cases where SMILES generation generates a RuntimeError.
- reporter (FilterReporter) – If present, information will be logged.
-
schrodinger.structutils.smilesfilter.
add_smiles
(smiles_generator, struct_iterator, put_output, error_handler=None)¶ Calculate SMILES strings with ‘smiles_generator’ for each structure in ‘struct_iterator’.
Parameters
smiles_generator (SmilesGenerator)
- struct_iterator (iterator return Structure objects)
- Any iterator returning Structure objects (such as a StructureReader) will work.
- put_output (callable)
- This function will be called with (structure, SMILES string) arguments when a SMILES string can be calculated.
- error_handler (callable)
- A callback function that takes (index, structure, exception) and is called in cases where SMILES generation generates a RuntimeError.
-
class
schrodinger.structutils.smilesfilter.
FilterReporter
(logger)¶ Bases:
object
A class to handle reporting of results from the remove_dupes function.
-
__init__
(logger)¶ Parameters
- logger (logging.Logger)
- The logger instance that will be used to output messages.
-
logResult
(index, orig_index, title, smiles, dupe_index)¶ Log messages for a given result.
Parameters
- index (int)
- Index of the current structure.
- orig_index (int)
- Index of the unique structure of which the current one is a duplicate.
- title (str)
- Title of the current structure.
- smiles (str)
- SMILES string of the structure.
- dupe_index (int)
- Index of the duplicate structure in the saved duplicates file.
-
summarize
(total, unique, duplicates, error_count)¶ Generate a summary of the filter results.
Parameters
- total (int)
- Total number of structures filtered.
- unique (int)
- Number of unique structures found.
- duplicates (int)
- Number of duplicates found.
- error_count (int)
- Number of structures generating errors in SMILES conversion.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.structutils.smilesfilter', '__doc__': '\n A class to handle reporting of results from the remove_dupes function.\n ', '__init__': <function FilterReporter.__init__>, 'logResult': <function FilterReporter.logResult>, 'summarize': <function FilterReporter.summarize>, '__dict__': <attribute '__dict__' of 'FilterReporter' objects>, '__weakref__': <attribute '__weakref__' of 'FilterReporter' 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.structutils.smilesfilter'¶
-
__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.structutils.smilesfilter.
SmilesErrorHandler
(logger, struct_writer=None, message=None)¶ Bases:
object
A class that acts as an error handler for cases where SMILES generation fails. It is used as a callable that takes arguments of (index, struct, exception).
-
__init__
(logger, struct_writer=None, message=None)¶ Parameters
- logger (logging.Logger)
- The logger instance that will be used to output messages.
- struct_writer (obj with append method)
- An instance that will log structures that have errors. Any instance with an append method (such as a StructureWriter or list) can be used.
- message (str)
- The message to use as the logging template. It should have format conversion specifiers for (index, structure title, exception) (types of int, str, exception).
-
__call__
(index, struct, exception)¶ This logs the message to the object’s ‘logger’ attribute and appends the structure to the object’s ‘struct_writer’, which can be anything with an append method.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.structutils.smilesfilter', '__doc__': '\n A class that acts as an error handler for cases where SMILES generation\n fails. It is used as a callable that takes arguments of (index, struct,\n exception).\n\n ', '__init__': <function SmilesErrorHandler.__init__>, '__call__': <function SmilesErrorHandler.__call__>, '__dict__': <attribute '__dict__' of 'SmilesErrorHandler' objects>, '__weakref__': <attribute '__weakref__' of 'SmilesErrorHandler' 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.structutils.smilesfilter'¶
-
__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)
-