public void testForDuplicateDefinitions() { IAtomType[] expectedTypesArray = getFactory().getAllAtomTypes(); Set<String> alreadyDefinedTypes = new HashSet<String>(); for (int i = 0; i < expectedTypesArray.length; i++) { String definedType = expectedTypesArray[i].getAtomTypeName(); if (alreadyDefinedTypes.contains(definedType)) { Assert.fail("Duplicate atom type definition in XML: " + definedType); } alreadyDefinedTypes.add(definedType); } }
public void assertAtomType(Map<String, Integer> testedAtomTypes, String error, String expectedID, IAtomType foundAtomType) { addTestedAtomType(testedAtomTypes, expectedID); Assert.assertNotNull("No atom type was recognized, but expected: " + expectedID, foundAtomType); Assert.assertEquals(error, expectedID, foundAtomType.getAtomTypeName()); }
@Test public void testFindMatchingAtomType_IAtomContainer() throws Exception { String filename = "data/mol2/atomtyping.mol2"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); Mol2Reader reader = new Mol2Reader(ins); IAtomContainer mol = (IAtomContainer) reader.read(new AtomContainer()); // just check consistency; other methods do perception testing SybylAtomTypeMatcher matcher = SybylAtomTypeMatcher.getInstance(DefaultChemObjectBuilder.getInstance()); IAtomType[] types = matcher.findMatchingAtomTypes(mol); for (int i = 0; i < types.length; i++) { IAtomType type = matcher.findMatchingAtomType(mol, mol.getAtom(i)); Assert.assertEquals(type.getAtomTypeName(), types[i].getAtomTypeName()); } }
@Test public void test4Sulphur() throws Exception { String smiles = "Br.Br.CS(CCC(N)C#N)C[C@H]1OC([C@H](O)[C@@H]1O)n2cnc3c(N)ncnc23"; IAtomContainer mol = smilesParser.parseSmiles(smiles); IAtomType[] types = atomTypeMatcher.findMatchingAtomTypes(mol); for (IAtomType type : types) { Assert.assertNotNull(type.getAtomTypeName()); } }
@Test public void testYetAnotherNitrogen() throws Exception { String smiles = "CCCN1CC(CSC)CC2C1Cc3c[nH]c4cccc2c34"; IAtomContainer mol = smilesParser.parseSmiles(smiles); IAtomType[] types = atomTypeMatcher.findMatchingAtomTypes(mol); for (IAtomType type : types) { Assert.assertNotNull(type.getAtomTypeName()); } }
@Test public void testGetAtomTypeName() { IAtomType at = (IAtomType) newChemObject(); at.setAtomTypeName("C4"); Assert.assertEquals("C4", at.getAtomTypeName()); }
@Test public void testSetAtomTypeName_String() { IAtomType at = (IAtomType) newChemObject(); at.setAtomTypeName("C4"); 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_String_String() { IAtomType at = new AtomType("C4", "C"); Assert.assertEquals("C", at.getSymbol()); Assert.assertEquals("C4", at.getAtomTypeName()); }
@Test public void testDebugAtomType_String_String() { IAtomType at = new DebugAtomType("C4", "C"); Assert.assertEquals("C", at.getSymbol()); Assert.assertEquals("C4", at.getAtomTypeName()); }
/** * Uses findMatchingAtomType(IAtomContainer) type. */ @Test public void testBenzene_AtomContainer() throws Exception { IAtomContainer benzene = TestMoleculeFactory.makeBenzene(); // test if the perceived atom types match that SybylAtomTypeMatcher matcher = SybylAtomTypeMatcher.getInstance(benzene.getBuilder()); IAtomType[] types = matcher.findMatchingAtomTypes(benzene); for (IAtomType type : types) { Assert.assertEquals("C.ar", type.getAtomTypeName()); } }
@Test public void testNitrogen_SP2() throws Exception { String smiles1 = "c1c2cc[nH]cc2nc1"; IAtomContainer mol1 = smilesParser.parseSmiles(smiles1); Assert.assertEquals(9, mol1.getAtomCount()); IAtomType[] types1 = atomTypeMatcher.findMatchingAtomTypes(mol1); for (IAtomType type : types1) { Assert.assertNotNull(type.getAtomTypeName()); } }
/** * Uses findMatchingAtomType(IAtomContainer, IAtom) type. */ @Test public void testBenzene() throws Exception { IAtomContainer benzene = TestMoleculeFactory.makeBenzene(); // test if the perceived atom types match that SybylAtomTypeMatcher matcher = SybylAtomTypeMatcher.getInstance(benzene.getBuilder()); IAtomType[] types = matcher.findMatchingAtomTypes(benzene); for (IAtomType type : types) { Assert.assertEquals("C.ar", type.getAtomTypeName()); } }
@Test public void testNitrogen() throws Exception { String smiles1 = "c1c2cc[NH]cc2nc1"; IAtomContainer mol1 = smilesParser.parseSmiles(smiles1); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1); Assert.assertEquals(9, mol1.getAtomCount()); IAtomType[] types1 = atomTypeMatcher.findMatchingAtomTypes(mol1); for (IAtomType type : types1) { Assert.assertNotNull(type.getAtomTypeName()); } }
@Test public void testSetMM2Parameters() throws CDKException { forceFieldConfigurator.setMM2Parameters(DefaultChemObjectBuilder.getInstance()); assertNotNull(forceFieldConfigurator.getParameterSet()); List<IAtomType> atomtypeList = forceFieldConfigurator.getAtomTypes(); IAtomType atomtype1 = atomtypeList.get(1); assertEquals("Csp2", atomtype1.getAtomTypeName()); assertEquals(6, (int) atomtype1.getAtomicNumber()); assertEquals(12, (int) atomtype1.getMassNumber()); }
@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 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 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()); }
/** * @cdk.bug 1382 */ @Test public void testCarbonDiradical() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom atom = new Atom("C"); mol.addAtom(atom); mol.addSingleElectron(0); mol.addSingleElectron(0); IAtomTypeMatcher atm = getAtomTypeMatcher(mol.getBuilder()); IAtomType foundType = atm.findMatchingAtomType(mol, atom); Assert.assertEquals("X", foundType.getAtomTypeName()); }