SMILES to 3D conversion¶
Reading SMILES¶
It is possible to read a SMILES string and create a ccdc.molecule.Molecule class from that.
>>> from ccdc.molecule import Molecule
>>> citric = Molecule.from_string("OC(=O)CC(O)(C(=O)O)CC(=O)O")
>>> print(type(citric))
<class 'ccdc.molecule.Molecule'>
3D Generation¶
A SMILES string can be used to generate 3D coordinates by using ccdc.conformer.ConformerGenerator.generate()
function.
>>> from ccdc import io
>>> from ccdc import conformer
>>> conformer_generator = conformer.ConformerGenerator()
>>> conformer_generator.settings.max_conformers = 1
>>> m = Molecule.from_string("C1CCCCC1")
>>> conformers = conformer_generator.generate(m)
>>> with io.EntryWriter("compound.mol2") as writer:
... writer.write(conformers[0].molecule)
2D Generation¶
We can generate a 2D diagram from SMILES string as well.
>>> from ccdc.diagram import DiagramGenerator
>>> diagram_generator = DiagramGenerator()
>>> img = diagram_generator.image(citric)
>>> img.save("citric.png")