schrodinger.rdkit.sorted_molwriter module¶
This module contains the SortedMolWriter class, which writes a sorted, capped list of molecules to a SMILES-CSV file. If capping at <n> molecules, SortedMolWriter holds a maximum of <n> rows of data in memory, where a row consists of the SMILES string, molecule name and a dictionary of properties.
Copyright Schrodinger LLC, All Rights Reserved.
- class schrodinger.rdkit.sorted_molwriter.SortedMolWriter(csv_file, sort_prop, max_mol, sort_reverse=False, user_props=None)¶
Bases:
object
- __init__(csv_file, sort_prop, max_mol, sort_reverse=False, user_props=None)¶
- Parameters
csv_file (str) – Output SMILES-CSV file name. Will be compressed if csv_file ends with ‘gz’.
sort_prop (str) – The name of the property on which molecules should be sorted. Must be present for all molecules.
max_mol (int) – Cap molecules at this number. Take care if using a large value, as this determines the number of rows held in memory. Capping can be disabled by supplying a negative value, but this should be done only if one knows the total number of rows will fit comfortably in memory.
sort_reverse (bool) – Whether to sort by decreasing value of sort_prop
user_props (Iterable of str or NoneType) – Names of properties to output. Empty fields are written for missing properties. By default, the union of all properties encountered are output.
- add(mol)¶
Adds a molecule to the capped list.
- Parameters
mol (rdkit.Chem.rdchem.Mol) – The molecule to add