Beispiel #1
0
        public void TestRemoveHydrogensAndPreserveAtomID()
        {
            string rawMolSmiles  = "[H]POOSC(Br)C(Cl)C(F)I";
            var    sp            = CDK.SmilesParser;
            var    atomContainer = sp.ParseSmiles(rawMolSmiles);
            IAtom  beforeAtom    = null;
            IAtom  afterAtom     = null;

            foreach (var a in atomContainer.Atoms)
            {
                if (string.Equals(a.Symbol, "P", StringComparison.OrdinalIgnoreCase))
                {
                    beforeAtom = a;
                    a.Id       = "TEST";
                    break;
                }
            }
            IAtomContainer result = SMSDNormalizer.RemoveHydrogensAndPreserveAtomID(atomContainer);

            foreach (var a in result.Atoms)
            {
                if (string.Equals(a.Symbol, "P", StringComparison.OrdinalIgnoreCase))
                {
                    afterAtom = a;
                    break;
                }
            }

            Assert.AreEqual(afterAtom.Id, beforeAtom.Id);
        }
Beispiel #2
0
        public void TestPercieveAtomTypesAndConfigureAtoms()
        {
            string rawMolSmiles  = "[H]POOSC(Br)C(Cl)C(F)I";
            var    sp            = CDK.SmilesParser;
            var    atomContainer = sp.ParseSmiles(rawMolSmiles);

            SMSDNormalizer.PercieveAtomTypesAndConfigureAtoms(atomContainer);
            Assert.IsNotNull(atomContainer);
        }
Beispiel #3
0
        public void TestConvertExplicitToImplicitHydrogens()
        {
            string         rawMolSmiles  = "[H]POOSC(Br)C(Cl)C(F)I";
            var            sp            = CDK.SmilesParser;
            var            atomContainer = sp.ParseSmiles(rawMolSmiles);
            int            expResult     = 11;
            IAtomContainer result        = SMSDNormalizer.ConvertExplicitToImplicitHydrogens(atomContainer);

            Assert.AreEqual(expResult, result.Atoms.Count);
        }
Beispiel #4
0
        public void TestAromatizeMolecule()
        {
            string rawMolSmiles = "C1=CC2=C(C=C1)C=CC=C2";
            var    sp           = CDK.SmilesParser;
            var    mol          = sp.ParseSmiles(rawMolSmiles);

            SMSDNormalizer.AromatizeMolecule(mol);
            int count = 0;

            foreach (var b in mol.Bonds)
            {
                if (b.IsAromatic && b.Order.Equals(BondOrder.Double))
                {
                    count++;
                }
            }
            Assert.AreEqual(5, count);
        }
Beispiel #5
0
        public void TestGetHydrogenCount()
        {
            string rawMolSmiles  = "[H]POOSC(Br)C(Cl)C(F)I";
            var    sp            = CDK.SmilesParser;
            var    atomContainer = sp.ParseSmiles(rawMolSmiles);
            IAtom  atom          = null;

            foreach (var a in atomContainer.Atoms)
            {
                if (string.Equals(a.Symbol, "P", StringComparison.OrdinalIgnoreCase))
                {
                    atom = a;
                    break;
                }
            }
            int expResult = 2;
            int result    = SMSDNormalizer.GetHydrogenCount(atomContainer, atom);

            Assert.AreEqual(expResult, result);
        }
Beispiel #6
0
        public void TestMakeDeepCopy()
        {
            string rawMolSmiles = "[H]POOSC(Br)C(Cl)C(F)I";
            var    sp           = CDK.SmilesParser;
            var    container    = sp.ParseSmiles(rawMolSmiles);

            int counter = 0;

            foreach (var a in container.Atoms)
            {
                a.Id = (counter++).ToString();
            }

            IAtomContainer result = SMSDNormalizer.MakeDeepCopy(container);

            for (int i = 0; i < result.Atoms.Count; i++)
            {
                Assert.AreEqual(result.Atoms[i].Symbol, container.Atoms[i].Symbol);
                Assert.AreEqual(result.Atoms[i].Id, container.Atoms[i].Id);
            }
        }