コード例 #1
0
ファイル: FMFDescriptor.cs プロジェクト: ch-hristov/NCDK
        /// <summary>
        /// Calculates the FMF descriptor value for the given <see cref="IAtomContainer"/>.
        /// </summary>
        /// <returns>An object of <see cref="Result"/> that contains the
        /// calculated FMF descriptor value as well as specification details</returns>
        public Result Calculate(IAtomContainer container)
        {
            container = (IAtomContainer)container.Clone();

            var fragmenter = new MurckoFragmenter(true, 3);

            fragmenter.GenerateFragments(container);
            var framework   = fragmenter.GetFrameworksAsContainers().ToReadOnlyList();
            var ringSystems = fragmenter.GetRingSystemsAsContainers().ToReadOnlyList();
            {
                double result;

                if (framework.Count == 1)
                {
                    result = framework[0].Atoms.Count / (double)container.Atoms.Count;
                }
                else if (framework.Count == 0 && ringSystems.Count == 1)
                {
                    result = ringSystems[0].Atoms.Count / (double)container.Atoms.Count;
                }
                else
                {
                    result = 0;
                }

                return(new Result(result));
            }
        }
コード例 #2
0
        public void Test2FragmentComplexityDescriptor()
        {
            var            filename = "NCDK.Data.MDL.murckoTest10.mol";
            IAtomContainer mol;

            using (var reader = new MDLV2000Reader(ResourceLoader.GetAsStream(filename), ChemObjectReaderMode.Strict))
            {
                mol = reader.Read(builder.NewAtomContainer());
            }
            var gf = new MurckoFragmenter();

            gf.GenerateFragments(mol);
            var    setOfFragments = gf.GetFrameworksAsContainers();
            double Complexity     = 0;

            foreach (var setOfFragment in setOfFragments)
            {
                AddExplicitHydrogens(setOfFragment);
                Complexity = CreateDescriptor().Calculate(setOfFragment).Value;
            }
            Assert.AreEqual(544.01, Complexity, 0.01);
        }