/** * Get an array of all atomTypes known to the AtomTypeFactory for the given * element symbol and atomtype class. * * @param symbol An element symbol to search for * @return An array of atomtypes that matches the given element symbol * and atomtype class */ public IAtomType[] getAtomTypes(String symbol) { logger.debug("Request for atomtype for symbol ", symbol); List<IAtomType> atomList = new ArrayList<IAtomType>(); for (IAtomType atomType : atomTypes.values()) { if (Objects.equals(atomType.getSymbol(), symbol)) { atomList.add(atomType); } } IAtomType[] atomTypes = (IAtomType[]) atomList.toArray(new IAtomType[atomList.size()]); if (atomTypes.length > 0) logger.debug("Atomtype for symbol ", symbol, " has this number of types: " + atomTypes.length); else logger.debug("No atomtype for symbol ", symbol); return atomTypes; }
@Test public void testDebugAtomType_String() { IAtomType at = new DebugAtomType("C"); Assert.assertEquals("C", at.getSymbol()); }
@Test public void testAtomType_String() { IAtomType at = new AtomType("C"); Assert.assertEquals("C", at.getSymbol()); }
@Test public void testAtomType_String() { IAtomType at = new AtomType("C"); Assert.assertEquals("C", at.getSymbol()); }
@Test public void testGetAtomTypes_String() throws Exception { IAtomType[] atomTypes = atf.getAtomTypes("C"); Assert.assertNotNull(atomTypes); Assert.assertTrue(0 < atomTypes.length); Assert.assertEquals("C", atomTypes[0].getSymbol()); }
@Test public void testAtomType_String_String() { IAtomType at = new AtomType("C4", "C"); Assert.assertEquals("C", at.getSymbol()); Assert.assertEquals("C4", at.getAtomTypeName()); }
@Test public void testAtomType_String_String() { IAtomType at = new AtomType("C4", "C"); Assert.assertEquals("C", at.getSymbol()); Assert.assertEquals("C4", at.getAtomTypeName()); }
@Test public void testAtomType_IElement() { IElement element = new Element("C"); IAtomType at = element.getBuilder().newInstance(IAtomType.class, element); Assert.assertEquals("C", at.getSymbol()); }
@Test public void testDebugAtomType_IElement() { IElement element = new DebugElement("C"); IAtomType at = element.getBuilder().newInstance(IAtomType.class, element); Assert.assertEquals("C", at.getSymbol()); }
@Test public void testDebugAtomType_String_String() { IAtomType at = new DebugAtomType("C4", "C"); Assert.assertEquals("C", at.getSymbol()); Assert.assertEquals("C4", at.getAtomTypeName()); }
@Test public void testAtomType_IElement() { IElement element = newChemObject().getBuilder().newInstance(IElement.class, "C"); IAtomType at = new AtomType(element); Assert.assertEquals("C", at.getSymbol()); }
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 testPossibleAtomTypes_IAtomContainer_IAtom() throws java.lang.Exception { IAtomContainer mol = new AtomContainer(); Atom atom = new Atom("C"); atom.setImplicitHydrogenCount(3); Atom atom2 = new Atom("N"); atom2.setImplicitHydrogenCount(2); mol.addAtom(atom); mol.addAtom(atom2); mol.addBond(new Bond(atom, atom2, IBond.Order.SINGLE)); StructGenAtomTypeGuesser atm = new StructGenAtomTypeGuesser(); List<IAtomType> matched = atm.possibleAtomTypes(mol, atom); Assert.assertNotNull(matched); Assert.assertTrue(matched.size() > 0); Assert.assertTrue(matched.get(0) instanceof IAtomType); Assert.assertEquals("C", ((IAtomType) matched.get(0)).getSymbol()); }
@Test public void testN3() throws Exception { IAtomContainer mol = new AtomContainer(); Atom atom = new Atom("N"); atom.setImplicitHydrogenCount(3); mol.addAtom(atom); StructGenMatcher atm = new StructGenMatcher(); IAtomType matched = atm.findMatchingAtomType(mol, atom); Assert.assertNotNull(matched); Assert.assertEquals("N", matched.getSymbol()); }
@Test public void testGetAtomTypeFromPDB() throws Exception { AtomTypeFactory factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/pdb_atomtypes.xml", new ChemObject().getBuilder()); IAtomType atomType = factory.getAtomType("ALA.CA"); Assert.assertNotNull(atomType); Assert.assertEquals("C", atomType.getSymbol()); Assert.assertEquals("ALA.CA", atomType.getAtomTypeName()); }
@Test public void testGetAtomTypeFromJmol() throws Exception { AtomTypeFactory factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/jmol_atomtypes.txt", new ChemObject().getBuilder()); IAtomType atomType = factory.getAtomType("H"); Assert.assertNotNull(atomType); Assert.assertEquals("H", atomType.getSymbol()); Assert.assertEquals("H", atomType.getAtomTypeName()); }
@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)); }
@Test public void testGetAtomType_String() throws Exception { IAtomType atomType = atf.getAtomType("C4"); Assert.assertNotNull(atomType); Assert.assertEquals("C", atomType.getSymbol()); Assert.assertEquals("C4", atomType.getAtomTypeName()); Assert.assertEquals(4.0, atomType.getBondOrderSum(), 0.001); Assert.assertEquals(IBond.Order.TRIPLE, atomType.getMaxBondOrder()); }
@Test public void testFindMatchingAtomType_IAtomContainer_IAtom() throws Exception { IAtomContainer mol = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class); IAtom atom = DefaultChemObjectBuilder.getInstance().newInstance(IAtom.class, "C"); atom.setImplicitHydrogenCount(4); mol.addAtom(atom); StructGenMatcher atm = new StructGenMatcher(); IAtomType matched = atm.findMatchingAtomType(mol, atom); Assert.assertNotNull(matched); Assert.assertEquals("C", matched.getSymbol()); }
@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()); }