PartialTChargePEOEDescriptor 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) { new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Double.NaN), NAMES, e); } if (lpeChecker) { LonePairElectronChecker lpcheck = new LonePairElectronChecker(); try { lpcheck.saturate(ac); } catch (CDKException e) { new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Double.NaN), NAMES, e); } } if (maxIterations != -1) pepe.setMaxGasteigerIters(maxIterations); if (maxResonStruc != -1) pepe.setMaxResoStruc(maxResonStruc); try { peoe.assignGasteigerMarsiliSigmaPartialCharges(ac, true); List<Double> peoeAtom = new ArrayList<Double>(); for (Iterator<IAtom> it = ac.atoms().iterator(); it.hasNext();) peoeAtom.add(it.next().getCharge()); for (Iterator<IAtom> it = ac.atoms().iterator(); it.hasNext();) it.next().setCharge(0.0); pepe.assignGasteigerPiPartialCharges(ac, true); for (int i = 0; i < ac.getAtomCount(); i++) cacheDescriptorValue(ac.getAtom(i), ac, new DoubleResult(peoeAtom.get(i) + ac.getAtom(i).getCharge())); } catch (Exception e) { new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Double.NaN), NAMES, e); } } 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; } PartialTChargePEOEDescriptor(); @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 testPartialTChargeDescriptor_Methyl_Fluoride() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {-0.2527, 0.0795, 0.0577, 0.0577, 0.0577}; IAtomicDescriptor descriptor = new PartialTChargePEOEDescriptor(); 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); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); addExplicitHydrogens(molecule); lpcheck.saturate(molecule); addExplicitHydrogens(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.01); } }
@Test @Category(SlowTest.class) public void testPartialTChargeDescriptor_Fluoroethylene() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {-0.1839, 0.079, -0.1019, 0.0942, 0.0563, 0.0563}; IAtomicDescriptor descriptor = new PartialTChargePEOEDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("F-C=C"); 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.04); } }
@Test @Category(SlowTest.class) public void testPartialTChargeDescriptor_FormicAcid() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {0.2672, -0.3877, -0.2365, 0.1367, 0.2203}; IAtomicDescriptor descriptor = new PartialTChargePEOEDescriptor(); 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 testPartialTChargeDescriptor_Fluorobenzene() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {-0.1785, 0.1227, -0.0373, -0.0598, -0.0683}; IAtomicDescriptor descriptor = new PartialTChargePEOEDescriptor(); 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); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(2, 3, IBond.Order.SINGLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(3, 4, IBond.Order.DOUBLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(4, 5, IBond.Order.SINGLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(5, 6, IBond.Order.DOUBLE); molecule.addBond(6, 1, IBond.Order.SINGLE); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); addExplicitHydrogens(molecule); lpcheck.saturate(molecule); for (int i = 0; i < 5; i++) { double result = ((DoubleResult) descriptor.calculate(molecule.getAtom(i), molecule).getValue()) .doubleValue(); Assert.assertEquals(testResult[i], result, 0.012); } }
@Test @Category(SlowTest.class) public void testPartialTChargeDescriptor_Methoxyethylene() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {-0.1211, 0.0314, -0.3121, 0.0429, 0.056, 0.056, 0.0885, 0.056, 0.056, 0.056}; IAtomicDescriptor descriptor = new PartialTChargePEOEDescriptor(); 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, "O")); molecule.addBond(1, 2, IBond.Order.SINGLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(2, 3, 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 testPartialTChargeDescriptor_1_Methoxybutadiene() throws ClassNotFoundException, CDKException, java.lang.Exception { double[] testResult = {-0.1331, -0.0678, -0.0803, 0.0385, -0.2822, 0.0429, 0.0541, 0.0541, 0.0619, 0.0644, 0.0891, 0.0528, 0.0528, 0.0528, 0.0528}; IAtomicDescriptor descriptor = new PartialTChargePEOEDescriptor(); 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); } }