Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix bond orders if one aromatic bond is detected.
Replace when we can detect SINGLE_OR_DOUBLE order.
See bug #3241
  • Loading branch information
olas committed Jul 10, 2012
1 parent 129a585 commit 987b3b2
Showing 1 changed file with 28 additions and 0 deletions.
Expand Up @@ -2954,6 +2954,34 @@ public String getMDLMolfileString(IMolecule molecule_in) throws BioclipseExcepti

ICDKMolecule molecule = asCDKMolecule(molecule_in);

/*
* Fix bond orders if one aromatic bond is detected.
* FIXME: Replace this when we can detect SINGLE_OR_DOUBLE order.
*/
boolean doFixBondOrders = false;
for (IBond bond : molecule.getAtomContainer().bonds()){
if (bond.getFlag(CDKConstants.ISAROMATIC)){
System.out.println("Bond is aromatic");
doFixBondOrders = true;
}
}
if (doFixBondOrders){
logger.debug("At least one aromatic bond found, " +
"fixing bond orders.");
FixBondOrdersTool fbt = new FixBondOrdersTool();
try {
IAtomContainer fixedAC = fbt.kekuliseAromaticRings(
(org.openscience.cdk.interfaces.IMolecule)
molecule.getAtomContainer());
molecule=new CDKMolecule(fixedAC);
} catch (CDKException e) {
logger.error(
"Error fixing bond orders in MDL serialization. " +
"Reason: " + e.getMessage(),e);
return null;
}
}

StringWriter stringWriter = new StringWriter();
MDLV2000Writer writer = new MDLV2000Writer(stringWriter);
try {
Expand Down

0 comments on commit 987b3b2

Please sign in to comment.