m.creator = creator
yield m
def to_smiles(self, **kwargs):
This function creates and stores the SMILES string for a pre-built molecule.
Parameters
----------
kwargs:
The arguments for the rdkit.Chem.MolToSmiles function.
The documentation is available at: http://rdkit.org/docs/source/rdkit.Chem.rdmolfiles.html//rdkit.Chem.rdmolfiles.MolToSmiles
Notes
-----
- The rdkit or pybel molecule object must be created in advance.
- If only pybel molecule is available, we create an rdkit molecule using its SMILES representation, and then recreate the SMILES string using rdkit arguments.
- The molecule will be modified in place.
- For rdkit molecule the SMILES string is canocical by default, unless when one requests kekuleSmiles.
// molecule must exist
engine = self._check_original_molecule()if engine == "pybel":
smiles = self.pybel_molecule.write("smi").strip().split("\t")[0]
self._load_rdkit(smiles, "smiles", from_load=False)
self.to_smiles()
else:
self._to_smiles_rdkit(**kwargs)
def _to_smiles_rdkit(self, **kwargs):
This internal function creates and stores the SMILES string for rdkit molecule.