Beispiel #1
0
 void Main()
 {
     IAtomContainer query  = null;
     IAtomContainer target = null;
     IChemObjectSet <IAtomContainer> ms = null;
     {
         #region
         Pattern pattern = Ullmann.CreateSubstructureFinder(query);
         pattern.MatchAll(target).Filter(new UniqueAtomMatches().Apply);
         #endregion
     }
 }
Beispiel #2
0
        void Main()
        {
            IAtomContainer query  = null;
            IAtomContainer target = null;

            int[][] queryGraph = null;
            {
                #region
                Pattern pattern = Ullmann.CreateSubstructureFinder(query);
                var     unique  = pattern.MatchAll(target).Filter(new UniqueBondMatches(queryGraph).Apply);
                #endregion
            }
        }
Beispiel #3
0
        /// <summary>
        /// Perform a SMARTS match and check whether the query is present in the target molecule.
        /// <para>This function simply
        /// checks whether the query pattern matches the specified molecule. However the function will also, internally, save
        /// the mapping of query atoms to the target molecule</para>
        /// </summary>
        /// <param name="atomContainer">The target moleculoe</param>
        /// <param name="forceInitialization">If true, then the molecule is initialized (ring perception, aromaticity etc). If
        ///                            false, the molecule is only initialized if it is different (in terms of object
        ///                            reference) than one supplied in a previous call to this method.</param>
        /// <returns>true if the pattern is found in the target molecule, false otherwise</returns>
        /// <exception cref="CDKException">if there is an error in ring, aromaticity or isomorphism perception</exception>
        /// <seealso cref="GetMatchingAtoms"/>
        /// <seealso cref="MatchesCount"/>
        /// <seealso cref="Matches(IAtomContainer)"/>
        public bool Matches(IAtomContainer atomContainer, bool forceInitialization)
        {
            if (this.atomContainer == atomContainer)
            {
                if (forceInitialization)
                {
                    InitializeMolecule();
                }
            }
            else
            {
                this.atomContainer = atomContainer;
                InitializeMolecule();
            }

            // lets see if we have a single atom query
            if (query.Atoms.Count == 1)
            {
                // lets get the query atom
                var queryAtom = (IQueryAtom)query.Atoms[0];

                mappings = new List <int[]>();
                for (int i = 0; i < atomContainer.Atoms.Count; i++)
                {
                    if (queryAtom.Matches(atomContainer.Atoms[i]))
                    {
                        mappings.Add(new int[] { i });
                    }
                }
            }
            else
            {
                mappings = Ullmann.CreateSubstructureFinder(query).MatchAll(atomContainer)
                           .Where(n => new SmartsStereoMatch(query, atomContainer).Apply(n))
                           .ToList();
            }

            return(mappings.Count != 0);
        }
Beispiel #4
0
        void Main()
        {
            IAtomContainer queryStructure      = null;
            IChemObjectSet <IAtomContainer> ms = null;
            {
                #region 1
                IAtomContainer query   = queryStructure;
                Pattern        pattern = Ullmann.FindSubstructure(query);

                int hits = 0;
                foreach (var m in ms)
                {
                    if (pattern.Matches(m))
                    {
                        hits++;
                    }
                }
                #endregion
            }
            {
                #region 2
                IAtomContainer query   = queryStructure;
                Pattern        pattern = Ullmann.FindSubstructure(query);

                int hits = 0;
                foreach (var m in ms)
                {
                    int[] match = pattern.Match(m);
                    if (match.Length > 0)
                    {
                        hits++;
                    }
                }
                #endregion
            }
        }
Beispiel #5
0
 public override Pattern Create(IAtomContainer container)
 {
     return(Ullmann.FindSubstructure(container));
 }