if (type != null && !type.getAtomTypeName().equals("X") && type.getFormalNeighbourCount() != null) { type.getFormalNeighbourCount() - connectedAtomCount, atom.getImplicitHydrogenCount()}); atom.setImplicitHydrogenCount(type.getFormalNeighbourCount() - connectedAtomCount);
@Override public boolean isSaturated(IAtom atom, IAtomContainer container) throws CDKException { IAtomType type = atomTypeList.getAtomType(atom.getAtomTypeName()); if (type == null) throw new CDKException("Atom type is not a recognized CDK atom type: " + atom.getAtomTypeName()); if (type.getFormalNeighbourCount() == CDKConstants.UNSET) throw new CDKException( "Atom type is too general; cannot decide the number of implicit hydrogen to add for: " + atom.getAtomTypeName()); if (type.getProperty(CDKConstants.PI_BOND_COUNT) == CDKConstants.UNSET) throw new CDKException("Atom type is too general; cannot determine the number of pi bonds for: " + atom.getAtomTypeName()); double bondOrderSum = container.getBondOrderSum(atom); IBond.Order maxBondOrder = container.getMaximumBondOrder(atom); Integer hcount = atom.getImplicitHydrogenCount() == CDKConstants.UNSET ? 0 : atom.getImplicitHydrogenCount(); int piBondCount = ((Integer) type.getProperty(CDKConstants.PI_BOND_COUNT)).intValue(); int formalNeighborCount = type.getFormalNeighbourCount().intValue(); int typeMaxBondOrder = piBondCount + 1; int typeBondOrderSum = formalNeighborCount + piBondCount; if (bondOrderSum + hcount == typeBondOrderSum && maxBondOrder.numeric() <= typeMaxBondOrder) { return true; } return false; }
/** * Sets the implicit hydrogen count for the indicated IAtom in the given IAtomContainer. * If the atom type is "X", then the atom is assigned zero implicit hydrogens. * * @param container The molecule to which H's will be added * @param atom IAtom to set the implicit hydrogen count for * @throws CDKException Throws if insufficient information is present */ public void addImplicitHydrogens(IAtomContainer container, IAtom atom) throws CDKException { if (atom.getAtomTypeName() == null) throw new CDKException("IAtom is not typed! " + atom.getSymbol()); if ("X".equals(atom.getAtomTypeName())) { if (atom.getImplicitHydrogenCount() == null) atom.setImplicitHydrogenCount(0); return; } IAtomType type = atomTypeList.getAtomType(atom.getAtomTypeName()); if (type == null) throw new CDKException("Atom type is not a recognized CDK atom type: " + atom.getAtomTypeName()); if (type.getFormalNeighbourCount() == CDKConstants.UNSET) throw new CDKException( "Atom type is too general; cannot decide the number of implicit hydrogen to add for: " + atom.getAtomTypeName()); // very simply counting: each missing explicit neighbor is a missing hydrogen atom.setImplicitHydrogenCount(type.getFormalNeighbourCount() - container.getConnectedBondsCount(atom)); } }
@Override public boolean isSaturated(IAtom atom, IAtomContainer container) throws CDKException { IAtomType type = atomTypeList.getAtomType(atom.getAtomTypeName()); if (type == null) throw new CDKException("Atom type is not a recognized CDK atom type: " + atom.getAtomTypeName()); if (type.getFormalNeighbourCount() == CDKConstants.UNSET) throw new CDKException( "Atom type is too general; cannot decide the number of implicit hydrogen to add for: " + atom.getAtomTypeName()); if (type.getProperty(CDKConstants.PI_BOND_COUNT) == CDKConstants.UNSET) throw new CDKException("Atom type is too general; cannot determine the number of pi bonds for: " + atom.getAtomTypeName()); double bondOrderSum = container.getBondOrderSum(atom); IBond.Order maxBondOrder = container.getMaximumBondOrder(atom); Integer hcount = atom.getImplicitHydrogenCount() == CDKConstants.UNSET ? 0 : atom.getImplicitHydrogenCount(); int piBondCount = ((Integer) type.getProperty(CDKConstants.PI_BOND_COUNT)).intValue(); int formalNeighborCount = type.getFormalNeighbourCount().intValue(); int typeMaxBondOrder = piBondCount + 1; int typeBondOrderSum = formalNeighborCount + piBondCount; if (bondOrderSum + hcount == typeBondOrderSum && maxBondOrder.numeric() <= typeMaxBondOrder) { return true; } return false; }
atom.setFormalNeighbourCount(at.getFormalNeighbourCount()); key = "vdw" + ID; data = (List) parameterSet.get(key);
/** * Sets the implicit hydrogen count for the indicated IAtom in the given IAtomContainer. * If the atom type is "X", then the atom is assigned zero implicit hydrogens. * * @param container The molecule to which H's will be added * @param atom IAtom to set the implicit hydrogen count for * @throws CDKException Throws if insufficient information is present */ public void addImplicitHydrogens(IAtomContainer container, IAtom atom) throws CDKException { if (atom.getAtomTypeName() == null) throw new CDKException("IAtom is not typed! " + atom.getSymbol()); if ("X".equals(atom.getAtomTypeName())) { if (atom.getImplicitHydrogenCount() == null) atom.setImplicitHydrogenCount(0); return; } IAtomType type = atomTypeList.getAtomType(atom.getAtomTypeName()); if (type == null) throw new CDKException("Atom type is not a recognized CDK atom type: " + atom.getAtomTypeName()); if (type.getFormalNeighbourCount() == CDKConstants.UNSET) throw new CDKException( "Atom type is too general; cannot decide the number of implicit hydrogen to add for: " + atom.getAtomTypeName()); // very simply counting: each missing explicit neighbor is a missing hydrogen atom.setImplicitHydrogenCount(type.getFormalNeighbourCount() - container.getConnectedBondsCount(atom)); } }
int requiredContainerCount = type.getFormalNeighbourCount(); if (actualContainerCount != requiredContainerCount) return false; } else if (atom.getImplicitHydrogenCount() != CDKConstants.UNSET) { int hCount = atom.getImplicitHydrogenCount(); int actualNeighbourCount = connectedAtoms + hCount; int requiredNeighbourCount = type.getFormalNeighbourCount(); if (actualNeighbourCount > requiredNeighbourCount) return false;
@Test public void testSetFormalNeighbourCount_Integer() { int count = 4; IAtomType a = (IAtomType) newChemObject(); a.setFormalNeighbourCount(count); Assert.assertEquals(count, (int) a.getFormalNeighbourCount()); }
/** * Constructs an isotope by copying the symbol, atomic number, * flags, identifier, exact mass, natural abundance and mass * number from the given IIsotope. It does not copy the * listeners and properties. If the element is an instanceof * IAtomType, then the maximum bond order, bond order sum, * van der Waals and covalent radii, formal charge, hybridization, * electron valency, formal neighbour count and atom type name * are copied too. * * @param element IIsotope to copy information from */ public AtomType(IElement element) { super(element); if (element instanceof IAtomType) { this.maxBondOrder = ((IAtomType) element).getMaxBondOrder(); this.bondOrderSum = ((IAtomType) element).getBondOrderSum(); this.covalentRadius = ((IAtomType) element).getCovalentRadius(); this.formalCharge = ((IAtomType) element).getFormalCharge(); this.hybridization = ((IAtomType) element).getHybridization(); this.electronValency = ((IAtomType) element).getValency(); this.formalNeighbourCount = ((IAtomType) element).getFormalNeighbourCount(); this.identifier = ((IAtomType) element).getAtomTypeName(); } }
/** * Constructs an isotope by copying the symbol, atomic number, * flags, identifier, exact mass, natural abundance and mass * number from the given IIsotope. It does not copy the * listeners and properties. If the element is an instance of * IAtomType, then the maximum bond order, bond order sum, * van der Waals and covalent radii, formal charge, hybridization, * electron valency, formal neighbour count and atom type name * are copied too. * * @param element IIsotope to copy information from */ public AtomType(IElement element) { super(element); if (element instanceof IAtomType) { this.maxBondOrder = ((IAtomType) element).getMaxBondOrder(); this.bondOrderSum = ((IAtomType) element).getBondOrderSum(); this.covalentRadius = ((IAtomType) element).getCovalentRadius(); this.formalCharge = ((IAtomType) element).getFormalCharge(); this.hybridization = ((IAtomType) element).getHybridization(); this.electronValency = ((IAtomType) element).getValency(); this.formalNeighbourCount = ((IAtomType) element).getFormalNeighbourCount(); this.identifier = ((IAtomType) element).getAtomTypeName(); } }
/** * Constructs an isotope by copying the symbol, atomic number, * flags, identifier, exact mass, natural abundance and mass * number from the given IIsotope. It does not copy the * listeners and properties. If the element is an instanceof * IAtomType, then the maximum bond order, bond order sum, * van der Waals and covalent radii, formal charge, hybridization, * electron valency, formal neighbour count and atom type name * are copied too. * * @param element IIsotope to copy information from */ public AtomType(IElement element) { super(element); if (element instanceof IAtomType) { this.maxBondOrder = ((IAtomType) element).getMaxBondOrder(); this.bondOrderSum = ((IAtomType) element).getBondOrderSum(); this.covalentRadius = ((IAtomType) element).getCovalentRadius(); this.formalCharge = ((IAtomType) element).getFormalCharge(); this.hybridization = ((IAtomType) element).getHybridization(); this.electronValency = ((IAtomType) element).getValency(); this.formalNeighbourCount = ((IAtomType) element).getFormalNeighbourCount(); this.identifier = ((IAtomType) element).getAtomTypeName(); } }
/** * Constructs an isotope by copying the symbol, atomic number, * flags, identifier, exact mass, natural abundance and mass * number from the given IIsotope. It does not copy the * listeners and properties. If the element is an instance of * IAtomType, then the maximum bond order, bond order sum, * van der Waals and covalent radii, formal charge, hybridization, * electron valency, formal neighbour count and atom type name * are copied too. * * @param element IIsotope to copy information from */ public AtomType(IElement element) { super(element); if (element instanceof IAtomType) { this.maxBondOrder = ((IAtomType) element).getMaxBondOrder(); this.bondOrderSum = ((IAtomType) element).getBondOrderSum(); this.covalentRadius = ((IAtomType) element).getCovalentRadius(); this.formalCharge = ((IAtomType) element).getFormalCharge(); this.hybridization = ((IAtomType) element).getHybridization(); this.electronValency = ((IAtomType) element).getValency(); this.formalNeighbourCount = ((IAtomType) element).getFormalNeighbourCount(); this.identifier = ((IAtomType) element).getAtomTypeName(); } }
/** * Method to test the clone() method */ @Test public void testClone_FormalNeighbourCount() throws Exception { IAtomType at = (IAtomType) newChemObject(); at.setFormalNeighbourCount(1); IAtomType clone = (IAtomType) at.clone(); at.setFormalNeighbourCount(2); Assert.assertEquals(1, (int) clone.getFormalNeighbourCount()); }
ImmutableAtomType(IAtomType type) { this.element = type.getSymbol(); this.atomicNumber = type.getAtomicNumber(); this.naturalAbundance = type.getNaturalAbundance(); this.exactMass = type.getExactMass(); this.massNumber = type.getMassNumber(); this.formalCharge = type.getFormalCharge(); this.hybridization = type.getHybridization(); this.formalNeighbourCount = type.getFormalNeighbourCount(); this.identifier = type.getAtomTypeName(); this.maxBondOrder = type.getMaxBondOrder(); this.bondOrderSum = type.getBondOrderSum(); this.covalentRadius = type.getCovalentRadius(); this.flags = (short)type.getFlagValue(); this.properties = Collections.unmodifiableMap(type.getProperties()); if (type.getValency() != null) { this.electronValency = type.getValency(); } else { Integer piBondCount = type.getProperty(CDKConstants.PI_BOND_COUNT, Integer.class); if (piBondCount != null && formalNeighbourCount != null) { this.electronValency = piBondCount + formalNeighbourCount; } else { this.electronValency = null; } } }
ImmutableAtomType(IAtomType type) { this.element = type.getSymbol(); this.atomicNumber = type.getAtomicNumber(); this.naturalAbundance = type.getNaturalAbundance(); this.exactMass = type.getExactMass(); this.massNumber = type.getMassNumber(); this.formalCharge = type.getFormalCharge(); this.hybridization = type.getHybridization(); this.formalNeighbourCount = type.getFormalNeighbourCount(); this.identifier = type.getAtomTypeName(); this.maxBondOrder = type.getMaxBondOrder(); this.bondOrderSum = type.getBondOrderSum(); this.covalentRadius = type.getCovalentRadius(); this.flags = (short)type.getFlagValue(); this.properties = Collections.unmodifiableMap(type.getProperties()); if (type.getValency() != null) { this.electronValency = type.getValency(); } else { Integer piBondCount = type.getProperty(CDKConstants.PI_BOND_COUNT, Integer.class); if (piBondCount != null && formalNeighbourCount != null) { this.electronValency = piBondCount + formalNeighbourCount; } else { this.electronValency = null; } } }
@Test public void testSetMMFF94Parameters() throws Exception { forceFieldConfigurator.setMMFF94Parameters(DefaultChemObjectBuilder.getInstance()); assertNotNull(forceFieldConfigurator.getParameterSet()); List<IAtomType> atomtypeList = forceFieldConfigurator.getAtomTypes(); IAtomType atomtype4 = atomtypeList.get(4); assertEquals("CO2M", atomtype4.getAtomTypeName()); assertEquals(6, (int) atomtype4.getAtomicNumber()); assertEquals(3, (int) atomtype4.getFormalNeighbourCount()); assertEquals(12, (int) atomtype4.getMassNumber()); }
@Test public void testReadAtomTypes_CDK() { OWLAtomTypeReader reader = new OWLAtomTypeReader(new StringReader(OWL_CONTENT)); Assert.assertNotNull(reader); List<IAtomType> types = reader.readAtomTypes(new ChemObject().getBuilder()); Assert.assertNotNull(types); Assert.assertEquals(1, types.size()); Object object = types.get(0); Assert.assertNotNull(object); Assert.assertTrue(object instanceof IAtomType); IAtomType atomType = (IAtomType) object; Assert.assertEquals("C", atomType.getSymbol()); Assert.assertEquals("C.sp3.0", atomType.getAtomTypeName()); Assert.assertEquals(0, atomType.getFormalCharge().intValue()); Assert.assertEquals(IAtomType.Hybridization.SP3, atomType.getHybridization()); Assert.assertEquals(4, atomType.getFormalNeighbourCount().intValue()); Assert.assertEquals(0, atomType.getProperty(CDKConstants.LONE_PAIR_COUNT)); Assert.assertEquals(0, atomType.getProperty(CDKConstants.PI_BOND_COUNT)); Assert.assertEquals(0, atomType.getProperty(CDKConstants.SINGLE_ELECTRON_COUNT)); }
if (matched.getFormalNeighbourCount() != CDKConstants.UNSET) { Assert.assertFalse("Number of neighbors is too high", connectionCount > matched.getFormalNeighbourCount());
@Test public void testGetAtomTypeFromOWL_Sybyl() throws Exception { AtomTypeFactory factory = AtomTypeFactory.getInstance("org/openscience/cdk/dict/data/sybyl-atom-types.owl", new ChemObject().getBuilder()); IAtomType atomType = factory.getAtomType("C.3"); Assert.assertNotNull(atomType); Assert.assertEquals("C", atomType.getSymbol()); Assert.assertEquals("C.3", atomType.getAtomTypeName()); Assert.assertEquals(4, atomType.getFormalNeighbourCount().intValue()); Assert.assertEquals(IAtomType.Hybridization.SP3, atomType.getHybridization()); Assert.assertEquals(0, atomType.getFormalCharge().intValue()); Assert.assertNotNull(atomType.getProperty(CDKConstants.LONE_PAIR_COUNT)); Assert.assertTrue(atomType.getProperty(CDKConstants.LONE_PAIR_COUNT) instanceof Integer); Assert.assertEquals(0, ((Integer) atomType.getProperty(CDKConstants.LONE_PAIR_COUNT)).intValue()); Assert.assertNotNull(atomType.getProperty(CDKConstants.PI_BOND_COUNT)); Assert.assertTrue(atomType.getProperty(CDKConstants.PI_BOND_COUNT) instanceof Integer); Assert.assertEquals(0, ((Integer) atomType.getProperty(CDKConstants.PI_BOND_COUNT)).intValue()); }
totalDiff.addChild(AtomTypeHybridizationDifference.construct("H", firstElem.getHybridization(), secondElem.getHybridization())); totalDiff.addChild(IntegerDifference.construct("NC", firstElem.getFormalNeighbourCount(), secondElem.getFormalNeighbourCount())); totalDiff.addChild(DoubleDifference.construct("CR", firstElem.getCovalentRadius(), secondElem.getCovalentRadius()));