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.

class schrodinger.structutils.smilesfilter.FilterReporter(logger)

A class to handle reporting of results from the remove_dupes function.

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 schrodinger.structutils.smilesfilter.SmilesErrorHandler(logger, struct_writer=None, message=None)

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).

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.
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.