ChiClusterDescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor { @Override public DescriptorValue calculate(IAtomContainer container) { if (sp == null) sp = new SmilesParser(container.getBuilder()); IAtomContainer localAtomContainer = AtomContainerManipulator.removeHydrogens(container); CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(container.getBuilder()); Iterator<IAtom> atoms = localAtomContainer.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = atoms.next(); IAtomType type; try { type = matcher.findMatchingAtomType(localAtomContainer, atom); AtomTypeManipulator.configure(atom, type); } catch (Exception e) { return getDummyDescriptorValue(new CDKException("Error in atom typing: " + e.getMessage())); } } CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(container.getBuilder()); try { hAdder.addImplicitHydrogens(localAtomContainer); } catch (CDKException e) { return getDummyDescriptorValue(new CDKException("Error in hydrogen addition: " + e.getMessage())); } List subgraph3 = order3(localAtomContainer); List subgraph4 = order4(localAtomContainer); List subgraph5 = order5(localAtomContainer); List subgraph6 = order6(localAtomContainer); double order3s = ChiIndexUtils.evalSimpleIndex(localAtomContainer, subgraph3); double order4s = ChiIndexUtils.evalSimpleIndex(localAtomContainer, subgraph4); double order5s = ChiIndexUtils.evalSimpleIndex(localAtomContainer, subgraph5); double order6s = ChiIndexUtils.evalSimpleIndex(localAtomContainer, subgraph6); double order3v, order4v, order5v, order6v; try { order3v = ChiIndexUtils.evalValenceIndex(localAtomContainer, subgraph3); order4v = ChiIndexUtils.evalValenceIndex(localAtomContainer, subgraph4); order5v = ChiIndexUtils.evalValenceIndex(localAtomContainer, subgraph5); order6v = ChiIndexUtils.evalValenceIndex(localAtomContainer, subgraph6); } catch (CDKException e) { return getDummyDescriptorValue(new CDKException("Error in substructure search: " + e.getMessage())); } DoubleArrayResult retval = new DoubleArrayResult(); retval.add(order3s); retval.add(order4s); retval.add(order5s); retval.add(order6s); retval.add(order3v); retval.add(order4v); retval.add(order5v); retval.add(order6v); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval, getDescriptorNames()); } ChiClusterDescriptor(); @Override DescriptorSpecification getSpecification(); @Override String[] getParameterNames(); @Override Object getParameterType(String name); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtomContainer container); @Override IDescriptorResult getDescriptorResultType();  }
@Test public void testDan64() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom a1 = mol.getBuilder().newInstance(IAtom.class, "C"); a1.setPoint2d(new Point2d(0.7500000000000004, 2.799038105676658)); mol.addAtom(a1); IAtom a2 = mol.getBuilder().newInstance(IAtom.class, "C"); a2.setPoint2d(new Point2d(0.0, 1.5)); mol.addAtom(a2); IAtom a3 = mol.getBuilder().newInstance(IAtom.class, "C"); a3.setPoint2d(new Point2d(0.0, 0.0)); mol.addAtom(a3); IAtom a4 = mol.getBuilder().newInstance(IAtom.class, "O"); a4.setPoint2d(new Point2d(-1.2990381056766582, 0.7500000000000001)); mol.addAtom(a4); IBond b1 = mol.getBuilder().newInstance(IBond.class, a2, a1, IBond.Order.SINGLE); mol.addBond(b1); IBond b2 = mol.getBuilder().newInstance(IBond.class, a3, a2, IBond.Order.SINGLE); mol.addBond(b2); IBond b3 = mol.getBuilder().newInstance(IBond.class, a4, a3, IBond.Order.SINGLE); mol.addBond(b3); IBond b4 = mol.getBuilder().newInstance(IBond.class, a4, a2, IBond.Order.SINGLE); mol.addBond(b4); DoubleArrayResult ret = (DoubleArrayResult) descriptor.calculate(mol).getValue(); Assert.assertEquals(0.2887, ret.get(0), 0.0001); Assert.assertEquals(0.0000, ret.get(1), 0.0001); Assert.assertEquals(0.0000, ret.get(2), 0.0001); Assert.assertEquals(0.0000, ret.get(3), 0.0001); Assert.assertEquals(0.1667, ret.get(4), 0.0001); Assert.assertEquals(0.0000, ret.get(5), 0.0001); Assert.assertEquals(0.0000, ret.get(6), 0.0001); Assert.assertEquals(0.0000, ret.get(7), 0.0001); }
@Test public void testDan154() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom a1 = mol.getBuilder().newInstance(IAtom.class, "C"); a1.setPoint2d(new Point2d(0.0, 1.5)); mol.addAtom(a1); IAtom a2 = mol.getBuilder().newInstance(IAtom.class, "C"); a2.setPoint2d(new Point2d(0.0, 0.0)); mol.addAtom(a2); IAtom a3 = mol.getBuilder().newInstance(IAtom.class, "C"); a3.setPoint2d(new Point2d(-1.2990381056766584, -0.7500000000000001)); mol.addAtom(a3); IAtom a4 = mol.getBuilder().newInstance(IAtom.class, "C"); a4.setPoint2d(new Point2d(-2.598076211353316, -2.220446049250313E-16)); mol.addAtom(a4); IAtom a5 = mol.getBuilder().newInstance(IAtom.class, "C"); a5.setPoint2d(new Point2d(-2.5980762113533165, 1.5)); mol.addAtom(a5); IAtom a6 = mol.getBuilder().newInstance(IAtom.class, "C"); a6.setPoint2d(new Point2d(-1.2990381056766582, 2.2500000000000004)); mol.addAtom(a6); IAtom a7 = mol.getBuilder().newInstance(IAtom.class, "Cl"); a7.setPoint2d(new Point2d(-1.2990381056766582, 3.7500000000000004)); mol.addAtom(a7); IAtom a8 = mol.getBuilder().newInstance(IAtom.class, "Cl"); a8.setPoint2d(new Point2d(1.2990381056766576, -0.7500000000000007)); mol.addAtom(a8); IBond b1 = mol.getBuilder().newInstance(IBond.class, a2, a1, IBond.Order.DOUBLE); mol.addBond(b1); IBond b2 = mol.getBuilder().newInstance(IBond.class, a3, a2, IBond.Order.SINGLE); mol.addBond(b2); IBond b3 = mol.getBuilder().newInstance(IBond.class, a4, a3, IBond.Order.DOUBLE); mol.addBond(b3); IBond b4 = mol.getBuilder().newInstance(IBond.class, a5, a4, IBond.Order.SINGLE); mol.addBond(b4); IBond b5 = mol.getBuilder().newInstance(IBond.class, a6, a5, IBond.Order.DOUBLE); mol.addBond(b5); IBond b6 = mol.getBuilder().newInstance(IBond.class, a6, a1, IBond.Order.SINGLE); mol.addBond(b6); IBond b7 = mol.getBuilder().newInstance(IBond.class, a7, a6, IBond.Order.SINGLE); mol.addBond(b7); IBond b8 = mol.getBuilder().newInstance(IBond.class, a8, a2, IBond.Order.SINGLE); mol.addBond(b8); DoubleArrayResult ret = (DoubleArrayResult) descriptor.calculate(mol).getValue(); Assert.assertEquals(0.5774, ret.get(0), 0.0001); Assert.assertEquals(0.0000, ret.get(1), 0.0001); Assert.assertEquals(0.0000, ret.get(2), 0.0001); Assert.assertEquals(0.0000, ret.get(3), 0.0001); Assert.assertEquals(0.3780, ret.get(4), 0.0001); Assert.assertEquals(0.0000, ret.get(5), 0.0001); Assert.assertEquals(0.0000, ret.get(6), 0.0001); Assert.assertEquals(0.0000, ret.get(7), 0.0001); }
@Test public void testDan248() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom a1 = mol.getBuilder().newInstance(IAtom.class, "C"); a1.setPoint2d(new Point2d(0.0, 1.5)); mol.addAtom(a1); IAtom a2 = mol.getBuilder().newInstance(IAtom.class, "C"); a2.setPoint2d(new Point2d(0.0, 0.0)); mol.addAtom(a2); IAtom a3 = mol.getBuilder().newInstance(IAtom.class, "C"); a3.setPoint2d(new Point2d(-1.2990381056766584, -0.7500000000000001)); mol.addAtom(a3); IAtom a4 = mol.getBuilder().newInstance(IAtom.class, "C"); a4.setPoint2d(new Point2d(-2.598076211353316, -2.220446049250313E-16)); mol.addAtom(a4); IAtom a5 = mol.getBuilder().newInstance(IAtom.class, "C"); a5.setPoint2d(new Point2d(-2.5980762113533165, 1.5)); mol.addAtom(a5); IAtom a6 = mol.getBuilder().newInstance(IAtom.class, "C"); a6.setPoint2d(new Point2d(-1.2990381056766582, 2.2500000000000004)); mol.addAtom(a6); IAtom a7 = mol.getBuilder().newInstance(IAtom.class, "C"); a7.setPoint2d(new Point2d(-3.897114317029975, 2.249999999999999)); mol.addAtom(a7); IAtom a8 = mol.getBuilder().newInstance(IAtom.class, "O"); a8.setPoint2d(new Point2d(-1.2990381056766587, -2.25)); mol.addAtom(a8); IAtom a9 = mol.getBuilder().newInstance(IAtom.class, "C"); a9.setPoint2d(new Point2d(1.477211629518312, 1.2395277334996044)); mol.addAtom(a9); IAtom a10 = mol.getBuilder().newInstance(IAtom.class, "C"); a10.setPoint2d(new Point2d(0.5130302149885025, 2.909538931178863)); mol.addAtom(a10); IBond b1 = mol.getBuilder().newInstance(IBond.class, a2, a1, IBond.Order.SINGLE); mol.addBond(b1); IBond b2 = mol.getBuilder().newInstance(IBond.class, a3, a2, IBond.Order.SINGLE); mol.addBond(b2); IBond b3 = mol.getBuilder().newInstance(IBond.class, a4, a3, IBond.Order.SINGLE); mol.addBond(b3); IBond b4 = mol.getBuilder().newInstance(IBond.class, a5, a4, IBond.Order.DOUBLE); mol.addBond(b4); IBond b5 = mol.getBuilder().newInstance(IBond.class, a6, a5, IBond.Order.SINGLE); mol.addBond(b5); IBond b6 = mol.getBuilder().newInstance(IBond.class, a6, a1, IBond.Order.SINGLE); mol.addBond(b6); IBond b7 = mol.getBuilder().newInstance(IBond.class, a7, a5, IBond.Order.SINGLE); mol.addBond(b7); IBond b8 = mol.getBuilder().newInstance(IBond.class, a8, a3, IBond.Order.DOUBLE); mol.addBond(b8); IBond b9 = mol.getBuilder().newInstance(IBond.class, a9, a1, IBond.Order.SINGLE); mol.addBond(b9); IBond b10 = mol.getBuilder().newInstance(IBond.class, a10, a1, IBond.Order.SINGLE); mol.addBond(b10); DoubleArrayResult ret = (DoubleArrayResult) descriptor.calculate(mol).getValue(); Assert.assertEquals(1.7845, ret.get(0), 0.0001); Assert.assertEquals(0.2500, ret.get(1), 0.0001); Assert.assertEquals(0.0000, ret.get(2), 0.0001); Assert.assertEquals(0.0000, ret.get(3), 0.0001); Assert.assertEquals(1.4946, ret.get(4), 0.0001); Assert.assertEquals(0.2500, ret.get(5), 0.0001); Assert.assertEquals(0.0000, ret.get(6), 0.0001); Assert.assertEquals(0.0000, ret.get(7), 0.0001); }
@Test public void testCovalentMetal() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("CCCC[Sn](CCCC)(CCCC)c1cc(Cl)c(Nc2nc(C)nc(N(CCC)CC3CC3)c2Cl)c(Cl)c1"); DoubleArrayResult ret = (DoubleArrayResult) descriptor.calculate(mol).getValue(); Assert.assertNotNull(ret); }
@Test(expected = NullPointerException.class) public void testCovalentPlatinum() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("CC1CN[Pt]2(N1)OC(=O)C(C)P(=O)(O)O2"); descriptor.calculate(mol).getValue(); }