/** * A unit test suite for JUnit. * * @return The test suite * @throws Exception */ @Test public void testSetMaxIterations_Int() throws Exception { Electronegativity pe = new Electronegativity(); int maxIter = 10; pe.setMaxIterations(maxIter); Assert.assertSame(maxIter, pe.getMaxIterations()); }
/** * The method calculates the sigma electronegativity of a given bond * It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools.HydrogenAdder. * *@param atomContainer AtomContainer *@return return the sigma electronegativity */ @Override public DescriptorValue calculate(IBond aBond, IAtomContainer atomContainer) { IAtomContainer ac; IBond bond; try { ac = (IAtomContainer) atomContainer.clone(); bond = ac.getBond(atomContainer.indexOf(aBond)); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac); } catch (CDKException e) { return getDummyDescriptorValue(e); } catch (CloneNotSupportedException e) { return getDummyDescriptorValue(e); } if (maxIterations != -1 && maxIterations != 0) electronegativity.setMaxIterations(maxIterations); double electroAtom1 = electronegativity.calculateSigmaElectronegativity(ac, bond.getBegin()); double electroAtom2 = electronegativity.calculateSigmaElectronegativity(ac, bond.getEnd()); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Math.abs(electroAtom1 - electroAtom2)), NAMES); }
/** * The method calculates the sigma electronegativity of a given atom * It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools.HydrogenAdder. * *@param atom The IAtom for which the DescriptorValue is requested *@param ac AtomContainer *@return return the sigma electronegativity */ @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); }