private boolean isChemicallyValid(IAtomContainer union) throws CDKException { for (IAtom atom : union.atoms()) { if ((union.getConnectedBondsCount(atom) + atom.getFormalCharge()) > atom.getFormalNeighbourCount()) { return false; } } return true; }
/** * This method calculates the ionization potential of an atom. * * @param atom The IAtom to ionize. * @param container Parameter is the IAtomContainer. * @return The ionization potential. Not possible the ionization. */ @Override public DescriptorValue calculate(IAtom atom, IAtomContainer container) { double value = 0; // FIXME: for now I'll cache a few modified atomic properties, and restore them at the end of // this method String originalAtomtypeName = atom.getAtomTypeName(); Integer originalNeighborCount = atom.getFormalNeighbourCount(); Integer originalValency = atom.getValency(); IAtomType.Hybridization originalHybrid = atom.getHybridization(); Double originalBondOrderSum = atom.getBondOrderSum(); Order originalMaxBondOrder = atom.getMaxBondOrder(); if (!isCachedAtomContainer(container)) { try { AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(container); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(container); } catch (CDKException e) { return new DescriptorValue( getSpecification(), getParameterNames(), getParameters(), new DoubleResult(Double.NaN), getDescriptorNames(), e); } } try { value = IonizationPotentialTool.predictIP(container, atom); } catch (CDKException e) { return new DescriptorValue( getSpecification(), getParameterNames(), getParameters(), new DoubleResult(Double.NaN), getDescriptorNames(), e); } // restore original props atom.setAtomTypeName(originalAtomtypeName); atom.setFormalNeighbourCount(originalNeighborCount); atom.setValency(originalValency); atom.setHybridization(originalHybrid); atom.setMaxBondOrder(originalMaxBondOrder); atom.setBondOrderSum(originalBondOrderSum); return new DescriptorValue( getSpecification(), getParameterNames(), getParameters(), new DoubleResult(value), getDescriptorNames()); }