コード例 #1
0
        public void TestSFBug999330()
        {
            var file1 = "NCDK.Data.MDL.5SD.mol";
            var file2 = "NCDK.Data.MDL.ADN.mol";

            var mol1 = builder.NewAtomContainer();

            using (var reader = new MDLV2000Reader(ResourceLoader.GetAsStream(file1), ChemObjectReaderMode.Strict))
            {
                reader.Read(mol1);
            }

            var mol2 = builder.NewAtomContainer();

            using (var reader = new MDLV2000Reader(ResourceLoader.GetAsStream(file2), ChemObjectReaderMode.Strict))
            {
                reader.Read(mol2);
            }

            var permutor = new AtomContainerAtomPermutor(mol2);

            permutor.MoveNext();
            mol2 = builder.NewAtomContainer(permutor.Current);

            var list1 = uiTester.GetOverlaps(mol1, mol2);
            var list2 = uiTester.GetOverlaps(mol2, mol1);

            Assert.AreEqual(1, list1.Count);
            Assert.AreEqual(1, list2.Count);
            Assert.AreEqual(list1[0].Atoms.Count, list2[0].Atoms.Count);
        }
コード例 #2
0
        public void FullPermutationTest(IAtomContainer mol)
        {
            AtomContainerAtomPermutor permutor = new AtomContainerAtomPermutor(mol);
            string expected = new MoleculeSignature(mol).ToCanonicalString();
            int    numberOfPermutationsTried = 0;

            while (permutor.HasNext())
            {
                permutor.MoveNext();
                IAtomContainer permutation = permutor.Current;
                string         actual      = new MoleculeSignature(permutation).ToCanonicalString();
                numberOfPermutationsTried++;
                Assert.AreEqual(expected, actual, $"Failed on permutation{numberOfPermutationsTried}");
            }
        }
コード例 #3
0
        public void TestAtomPermutation()
        {
            IAtomContainer            pamine = MakePropylAmine();
            ShortestPathFingerprinter fp     = new ShortestPathFingerprinter();
            IBitFingerprint           bs1    = fp.GetBitFingerprint(pamine);

            AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine);

            while (acp.MoveNext())
            {
                IAtomContainer  container = acp.Current;
                IBitFingerprint bs2       = fp.GetBitFingerprint(container);
                Assert.IsTrue(bs1.Equals(bs2));
            }
        }
コード例 #4
0
        public void TestAtomPermutation2()
        {
            IAtomContainer  pamine = TestMoleculeFactory.MakeCyclopentane();
            Fingerprinter   fp     = new Fingerprinter();
            IBitFingerprint bs1    = fp.GetBitFingerprint(pamine);

            AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine);

            while (acp.MoveNext())
            {
                IAtomContainer  container = acp.Current;
                IBitFingerprint bs2       = fp.GetBitFingerprint(container);
                Assert.IsTrue(bs1.Equals(bs2));
            }
        }
コード例 #5
0
        public void TestAtomPermutation2()
        {
            IAtomContainer pamine = TestMoleculeFactory.MakeCyclopentane();

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(pamine);
            ShortestPathFingerprinter fp  = new ShortestPathFingerprinter();
            IBitFingerprint           bs1 = fp.GetBitFingerprint(pamine);

            AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine);

            while (acp.MoveNext())
            {
                IAtomContainer  container = acp.Current;
                IBitFingerprint bs2       = fp.GetBitFingerprint(container);
                Assert.IsTrue(bs1.Equals(bs2));
            }
        }
コード例 #6
0
        /// <summary>
        /// This test is checking all permutations of an atom container to see
        /// if the refiner gives the canonical labelling map (effectively).
        /// </summary>
        /// <param name="atomContainer"></param>
        public void CheckForCanonicalForm(IAtomContainer atomContainer)
        {
            AtomContainerAtomPermutor    permutor = new AtomContainerAtomPermutor(atomContainer);
            AtomDiscretePartitionRefiner refiner  = new AtomDiscretePartitionRefiner();

            refiner.Refine(atomContainer);
            Permutation best = refiner.GetBest().Invert();
            string      cert = AtomContainerPrinter.ToString(atomContainer, best, true);

            while (permutor.MoveNext())
            {
                IAtomContainer permutedContainer = permutor.Current;
                refiner.Refine(permutedContainer);
                best = refiner.GetBest().Invert();
                string permCert = AtomContainerPrinter.ToString(permutedContainer, best, true);
                Assert.AreEqual(cert, permCert);
            }
        }
コード例 #7
0
ファイル: CDKMCSTest.cs プロジェクト: roddickchen/NCDK
        public void TestSFBug999330()
        {
            var file1 = "NCDK.Data.MDL.5SD.mol";
            var file2 = "NCDK.Data.MDL.ADN.mol";
            var mol1  = builder.NewAtomContainer();
            var mol2  = builder.NewAtomContainer();

            var ins1 = ResourceLoader.GetAsStream(file1);

            new MDLV2000Reader(ins1, ChemObjectReaderMode.Strict).Read(mol1);
            var ins2 = ResourceLoader.GetAsStream(file2);

            new MDLV2000Reader(ins2, ChemObjectReaderMode.Strict).Read(mol2);
            var permutor = new AtomContainerAtomPermutor(mol2);

            permutor.MoveNext();
            mol2 = builder.NewAtomContainer(permutor.Current);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1);
            var adder = CDK.HydrogenAdder;

            adder.AddImplicitHydrogens(mol1);
            Aromaticity.CDKLegacy.Apply(mol1);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2);
            adder = CDK.HydrogenAdder;
            adder.AddImplicitHydrogens(mol2);
            Aromaticity.CDKLegacy.Apply(mol2);

            var list1 = CDKMCS.GetOverlaps(mol1, mol2, true);
            var list2 = CDKMCS.GetOverlaps(mol2, mol1, true);

            Assert.AreEqual(1, list1.Count);
            Assert.AreEqual(1, list2.Count);
            Assert.AreEqual(list1[0].Atoms.Count, list2[0].Atoms.Count);
        }