/** * Create a stream for the provided state. * * @param state the state to stream over */ StateStream(final State state) { this.state = state; this.stack = new CandidateStack(state.nMax()); this.next = state.nMax() == 0 || state.mMax() == 0 ? null : findNext(); // first-mapping }
/** * 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()); }
/**{@inheritDoc} */ @Override public Iterator<int[]> iterator() { if (subgraph) { return new StateStream(new VFSubState(container1, container2, g1, g2, bonds1, bonds2, atomMatcher, bondMatcher)); } return new StateStream( new VFState(container1, container2, g1, g2, bonds1, bonds2, atomMatcher, bondMatcher)); } }
/** * 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()); }
Mappings filter(Mappings mappings, IAtomContainer query, IAtomContainer target) { // apply required post-match filters if (hasStereo) { mappings = hasQueryStereo ? mappings.filter(new QueryStereoFilter(query, target)) : mappings.filter(new StereoMatch(query, target)); } if (hasCompGrp) mappings = mappings.filter(new ComponentFilter(query, target)); if (hasRxnMap) mappings = mappings.filter(new AtomMapFilter(query, target)); return mappings; }
@Test public void infeasibleRemainCount() throws Exception { VFSubState state = createBenzeneToNaphthalene(AtomMatcher.forAny(), BondMatcher.forAny()); assertTrue(state.feasible(0, 0)); // 0,0 is feasible // XXX: depends on molecule order not changing state.m1[1] = 1; state.m1[5] = 5; state.t2[1] = 1; state.t2[9] = 1; assertFalse(state.feasible(0, 0)); // 0,0 is infeasible }
@Test(expected = UnsupportedOperationException.class) public void remove() throws Exception { VFSubState state = createBenzeneToNaphthalene(AtomMatcher.forAny(), BondMatcher.forAny()); Iterator<int[]> it = new StateStream(state); it.remove(); }
@Test public void infeasibleTerminalCount() throws Exception { VFState state = createBenzeneToNaphthalene(AtomMatcher.forAny(), BondMatcher.forAny()); assertTrue(state.feasible(4, 4)); // 4, 4 is feasible state.add(0, 0); state.add(1, 1); state.add(2, 2); state.add(3, 3); assertFalse(state.feasible(4, 4)); // 4, 4 is infeasible }
/**{@inheritDoc} */ @Override public Iterator<int[]> iterator() { return new StateStream(new UllmannState(container1, container2, g1, g2, bonds1, bonds2, atomMatcher, bondMatcher)); } }
private DfPattern(IQueryAtomContainer query) { this.query = query; determineFilters(query); state = new DfState(query); }
/** * Atoms are always compatible. * * @return a matcher for which all atoms match */ public static AtomMatcher forAny() { return new AnyMatcher(); }
/** * Atoms are compatible if the second atom ({@code atom2}) is accepted by * the {@link IQueryAtom}, {@code atom1}. * * @return a matcher which checks query atom compatibility */ public static AtomMatcher forQuery() { return new QueryMatcher(); }
@Test public void infeasibleTerminalCount() throws Exception { VFSubState state = createBenzeneToNaphthalene(AtomMatcher.forAny(), BondMatcher.forAny()); assertTrue(state.feasible(0, 0)); // 0,0 is feasible // XXX: depends on molecule order not changing state.t1[1] = 1; state.t1[5] = 1; assertFalse(state.feasible(0, 0)); // 0,0 is infeasible }