@Test public void imidazole() throws Exception { Graph g = convert(TestMoleculeFactory.makeImidazole(), true, SmiFlavor.UseAromaticSymbols); assertThat(g.toSmiles(), is("c1[nH]cnc1")); }
@Test public void imidazole_ignoreAromatic() throws Exception { Graph g = convert(TestMoleculeFactory.makeImidazole(), true, 0); assertThat(g.toSmiles(), is("C=1NC=NC1")); }
@Test public void benzene_kekule() throws Exception { Graph g = convert(TestMoleculeFactory.makeBenzene(), 0); assertThat(g.toSmiles(), is("C=1C=CC=CC1")); }
@Test public void benzene() throws Exception { IAtomContainer ac = TestMoleculeFactory.makeBenzene(); Graph g = convert(ac, true, SmiFlavor.UseAromaticSymbols); assertThat(g.toSmiles(), is("c1ccccc1")); }
@Test public void adeneine() throws Exception { Graph g = convert(TestMoleculeFactory.makeAdenine(), 0); assertThat(g.toSmiles(), is("C12=C(N=CN=C1N)NC=N2")); }
@Test public void imidazole_kekule() throws Exception { Graph g = convert(TestMoleculeFactory.makeImidazole(), false, 0); assertThat(g.toSmiles(), is("C=1NC=NC1")); }
/** * * @param ac * @return * @throws CDKException * @throws IOException */ public static String create(IAtomContainer ac) throws CDKException, IOException { EdgeToBondMap bonds = withSpaceFor(ac); int[][] graph = toAdjList(ac, bonds); long[] labels = label(ac, graph, betterInvariants(ac, graph, bonds)); Graph g = CDK2BEAM.toBeamGraph(ac); g = g.permute(toPermutation(labels)); g = g.resonate(); // ensure consistent Kekule form return g.toSmiles(); }
@Test public void oxidanide() throws Exception { IAtomContainer ac = new AtomContainer(); IAtom a = new Atom("O"); a.setFormalCharge(-1); ac.addAtom(a); Graph g = convert(ac, 0); assertThat(g.atom(0).charge(), is(-1)); assertThat(g.toSmiles(), is("[OH-]")); }
@Test public void oxidandiide() throws Exception { IAtomContainer ac = new AtomContainer(); IAtom a = new Atom("O"); a.setFormalCharge(-2); ac.addAtom(a); Graph g = convert(ac, 0); assertThat(g.atom(0).charge(), is(-2)); assertThat(g.toSmiles(), is("[O-2]")); }
@Test public void C13_nonIsomeric() throws Exception { IAtomContainer ac = new AtomContainer(); IAtom a = new Atom("C"); a.setMassNumber(13); ac.addAtom(a); Graph g = convert(ac, false, 0); // non-isomeric assertThat(g.atom(0).isotope(), is(-1)); assertThat(g.toSmiles(), is("C")); }
@Test public void C13_isomeric() throws Exception { IAtomContainer ac = new AtomContainer(); IAtom a = new Atom("C"); a.setMassNumber(13); ac.addAtom(a); Graph g = convert(ac, SmiFlavor.AtomicMass); assertThat(g.atom(0).isotope(), is(13)); assertThat(g.toSmiles(), is("[13CH4]")); }
@Test public void azanium() throws Exception { IAtomContainer ac = new AtomContainer(); IAtom a = new Atom("N"); a.setFormalCharge(+1); ac.addAtom(a); Graph g = convert(ac, 0); assertThat(g.atom(0).charge(), is(+1)); assertThat(g.toSmiles(), is("[NH4+]")); }
@Test public void writeAtomClass() throws Exception { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("O")); ac.addBond(0, 1, SINGLE); ac.addBond(1, 2, SINGLE); ac.getAtom(0).setProperty(CDKConstants.ATOM_ATOM_MAPPING, 3); ac.getAtom(1).setProperty(CDKConstants.ATOM_ATOM_MAPPING, 1); ac.getAtom(2).setProperty(CDKConstants.ATOM_ATOM_MAPPING, 2); assertThat(convert(ac, SmiFlavor.AtomAtomMap).toSmiles(), is("[CH3:3][CH2:1][OH:2]")); }
@Test public void s_penta_2_3_diene_impl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(0), m.getAtom(1), m.getAtom(3), m.getAtom(4)}, CLOCKWISE); m.setStereoElements(Collections.singletonList(element)); assertThat(convert(m, SmiFlavor.Stereo).toSmiles(), is("CC=[C@@]=CC")); }
@Test public void r_penta_2_3_diene_impl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(0), m.getAtom(1), m.getAtom(3), m.getAtom(4)}, ANTI_CLOCKWISE); m.setStereoElements(Collections.singletonList(element)); assertThat(convert(m, SmiFlavor.Stereo).toSmiles(), is("CC=[C@]=CC")); }
/** * (E)-1,2-difluoroethene * * @cdk.inchi InChI=1/C2H2F2/c3-1-2-4/h1-2H/b2-1+ */ @Test public void e_1_2_difluoroethene() throws Exception { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("F")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("F")); ac.addBond(0, 1, SINGLE); ac.addBond(1, 2, DOUBLE); ac.addBond(2, 3, SINGLE); ac.addStereoElement(new DoubleBondStereochemistry(ac.getBond(1), new IBond[]{ac.getBond(0), ac.getBond(2)}, OPPOSITE)); Graph g = convert(ac, SmiFlavor.StereoCisTrans); assertThat(g.toSmiles(), is("F/C=C/F")); }
/** * (Z)-1,2-difluoroethene * * @cdk.inchi InChI=1/C2H2F2/c3-1-2-4/h1-2H/b2-1- */ @Test public void z_1_2_difluoroethene() throws Exception { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("F")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("F")); ac.addBond(0, 1, SINGLE); ac.addBond(1, 2, DOUBLE); ac.addBond(2, 3, SINGLE); ac.addStereoElement(new DoubleBondStereochemistry(ac.getBond(1), new IBond[]{ac.getBond(0), ac.getBond(2)}, TOGETHER)); Graph g = convert(ac, SmiFlavor.StereoCisTrans); assertThat(g.toSmiles(), is("F/C=C\\F")); }
@Test public void s_penta_2_3_diene_expl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("H")); m.addAtom(new Atom("H")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); m.addBond(1, 5, IBond.Order.SINGLE); m.addBond(3, 6, IBond.Order.SINGLE); int[][] atoms = new int[][]{{0, 5, 6, 4}, {5, 0, 6, 4}, {5, 0, 4, 6}, {0, 5, 4, 6}, {4, 6, 5, 0}, {4, 6, 0, 5}, {6, 4, 0, 5}, {6, 4, 5, 0},}; Stereo[] stereos = new Stereo[]{Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE}; for (int i = 0; i < atoms.length; i++) { IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(atoms[i][0]), m.getAtom(atoms[i][1]), m.getAtom(atoms[i][2]), m.getAtom(atoms[i][3])}, stereos[i]); m.setStereoElements(Collections.singletonList(element)); assertThat(convert(m, SmiFlavor.Stereo).toSmiles(), is("CC(=[C@]=C(C)[H])[H]")); } }
/** * (2R)-butan-2-ol * * @cdk.inchi InChI=1/C4H10O/c1-3-4(2)5/h4-5H,3H2,1-2H3/t4-/s2 */ @Test public void _2R_butan_2_ol() throws Exception { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("O")); ac.addAtom(new Atom("H")); ac.addBond(0, 1, SINGLE); ac.addBond(1, 2, SINGLE); ac.addBond(2, 3, SINGLE); ac.addBond(2, 4, SINGLE); ac.addBond(2, 5, SINGLE); ac.addStereoElement(new TetrahedralChirality(ac.getAtom(2), new IAtom[]{ac.getAtom(1), // C-C ac.getAtom(3), // C ac.getAtom(4), // O ac.getAtom(5), // H }, CLOCKWISE)); Graph g = convert(ac, SmiFlavor.StereoTetrahedral); assertThat(g.toSmiles(), is("CC[C@@](C)(O)[H]")); }
/** * (2S)-butan-2-ol * * @cdk.inchi InChI=1/C4H10O/c1-3-4(2)5/h4-5H,3H2,1-2H3/t4-/s2 */ @Test public void _2S_butan_2_ol() throws Exception { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("O")); ac.addAtom(new Atom("H")); ac.addBond(0, 1, SINGLE); ac.addBond(1, 2, SINGLE); ac.addBond(2, 3, SINGLE); ac.addBond(2, 4, SINGLE); ac.addBond(2, 5, SINGLE); ac.addStereoElement(new TetrahedralChirality(ac.getAtom(2), new IAtom[]{ac.getAtom(1), // C-C ac.getAtom(3), // C ac.getAtom(4), // O ac.getAtom(5), // H }, ANTI_CLOCKWISE)); Graph g = convert(ac, SmiFlavor.StereoTetrahedral); assertThat(g.toSmiles(), is("CC[C@](C)(O)[H]")); }