/** * Filter the mappings for those which preserve stereochemistry specified in * the query. * * @return fluent-api instance * @deprecated Results now automatically consider stereo if it's present, to * match without stereochemistry remove the stereo features. */ @Deprecated public Mappings stereochemistry() { // query structures currently have special requirements (i.e. SMARTS) if (query instanceof IQueryAtomContainer) return this; return filter(new StereoMatch(query, target)); }
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 @SuppressWarnings("unchecked") public void filter() throws Exception { Iterable<int[]> iterable = mock(Iterable.class); Iterator<int[]> iterator = mock(Iterator.class); when(iterable.iterator()).thenReturn(iterator); int[] p1 = {0, 1, 2}; int[] p2 = {0, 2, 1}; int[] p3 = {0, 3, 4}; int[] p4 = {0, 4, 3}; when(iterator.hasNext()).thenReturn(true, true, true, true, false); when(iterator.next()).thenReturn(p1, p2, p3, p4); Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), iterable); Predicate<int[]> f = mock(Predicate.class); when(f.apply(p1)).thenReturn(false); when(f.apply(p2)).thenReturn(true); when(f.apply(p3)).thenReturn(false); when(f.apply(p4)).thenReturn(true); assertThat(ms.filter(f).toArray(), is(new int[][]{p2, p4})); }
mappings = FluentIterable.from(VentoFoggia.findSubstructure(query) .matchAll(atomContainer) .filter(new SmartsStereoMatch(query, atomContainer))) .toList();