From: Rajarshi G. <rx...@ps...> - 2004-11-01 00:44:03
|
Hi, I've been looking at Renderer2D.java and a problem with its rendering of some structures that have aromatic rings. For example I declare a benzene molecule (exlcuding H's) as c[0] = new Molecule(); c[0].addAtom(new Atom("C")); c[0].addAtom(new Atom("C")); c[0].addAtom(new Atom("C")); c[0].addAtom(new Atom("C")); c[0].addAtom(new Atom("C")); c[0].addAtom(new Atom("C")); c[0].addBond(0,1,1.5); c[0].addBond(1,2,1.5); c[0].addBond(2,3,1.5); c[0].addBond(3,4,1.5); c[0].addBond(4,5,1.5); c[0].addBond(5,0,1.5); and then do StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.setMolecule((Molecule)c[0]); sdg.generateCoordinates(); and subsequently render the molecule retruned from sdg.getMolecule() The rendered version shows only single bonds. Strangely if I draw a benzene in Jchempaint and save it as CML (in which only the bonds are declared to be aromatic) the renderer shows the proper aromatic ring. I see a similar effect (single bonds in place of aromatic bonds) when I try to display HIN files. But the same HIN file when converted to MDL mol via Babel displays fine. Looking at Renderer2D.java line 877 says: if (!bonds[i].getFlag(CDKConstants.ISAROMATIC)) return false; Clearly a ring is drawn aromatic if aromaticity detection has occured. The HIN reader does not do this and my hand declared benzene does not do this. I assume that the CML and MDL mol readers are doing aromaticity detection. However it seems that if the structure file declares bonds (of an aromatic ring) to be aromatic the renderer should take note of this. So rewriting the above line as if (!bonds[i].getFlag(CDKConstants.ISAROMATIC) && bonds[i].getOrder() != CDKConstants.BONDORDER_AROMATIC) return false; makes it take into account bond orders defined in the structure file even if aromaticity detection has not been carried out. Using this form, the Renderer2D class displays the above benzene fragment correctly. Is this a valid point or will the above change mess something up somewhere else? ------------------------------------------------------------------- Rajarshi Guha <rx...@ps...> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE ------------------------------------------------------------------- Q: What do you get when you cross a mosquito with a mountain climber? A: Nothing. You can't cross a vector with a scaler. |