Пример #1
0
        public void LoadFromFile()
        {
            var factory = new Abbreviations();

            //Assert.AreEqual(27, factory.LoadFromFile("obabel_superatoms.smi"));
            Assert.AreEqual(27, factory.LoadFromFile("NCDK.Depict.obabel_superatoms.smi"));
        }
Пример #2
0
        public void SnCl2()
        {
            var factory = new Abbreviations();
            var mol     = Smi("Cl[Sn]Cl");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("SnCl2", sgroups[0].Subscript);
        }
Пример #3
0
        public void HOOH()
        {
            var factory = new Abbreviations();
            var mol     = Smi("OO");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("HOOH", sgroups[0].Subscript);
        }
Пример #4
0
        public void AvoidOverZealousAbbreviations()
        {
            var factory = new Abbreviations {
                "*c1ccccc1 Ph"
            };
            var mol = Smi("Clc1ccccc1");

            Assert.AreEqual(0, factory.Apply(mol));
        }
Пример #5
0
        public void PhenylShouldNotMatchBenzene()
        {
            var factory = new Abbreviations {
                "*c1ccccc1 Ph"
            };
            var mol     = Smi("c1ccccc1");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(0, sgroups.Count);
        }
Пример #6
0
        public void HclSaltOfEdci()
        {
            var factory = new Abbreviations {
                "CCN=C=NCCCN(C)C EDCI"
            };
            var mol     = Smi("CCN=C=NCCCN(C)C.Cl");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("EDCI·HCl", sgroups[0].Subscript);
        }
Пример #7
0
        public void SO3minusFromHeteroCollapseNone()
        {
            var factory = new Abbreviations {
                "*S(=O)(=O)[O-] SO3-"
            };
            var mol     = Smi("c1ccccc1N(S(=O)(=O)[O-])S(=O)(=O)[O-]");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(2, sgroups.Count);
            Assert.AreEqual("SO3-", sgroups[0].Subscript);
            Assert.AreEqual("SO3-", sgroups[1].Subscript);
        }
Пример #8
0
        public void PotassiumCarbonate()
        {
            var mol     = Smi("[K+].[O-]C(=O)[O-].[K+]");
            var factory = new Abbreviations {
                "[K+].[O-]C(=O)[O-].[K+] K2CO3"
            };
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("K2CO3", sgroups[0].Subscript);
            Assert.AreEqual(6, sgroups[0].Atoms.Count);
        }
Пример #9
0
        public void IPrFromHeteroCollapse()
        {
            var factory = new Abbreviations {
                "*C(C)C iPr"
            };
            var mol     = Smi("[CH3:27][CH:19]([CH3:28])[C:20]1=[N:26][C:23](=[CH:22][S:21]1)[C:24](=[O:25])O");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("iPr", sgroups[0].Subscript);
            Assert.AreEqual(1, sgroups[0].Bonds.Count);
            Assert.AreEqual(3, sgroups[0].Atoms.Count);
        }
Пример #10
0
        public void PhenylShouldMatchKekuleForm()
        {
            var factory = new Abbreviations {
                "*c1ccccc1 Ph"
            };
            var mol     = Smi("CCCCC1=CC=CC=C1");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("Ph", sgroups[0].Subscript);
            Assert.AreEqual(6, sgroups[0].Atoms.Count);
            Assert.AreEqual(1, sgroups[0].Bonds.Count);
        }
Пример #11
0
        public void PhenylShouldAbbreviateExplicitHydrogens()
        {
            var factory = new Abbreviations {
                "*c1ccccc1 Ph"
            };
            var mol     = Smi("CCCCc1ccc([H])cc1");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("Ph", sgroups[0].Subscript);
            Assert.AreEqual(7, sgroups[0].Atoms.Count);
            Assert.AreEqual(1, sgroups[0].Bonds.Count);
        }
Пример #12
0
        public void DcmAndTfaNoSingleFrag()
        {
            var factory = new Abbreviations();
            var mol     = Smi("ClCCl.FC(F)(F)C(=O)O");

            factory.Add("ClCCl DCM");
            factory.Add("FC(F)(F)C(=O)O TFA");
            factory.ContractToSingleLabel = false;
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("DCM", sgroups[0].Subscript);
        }
Пример #13
0
        public void NBocFromHeteroCollapseExplicitH()
        {
            var factory = new Abbreviations {
                "*C(=O)OC(C)(C)C Boc"
            };
            var mol     = Smi("c1cc2ccccc2ccn1C(=O)OC(C)(C)C");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("NBoc", sgroups[0].Subscript);
            Assert.AreEqual(2, sgroups[0].Bonds.Count);
            Assert.AreEqual(8, sgroups[0].Atoms.Count);
        }
