PiElectronegativityDescriptor extends AbstractAtomicDescriptor implements IAtomicDescriptor { @Override public DescriptorValue calculate(IAtom atom, IAtomContainer atomContainer) { IAtomContainer clone; IAtom localAtom; try { clone = (IAtomContainer) atomContainer.clone(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(clone); if (lpeChecker) { LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(atomContainer); } localAtom = clone.getAtom(atomContainer.indexOf(atom)); } catch (CloneNotSupportedException e) { return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Double.NaN), NAMES, null); } catch (CDKException e) { return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Double.NaN), NAMES, null); } if (maxIterations != -1 && maxIterations != 0) electronegativity.setMaxIterations(maxIterations); if (maxResonStruc != -1 && maxResonStruc != 0) electronegativity.setMaxResonStruc(maxResonStruc); double result = electronegativity.calculatePiElectronegativity(clone, localAtom); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(result), NAMES); } PiElectronegativityDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtom atom, IAtomContainer atomContainer); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testPiElectronegativityDescriptor_Ethylene() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {5.1519, 5.1519, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PiElectronegativityDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C=C"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); addExplicitHydrogens(mol); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(mol); for (int i = 0; i < 3; i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); if (result == 0.0) Assert.assertEquals(testResult[i], result, 0.0001); else { Assert.assertTrue(result != 0.0); Assert.assertEquals(testResult[i], result, 0.02); } } }
@Test public void testPiElectronegativityDescriptor_Fluoroethylene() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {4.7796, 5.9414, 5.0507, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PiElectronegativityDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("F-C=C"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); addExplicitHydrogens(mol); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(mol); for (int i = 0; i < 3; i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); if (result == 0.0) Assert.assertEquals(testResult[i], result, 0.0001); else { Assert.assertTrue(result != 0.0); Assert.assertEquals(testResult[i], result, 0.7); } } }
@Test public void testPiElectronegativityDescriptor_FormicAcid() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {6.8954, 7.301, 4.8022, 0.0, 0.0}; IAtomicDescriptor descriptor = new PiElectronegativityDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C(=O)O"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); addExplicitHydrogens(mol); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(mol); for (int i = 0; i < mol.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); if (result == 0.0) Assert.assertEquals(testResult[i], result, 0.0001); else { Assert.assertTrue(result != 0.0); Assert.assertEquals(testResult[i], result, 2); } } }
@Test public void testPiElectronegativityDescriptor_Methoxyethylene() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {4.916, 5.7345, 3.971, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PiElectronegativityDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C=C-O-C"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); addExplicitHydrogens(mol); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(mol); for (int i = 0; i < mol.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); if (result == 0.0) Assert.assertEquals(testResult[i], result, 0.0001); else { Assert.assertTrue(result != 0.0); Assert.assertEquals(testResult[i], result, 0.5); } } }
@Test public void testPiElectronegativity1() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {5.1788, 5.465, 5.2475, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PiElectronegativityDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("F[C+][C-]"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); addExplicitHydrogens(mol); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(mol); for (int i = 0; i < mol.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); if (result == 0.0) Assert.assertEquals(testResult[i], result, 0.0001); else { Assert.assertTrue(result != 0.0); Assert.assertEquals(testResult[i], result, 2.0); } } }
@Test public void testPiElectronegativity2() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {0.0, 0.0, 3.2849, 0.0, 0.0, 0.0, 3.2849, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PiElectronegativityDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("CCOCCCO"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); addExplicitHydrogens(mol); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(mol); for (int i = 0; i < mol.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); if (result == 0.0) Assert.assertEquals(testResult[i], result, 0.0001); else { Assert.assertTrue(result != 0.0); Assert.assertEquals(testResult[i], result, 0.2); } } }
@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); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molA); addExplicitHydrogens(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); IAtomicDescriptor descriptor = new PiElectronegativityDescriptor(); double resultB = ((DoubleResult) descriptor.calculate(molB.getAtom(3), molB).getValue()).doubleValue(); Assert.assertEquals(resultA, resultB, 0.00001); }