Ha! hang on... the output is correct... index != number. Sorry jumped to
the more technical problems that can happen. getAtomNumber reports the atom
index 0 ≤ i < n (the atom numbers are 1 < i ≤ n).

*39 connected to 38, 40, 41*

in the depiction is

*40 connected to 39, 41, 42*

which is correct.

I actually added a patch to help with this confusion (see
https://github.com/cdk/cdk/pull/306). In future it will be
*mol.indexOf(atom)* which is much clearer.

Anyways following on from my previous code you can print the "index" as
follows:

SmilesParser    smipar = new
SmilesParser(SilentChemObjectBuilder.getInstance());
SmilesGenerator smigen = new SmilesGenerator(SmiFlavor.Canonical |
SmiFlavor.CxAtomValue);
for (String smi : new String[]{"CCO", "C(C)O", "OCC"}) {
    IAtomContainer mol = smipar.parseSmiles(smi);
    for (int i = 0; i < mol.getAtomCount(); i++)
        mol.getAtom(i).setProperty(CDKConstants.COMMENT, i);
    System.out.println(smigen.create(mol));
}

OCC |$_AV:2;1;0$| -
https://cdkdepict-openchem.rhcloud.com/depict/bow/svg?smi=OCC%20%7C%24_AV%3A2%3B1%3B0%24%7C&w=80&h=50&abbr=on&suppressh=true&showtitle=false&zoom=1.3&annotate=atomvalue
OCC |$_AV:2;0;1$| -
https://cdkdepict-openchem.rhcloud.com/depict/bow/svg?smi=OCC%20%7C%24_AV%3A2%3B0%3B1%24%7C&w=80&h=50&abbr=on&suppressh=true&showtitle=false&zoom=1.3&annotate=atomvalue
OCC |$_AV:0;1;2$| -
https://cdkdepict-openchem.rhcloud.com/depict/bow/svg?smi=OCC%20%7C%24_AV%3A0%3B1%3B2%24%7C&w=80&h=50&abbr=on&suppressh=true&showtitle=false&zoom=1.3&annotate=atomvalue





John

On 26 April 2017 at 14:12, John Mayfield <[email protected]>
wrote:

> I forgot to say that I use idk 1.5.3 and the substance which is used in
>> the code is parsed from the same smiles as the one which is printed in the
>> svg file.
>
>
> Why? 1.5.3 is really old, use 2.0-SNAPSHOT if you can.
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to