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));
So there is a couple of issues here
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
oh cool, I did not know the FixBondOrders tool, that helps a lot, thanks
Resolved - SMILES -> SDF conversion improved in > 1.5