InChINumbersTools { public static long[] getNumbers(IAtomContainer atomContainer) throws CDKException { String aux = auxInfo(atomContainer); long[] numbers = new long[atomContainer.getAtomCount()]; parseAuxInfo(aux, numbers); return numbers; }  static long[] getNumbers(IAtomContainer atomContainer); static void parseAuxInfo(String aux, long[] numbers); static long[] getUSmilesNumbers(IAtomContainer container);  }
@Test public void testSimpleNumbering() throws CDKException { IAtomContainer container = new AtomContainer(); container.addAtom(new Atom("O")); container.addAtom(new Atom("C")); container.addBond(0, 1, IBond.Order.SINGLE); long[] numbers = InChINumbersTools.getNumbers(container); Assert.assertEquals(2, numbers.length); Assert.assertEquals(2, numbers[0]); Assert.assertEquals(1, numbers[1]); }
@Test public void testHydrogens() throws CDKException { IAtomContainer container = new AtomContainer(); container.addAtom(new Atom("H")); container.addAtom(new Atom("C")); container.addBond(0, 1, IBond.Order.SINGLE); container.addAtom(new Atom("H")); container.addBond(1, 2, IBond.Order.SINGLE); container.addAtom(new Atom("H")); container.addBond(1, 3, IBond.Order.SINGLE); container.addAtom(new Atom("H")); container.addBond(1, 4, IBond.Order.SINGLE); long[] numbers = InChINumbersTools.getNumbers(container); Assert.assertEquals(5, numbers.length); Assert.assertEquals(0, numbers[0]); Assert.assertEquals(1, numbers[1]); Assert.assertEquals(0, numbers[2]); Assert.assertEquals(0, numbers[3]); Assert.assertEquals(0, numbers[4]); }
@Test public void testGlycine() throws Exception { SmilesParser parser = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer atomContainer = parser.parseSmiles("C(C(=O)O)N"); long[] numbers = InChINumbersTools.getNumbers(atomContainer); Assert.assertEquals(5, numbers.length); Assert.assertEquals(1, numbers[0]); Assert.assertEquals(2, numbers[1]); Assert.assertEquals(4, numbers[2]); Assert.assertEquals(5, numbers[3]); Assert.assertEquals(3, numbers[4]); }
@Test public void testGlycine_uSmiles() throws Exception { SmilesParser parser = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer atomContainer = parser.parseSmiles("C(C(=O)O)N"); long[] numbers = InChINumbersTools.getNumbers(atomContainer); Assert.assertEquals(5, numbers.length); Assert.assertEquals(1, numbers[0]); Assert.assertEquals(2, numbers[1]); Assert.assertEquals(4, numbers[2]); Assert.assertEquals(5, numbers[3]); Assert.assertEquals(3, numbers[4]); }