Additional Functionality Reference
- lwreg.utils.configure_from_database(dbname=None, connection=None, dbtype=None, host=None, user=None, password=None, lwregSchema=None, cacheConnection=True)
Returns a config dict with values from the registration metadata table in the database.
Note that in order for this to work the arguments must provide whatever information is needed to connect to the database. This can be ‘connection’ with a direct connection object or ‘dbname’ and ‘dbtype’ (potentially with ‘host’, ‘user’, and ‘password’ if those are required). If you used a nondefault schema when initializing the database, you’ll also need to provide ‘lwregSchema’ here. If ‘dbtype’ is not provided, the following heuristics are used:
if ‘dbname’ corresponds to an existing file, then sqlite3 is used
if ‘host’ is provided, then postgresql is used
otherwise the default dbtype, currently sqlite3, is used
- Parameters:
dbname – the name of the database (one of dbname or connection must be provided)
connection – a connection object (one of dbname or connection must be provided)
dbtype – the type of database (sqlite3 or postgresql)
host – the host to connect to (for postgresql)
user – the user to connect as (for postgresql)
password – the password to use (for postgresql)
lwregSchema – the schema name to use for the lwreg tables (for postgresql)
cacheConnection (bool) – Cache connection after retrieveing the config
- Returns:
A config dictionary with values from the registration metadata table in the database.
- Raises:
ValueError – If neither dbname nor connection is provided.
- lwreg.utils.set_default_config(config)
Sets the default configuration to be used by the other functions in this module to the configuration object which is passed in
- Parameters:
config – configuration dict
- Returns:
None
- lwreg.utils.connect(config)
Creates a connection to the database and returns it
- Parameters:
config – configuration dict
- Returns:
a database connection object (by default this is cached and reused in subsequent calls)
- lwreg.utils.get_all_identifiers(config=None)
Returns a tuple with all of the identifiers in the database. If in molecule mode, it returns a tuple with all of the molregnos in the database. If in conformer mode, it returns a tuple of all (molregno, conf_id) tuples in the database.
- Parameters:
config – Configuration dictionary.
- Returns:
A tuple with all of the identifiers in the database.
- lwreg.utils.get_all_registry_numbers(config=None)
Returns a tuple with all of the registry numbers (molregnos) in the database.
- Parameters:
config – Configuration dictionary.
- Returns:
A tuple with all of the registry numbers (molregnos) in the database.
- lwreg.utils.registration_counts(config=None)
Returns the number of entries in the registration database
the result is the number of molecules if registerConformers is not set, and a tuple of (number of molecules, number of conformers) if it is
- Parameters:
config – Configuration dictionary.
- Returns:
either the number of molecule in the database or a 2-tuple withe (number of molecules, number of conformers).
- lwreg.utils.bulk_register(config=None, mols=None, sdfile=None, smilesfile=None, escape_property=None, fail_on_duplicate=True, no_verbose=True, show_progress=False)
Registers multiple new molecules, assuming they don’t already exist, and returns the new registry numbers (molregno).
RegistrationFailureReasons.DUPLICATEiffail_on_duplicateis True and a molecule is a duplicateRegistrationFailureReasons.PARSE_FAILUREif there was a problem processing the molecule.Only one of the molecule format objects should be provided.
- Parameters:
config – Configuration dict or filename.
mols – An iterable of RDKit molecule objects.
sdfile – SDF filename.
smilesfile – SMILES filename.
escape_property – The molecule property to use as the escape layer.
fail_on_duplicate – If True, then
RegistrationFailureReasons.DUPLICATEwill be returned for each already-registered molecule, otherwise the already existing structure ID will be returned.no_verbose – If False, then the registry numbers will be printed.
show_progress – If True, then a progress bar will be shown for the molecules.
- Returns:
A tuple containing the registry numbers or failure reasons for each molecule.
- lwreg.utils.register_multiple_conformers(config=None, mol=None, escape=None, fail_on_duplicate=True, no_verbose=True)
Registers all of the conformers of a multi-conformer molecule Using this function only makes sense when registerConformers is enabled.
- Parameters:
config – Configuration dictionary or filename.
mol – RDKit molecule object (must have at least one conformer).
escape – The escape layer.
fail_on_duplicate – If True,
RegistrationFailureReasons.DUPLICATEwill be returned for each already-registered conformer, otherwise the already existing structure ID will be returned.no_verbose – If False, the registry number will be printed.
- Returns:
A tuple of (molregno, conf_id) for each conformer registered.