/** * Create a pattern which can be used to find molecules which contain the * {@code query} structure. The default structure search implementation is * {@link VentoFoggia}. * * @param query the substructure to find * @return a pattern for finding the {@code query} * @see VentoFoggia */ public static Pattern findSubstructure(IAtomContainer query) { return VentoFoggia.findSubstructure(query); }
@Override Pattern create(IAtomContainer container) { return VentoFoggia.findSubstructure(container); } }
/** * Adds a Molecule to the list of templates use by this TemplateHandler. * * @param molecule The molecule to be added to the TemplateHandler */ public void addMolecule(IAtomContainer molecule) { if (!GeometryUtil.has2DCoordinates(molecule)) throw new IllegalArgumentException("Template did not have 2D coordinates"); // we want a consistent scale! GeometryUtil.scaleMolecule(molecule, GeometryUtil.getScaleFactor(molecule, StructureDiagramGenerator.DEFAULT_BOND_LENGTH)); templates.add(molecule); anonPatterns.add(VentoFoggia.findSubstructure(molecule, anonAtomMatcher, anonBondMatcher)); elemPatterns.add(VentoFoggia.findSubstructure(molecule, elemAtomMatcher, anonBondMatcher)); }
/** * Adds a Molecule to the list of templates use by this TemplateHandler. * * @param molecule The molecule to be added to the TemplateHandler */ public void addMolecule(IAtomContainer molecule) { if (!GeometryUtil.has2DCoordinates(molecule)) throw new IllegalArgumentException("Template did not have 2D coordinates"); // we want a consistent scale! GeometryUtil.scaleMolecule(molecule, GeometryUtil.getScaleFactor(molecule, StructureDiagramGenerator.DEFAULT_BOND_LENGTH)); templates.add(molecule); anonPatterns.add(VentoFoggia.findSubstructure(molecule, anonAtomMatcher, anonBondMatcher)); elemPatterns.add(VentoFoggia.findSubstructure(molecule, elemAtomMatcher, anonBondMatcher)); }
/** * 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()); }
@Test public void uniqueBonds() throws Exception { IAtomContainer query = smi("C1CCC1"); IAtomContainer target = smi("C12C3C1C23"); Iterable<int[]> mappings = VentoFoggia.findSubstructure(query).matchAll(target); // using unique atoms we may think we only found 1 mapping assertThat(Iterables.size(Iterables.filter(mappings, new UniqueAtomMatches())), is(1)); // when in fact we found 4 different mappings assertThat(Iterables.size(Iterables.filter(mappings, new UniqueBondMatches(GraphUtil.toAdjList(query)))), is(3)); }
@Test public void napthaleneSubsearch() throws Exception { int[] match = VentoFoggia.findSubstructure(TestMoleculeFactory.makeNaphthalene()).match( TestMoleculeFactory.makeBenzene()); assertThat(match, is(new int[0])); int count = FluentIterable.from( VentoFoggia.findSubstructure(TestMoleculeFactory.makeNaphthalene()).matchAll( TestMoleculeFactory.makeBenzene())).size(); assertThat(count, is(0)); } }
@Test public void benzeneSubsearch() throws Exception { int[] match = VentoFoggia.findSubstructure(TestMoleculeFactory.makeBenzene()).match( TestMoleculeFactory.makeNaphthalene()); assertThat(match, is(new int[]{2, 7, 6, 5, 4, 3})); int count = FluentIterable.from( VentoFoggia.findSubstructure(TestMoleculeFactory.makeBenzene()).matchAll( TestMoleculeFactory.makeNaphthalene())).size(); assertThat(count, is(6)); // note: aromatic one would be 24 }
mappings = FluentIterable.from(VentoFoggia.findSubstructure(query) .matchAll(atomContainer) .filter(new SmartsStereoMatch(query, atomContainer)))
Pattern ptrn = VentoFoggia.findSubstructure(substructure, new AtomMatcher() { @Override public boolean matches(IAtom a, IAtom b) {
Pattern ptrn = VentoFoggia.findSubstructure(substructure, new AtomMatcher() { @Override public boolean matches(IAtom a, IAtom b) {