Basic Functionality Reference
- lwreg.utils.initdb(config=None)
Initializes the registration database.
You will be prompted to confirm this action since this call will destroy any existing information in the registration database.
- Parameters:
config – Configuration dictionary, defaults to None.
- Returns:
Returns the result of the _initdb function if confirmed, otherwise False.
- lwreg.utils.register(config=None, mol=None, molfile=None, molblock=None, smiles=None, escape=None, fail_on_duplicate=True, confId=-1, no_verbose=True)
Registers a new molecule, assuming it doesn’t already exist, and returns the new registry number (molregno).
Only one of the molecule format objects should be provided.
- Parameters:
config – Configuration dictionary or filename.
mol – RDKit molecule object.
molfile – MOL or SDF filename.
molblock – MOL or SDF block.
smiles – SMILES string.
escape – The escape layer.
fail_on_duplicate – If True, an exception is raised when trying to register a duplicate.
confId – The conformer ID to use when in registerConformers mode.
no_verbose – If False, the registry number will be printed.
- Returns:
The new registry number (molregno) or a tuple of (molregno, conf_id) if registerConformers mode is enabled.
- Raises:
RegistrationFailureReasons.PARSE_FAILURE – If molecule parsing fails.
RegistrationFailureReasons.FILTERED – If molecule is filtered out.
- lwreg.utils.query(config=None, layers='ALL', ids=None, mol=None, molfile=None, molblock=None, smiles=None, escape=None, no_verbose=True)
Queries to see if a molecule has already been registered, and returns the corresponding registry numbers. Only one of the molecule format objects should be provided.
- Parameters:
config – Configuration dict or filename.
layers – Hash layers to be used to determine identity.
ids – List or tuple of molregnos. Only makes sense if registerConformers is set, in which case this will return all conf_ids for the molregnos in the ids list as a list of (molregno, conf_id) tuples.
mol – RDKit molecule object.
molfile – MOL or SDF filename.
molblock – MOL or SDF block.
smiles – SMILES string.
escape – The escape layer.
no_verbose – If False, the registry numbers will be printed.
- Raises:
ValueError – If ids are provided but registerConformers is not enabled.
- Returns:
List of registry numbers or list of (molregno, conf_id) tuples.
- lwreg.utils.retrieve(config=None, ids=None, id=None, as_submitted=False, as_hashes=False, no_verbose=True)
Returns the molecule data for one or more registry ids (molregnos).
The return value is a dictionary of (data, format) 2-tuples with molregnos as keys.
Only one of id or ids should be provided.
If registerConformers is set, the conformers can be retrieved by providing the tuples of (molregno, conf_id) and the return value will be a dictionary of (data, ‘mol’) 2-tuples with (molregno, conf_id) tuples as keys.
- Parameters:
config (dict) – Configuration dictionary.
ids (list) – An iterable of registry ids (molregnos).
id (int) – A registry id (molregno).
as_submitted (bool) – If True, then the structure will be returned as registered.
as_hashes (bool) – If True, then the hashes will be returned (as a dict) instead of the structures.
no_verbose (bool) – If this is False, then the registry number will be printed.
- Returns:
A dictionary of (data, format) 2-tuples with molregnos as keys.