示例#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
 static void Prepare(IAtomContainer target)
 {
     // apply the daylight aromaticity model
     try
     {
         Cycles.MarkRingAtomsAndBonds(target);
         arom.Apply(target);
     }
     catch (CDKException e)
     {
         Trace.TraceError(e.Message);
     }
 }
示例#3
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,
            ICycleFinder 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);
            }
        }
示例#4
0
        public override IReadOnlyDictionary <string, int> GetRawFingerprint(IAtomContainer atomContainer)
        {
            aromaticity.Apply(atomContainer);
            var smiles = ReplaceDigits(gen.Create(atomContainer));
            var map    = new Dictionary <string, int>();

            for (int i = 0, l = smiles.Length - n + 1; i < l; i++)
            {
                string subsmi = smiles.Substring(i, n);
                if (!map.TryGetValue(subsmi, out int count))
                {
                    map[subsmi] = 1;
                }
                else
                {
                    map[subsmi] = count + 1;
                }
            }
            return(map);
        }
示例#5
0
        /// <summary>
        /// Prepare the target molecule for analysis.
        /// <para>
        /// We perform ring perception and aromaticity detection and set up
        /// the appropriate properties. Right now, this function is called each time we need to do a query and this is
        /// inefficient.</para>
        /// </summary>
        /// <exception cref="CDKException">if there is a problem in ring perception or aromaticity detection, which is usually related to a timeout in the ring finding code.</exception>
        private void InitializeMolecule()
        {
            // initialise required invariants - the query has ISINRING set if
            // the query contains ring queries [R?] [r?] [x?] etc.
            SmartsMatchers.Prepare(atomContainer, true);

            // providing skip aromaticity has not be set apply the desired
            // aromaticity model
            try
            {
                if (!skipAromaticity)
                {
                    aromaticity.Apply(atomContainer);
                }
            }
            catch (CDKException e)
            {
                Debug.WriteLine(e.ToString());
                throw new CDKException(e.ToString(), e);
            }
        }