Пример #14
0
        public void TFASaltDisconnected()
        {
            Abbreviations  factory = new Abbreviations();
            IAtomContainer mol     = Smi("c1ccccc1c1ccccc1.FC(F)(F)C(=O)O");

            factory.Add("*C(F)(F)F CF3");
            factory.Add("*C(=O)O CO2H");
            factory.Add("FC(F)(F)C(=O)O TFA");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("TFA", sgroups[0].Subscript);
        }
Пример #15
0
        public void AvoidAmbiguity()
        {
            var smi     = "C1CCCCC1=NC(C)C";
            var factory = new Abbreviations
            {
                "*C(C)C iPr"
            };
            var mol     = Smi(smi);
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("iPr", sgroups[0].Subscript);
        }
Пример #16
0
        public void AbbreviationsHavePriority()
        {
            var factory = new Abbreviations
            {
                "*CCC Pr",
                "*CC Et"
            };
            var mol     = Smi("c1ccccc1CCC");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("Pr", sgroups[0].Subscript);
        }
Пример #17
0
        public void MultipleDisconnectedAbbreviations2()
        {
            var smi     = "ClCCl.Cl[Pd]Cl.[Fe+2].c1ccc(P([c-]2cccc2)c2ccccc2)cc1.c1ccc(P([c-]2cccc2)c2ccccc2)cc1";
            var factory = new Abbreviations
            {
                "Cl[Pd]Cl.[Fe+2].c1ccc(P([c-]2cccc2)c2ccccc2)cc1.c1ccc(P([c-]2cccc2)c2ccccc2)cc1 Pd(dppf)Cl2",
                "Cl[Pd]Cl PdCl2"
            };
            var mol     = Smi(smi);
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(1, sgroups.Count);
            Assert.AreEqual("Pd(dppf)Cl2", sgroups[0].Subscript);
        }
Пример #18
0
        public void TFASaltConnected()
        {
            var factory = new Abbreviations();
            var mol     = Smi("FC(F)(F)C(=O)O");

            factory.Add("*C(F)(F)F CF3");
            factory.Add("*C(=O)O CO2H");
            factory.Add("FC(F)(F)C(=O)O TFA");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(2, sgroups.Count);
            for (int i = 0; i < 2; i++)
            {
                var sgroup = sgroups[i];
                Assert.IsTrue(sgroup.Subscript.Contains("CF3") || sgroup.Subscript.Contains("CO2H"));
            }
            Assert.AreNotEqual(sgroups[0].Subscript, sgroups[1].Subscript);
        }
Пример #19
0
        public void NitroGroups()
        {
            var factory = new Abbreviations
            {
                "*N(=O)(=O) NO2",
                "*[N+]([O-])(=O) NO2"
            };
            var mol     = Smi("O=N(=O)CCCC[N+]([O-])=O");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(2, sgroups.Count);
            Assert.AreEqual("NO2", sgroups[0].Subscript);
            Assert.AreEqual(3, sgroups[0].Atoms.Count);
            Assert.AreEqual(1, sgroups[0].Bonds.Count);
            Assert.AreEqual("NO2", sgroups[1].Subscript);
            Assert.AreEqual(3, sgroups[1].Atoms.Count);
            Assert.AreEqual(1, sgroups[1].Bonds.Count);
        }
Пример #20
0
        public void DontOverwriteExistingSgroups()
        {
            var factory = new Abbreviations {
                "*CCC Bu"
            };
            var mol    = Smi("c1ccccc1CCC");
            var sgroup = new Sgroup();

            sgroup.Atoms.Add(mol.Atoms[6]);
            sgroup.Atoms.Add(mol.Atoms[7]);
            sgroup.Atoms.Add(mol.Atoms[8]);
            sgroup.Type      = SgroupType.CtabAbbreviation;
            sgroup.Subscript = "n-Bu";
            mol.SetCtabSgroups(new[] { sgroup });
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(0, sgroups.Count);
        }
Пример #21
0
        public void Phenyl()
        {
            var factory = new Abbreviations {
                "*c1ccccc1 Ph"
            };
            var mol     = Smi("CCCCCCC(c1ccccc1)(c1ccccc1)c1ccccc1");
            var sgroups = factory.Generate(mol);

            Assert.AreEqual(3, sgroups.Count);
            Assert.AreEqual("Ph", sgroups[0].Subscript);
            Assert.AreEqual(6, sgroups[0].Atoms.Count);
            Assert.AreEqual(1, sgroups[0].Bonds.Count);
            Assert.AreEqual("Ph", sgroups[1].Subscript);
            Assert.AreEqual(6, sgroups[1].Atoms.Count);
            Assert.AreEqual(1, sgroups[1].Bonds.Count);
            Assert.AreEqual("Ph", sgroups[2].Subscript);
            Assert.AreEqual(6, sgroups[2].Atoms.Count);
            Assert.AreEqual(1, sgroups[2].Bonds.Count);
        }