InChIToStructure { public IAtomContainer getAtomContainer() { return (molecule); } protected  InChIToStructure(String inchi, IChemObjectBuilder builder); protected  InChIToStructure(String inchi, IChemObjectBuilder builder, String options); protected  InChIToStructure(String inchi, IChemObjectBuilder builder, List<String> options); IAtomContainer getAtomContainer(); INCHI_RET getReturnStatus(); String getMessage(); String getLog(); long[][] getWarningFlags();  }
@Test public void testGetAtomContainer() throws CDKException { InChIToStructure parser = new InChIToStructure("InChI=1S/CH4/h1H4", DefaultChemObjectBuilder.getInstance()); IAtomContainer container = parser.getAtomContainer(); assertNotNull(container); Assert.assertEquals(1, container.getAtomCount()); }
@Test public void nonNullAtomicNumbers() throws CDKException { InChIToStructure parser = new InChIToStructure("InChI=1S/CH4/h1H4", DefaultChemObjectBuilder.getInstance()); IAtomContainer container = parser.getAtomContainer(); for (IAtom atom : container.atoms()) { assertNotNull(atom.getAtomicNumber()); } assertNotNull(container); Assert.assertEquals(1, container.getAtomCount()); }
@Test public void testFixedHydrogens() throws CDKException { InChIToStructure parser = new InChIToStructure("InChI=1/CH2O2/c2-1-3/h1H,(H,2,3)/f/h2H", DefaultChemObjectBuilder.getInstance()); IAtomContainer container = parser.getAtomContainer(); assertNotNull(container); Assert.assertEquals(3, container.getAtomCount()); Assert.assertEquals(2, container.getBondCount()); assertTrue(container.getBond(0).getOrder() == Order.DOUBLE || container.getBond(1).getOrder() == Order.DOUBLE); }
@Test public void r_penta_2_3_diene() throws Exception { InChIToStructure parser = new InChIToStructure("InChI=1S/C5H8/c1-3-5-4-2/h3-4H,1-2H3/t5-/m0/s1", SilentChemObjectBuilder.getInstance()); IAtomContainer container = parser.getAtomContainer(); Iterator<IStereoElement> ses = container.stereoElements().iterator(); org.hamcrest.MatcherAssert.assertThat(container, is(instanceOf(SilentChemObjectBuilder.getInstance().newAtomContainer().getClass()))); assertTrue(ses.hasNext()); IStereoElement se = ses.next(); assertThat(se, is(instanceOf(ExtendedTetrahedral.class))); ExtendedTetrahedral element = (ExtendedTetrahedral) se; assertThat(element.peripherals(), is(new IAtom[]{container.getAtom(5), container.getAtom(0), container.getAtom(1), container.getAtom(6)})); assertThat(element.focus(), is(container.getAtom(4))); assertThat(element.winding(), is(ITetrahedralChirality.Stereo.ANTI_CLOCKWISE)); }
@Test public void s_penta_2_3_diene() throws Exception { InChIToStructure parser = new InChIToStructure("InChI=1S/C5H8/c1-3-5-4-2/h3-4H,1-2H3/t5-/m1/s1", SilentChemObjectBuilder.getInstance()); IAtomContainer container = parser.getAtomContainer(); Iterator<IStereoElement> ses = container.stereoElements().iterator(); org.hamcrest.MatcherAssert.assertThat(container, is(instanceOf(SilentChemObjectBuilder.getInstance().newAtomContainer().getClass()))); assertTrue(ses.hasNext()); IStereoElement se = ses.next(); assertThat(se, is(instanceOf(ExtendedTetrahedral.class))); ExtendedTetrahedral element = (ExtendedTetrahedral) se; assertThat(element.peripherals(), is(new IAtom[]{container.getAtom(5), container.getAtom(0), container.getAtom(1), container.getAtom(6)})); assertThat(element.focus(), is(container.getAtom(4))); assertThat(element.winding(), is(ITetrahedralChirality.Stereo.CLOCKWISE)); }
@Test public void diazene() throws Exception { InChIToStructure parse = new InChIToStructure("InChI=1S/H2N2/c1-2/h1-2H/b2-1+", SilentChemObjectBuilder.getInstance()); IAtomContainer mol = parse.getAtomContainer(); assertThat(mol.getAtomCount(), is(4)); assertThat(mol.stereoElements().iterator().hasNext(), is(true)); }
@Test public void readImplicitDeuteriums() throws Exception { String inchi = "InChI=1S/C22H32O2/c1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22(23)24/h3-4,6-7,9-10,12-13,15-16,18-19H,2,5,8,11,14,17,20-21H2,1H3,(H,23,24)/b4-3-,7-6-,10-9-,13-12-,16-15-,19-18-/i1D3,2D2"; InChIToStructure intostruct = InChIGeneratorFactory.getInstance().getInChIToStructure(inchi, DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = intostruct.getAtomContainer(); int dCount = 0; for (IAtom atom : mol.atoms()) { Integer mass = atom.getMassNumber(); if (mass != null && mass.equals(2)) dCount++; } assertThat(dCount, is(5)); }