OverlapResolver { public double getBondOverlapScore(IAtomContainer ac, Vector overlappingBonds) { overlappingBonds.removeAllElements(); double overlapScore = 0; IBond bond1 = null; IBond bond2 = null; double bondLength = GeometryUtil.getBondLengthAverage(ac);; double overlapCutoff = bondLength / 2; for (int f = 0; f < ac.getBondCount(); f++) { bond1 = ac.getBond(f); for (int g = f; g < ac.getBondCount(); g++) { bond2 = ac.getBond(g); if (!bond1.isConnectedTo(bond2)) { if (areIntersected(bond1, bond2)) { overlapScore += overlapCutoff; overlappingBonds.addElement(new OverlapPair(bond1, bond2)); } } } } return overlapScore; } OverlapResolver(); double resolveOverlap(IAtomContainer ac, IRingSet sssr); double displace(IAtomContainer ac, Vector overlappingAtoms, Vector overlappingBonds); double getOverlapScore(IAtomContainer ac, Vector overlappingAtoms, Vector overlappingBonds); double getAtomOverlapScore(IAtomContainer ac, Vector overlappingAtoms); double getBondOverlapScore(IAtomContainer ac, Vector overlappingBonds); boolean areIntersected(IBond bond1, IBond bond2);  }
@Test public void testResolveOverlap3() throws Exception { logger.debug("Test case with bond overlap"); String filename = "data/cml/overlaptest3.cml"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); CMLReader reader = new CMLReader(ins); IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); IAtomContainer atomContainer = (IAtomContainer) ChemFileManipulator.getAllAtomContainers(chemFile).get(0); double score = new OverlapResolver().getBondOverlapScore(atomContainer, new Vector()); Assert.assertTrue(score > 0); logger.debug("End of test case with bond overlap"); }