cdk icon indicating copy to clipboard operation
cdk copied to clipboard

stereo information unavailable when generating SMILES from IAtomcontainer

Open biotech7 opened this issue 10 months ago • 10 comments

Based on this link https://egonw.github.io/cdkbook/stereo.html#sec:stereo:bond, a simple molecule was constructed. but stereo information unvalaible when converting molecule to smiles. code to reproduce.

IAtomContainer isomer = new AtomContainer();
        isomer.addAtom(new Atom("C"));
        isomer.addAtom(new Atom("Cl"));
        isomer.addAtom(new Atom("Br"));
        isomer.addAtom(new Atom("F"));
        isomer.addAtom(new Atom("I"));
        isomer.addBond(0, 1, IBond.Order.SINGLE);
        isomer.addBond(0, 2, IBond.Order.SINGLE);
        isomer.getBond(1).setStereo(IBond.Stereo.UP);
        isomer.addBond(0, 3, IBond.Order.SINGLE);
        isomer.getBond(2).setStereo(IBond.Stereo.UP);
        isomer.addBond(0, 4, IBond.Order.SINGLE);

        AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(isomer);
        CDKHydrogenAdder adder = CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance());
        adder.addImplicitHydrogens(isomer);

        SmilesGenerator generator = new SmilesGenerator(SmiFlavor.UniversalSmiles);
        System.out.println(generator.create(isomer));

output: C(Br)(Cl)(F)I

Another trial was conducted as following procedure:stereo-included smiles was introduced and converted to IAtomcontainer, finally "reversed" to smiles string. stereo info showed up. code to reproduce:

        String smi = "F[C@](Cl)(Br)I";
        IChemObjectBuilder builder = new SilentChemObjectBuilder();
        SmilesParser parser = new SmilesParser(builder);
        isomer = parser.parseSmiles(smi);
        System.out.println(generator.create(isomer));

output: C@@(Cl)(F)I

why the stereo info omitted in the first example?

env. information: OS: windows 11 CDK: 2.9 IDE: IDEA 2023.2

biotech7 avatar Sep 10 '23 07:09 biotech7