示例#1
0
        /// <summary>
        /// Returns whether the chemical structure contains a specified substructure.
        /// </summary>
        /// <param name="substructureQuery">The specified substructure to search for.</param>
        /// <returns>True if this chemical structure contains the specified substructure.</returns>
        public bool HasSubstructure(ChemicalStructure substructureQuery)
        {
            bool hasSubstructure = false;

            using (Indigo indigo = new Indigo())
            {
                // Load inputs.
                IndigoObject structure    = CreateIndigoStructure(indigo);
                IndigoObject substructure = indigo.loadQueryMolecule(substructureQuery.MolfileContents);

                // Perform the match.
                IndigoObject substructureMatcher = indigo.substructureMatcher(structure);
                hasSubstructure = (substructureMatcher.match(substructure) != null);

                // Dispose.
                structure.Dispose();
                substructure.Dispose();
                substructureMatcher.Dispose();
            }

            return(hasSubstructure);
        }