SmilesParser { public IAtomContainer parseSmiles(String smiles) throws InvalidSmilesException { return parseSmiles(smiles, false); } SmilesParser(final IChemObjectBuilder builder); void setStrict(boolean strict); IReaction parseReactionSmiles(String smiles); IAtomContainer parseSmiles(String smiles); @Deprecated void setPreservingAromaticity(boolean preservingAromaticity); @Deprecated boolean isPreservingAromaticity(); void kekulise(boolean kekulise);  }
@Test(timeout = 1000) public void testBug1579229() throws Exception { String smiles = "c1c(c23)ccc(c34)ccc4ccc2c1"; IAtomContainer mol = sp.parseSmiles(smiles); atomtype(mol); assertAtomTypesPerceived(mol); Assert.assertEquals(14, mol.getAtomCount()); assertTrue(Aromaticity.cdkLegacy().apply(mol)); for (IAtom atom : mol.atoms()) { Assert.assertEquals(IAtomType.Hybridization.SP2, atom.getHybridization()); } }
@Ignore @Test(timeout = 1000) public void testAromaticSmilesWithCharge() throws Exception { String smiles = "c1cc[c-]c1"; IAtomContainer molecule = sp.parseSmiles(smiles); assertAtomTypesPerceived(molecule); assertTrue(molecule.getAtom(0).getFlag(CDKConstants.ISAROMATIC)); assertTrue(molecule.getBond(0).getFlag(CDKConstants.ISAROMATIC)); }
@Test public void testConnectedByRingClosure_TwoAtom() throws Exception { String methanol = "C1.O1"; IAtomContainer mol = sp.parseSmiles(methanol); Assert.assertEquals(2, mol.getAtomCount()); Assert.assertEquals(1, mol.getBondCount()); IAtomContainerSet fragments = ConnectivityChecker.partitionIntoMolecules(mol); int fragmentCount = fragments.getAtomContainerCount(); Assert.assertEquals(1, fragmentCount); IAtomContainer mol1 = fragments.getAtomContainer(0); Assert.assertEquals(2, mol1.getAtomCount()); }
@Test(timeout = 1000) public void testTungsten() throws Exception { String smiles = "[W]"; IAtomContainer mol = sp.parseSmiles(smiles); assertAtomTypesPerceived(mol); Assert.assertEquals(1, mol.getAtomCount()); Assert.assertEquals("W", mol.getAtom(0).getSymbol()); }
@Test public void testMercaptan() throws Exception { IAtomContainer mol = sp.parseSmiles("C=CCS"); assertAtomTypesPerceived(mol); }
@Test public void test3amino4methylpyridine() throws Exception { IAtomContainer mol = sp.parseSmiles("c1c(C)c(N)cnc1"); assertAtomTypesPerceived(mol); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); boolean isaromatic = Aromaticity.cdkLegacy().apply(mol); assertTrue(isaromatic); }
@Test(expected = InvalidSmilesException.class) public void testPyrrole3() throws Exception { String smiles = "n1cccc1"; sp.parseSmiles(smiles); }
@Test(expected = InvalidSmilesException.class) public void testImidazole3() throws Exception { String smiles = "n1cncc1"; sp.parseSmiles(smiles); }
@Test public void testBug1963731() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer molecule = sp.parseSmiles("C(C1C(C(C(C(O1)O)N)O)O)O"); int hcount = 0; for (int i = 0; i < molecule.getBondCount(); i++) { hcount += molecule.getAtom(i).getImplicitHydrogenCount(); } Assert.assertEquals(13, hcount); }
@Test public void testONSSolubility1() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer molecule = sp.parseSmiles("Oc1ccc(cc1OC)C=O"); Assert.assertEquals(11, molecule.getAtomCount()); Assert.assertEquals(11, molecule.getBondCount()); }
@Test public void test1456139() throws Exception { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("Cc1nn(C)cc1[C@H]2[C@H](C(=O)N)C(=O)C[C@@](C)(O)[C@@H]2C(=O)N"); IAtomContainer mol2 = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class, mol); Assert.assertNotNull(mol2); Assert.assertEquals(22, mol2.getAtomCount()); }
@Test public void testExplicitH() throws Exception { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol; mol = p.parseSmiles("CO[H]"); Assert.assertEquals(3, mol.getAtomCount()); mol = p.parseSmiles("[CH3][OH]"); Assert.assertEquals(2, mol.getAtomCount()); mol = p.parseSmiles("C([H])([H])([H])O([H])"); Assert.assertEquals(6, mol.getAtomCount()); }
@Test public void testno937() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C[nH0]1c[nH0]cc1"); Assert.assertNotNull(mol.getAtom(1).getImplicitHydrogenCount()); Assert.assertEquals(0, mol.getAtom(1).getImplicitHydrogenCount().intValue()); Assert.assertNotNull(mol.getAtom(3).getImplicitHydrogenCount()); Assert.assertEquals(0, mol.getAtom(3).getImplicitHydrogenCount().intValue()); }
@Test public void testHardcodedH() throws InvalidSmilesException { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C[CH1]NC"); Assert.assertNotNull(mol.getAtom(1).getImplicitHydrogenCount()); Assert.assertEquals(1, mol.getAtom(1).getImplicitHydrogenCount().intValue()); mol = sp.parseSmiles("C[CH]NC"); Assert.assertNotNull(mol.getAtom(1).getImplicitHydrogenCount()); Assert.assertEquals(1, mol.getAtom(1).getImplicitHydrogenCount().intValue()); mol = sp.parseSmiles("C[CH0]NC"); Assert.assertNotNull(mol.getAtom(1).getImplicitHydrogenCount()); Assert.assertEquals(0, mol.getAtom(1).getImplicitHydrogenCount().intValue()); }
@Test(expected = InvalidSmilesException.class) public void testBadRingClosure1() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); p.parseSmiles("c1ccccc1Cc1ccccc"); }
@Test(expected = InvalidSmilesException.class) public void testBadRingClosure2() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); p.parseSmiles("NC1=CC=C(N)C=C"); }
@Test public void testPyrrole_2() throws Exception { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("c1c[nH]cc1"); assertThat(mol.getBond(mol.getAtom(0), mol.getAtom(1)).getOrder(), is(IBond.Order.DOUBLE)); assertThat(mol.getBond(mol.getAtom(1), mol.getAtom(2)).getOrder(), is(IBond.Order.SINGLE)); assertThat(mol.getBond(mol.getAtom(2), mol.getAtom(3)).getOrder(), is(IBond.Order.SINGLE)); assertThat(mol.getBond(mol.getAtom(3), mol.getAtom(4)).getOrder(), is(IBond.Order.DOUBLE)); assertThat(mol.getBond(mol.getAtom(4), mol.getAtom(0)).getOrder(), is(IBond.Order.SINGLE)); atomtype(mol); Aromaticity.cdkLegacy().apply(mol); for (IAtom atom : mol.atoms()) { assertTrue(atom.getFlag(CDKConstants.ISAROMATIC)); } }
@Test public void testCeParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("Cl[Ce](Cl)Cl"); Assert.assertEquals("Ce", mol.getAtom(1).getSymbol()); }
@Test public void testErParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("Cl[Er](Cl)Cl"); Assert.assertEquals("Er", mol.getAtom(1).getSymbol()); }
@Test public void testGdParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("Cl[Gd](Cl)Cl"); Assert.assertEquals("Gd", mol.getAtom(1).getSymbol()); }
@Test public void testSmParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("Cl[Sm](Cl)Cl"); Assert.assertEquals("Sm", mol.getAtom(1).getSymbol()); }
@Test public void testLaParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[Cl-].[Cl-].[Cl-].[La+3]"); Assert.assertEquals("La", mol.getAtom(3).getSymbol()); }
@Test public void testAcParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[255Ac]"); Assert.assertEquals("Ac", mol.getAtom(0).getSymbol()); }
@Test public void testPuParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[Pu]"); Assert.assertEquals("Pu", mol.getAtom(0).getSymbol()); }
@Test public void testPrParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[Pr]"); Assert.assertEquals("Pr", mol.getAtom(0).getSymbol()); }
@Test public void testPaParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[Pa]"); Assert.assertEquals("Pa", mol.getAtom(0).getSymbol()); }
@Test public void testTbParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[Tb]"); Assert.assertEquals("Tb", mol.getAtom(0).getSymbol()); }
@Test public void testAmParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[Am]"); Assert.assertEquals("Am", mol.getAtom(0).getSymbol()); }
@Test public void testPmParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[Pm]"); Assert.assertEquals("Pm", mol.getAtom(0).getSymbol()); }
@Test public void testHoParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[Ho]"); Assert.assertEquals("Ho", mol.getAtom(0).getSymbol()); }
@Test public void testCfParsing() throws InvalidSmilesException { SmilesParser p = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = p.parseSmiles("[Cf]"); Assert.assertEquals("Cf", mol.getAtom(0).getSymbol()); }
@Test public void testAtAt() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("Br[C@@H](Cl)I"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals(mol.getAtom(0), ligands[0]); Assert.assertEquals(mol.getAtom(1), ligands[1]); Assert.assertEquals(mol.getAtom(2), ligands[2]); Assert.assertEquals(mol.getAtom(3), ligands[3]); Assert.assertEquals(Stereo.CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testAt() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("Br[C@H](Cl)I"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals(mol.getAtom(0), ligands[0]); Assert.assertEquals(mol.getAtom(1), ligands[1]); Assert.assertEquals(mol.getAtom(2), ligands[2]); Assert.assertEquals(mol.getAtom(3), ligands[3]); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testAtAt_ExplicitHydrogen() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("Br[C@@]([H])(Cl)I"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals("Br", ligands[0].getSymbol()); Assert.assertEquals("H", ligands[1].getSymbol()); Assert.assertEquals("Cl", ligands[2].getSymbol()); Assert.assertEquals("I", ligands[3].getSymbol()); Assert.assertEquals(Stereo.CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testAt_ExplicitHydrogen() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("Br[C@]([H])(Cl)I"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals("Br", ligands[0].getSymbol()); Assert.assertEquals("H", ligands[1].getSymbol()); Assert.assertEquals("Cl", ligands[2].getSymbol()); Assert.assertEquals("I", ligands[3].getSymbol()); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testRingClosure() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C12(OC1)CCC2"); Assert.assertEquals(6, mol.getAtomCount()); Assert.assertEquals("C", mol.getAtom(0).getSymbol()); Assert.assertEquals("O", mol.getAtom(1).getSymbol()); Assert.assertEquals("C", mol.getAtom(2).getSymbol()); Assert.assertEquals(4, mol.getConnectedBondsCount(mol.getAtom(0))); Assert.assertEquals(2, mol.getConnectedBondsCount(mol.getAtom(1))); Assert.assertEquals(2, mol.getConnectedBondsCount(mol.getAtom(2))); }
@Test public void testRingClosure_At() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[C@]12(OC1)NCN2"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals(mol.getAtom(1), ligands[0]); Assert.assertEquals(mol.getAtom(2), ligands[1]); Assert.assertEquals(mol.getAtom(3), ligands[2]); Assert.assertEquals(mol.getAtom(5), ligands[3]); Assert.assertEquals(Stereo.CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testNeighboringChirality() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); final IAtomContainer mol = sp.parseSmiles("C[C@H](O)[C@H](O)C"); List<IStereoElement> stereoElements = new ArrayList<IStereoElement>(FluentIterable.from(mol.stereoElements()) .toList()); Collections.sort(stereoElements, new Comparator<IStereoElement>() { @Override public int compare(IStereoElement o1, IStereoElement o2) { return Ints.compare(mol.indexOf(((ITetrahedralChirality) o1).getChiralAtom()), mol.indexOf(((ITetrahedralChirality) o2).getChiralAtom())); } }); assertThat(stereoElements.size(), is(2)); IStereoElement stereoElement = stereoElements.get(0); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals(mol.getAtom(0), ligands[0]); Assert.assertEquals(mol.getAtom(1), ligands[1]); Assert.assertEquals(mol.getAtom(2), ligands[2]); Assert.assertEquals(mol.getAtom(3), ligands[3]); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); stereoElement = stereoElements.get(1); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals(mol.getAtom(1), ligands[0]); Assert.assertEquals(mol.getAtom(3), ligands[1]); Assert.assertEquals(mol.getAtom(4), ligands[2]); Assert.assertEquals(mol.getAtom(5), ligands[3]); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testChiralityInBranch() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("NC([C@H](O)C)Cl"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals(mol.getAtom(1), ligands[0]); Assert.assertEquals(mol.getAtom(2), ligands[1]); Assert.assertEquals(mol.getAtom(3), ligands[2]); Assert.assertEquals(mol.getAtom(4), ligands[3]); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testChiralityWithTonsOfDots() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("I1.Cl2.Br3.[C@]123CCC"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals("I", ligands[0].getSymbol()); Assert.assertEquals("Cl", ligands[1].getSymbol()); Assert.assertEquals("Br", ligands[2].getSymbol()); Assert.assertEquals("C", ligands[3].getSymbol()); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testChiralAtomWithDisconnectedLastAtom() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("Br1.[C@]1(Cl)(OC)CCC"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals("Br", ligands[0].getSymbol()); Assert.assertEquals("Cl", ligands[1].getSymbol()); Assert.assertEquals("O", ligands[2].getSymbol()); Assert.assertEquals("C", ligands[3].getSymbol()); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testFromBlog1() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[C@@H]231.C2.N1.F3"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals(mol.getAtom(0), ligands[0]); Assert.assertEquals(mol.getAtom(1), ligands[1]); Assert.assertEquals(mol.getAtom(2), ligands[2]); Assert.assertEquals(mol.getAtom(3), ligands[3]); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); }
@Test public void testFromBlog2() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[C@@H](Cl)1[C@H](C)(F).Br1"); Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator(); for (int i = 0; i < 2; i++) { assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); assertTrue(stereoElement instanceof ITetrahedralChirality); ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); if (l4Chiral.getChiralAtom().equals(mol.getAtom(0))) { IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals(mol.getAtom(0), ligands[0]); Assert.assertEquals(mol.getAtom(1), ligands[1]); Assert.assertEquals(mol.getAtom(2), ligands[2]); Assert.assertEquals(mol.getAtom(5), ligands[3]); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); } else { IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); Assert.assertEquals(mol.getAtom(0), ligands[0]); Assert.assertEquals(mol.getAtom(2), ligands[1]); Assert.assertEquals(mol.getAtom(3), ligands[2]); Assert.assertEquals(mol.getAtom(4), ligands[3]); Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo()); } } }
@Test public void cyclohexaneWithAromaticBonds() throws Exception { IAtomContainer molecule = sp.parseSmiles("C:1:C:C:C:C:C1"); Assert.assertEquals(6, countAromaticAtoms(molecule)); Assert.assertEquals(6, countAromaticBonds(molecule)); for (IBond bond : molecule.bonds()) { assertThat(bond.getOrder(), is(IBond.Order.SINGLE)); assertTrue(bond.getFlag(CDKConstants.ISAROMATIC)); } }
@Test(expected = CDKException.class) public void testBug1234() throws Exception { sp.parseSmiles("C1C1"); }
@Test public void testFormalNeighborBount() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("Oc1ccc(O)cc1"); atomtype(mol); Assert.assertEquals("O.sp3", mol.getAtom(0).getAtomTypeName()); Assert.assertEquals(2, mol.getAtom(0).getFormalNeighbourCount().intValue()); Assert.assertEquals("C.sp2", mol.getAtom(1).getAtomTypeName()); Assert.assertEquals(3, mol.getAtom(1).getFormalNeighbourCount().intValue()); IAtomContainer clone = (IAtomContainer) mol.clone(); Assert.assertEquals("O.sp3", clone.getAtom(0).getAtomTypeName()); Assert.assertEquals(2, clone.getAtom(0).getFormalNeighbourCount().intValue()); Assert.assertEquals("C.sp2", clone.getAtom(1).getAtomTypeName()); Assert.assertEquals(3, clone.getAtom(1).getFormalNeighbourCount().intValue()); }
@Test public void warnOnDirectionalBonds() throws InvalidSmilesException { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("C/C=C/1.C/1"); }
@Test public void ignoreDoubleBond() throws InvalidSmilesException { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("C/C=C(/F)/C"); assertThat(mol.stereoElements().iterator().hasNext(), is(false)); }