SigmaElectronegativityDescriptor extends AbstractAtomicDescriptor implements IAtomicDescriptor { @Override public DescriptorValue calculate(IAtom atom, IAtomContainer ac) { IAtomContainer clone; IAtom localAtom; try { clone = (IAtomContainer) ac.clone(); localAtom = clone.getAtom(ac.indexOf(atom)); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(clone); } catch (CDKException e) { return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Double.NaN), NAMES, e); } catch (CloneNotSupportedException e) { return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Double.NaN), NAMES, e); } if (maxIterations != -1 && maxIterations != 0) electronegativity.setMaxIterations(maxIterations); double result = electronegativity.calculateSigmaElectronegativity(clone, localAtom); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(result), NAMES); } SigmaElectronegativityDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtom atom, IAtomContainer ac); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testSigmaElectronegativityDescriptor_Isopentyl_iodide() throws ClassNotFoundException, CDKException, java.lang.Exception { double testResult = 9.2264; IAtomicDescriptor descriptor = new SigmaElectronegativityDescriptor(); SmilesParser sp = new SmilesParser(builder); IAtomContainer mol = sp.parseSmiles("C(C)(C)CCI"); addExplicitHydrogens(mol); double result = ((DoubleResult) descriptor.calculate(mol.getAtom(5), mol).getValue()).doubleValue(); Assert.assertEquals(testResult, result, 0.08); }
@Test public void testSigmaElectronegativityDescriptor_Allyl_mercaptan() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {7.8634, 8.0467, 8.061, 8.5917}; IAtomicDescriptor descriptor = new SigmaElectronegativityDescriptor(); SmilesParser sp = new SmilesParser(builder); IAtomContainer mol = sp.parseSmiles("C=CCS"); addExplicitHydrogens(mol); for (int i = 0; i < 4; i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); Assert.assertEquals(testResult[i], result, 0.01); } }
@Test public void testCompareIonized() throws ClassNotFoundException, CDKException, java.lang.Exception { IAtomContainer molA = builder.newInstance(IAtomContainer.class); molA.addAtom(builder.newInstance(IAtom.class, "C")); molA.addAtom(builder.newInstance(IAtom.class, "C")); molA.addBond(0, 1, IBond.Order.SINGLE); molA.addAtom(builder.newInstance(IAtom.class, "C")); molA.addBond(1, 2, IBond.Order.SINGLE); molA.addAtom(builder.newInstance(IAtom.class, "Cl")); molA.addBond(2, 3, IBond.Order.SINGLE); addExplicitHydrogens(molA); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molA); lpcheck.saturate(molA); double resultA = ((DoubleResult) descriptor.calculate(molA.getAtom(3), molA).getValue()).doubleValue(); IAtomContainer molB = builder.newInstance(IAtomContainer.class); molB.addAtom(builder.newInstance(IAtom.class, "C")); molB.addAtom(builder.newInstance(IAtom.class, "C")); molB.addBond(0, 1, IBond.Order.SINGLE); molB.addAtom(builder.newInstance(IAtom.class, "C")); molB.addBond(1, 2, IBond.Order.SINGLE); molB.addAtom(builder.newInstance(IAtom.class, "Cl")); molB.getAtom(3).setFormalCharge(1); molB.addSingleElectron(3); molB.addLonePair(3); molB.addLonePair(3); molB.addBond(2, 3, IBond.Order.SINGLE); addExplicitHydrogens(molB); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molB); lpcheck.saturate(molB); Assert.assertEquals(1, molB.getAtom(3).getFormalCharge(), 0.00001); Assert.assertEquals(1, molB.getSingleElectronCount(), 0.00001); Assert.assertEquals(2, molB.getLonePairCount(), 0.00001); double resultB = ((DoubleResult) descriptor.calculate(molB.getAtom(3), molB).getValue()).doubleValue(); Assert.assertEquals(resultA, resultB, 0.00001); }