Closed sowiso closed 3 years ago
@sowiso, thanks for the feedback, we have found a bug in ObStructureGenerator.executeSync causing it always returns the 3D structure generated.
Currently, as a workaround, please use the execute
method rather than executeSync
:
Kekule.OpenBabel.enable(() => {
let smiles = "C1CCCCC1";
let mol = Kekule.IO.loadFormatData(smiles, "smi");
let generator = new Kekule.Calculator.ObStructure2DGenerator();
generator.setSourceMol(mol);
generator.execute(err => { // using execute rather than executeSync
if (!err)
{
let newMol = generator.getGeneratedMol();
composer.setChemObj(newMol);
}
});
});
The execute
method runs in web worker, so it may even provide a better user experience.
By the way, in recent versions, you can also utilize the newly introduced setChemObjData
method:
Kekule.OpenBabel.enable(() => {
composer.getEditor().setChemObjData('{"format": "smi", "data": "C1CCCCC1"}');
});
In default settings, when the editor detects that the input molecule is a 0D one(with out coordinates), it will automatically generate them for the molecule.
Thanks a lot @partridgejiang
I got it to work correctly now with execute()
. However, when I call it a second time, it seems like it's not working anymore, whereas executeSync()
is.
It looks like I get a similar behaviour when I load smiles manually via the menu. These steps reproduce the issue:
Hi @sowiso, the bugs in both execute() and executeSync() should be fixed now, please check the latest dist files, :).
Confirmed, this works perfectly now. Thanks!
I'm trying to load a simple molecule in the composer from a SMILES string, but do not really seem to get the desired result. Here's wat I tried:
This does import, but it does not draw very well. The drawing is so tiny, it's only visible when I select it:
So I read I could try to generate a 2D sctructure and tried this:
This works better, but now it looks like this: And the console shows this
Is there a way to get the smiles = "C1CCCCC1" look like this?
Thanks