public void BenzeneSubsearch() { int[] match = VentoFoggia.CreateSubstructureFinder(TestMoleculeFactory.MakeBenzene()).Match(TestMoleculeFactory.MakeNaphthalene()); Assert.IsTrue(Compares.AreDeepEqual(new int[] { 2, 7, 6, 5, 4, 3 }, match)); int count = VentoFoggia.CreateSubstructureFinder(TestMoleculeFactory.MakeBenzene()).MatchAll( TestMoleculeFactory.MakeNaphthalene()).ToReadOnlyList().Count; Assert.AreEqual(6, count); // note: aromatic one would be 24 }
public void NapthaleneSubsearch() { int[] match = VentoFoggia.CreateSubstructureFinder(TestMoleculeFactory.MakeNaphthalene()).Match( TestMoleculeFactory.MakeBenzene()); Assert.IsTrue(Compares.AreDeepEqual(Array.Empty <int>(), match)); int count = VentoFoggia.CreateSubstructureFinder(TestMoleculeFactory.MakeNaphthalene()).MatchAll( TestMoleculeFactory.MakeBenzene()).ToReadOnlyList().Count; Assert.AreEqual(0, count); }
public void UniqueBonds() { IAtomContainer query = Smi("C1CCC1"); IAtomContainer target = Smi("C12C3C1C23"); var mappings = VentoFoggia.CreateSubstructureFinder(query).MatchAll(target); // using unique atoms we may think we only found 1 mapping { var p = new UniqueAtomMatches(); Assert.AreEqual(1, mappings.Count(p.Apply)); } // when in fact we found 4 different mappings { var p = new UniqueBondMatches(GraphUtil.ToAdjList(query)); Assert.AreEqual(3, mappings.Count(p.Apply)); } }
/// <summary> /// Create a pattern which can be used to find molecules which contain the /// <paramref name="query"/> structure. The default structure search implementation is /// <see cref="VentoFoggia"/>. /// </summary> /// <param name="query">the substructure to find</param> /// <returns>a pattern for finding the <paramref name="query"/></returns> /// <seealso cref="VentoFoggia"/> public static Pattern CreateSubstructureFinder(IAtomContainer query) { return(VentoFoggia.CreateSubstructureFinder(query)); }