PartialPiChargeDescriptor extends AbstractAtomicDescriptor { @Override public DescriptorValue calculate(IAtom atom, IAtomContainer ac) { Double originalCharge = atom.getCharge(); String originalAtomtypeName = atom.getAtomTypeName(); Integer originalNeighborCount = atom.getFormalNeighbourCount(); Integer originalValency = atom.getValency(); IAtomType.Hybridization originalHybridization = atom.getHybridization(); Double originalBondOrderSum = atom.getBondOrderSum(); Order originalMaxBondOrder = atom.getMaxBondOrder(); if (!isCachedAtomContainer(ac)) { try { AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac); } catch (CDKException e) { return getDummyDescriptorValue(e); } if (lpeChecker) { LonePairElectronChecker lpcheck = new LonePairElectronChecker(); try { lpcheck.saturate(ac); } catch (CDKException e) { return getDummyDescriptorValue(e); } } if (maxIterations != -1) pepe.setMaxGasteigerIters(maxIterations); if (maxResonStruc != -1) pepe.setMaxResoStruc(maxResonStruc); try { for (int i = 0; i < ac.getAtomCount(); i++) ac.getAtom(i).setCharge(0.0); pepe.assignGasteigerPiPartialCharges(ac, true); for (int i = 0; i < ac.getAtomCount(); i++) { cacheDescriptorValue(ac.getAtom(i), ac, new DoubleResult(ac.getAtom(i).getCharge())); } } catch (Exception exception) { return getDummyDescriptorValue(exception); } } atom.setCharge(originalCharge); atom.setAtomTypeName(originalAtomtypeName); atom.setFormalNeighbourCount(originalNeighborCount); atom.setValency(originalValency); atom.setHybridization(originalHybridization); atom.setMaxBondOrder(originalMaxBondOrder); atom.setBondOrderSum(originalBondOrderSum); return getCachedDescriptorValue(atom) != null ? new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), getCachedDescriptorValue(atom), NAMES) : null; } PartialPiChargeDescriptor(); @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 @Category(SlowTest.class) public void testPartialPiChargeDescriptor_Methyl_Fluoride() throws Exception { double[] testResult = {0.0, 0.0, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PartialPiChargeDescriptor(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(new Atom("F")); molecule.addAtom(new Atom("C")); molecule.addBond(0, 1, IBond.Order.SINGLE); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); addExplicitHydrogens(molecule); lpcheck.saturate(molecule); for (int i = 0; i < molecule.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(molecule.getAtom(i), molecule).getValue()) .doubleValue(); Assert.assertEquals(testResult[i], result, 0.0001); } }
@Test @Category(SlowTest.class) public void testPartialPiChargeDescriptor_Fluoroethylene() throws Exception { double[] testResult = {0.0299, 0.0, -0.0299, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PartialPiChargeDescriptor(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(builder.newInstance(IAtom.class, "F")); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(0, 1, IBond.Order.SINGLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(1, 2, IBond.Order.DOUBLE); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); addExplicitHydrogens(molecule); lpcheck.saturate(molecule); for (int i = 0; i < molecule.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(molecule.getAtom(i), molecule).getValue()) .doubleValue(); Assert.assertEquals(testResult[i], result, 0.05); } }
@Test @Category(SlowTest.class) public void testPartialPiChargeDescriptor_FormicAcid() throws Exception { double[] testResult = {0.0221, -0.1193, 0.0972, 0.0, 0.0}; IAtomicDescriptor descriptor = new PartialPiChargeDescriptor(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addAtom(builder.newInstance(IAtom.class, "O")); molecule.addBond(0, 1, IBond.Order.DOUBLE); molecule.addAtom(builder.newInstance(IAtom.class, "O")); molecule.addBond(0, 2, IBond.Order.SINGLE); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); addExplicitHydrogens(molecule); lpcheck.saturate(molecule); for (int i = 0; i < molecule.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(molecule.getAtom(i), molecule).getValue()) .doubleValue(); Assert.assertEquals(testResult[i], result, 0.05); } }
@Test @Category(SlowTest.class) public void testPartialPiChargeDescriptor_1_Methoxybutadiene() throws Exception { double[] testResult = {-0.0333, 0.0, -0.0399, 0.0, 0.0733, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PartialPiChargeDescriptor(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(0, 1, IBond.Order.DOUBLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(1, 2, IBond.Order.SINGLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(2, 3, IBond.Order.DOUBLE); molecule.addAtom(builder.newInstance(IAtom.class, "O")); molecule.addBond(3, 4, IBond.Order.SINGLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(4, 5, IBond.Order.SINGLE); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); addExplicitHydrogens(molecule); lpcheck.saturate(molecule); for (int i = 0; i < molecule.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(molecule.getAtom(i), molecule).getValue()) .doubleValue(); Assert.assertEquals(testResult[i], result, 0.3); } }
@Test @Category(SlowTest.class) public void testPartialPiChargeDescriptoCharge_1() throws Exception { double[] testResult = {0.0613, -0.0554, 0.0, -0.0059, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PartialPiChargeDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("F[C+]([H])[C-]([H])[H]"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); lpcheck.saturate(mol); for (int i = 0; i < 6; i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); Assert.assertEquals(testResult[i], result, 0.2); } }
@Test @Category(SlowTest.class) public void testPartialPiChargeDescriptoCharge_2() throws Exception { double[] testResult = {-0.0822, 0.02, 0.0, 0.0423, 0.0, 0.02, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; IAtomicDescriptor descriptor = new PartialPiChargeDescriptor(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); mol.addAtom(builder.newInstance(IAtom.class, "N")); mol.addAtom(builder.newInstance(IAtom.class, "C")); mol.addBond(0, 1, Order.SINGLE); mol.addAtom(builder.newInstance(IAtom.class, "C")); mol.addBond(1, 2, Order.DOUBLE); mol.addAtom(builder.newInstance(IAtom.class, "C")); mol.addBond(2, 3, Order.SINGLE); mol.addAtom(builder.newInstance(IAtom.class, "C")); mol.addBond(3, 4, Order.DOUBLE); mol.addAtom(builder.newInstance(IAtom.class, "C")); mol.addBond(4, 5, Order.SINGLE); mol.addBond(5, 0, Order.DOUBLE); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); addExplicitHydrogens(mol); lpcheck.saturate(mol); for (int i = 0; i < mol.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); Assert.assertEquals(testResult[i], result, 0.05); } }
@Test @Category(SlowTest.class) public void testPartialPiChargeDescripto4() throws Exception { double[] testResult = {0.0}; IAtomicDescriptor descriptor = new PartialPiChargeDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("CCOCCCO"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); addExplicitHydrogens(mol); lpcheck.saturate(mol); for (int i = 0; i < mol.getAtomCount(); i++) { double result = ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue(); Assert.assertEquals(testResult[0], result, 0.0001); } }
@Test @Category(SlowTest.class) public void testDifferentStarts() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol1 = sp.parseSmiles("C=CCC=O"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1); addExplicitHydrogens(mol1); lpcheck.saturate(mol1); IAtomContainer mol2 = sp.parseSmiles("O=CCC=C"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2); addExplicitHydrogens(mol2); lpcheck.saturate(mol2); IAtomicDescriptor descriptor1 = new PartialPiChargeDescriptor(); IAtomicDescriptor descriptor2 = new PartialPiChargeDescriptor(); for (int i = 0; i < 5; i++) { double result1 = ((DoubleResult) descriptor1.calculate(mol1.getAtom(i), mol1).getValue()).doubleValue(); double result2 = ((DoubleResult) descriptor2.calculate(mol2.getAtom(5 - i - 1), mol2).getValue()) .doubleValue(); Assert.assertFalse(Double.isNaN(result1)); Assert.assertFalse(Double.isNaN(result2)); Assert.assertEquals(result1, result2, 0.0001); } }