Пример #1
0
        public void TestRgroupQueryFile3()
        {
            var filename = "NCDK.Data.MDL.rgfile.3.mol";

            Trace.TraceInformation("Testing: " + filename);
            var ins = ResourceLoader.GetAsStream(filename);
            RGroupQueryReader reader      = new RGroupQueryReader(ins);
            RGroupQuery       rGroupQuery = (RGroupQuery)reader.Read(new RGroupQuery(ChemObjectBuilder.Instance));

            reader.Close();
            Assert.IsNotNull(rGroupQuery);
            Assert.AreEqual(rGroupQuery.RGroupDefinitions.Count, 1);
            Assert.AreEqual(rGroupQuery.RootStructure.Atoms.Count, 10);
            Assert.AreEqual(rGroupQuery.RootAttachmentPoints.Count, 2);

            Assert.AreEqual(rGroupQuery.GetAllConfigurations().Count(), 8);

            //Test correctness AAL lines
            foreach (var at in rGroupQuery.GetRgroupQueryAtoms(1))
            {
                if (at is PseudoAtom)
                {
                    Assert.AreEqual(((PseudoAtom)at).Label, "R1");

                    var apoBonds = rGroupQuery.RootAttachmentPoints[at];
                    Assert.AreEqual(apoBonds.Count, 2);

                    var boundAtom1 = apoBonds[1].GetOther(at);
                    Assert.IsTrue(boundAtom1.Symbol.Equals("Te") || boundAtom1.Symbol.Equals("S"));

                    var boundAtom2 = apoBonds[2].GetOther(at);
                    Assert.IsTrue(boundAtom2.Symbol.Equals("Po") || boundAtom2.Symbol.Equals("O"));
                }
            }

            // Test that there only two Rgroup query atoms (R#). The third R is a
            // pseudo atom, but because it is not numbered it is not part of any
            // query condition.
            var allrGroupQueryAtoms = rGroupQuery.GetAllRgroupQueryAtoms();

            Assert.AreEqual(allrGroupQueryAtoms.Count, 2);
        }
Пример #2
0
        public void TestRgroupQueryFile1()
        {
            var filename = "NCDK.Data.MDL.rgfile.1.mol";

            Trace.TraceInformation("Testing: " + filename);
            var ins = ResourceLoader.GetAsStream(filename);
            RGroupQueryReader reader      = new RGroupQueryReader(ins);
            RGroupQuery       rGroupQuery = (RGroupQuery)reader.Read(new RGroupQuery(ChemObjectBuilder.Instance));

            reader.Close();
            Assert.IsNotNull(rGroupQuery);
            Assert.AreEqual(rGroupQuery.RGroupDefinitions.Count, 1);
            Assert.AreEqual(rGroupQuery.RootStructure.Atoms.Count, 7);

            foreach (var at in rGroupQuery.GetAllRgroupQueryAtoms())
            {
                if (at is PseudoAtom)
                {
                    Assert.AreEqual(((PseudoAtom)at).Label, "R1");
                    var rootApo  = rGroupQuery.RootAttachmentPoints;
                    var apoBonds = rootApo[at];
                    Assert.AreEqual(apoBonds.Count, 1);
                    // Assert that the root attachment is the bond between R1 and P
                    foreach (var bond in rGroupQuery.RootStructure.Bonds)
                    {
                        if (bond.Contains(at))
                        {
                            Assert.AreEqual(bond, apoBonds[1]);
                            foreach (var atInApo in bond.Atoms)
                            {
                                Assert.IsTrue(atInApo.Symbol.Equals("R") || atInApo.Symbol.Equals("P"));
                            }
                        }
                    }
                }
            }

            int val_1 = rGroupQuery.RGroupDefinitions.Keys.First();

            Assert.AreEqual(val_1, 1);
            RGroupList rList = rGroupQuery.RGroupDefinitions[val_1];

            Assert.AreEqual(rList.Occurrence, "0,1-3");

            var rGroups = rList.RGroups;

            Assert.AreEqual(rGroups[0].FirstAttachmentPoint.Symbol, "N");
            Assert.AreEqual(rGroups[1].FirstAttachmentPoint.Symbol, "O");
            Assert.AreEqual(rGroups[2].FirstAttachmentPoint.Symbol, "S");

            Assert.IsNull(rGroups[0].SecondAttachmentPoint);
            Assert.IsNull(rGroups[1].SecondAttachmentPoint);
            Assert.IsNull(rGroups[2].SecondAttachmentPoint);

            var configurations = rGroupQuery.GetAllConfigurations();

            Assert.AreEqual(configurations.Count(), 4);

            //IsRestH is set to true for R1, so with zero substitutes, the phosphor should get the restH flag set to true.
            bool restH_Identified = false;

            foreach (var atc in configurations)
            {
                if (atc.Atoms.Count == 6)
                {
                    foreach (var atom in atc.Atoms)
                    {
                        if (atom.Symbol.Equals("P"))
                        {
                            Assert.IsNotNull(atom.GetProperty <bool?>(CDKPropertyName.RestH));
                            Assert.AreEqual(atom.GetProperty <bool>(CDKPropertyName.RestH), true);
                            restH_Identified = true;
                        }
                    }
                }
            }
            Assert.IsTrue(restH_Identified);
        }