using System; using System.Collections.Generic; using System.Linq; using System.Text; using NUnit.Framework; using ChemAxon.NET.IKVM.Chemistry; using ChemAxon.NET.API; namespace ChemAxon.NET.UnitTest.API.Examples.Chemistry.Filter { public class FilterExample { public void Filter_Example() { var targets = new List<IJChemMolecule>(); targets.Add(MainFactory.Chemistry.CreateMolecule("benzene")); targets.Add(MainFactory.Chemistry.CreateMolecule("methylpropane")); targets.Add(MainFactory.Chemistry.CreateMolecule("hexane")); IEnumerable<IJChemMolecule> filterResult = DoFilter(targets); Console.WriteLine("Filter result:"); foreach (IJChemMolecule molecule in filterResult) Console.WriteLine(molecule.Formula); } public IEnumerable<IJChemMolecule> DoFilter(IEnumerable<IJChemMolecule> targets) { IFilter filter = MainFactory.Chemistry.CreateFilter(targets, SearchMode.AtomAtom); filter.Options.SearchType = Base.Search.Options.JChemSearchTypes.Substructure; filter.Options.ChargeMatchingOption = Base.Search.Options.JChemChargeMatchingModes.Exact; IJChemMolecule query = MainFactory.Chemistry.CreateMolecule("methane"); IEnumerable<IJChemMolecule> filterResult = filter.FindAll(query); return filterResult; } } }