MmffAtomTypeMatcher { String[] symbolicTypes(final IAtomContainer container) { EdgeToBondMap bonds = EdgeToBondMap.withSpaceFor(container); int[][] graph = GraphUtil.toAdjList(container, bonds); return symbolicTypes(container, graph, bonds, new HashSet<IBond>()); } MmffAtomTypeMatcher();   }
@Test(expected = IllegalArgumentException.class) public void hydrogenCountMustBeDefined() { IAtomContainer container = new AtomContainer(); container.addAtom(new Atom("C")); container.addAtom(new Atom("H")); container.addAtom(new Atom("H")); container.addAtom(new Atom("H")); container.addAtom(new Atom("H")); container.addBond(0, 1, SINGLE); container.addBond(0, 2, SINGLE); container.addBond(0, 3, SINGLE); container.addBond(0, 4, SINGLE); container.getAtom(0).setImplicitHydrogenCount(null); INSTANCE.symbolicTypes(container); }
@Test(expected = IllegalArgumentException.class) public void hydrogenCountMustBeExplicit() { IAtomContainer container = new AtomContainer(); container.addAtom(new Atom("C")); container.getAtom(0).setImplicitHydrogenCount(4); INSTANCE.symbolicTypes(container); }
@Test(expected = IllegalArgumentException.class) public void aromaticCompoundsAreRejected() { IAtomContainer container = new AtomContainer(); container.addAtom(new Atom("C")); container.getAtom(0).setImplicitHydrogenCount(4); container.getAtom(0).setFlag(CDKConstants.ISAROMATIC, true); INSTANCE.symbolicTypes(container); }
@Test public void bug3523240IsResolved() throws Exception { IAtomContainer container = new AtomContainer(50, 51, 0, 0); container.addAtom(atom("H", 0)); container.addAtom(atom("O", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("O", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("N", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("O", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addBond(0, 1, IBond.Order.SINGLE); container.addBond(1, 2, IBond.Order.SINGLE); container.addBond(2, 3, IBond.Order.DOUBLE); container.addBond(2, 4, IBond.Order.SINGLE); container.addBond(4, 5, IBond.Order.SINGLE); container.addBond(4, 6, IBond.Order.SINGLE); container.addBond(6, 7, IBond.Order.SINGLE); container.addBond(6, 8, IBond.Order.SINGLE); container.addBond(8, 9, IBond.Order.DOUBLE); container.addBond(8, 10, IBond.Order.SINGLE); container.addBond(10, 11, IBond.Order.SINGLE); container.addBond(10, 12, IBond.Order.SINGLE); container.addBond(12, 13, IBond.Order.SINGLE); container.addBond(12, 14, IBond.Order.SINGLE); container.addBond(12, 15, IBond.Order.SINGLE); container.addBond(15, 16, IBond.Order.SINGLE); container.addBond(15, 17, IBond.Order.SINGLE); container.addBond(15, 18, IBond.Order.SINGLE); container.addBond(18, 19, IBond.Order.SINGLE); container.addBond(18, 20, IBond.Order.SINGLE); container.addBond(20, 21, IBond.Order.SINGLE); container.addBond(20, 22, IBond.Order.SINGLE); container.addBond(20, 23, IBond.Order.SINGLE); container.addBond(10, 23, IBond.Order.SINGLE); container.addBond(23, 24, IBond.Order.SINGLE); container.addBond(23, 25, IBond.Order.SINGLE); container.addBond(18, 26, IBond.Order.SINGLE); container.addBond(26, 27, IBond.Order.SINGLE); container.addBond(26, 28, IBond.Order.SINGLE); container.addBond(28, 29, IBond.Order.SINGLE); container.addBond(28, 30, IBond.Order.SINGLE); container.addBond(28, 31, IBond.Order.SINGLE); container.addBond(26, 32, IBond.Order.SINGLE); container.addBond(32, 33, IBond.Order.SINGLE); container.addBond(32, 34, IBond.Order.SINGLE); container.addBond(32, 35, IBond.Order.SINGLE); container.addBond(4, 36, IBond.Order.SINGLE); container.addBond(36, 37, IBond.Order.SINGLE); container.addBond(36, 38, IBond.Order.SINGLE); container.addBond(36, 39, IBond.Order.SINGLE); container.addBond(39, 40, IBond.Order.DOUBLE); container.addBond(40, 41, IBond.Order.SINGLE); container.addBond(40, 42, IBond.Order.SINGLE); container.addBond(42, 43, IBond.Order.SINGLE); container.addBond(42, 44, IBond.Order.DOUBLE); container.addBond(44, 45, IBond.Order.SINGLE); container.addBond(44, 46, IBond.Order.SINGLE); container.addBond(46, 47, IBond.Order.SINGLE); container.addBond(46, 48, IBond.Order.DOUBLE); container.addBond(39, 48, IBond.Order.SINGLE); container.addBond(48, 49, IBond.Order.SINGLE); String[] expected = {"HOCO", "OC=O", "COO", "O=CO", "CR", "HC", "NC=O", "HNCO", "C=ON", "O=CN", "CR", "HC", "CR", "HC", "HC", "CR", "HC", "HC", "CR", "HC", "CR", "HC", "HC", "CR", "HC", "HC", "CR", "HC", "CR", "HC", "HC", "HC", "CR", "HC", "HC", "HC", "CR", "HC", "HC", "CB", "CB", "HC", "CB", "HC", "CB", "HC", "CB", "HC", "CB", "HC"}; String[] actual = INSTANCE.symbolicTypes(container); Assert.assertArrayEquals(expected, actual); }
@Test public void bug3524734IsResolved() throws Exception { IAtomContainer container = new AtomContainer(10, 9, 0, 0); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("N", 0)); container.addAtom(atom("O", 0)); container.addAtom(atom("O", 0)); container.addBond(0, 1, IBond.Order.SINGLE); container.addBond(1, 2, IBond.Order.SINGLE); container.addBond(1, 3, IBond.Order.SINGLE); container.addBond(1, 4, IBond.Order.SINGLE); container.addBond(4, 5, IBond.Order.SINGLE); container.addBond(4, 6, IBond.Order.SINGLE); container.addBond(4, 7, IBond.Order.SINGLE); container.addBond(7, 8, IBond.Order.SINGLE); container.addBond(7, 9, IBond.Order.DOUBLE); String[] expected = {"HC", "CR", "HC", "HC", "CR", "HC", "HC", "NO2", "O2N", "O2N"}; String[] actual = INSTANCE.symbolicTypes(container); Assert.assertArrayEquals(expected, actual); }
@Test public void hydroxyurea() { IAtomContainer container = new AtomContainer(9, 8, 0, 0); container.addAtom(atom("H", 0)); container.addAtom(atom("O", 0)); container.addAtom(atom("N", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("O", 0)); container.addAtom(atom("N", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addBond(0, 1, IBond.Order.SINGLE); container.addBond(1, 2, IBond.Order.SINGLE); container.addBond(2, 3, IBond.Order.SINGLE); container.addBond(2, 4, IBond.Order.SINGLE); container.addBond(4, 5, IBond.Order.DOUBLE); container.addBond(4, 6, IBond.Order.SINGLE); container.addBond(6, 7, IBond.Order.SINGLE); container.addBond(6, 8, IBond.Order.SINGLE); String[] expected = {"HO", "-O-", "NC=O", "HNCO", "CONN", "O=CN", "NC=O", "HNCO", "HNCO"}; String[] actual = INSTANCE.symbolicTypes(container); Assert.assertArrayEquals(expected, actual); }
@Test public void molecularHydrogenDoesNotBreakAssignment() { IAtomContainer container = new AtomContainer(2, 1, 0, 0); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addBond(0, 1, SINGLE); String[] expected = {null, null}; String[] actual = INSTANCE.symbolicTypes(container); Assert.assertArrayEquals(expected, actual); }
@Test public void methylamine() { IAtomContainer container = new AtomContainer(7, 6, 0, 0); container.addAtom(atom("H", 0)); container.addAtom(atom("N", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addBond(0, 1, IBond.Order.SINGLE); container.addBond(1, 2, IBond.Order.SINGLE); container.addBond(1, 3, IBond.Order.SINGLE); container.addBond(3, 4, IBond.Order.SINGLE); container.addBond(3, 5, IBond.Order.SINGLE); container.addBond(3, 6, IBond.Order.SINGLE); String[] expected = {"HNR", "NR", "HNR", "CR", "HC", "HC", "HC"}; String[] actual = INSTANCE.symbolicTypes(container); Assert.assertArrayEquals(expected, actual); }
@Test public void thiophene() { IAtomContainer container = new AtomContainer(9, 9, 0, 0); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("S", 0)); container.addBond(0, 1, IBond.Order.SINGLE); container.addBond(1, 2, IBond.Order.DOUBLE); container.addBond(2, 3, IBond.Order.SINGLE); container.addBond(2, 4, IBond.Order.SINGLE); container.addBond(4, 5, IBond.Order.SINGLE); container.addBond(4, 6, IBond.Order.DOUBLE); container.addBond(6, 7, IBond.Order.SINGLE); container.addBond(6, 8, IBond.Order.SINGLE); container.addBond(1, 8, IBond.Order.SINGLE); String[] expected = {"HC", "C5A", "C5B", "HC", "C5B", "HC", "C5A", "HC", "STHI"}; String[] actual = INSTANCE.symbolicTypes(container); Assert.assertArrayEquals(expected, actual); }
@Test public void furane() { IAtomContainer container = new AtomContainer(9, 9, 0, 0); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("O", 0)); container.addBond(0, 1, IBond.Order.SINGLE); container.addBond(1, 2, IBond.Order.DOUBLE); container.addBond(2, 3, IBond.Order.SINGLE); container.addBond(2, 4, IBond.Order.SINGLE); container.addBond(4, 5, IBond.Order.SINGLE); container.addBond(4, 6, IBond.Order.DOUBLE); container.addBond(6, 7, IBond.Order.SINGLE); container.addBond(6, 8, IBond.Order.SINGLE); container.addBond(1, 8, IBond.Order.SINGLE); String[] expected = {"HC", "C5A", "C5B", "HC", "C5B", "HC", "C5A", "HC", "OFUR"}; String[] actual = INSTANCE.symbolicTypes(container); Assert.assertArrayEquals(expected, actual); }
@Test public void methane() { IAtomContainer container = new AtomContainer(); container.addAtom(atom("C", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addAtom(atom("H", 0)); container.addBond(0, 1, SINGLE); container.addBond(0, 2, SINGLE); container.addBond(0, 3, SINGLE); container.addBond(0, 4, SINGLE); String[] expected = {"CR", "HC", "HC", "HC", "HC"}; String[] actual = INSTANCE.symbolicTypes(container); Assert.assertArrayEquals(expected, actual); }