示例#1
0
        public void TestAromaticBenzene()
        {
            var         sp          = CDK.SmilesParser;
            var         mol         = sp.ParseSmiles("C1=CC=CC=C1"); // benzene
            Aromaticity aromaticity = new Aromaticity(ElectronDonation.DaylightModel, Cycles.AllSimpleFinder);

            aromaticity.Apply(mol);
            AssertAtomTypesPerceived(mol);
            AddExplicitHydrogens(mol);
            Assert.AreEqual(2.02, CreateDescriptor(false).Calculate(mol, correctSalicylFactor: true).Value, 0.01);
        }
示例#2
0
        /// <summary>
        /// ApplyAromaticity
        ///
        /// Mimics the CDKHuckelAromaticityDetector
        ///  Aromaticity aromaticity = new Aromaticity(ElectronDonation.cdk(),	Cycles.cdkAromaticSet());
        ///
        /// Mimics the DoubleBondAcceptingAromaticityDetector
        ///  Aromaticity aromaticity = new Aromaticity(ElectronDonation.cdkAllowingExocyclic(), Cycles.cdkAromaticSet());
        ///
        /// A good model for writing SMILES
        ///  Aromaticity aromaticity = new Aromaticity(ElectronDonation.daylight(), Cycles.all());
        ///
        /// A good model for writing MDL/Mol2
        ///  Aromaticity aromaticity = new Aromaticity(ElectronDonation.piBonds(), Cycles.all());
        ///
        /// </summary>
        /// <param name="mol"></param>
        /// <param name="electronDonation"></param>
        /// <param name="cycleFinder"></param>
        /// <returns></returns>

        public static bool ApplyAromaticity(
            IAtomContainer mol,
            ElectronDonation electronDonation,
            CycleFinder cycleFinder)
        {
            Aromaticity aromaticity = new Aromaticity(electronDonation, cycleFinder);

            try
            {
                bool isAromatic = aromaticity.apply(mol);
                return(isAromatic);
            }
            catch (Exception e)
            {
                string msg = e.Message;                 // cycle computation was intractable
                return(false);
            }
        }
示例#3
0
 /// <summary>
 /// Set the aromaticity perception to use. Different aromaticity models
 /// may required certain attributes to be set (e.g. atom typing). These
 /// will not be automatically configured and should be preset before matching.
 /// </summary>
 /// <example>
 /// <include file='IncludeExamples.xml' path='Comments/Codes[@id="NCDK.Smiles.SMARTS.SMARTSQueryTool_Example.cs+SetAromaticity"]/*' />
 /// </example>
 /// <param name="aromaticity">the new aromaticity perception</param>
 /// <seealso cref="ElectronDonation"/>
 /// <seealso cref="Cycles"/>
 public void SetAromaticity(Aromaticity aromaticity)
 {
     this.aromaticity = CheckNotNull(aromaticity, "aromaticity was not provided");
 }