SmartsPattern extends Pattern { public static SmartsPattern create(String smarts, IChemObjectBuilder builder) { return new SmartsPattern(smarts, builder); } private  SmartsPattern(final String smarts, IChemObjectBuilder builder); static void prepare(IAtomContainer target); SmartsPattern setPrepare(boolean doPrep); @Override int[] match(IAtomContainer container); @Override Mappings matchAll(final IAtomContainer target); static SmartsPattern create(String smarts, IChemObjectBuilder builder); static SmartsPattern create(String smarts);  }
@Test public void isotopes() throws Exception { assertFalse(SmartsPattern.create("[12*]", bldr).matches(smi("C"))); assertFalse(SmartsPattern.create("[12*]", bldr).matches(smi("[CH4]"))); assertTrue(SmartsPattern.create("[12*]", bldr).matches(smi("[12CH4]"))); assertFalse(SmartsPattern.create("[12*]", bldr).matches(smi("[13CH4]"))); assertFalse(SmartsPattern.create("[13*]", bldr).matches(smi("C"))); assertFalse(SmartsPattern.create("[13*]", bldr).matches(smi("[CH4]"))); assertFalse(SmartsPattern.create("[13*]", bldr).matches(smi("[12CH4]"))); assertTrue(SmartsPattern.create("[13*]", bldr).matches(smi("[13CH4]"))); assertTrue(SmartsPattern.create("[0*]", bldr).matches(smi("C"))); assertTrue(SmartsPattern.create("[0*]", bldr).matches(smi("[CH4]"))); assertFalse(SmartsPattern.create("[0*]", bldr).matches(smi("[12CH4]"))); assertFalse(SmartsPattern.create("[0*]", bldr).matches(smi("[13CH4]"))); }
@Test public void components() throws Exception { assertTrue(SmartsPattern.create("(O).(O)", bldr).matches(smi("O.O"))); assertFalse(SmartsPattern.create("(O).(O)", bldr).matches(smi("OO"))); }
@Test public void stereochemistry() throws Exception { assertTrue(SmartsPattern.create("C[C@H](O)CC", bldr).matches(smi("C[C@H](O)CC"))); assertFalse(SmartsPattern.create("C[C@H](O)CC", bldr).matches(smi("C[C@@H](O)CC"))); assertFalse(SmartsPattern.create("C[C@H](O)CC", bldr).matches(smi("CC(O)CC"))); }
@Test public void smartsMatchingReaction() throws Exception { assertTrue(SmartsPattern.create("CC", bldr).matches(rsmi("CC>>"))); assertTrue(SmartsPattern.create("CC", bldr).matches(rsmi(">>CC"))); assertTrue(SmartsPattern.create("CC", bldr).matches(rsmi(">CC>"))); assertFalse(SmartsPattern.create("CO", bldr).matches(rsmi(">>CC"))); }
@Test public void reactionSmartsMatchingReaction() throws Exception { assertTrue(SmartsPattern.create("CC>>", bldr).matches(rsmi("CC>>"))); assertFalse(SmartsPattern.create("CC>>", bldr).matches(rsmi(">>CC"))); assertFalse(SmartsPattern.create("CC>>", bldr).matches(rsmi(">CC>"))); }
@Test public void reactionGrouping() throws Exception { assertTrue(SmartsPattern.create("[Na+].[OH-]>>", bldr).matches(rsmi("[Na+].[OH-]>>"))); assertTrue(SmartsPattern.create("[Na+].[OH-]>>", bldr).matches(rsmi("[Na+].[OH-]>> |f:0.1|"))); assertTrue(SmartsPattern.create("([Na+].[OH-])>>", bldr).matches(rsmi("[Na+].[OH-]>> |f:0.1|"))); assertFalse(SmartsPattern.create("([Na+].[OH-])>>", bldr).matches(rsmi("[Na+].[OH-]>>"))); }
@Test public void stereo_ring_closures() throws Exception { Pattern ptrn = SmartsPattern.create("[C@@]1(O[C@@]([C@@]([C@]([C@]1(C)O)(C)O)(O)C)(O)C)(O)C"); assertTrue(ptrn.matches(smi("[C@@]1(O[C@@]([C@@]([C@]([C@]1(C)O)(C)O)(O)C)(O)C)(O)C"))); }
@Test public void hasIsotope() throws Exception { Pattern ptrn = SmartsPattern.create("[!0]"); assertFalse(ptrn.matches(smi("C"))); assertTrue(ptrn.matches(smi("[12C]"))); assertTrue(ptrn.matches(smi("[13C]"))); }
@Test public void hIsotope() throws Exception { Pattern ptrn = SmartsPattern.create("[2#1,3#1]"); assertFalse(ptrn.matches(smi("[H][H]"))); assertTrue(ptrn.matches(smi("[2H]"))); assertTrue(ptrn.matches(smi("[3H]"))); }
@Test public void bug1358() throws Exception { Pattern ptrn = SmartsPattern.create("[$([*@](~*)(~*)(*)*),$([*@H](*)(*)*),$([*@](~*)(*)*)]"); assertFalse(ptrn.matches(smi("N#CN/C(=N/CCSCC=1N=CNC1C)NC"))); }