BondPartialPiChargeDescriptor extends AbstractBondDescriptor { @Override public DescriptorValue calculate(IBond bond, IAtomContainer ac) { Double originalCharge1 = bond.getBegin().getCharge(); String originalAtomtypeName1 = bond.getBegin().getAtomTypeName(); Integer originalNeighborCount1 = bond.getBegin().getFormalNeighbourCount(); IAtomType.Hybridization originalHybridization1 = bond.getBegin().getHybridization(); Integer originalValency1 = bond.getBegin().getValency(); Double originalCharge2 = bond.getEnd().getCharge(); String originalAtomtypeName2 = bond.getEnd().getAtomTypeName(); Integer originalNeighborCount2 = bond.getEnd().getFormalNeighbourCount(); IAtomType.Hybridization originalHybridization2 = bond.getEnd().getHybridization(); Integer originalValency2 = bond.getEnd().getValency(); Double originalBondOrderSum1 = bond.getBegin().getBondOrderSum(); Order originalMaxBondOrder1 = bond.getBegin().getMaxBondOrder(); Double originalBondOrderSum2 = bond.getEnd().getBondOrderSum(); Order originalMaxBondOrder2 = bond.getEnd().getMaxBondOrder(); if (!isCachedAtomContainer(ac)) { try { AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac); if (lpeChecker) { LonePairElectronChecker lpcheck = new LonePairElectronChecker(); 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 (Iterator<IBond> it = ac.bonds().iterator(); it.hasNext();) { IBond bondi = it.next(); double result = Math.abs(bondi.getBegin().getCharge() - bondi.getEnd().getCharge()); cacheDescriptorValue(bondi, ac, new DoubleResult(result)); } } catch (Exception ex1) { return getDummyDescriptorValue(ex1); } } bond.getBegin().setCharge(originalCharge1); bond.getBegin().setAtomTypeName(originalAtomtypeName1); bond.getBegin().setHybridization(originalHybridization1); bond.getBegin().setValency(originalValency1); bond.getBegin().setFormalNeighbourCount(originalNeighborCount1); bond.getEnd().setCharge(originalCharge2); bond.getEnd().setAtomTypeName(originalAtomtypeName2); bond.getEnd().setHybridization(originalHybridization2); bond.getEnd().setValency(originalValency2); bond.getEnd().setFormalNeighbourCount(originalNeighborCount2); bond.getBegin().setMaxBondOrder(originalMaxBondOrder1); bond.getBegin().setBondOrderSum(originalBondOrderSum1); bond.getEnd().setMaxBondOrder(originalMaxBondOrder2); bond.getEnd().setBondOrderSum(originalBondOrderSum2); return getCachedDescriptorValue(bond) != null ? new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), getCachedDescriptorValue(bond), NAMES) : null; } BondPartialPiChargeDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IBond bond, IAtomContainer ac); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testBondPiElectronegativityDescriptor() throws ClassNotFoundException, CDKException, java.lang.Exception { descriptor = new BondPartialPiChargeDescriptor(); double[] testResult = {0.0, 0.0}; SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("CF"); addExplicitHydrogens(mol); for (int i = 0; i < 2; i++) { double result = ((DoubleResult) descriptor.calculate(mol.getBond(i), mol).getValue()).doubleValue(); Assert.assertEquals(testResult[i], result, 0.01); } }
@Test public void testBondPiElectronegativityDescriptor_Allyl_bromide() throws ClassNotFoundException, CDKException, java.lang.Exception { descriptor = new BondPartialPiChargeDescriptor(); double[] testResult = {0.0022, 0.0011, 0.0011, 0.0011, 0.0011, 0.0, 0.0, 0.0}; SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C=CCBr"); addExplicitHydrogens(mol); for (int i = 0; i < 8; i++) { double result = ((DoubleResult) descriptor.calculate(mol.getBond(i), mol).getValue()).doubleValue(); Assert.assertEquals(testResult[i], result, 0.03); } }
@Test public void testBondPiElectronegativityDescriptor_Isopentyl_iodide() throws ClassNotFoundException, CDKException, java.lang.Exception { descriptor = new BondPartialPiChargeDescriptor(); double testResult = 0.0; SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C(C)(C)CCI"); addExplicitHydrogens(mol); for (int i = 0; i < 6; i++) { double result = ((DoubleResult) descriptor.calculate(mol.getBond(i), mol).getValue()).doubleValue(); Assert.assertEquals(testResult, result, 0.001); } }
@Test public void testBondPiElectronegativityDescriptor_Allyl_mercaptan() throws ClassNotFoundException, CDKException, java.lang.Exception { descriptor = new BondPartialPiChargeDescriptor(); double[] testResult = {0.0006, 0.0003, 0.0003, 0.0003, 0.0003, 0.0, 0.0, 0.0, 0.0}; SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C=CCS"); addExplicitHydrogens(mol); for (int i = 0; i < 9; i++) { double result = ((DoubleResult) descriptor.calculate(mol.getBond(i), mol).getValue()).doubleValue(); Assert.assertEquals(testResult[i], result, 0.03); } }