luna.mol.validator module¶
- class MolValidator(charge_model=<luna.mol.charge_model.OpenEyeModel object>, fix_nitro=True, fix_amidine_and_guanidine=True, fix_valence=True, fix_charges=True)[source]¶
Bases:
object
Validate and fix molecules with the errors most commonly found when parsing PDB files with Open Babel.
- Parameters
charge_model (
ChargeModel
) – A charge model object. By default, the implementation of OpenEye charge model is used.fix_nitro (bool) – If True, fix nitro groups whose nitrogens are perceived as having a valence of 5 and that are double-bonded to the oxygens. SMILES representation of the error: ‘[$([NX3v5]([!#8])(=O)=O)]’.
fix_amidine_and_guanidine (bool) – If True, fix amidine and guanidine-like groups. When the molecule is ionized, it may happen that the charge is incorrectly assigned to the central carbon, which ends up with a +1 charge and the nitrogen double-bonded to it ends up with a +0 charge.
fix_valence (bool) – If True, fix the valence of atoms. Currently, we only detect and fix errors of quaternary ammonium nitrogens. These charged atoms are sometimes perceived as having a valence equal to 5 and no charge, i.e., Open Babel considers those nitrogens as hypervalent.
fix_charges (bool) – If True, fix charges on basis of the charge model
charge_model
.
- validate_mol(mol_obj)[source]¶
Validate molecule
mol_obj
.It will first try to fix the provided molecule according to the initialization flags. If any errors are detected and if it fails to fix them, then this function may return False, i.e., the molecule is invalid.
- Parameters
mol_obj (
MolWrapper
,rdkit.Chem.rdchem.Mol
, oropenbabel.pybel.Molecule
) – The molecule.- Returns
is_valid – If the molecule is valid or not.
- Return type
- class RDKitValidator(sanitize_opts=rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_ALL)[source]¶
Bases:
object
Check if RDKit molecular objects are valid or not.
- Parameters
sanitize_opts (
rdkit.Chem.rdchem.SanitizeFlags
) – Sanitization operations to be carried out.
- is_valid(rdk_mol)[source]¶
Try to sanitize the molecule
rdk_mol
. If it succeeds, returns True. Otherwise, returns False.- Parameters
rdk_mol (
rdkit.Chem.rdchem.Mol
)- Returns
is_valid – If the molecule is valid or not.
- Return type