Mol
Class for handling SMILES strings and RDKit mol objects.
MoleculeRecord(smiles, identifier='')
¶
Enhanced class for managing SMILES strings and RDKit mol objects.
Handles all molecule-related operations including validation, conversion, neutralization, and hydrogen management.
Initialize a MoleculeRecord.
PARAMETER | DESCRIPTION |
---|---|
smiles
|
SMILES string representation of the molecule
TYPE:
|
identifier
|
Optional unique identifier for the molecule
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If smiles is not a valid string |
identifier = identifier
¶
Unique identifier for molecule
mol
¶
Get the RDKit mol object, creating it if necessary.
smiles = smiles
¶
Current SMILES after any processing
smiles_original = smiles
¶
Original SMILES used to initialize this MoleculeRecord
__eq__(other)
¶
Check equality based on canonical SMILES.
__hash__()
¶
Hash based on canonical SMILES.
__repr__()
¶
Detailed string representation of the molecule.
__str__()
¶
String representation of the molecule.
add_hydrogens(mol)
¶
Add explicit hydrogens to a molecule.
PARAMETER | DESCRIPTION |
---|---|
mol
|
RDKit mol object
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Mol | None
|
Mol object with explicit hydrogens or None if failed |
copy()
¶
Create a deep copy of this MoleculeRecord.
RETURNS | DESCRIPTION |
---|---|
MoleculeRecord
|
New MoleculeRecord instance |
get_atom_count()
¶
Get the number of atoms in the molecule.
RETURNS | DESCRIPTION |
---|---|
int
|
Number of atoms, or 0 if mol is invalid |
get_canonical_smiles(isomeric=True)
¶
get_heavy_atom_count()
¶
Get the number of heavy (non-hydrogen) atoms in the molecule.
RETURNS | DESCRIPTION |
---|---|
int
|
Number of heavy atoms, or 0 if mol is invalid |
get_neutralized(smiles)
¶
get_substructure_matches(pattern)
¶
has_substructure(pattern)
¶
is_atom_protected(mol, atom_idx)
¶
is_valid()
¶
Check if the current SMILES represents a valid molecule.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if valid, False otherwise |
make_canonical(isomeric=True)
¶
neutralize()
¶
Neutralize the molecule using the neutralizer.
RETURNS | DESCRIPTION |
---|---|
True if neutralization was successful, False otherwise |
prepare_for_protonation()
¶
Prepare molecule for protonation site detection.
RETURNS | DESCRIPTION |
---|---|
Mol
|
Prepared RDKit mol object or None if preparation fails |
process_azides()
¶
Process azide patterns in SMILES string.
PARAMETER | DESCRIPTION |
---|---|
smiles
|
Input SMILES string
|
RETURNS | DESCRIPTION |
---|---|
None
|
SMILES string with processed azides |
protect_atoms(mol, atom_indices)
¶
refresh_mol_from_smiles()
¶
Refresh the mol object from current SMILES string.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if successful, False otherwise |
remove_hydrogens(mol)
¶
Remove explicit hydrogens from a molecule.
PARAMETER | DESCRIPTION |
---|---|
mol
|
RDKit mol object
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Mol | None
|
Mol object without explicit hydrogens or None if failed |
to_mol()
¶
Convert current SMILES to a RDKit Mol object.
RETURNS | DESCRIPTION |
---|---|
Mol | None
|
RDKit Mol object or None if conversion fails |
to_mol_silenced(smiles)
¶
to_mol_with_hs()
¶
Get RDKit mol object with explicit hydrogens.
RETURNS | DESCRIPTION |
---|---|
Mol | None
|
RDKit Mol object with explicit hydrogens or None if conversion fails |
unprotect_atoms(mol)
¶
Set the protected property on all atoms to 0.
PARAMETER | DESCRIPTION |
---|---|
mol
|
RDKit mol object to unprotect
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Mol
|
The same mol object (modified in place) |