/** * Create a pattern which can be used to find molecules which contain the * {@code query} structure. * * @param query the substructure to find * @return a pattern for finding the {@code query} */ public static Pattern findSubstructure(IAtomContainer query) { boolean isQuery = query instanceof IQueryAtomContainer; return new Ullmann(query, isQuery ? AtomMatcher.forQuery() : AtomMatcher.forElement(), isQuery ? BondMatcher.forQuery() : BondMatcher.forOrder()); }
/** * Create a pattern which can be used to find molecules which contain the * {@code query} structure. * * @param query the substructure to find * @return a pattern for finding the {@code query} */ public static Pattern findSubstructure(IAtomContainer query) { boolean isQuery = query instanceof IQueryAtomContainer; return findSubstructure(query, isQuery ? AtomMatcher.forQuery() : AtomMatcher.forElement(), isQuery ? BondMatcher.forQuery() : BondMatcher.forOrder()); }
/** * Create a pattern which can be used to find molecules which are the same * as the {@code query} structure. * * @param query the substructure to find * @return a pattern for finding the {@code query} */ public static Pattern findIdentical(IAtomContainer query) { boolean isQuery = query instanceof IQueryAtomContainer; return findIdentical(query, isQuery ? AtomMatcher.forQuery() : AtomMatcher.forElement(), isQuery ? BondMatcher.forQuery() : BondMatcher.forOrder()); }
@Test public void queryMatch() { BondMatcher matcher = BondMatcher.forQuery(); IQueryBond bond1 = mock(IQueryBond.class); IBond bond2 = mock(IBond.class); IBond bond3 = mock(IBond.class); when(bond1.matches(bond2)).thenReturn(true); when(bond1.matches(bond3)).thenReturn(false); assertTrue(matcher.matches(bond1, bond2)); assertFalse(matcher.matches(bond1, bond3)); } }