#1307 aromaticity lost when writing to sdf

cdk-1.4.x
closed
nobody
None
1
2014-07-22
2013-06-24
No

Hi,

aromaticity is lost when writing non-kekulized molecules to sdf.

This was already discussed here: http://www.mail-archive.com/cdk-user@lists.sourceforge.net/msg02180.html
The proposed workaround/fix by egon does not work (not even the MDLV2000Writer).

The code example below produces the following output:

parse from smiles
c1ccccc1 aromtic ? true
C1=CC=CC=C1 aromtic ? true

write and read from sdf
c1ccccc1 aromtic ? false
C1=CC=CC=C1 aromtic ? false

detect aromaticity from sdf
c1ccccc1 aromtic ? false
C1=CC=CC=C1 aromtic ? true

Kind regards,
Martin

String smiles[] = { "c1ccccc1", "C1=CC=CC=C1" };

SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mols[] = new IAtomContainer[] { sp.parseSmiles(smiles[0]), sp.parseSmiles(smiles[1]) };

System.out.println("parse from smiles");
for (int i = 0; i < mols.length; i++)
    System.out.println(smiles[i] + " aromtic ? " + mols[i].getAtom(0).getFlag(CDKConstants.ISAROMATIC));

File tmp = File.createTempFile("file", "sdf");
SDFWriter writer = new SDFWriter(new FileOutputStream(tmp));
for (int i = 0; i < mols.length; i++)
    writer.write(mols[i]);
writer.close();

ISimpleChemObjectReader reader = new ReaderFactory().createReader(new InputStreamReader(
        new FileInputStream(tmp)));
IChemFile content = (IChemFile) reader.read((IChemObject) new ChemFile());
List<IAtomContainer> sdfMols = ChemFileManipulator.getAllAtomContainers(content);

System.out.println("\nwrite and read from sdf");
for (int i = 0; i < sdfMols.size(); i++)
    System.out.println(smiles[i] + " aromtic ? " + sdfMols.get(i).getAtom(0).getFlag(CDKConstants.ISAROMATIC));

for (int i = 0; i < sdfMols.size(); i++)
{
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(sdfMols.get(i));
    CDKHueckelAromaticityDetector.detectAromaticity(sdfMols.get(i));
}

System.out.println("\ndetect aromaticity from sdf");
for (int i = 0; i < sdfMols.size(); i++)
    System.out.println(smiles[i] + " aromtic ? " + sdfMols.get(i).getAtom(0).getFlag(CDKConstants.ISAROMATIC));

Discussion

  • John May

    John May - 2013-06-27

    So there is a couple of issues here
    - as you say, SDFWriter doesn't pass settings to MDLV2000Writer
    - even if the molecules were written as aromatic the the MDLV2000Reader would not be able to read it. They would be read as CTQueryBonds... which then need to be converted to 'normal' bonds and kekulise etc. The master version does have a 'single_or_double' flag but IMO this is not a good approach.

    One issue is there is no 'aromatic' bond type but only a flag. I believe the intention is to persist the kekule form after perception but actually it makes things more complicated as when read aromatic structures directly there's no obvious value for the bond order.... There isn't a right answer though - personally the kekulization tool (FixBondOrders) is probably best but I'm not sure how well that works.

    I should be able to fix the SDFWriter though so it passes on the options.

    The comments from this question demonstrate the issues quite well - Aromaticity Perception Differences

     
  • Martin Gütlein

    Martin Gütlein - 2013-06-28

    oh cool, I did not know the FixBondOrders tool, that helps a lot, thanks

     
  • John May

    John May - 2013-12-18
    • status: open --> closed
     
  • John May

    John May - 2013-12-18

    Resolved - SMILES -> SDF conversion improved in > 1.5

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks