Exemple #1
0
 /// <summary>
 /// Create an aromaticity model using the specified electron donation
 /// <paramref name="model"/> which is tested on the <paramref name="cycles"/>. The <paramref name="model"/> defines
 /// how many π-electrons each atom may contribute to an aromatic system. The
 /// <paramref name="cycles"/> defines the <see cref="ICycleFinder"/> which is used to find
 /// cycles in a molecule. The total electron donation from each atom in each
 /// cycle is counted and checked. If the electron contribution is equal to
 /// "4n + 2" for a "n &gt;= 0" then the cycle is considered
 /// aromatic.
 /// </summary>
 /// <remarks>
 /// Changing the electron contribution model or which cycles
 /// are tested affects which atoms/bonds are found to be aromatic. There are
 /// several <see cref="ElectronDonation"/> models and <see cref="Cycles"/>
 /// available. A good choice for the cycles
 /// is to use <see cref="Cycles.AllSimpleFinder()"/> falling back to
 /// <see cref="Cycles.RelevantFinder"/> on failure. Finding all cycles is very
 /// fast but may produce an exponential number of cycles. It is therefore not
 /// feasible for complex fused systems and an exception is thrown.
 /// In such cases the aromaticity can either be skipped or a simpler
 /// polynomial cycle set <see cref="Cycles.RelevantFinder"/> used.
 /// </remarks>
 /// <example>
 /// <include file='IncludeExamples.xml' path='Comments/Codes[@id="NCDK.Aromaticities.Aromaticity_Example.cs+ctor"]/*' />
 /// </example>
 /// <param name="model"></param>
 /// <param name="cycles"></param>
 /// <seealso cref="ElectronDonation"/>
 /// <seealso cref="Cycles"/>
 public Aromaticity(ElectronDonation model, ICycleFinder cycles)
 {
     this.model  = model ?? throw new ArgumentNullException(nameof(model));
     this.cycles = cycles ?? throw new ArgumentNullException(nameof(cycles));
 }
Exemple #2
0
        public static void Main(string[] args)
        {
            {
                var molecules = new Silent.AtomContainerSet();
                #region
                ElectronDonation model       = ElectronDonation.DaylightModel;
                ICycleFinder     cycles      = Cycles.Or(Cycles.AllSimpleFinder, Cycles.GetAllFinder(6));
                Aromaticity      aromaticity = new Aromaticity(model, cycles);

                // apply our configured model to each molecule
                foreach (IAtomContainer molecule in molecules)
                {
                    aromaticity.Apply(molecule);
                }
                #endregion
            }
            {
                #region ctor
                // mimics the CDKHuckelAromaticityDetector
                Aromaticity aromaticity_cdk = new Aromaticity(ElectronDonation.CDKModel, Cycles.CDKAromaticSetFinder);
                // mimics the DoubleBondAcceptingAromaticityDetector
                Aromaticity aromaticity_exo = new Aromaticity(ElectronDonation.CDKAllowingExocyclicModel, Cycles.CDKAromaticSetFinder);
                // a good model for writing SMILES
                Aromaticity aromaticity_smi = new Aromaticity(ElectronDonation.DaylightModel, Cycles.AllSimpleFinder);
                // a good model for writing MDL/Mol2
                Aromaticity aromaticity_mdl = new Aromaticity(ElectronDonation.PiBondsModel, Cycles.AllSimpleFinder);
                #endregion
            }
            {
                #region FindBonds
                Aromaticity    aromaticity = new Aromaticity(ElectronDonation.CDKModel, Cycles.AllSimpleFinder);
                IAtomContainer container   = TestMoleculeFactory.MakeAnthracene();
                AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(container);
                try
                {
                    var bonds          = aromaticity.FindBonds(container);
                    int nAromaticBonds = bonds.Count();
                }
                catch (CDKException)
                {
                    // cycle computation was intractable
                }
                #endregion
            }
            {
                #region Apply
                Aromaticity    aromaticity = new Aromaticity(ElectronDonation.CDKModel, Cycles.AllSimpleFinder);
                IAtomContainer container   = TestMoleculeFactory.MakeAnthracene();
                try
                {
                    if (aromaticity.Apply(container))
                    {
                        //
                    }
                }
                catch (CDKException)
                {
                    // cycle computation was intractable
                }
                #endregion
            }
            {
                #region CDKLegacy_CDKAromaticSetFinder
                new Aromaticity(ElectronDonation.CDKModel, Cycles.CDKAromaticSetFinder);
                #endregion
            }
            {
                #region CDKLegacy_AllFinder_RelevantFinder
                new Aromaticity(ElectronDonation.CDKModel, Cycles.Or(Cycles.AllSimpleFinder, Cycles.RelevantFinder));
                #endregion
            }
        }