Example #1
0
        public void BondStereoCisTrans()
        {
            var mol = new QueryAtomContainer(null);

            Assert.IsTrue(Smarts.Parse(mol, "C/C=C/,\\C"));
            Assert.AreEqual("C/C=C/,\\C", Smarts.Generate(mol));
        }
Example #2
0
        public void AtomStereo()
        {
            var mol = new QueryAtomContainer(null);

            Assert.IsTrue(Smarts.Parse(mol, "C[C@H](O)CC"));
            Assert.AreEqual("C[C@H1](O)CC", Smarts.Generate(mol));
        }
Example #3
0
        public void TestAliphaticSymbols()
        {
            foreach (var e in ChemicalElement.Values)
            {
                switch (e.Symbol)
                {
                case "R":
                    continue;

                default:
                    int len = e.Symbol.Length;
                    if (len == 1 || len == 2)
                    {
                        string smarts = $"[{e.Symbol}]";
                        var    mol    = new QueryAtomContainer();
                        Assert.IsTrue(Smarts.Parse(mol, smarts), smarts);
                        var expr = GetAtomExpr(mol.Atoms[0]);
                        var ee   = new Expr(ExprType.Element, e.AtomicNumber);
                        var ea   = new Expr(AliphaticElement, e.AtomicNumber);
                        Assert.IsTrue(expr.Equals(ee) || expr.Equals(ea));
                    }
                    break;
                }
            }
        }
Example #4
0
        public void BondFalse()
        {
            var mol = new QueryAtomContainer(null);

            Assert.IsTrue(Smarts.Parse(mol, "C!~C"));
            Assert.AreEqual("C!~C", Smarts.Generate(mol));
        }
Example #5
0
        public void BondTrue()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C~C~N(~O)~O"));
            Assert.AreEqual("C~C~N(~O)~O", Smarts.Generate(mol));
        }
Example #6
0
        public void RoundTripStereo()
        {
            var mol = new QueryAtomContainer();

            Smarts.Parse(mol, "O1.[S@]=1(C)CC");
            Assert.AreEqual("O=[S@@](C)CC", Smarts.Generate(mol));
        }
Example #7
0
        public void AromaticBond()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "[#6]:[#6]"));
            Assert.AreEqual("[#6]:[#6]", Smarts.Generate(mol));
        }
Example #8
0
        public static IAtomContainer MolFromSmarts(string smarts)
        {
            var mol = CDK.Builder.NewAtomContainer();

            Smarts.Parse(mol, smarts, SmartsFlaver.Daylight);
            return(mol);
        }
Example #9
0
        public void BondStereoCisThenTransUnspecWithNbrComplex()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C/?C=C(C)\\C=C\\O"));
            Assert.AreEqual("C/?C=C(C)/C=C/O", Smarts.Generate(mol));
        }
Example #10
0
        public void RingClosureExprs3()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C1-,=CCCC1"));
            Assert.AreEqual("C1CCCC-,=1", Smarts.Generate(mol));
        }
Example #11
0
        public void BondStereoUnspec()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C/C=C/?\\?C"));
            Assert.AreEqual("C/C=C!/!\\C", Smarts.Generate(mol));
        }
Example #12
0
        public void CompGroupingOnAgent()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, ">(c1ccccc1[O-].[Na+])>"));
            Assert.AreEqual(">(c1c(cccc1)[O-].[Na+])>", Smarts.Generate(mol));
        }
Example #13
0
        public void AtomStereoOrUnspec()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C[C@?H](O)CC"));
            Assert.AreEqual("C[CH1@?](O)CC", Smarts.Generate(mol));
        }
Example #14
0
        public void ReactionWithMaps()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "c1cccc[c:1]1[NH2:2]>>c1cccc[c:1]1[N:2](~O)~O"));
            Assert.AreEqual("c1[c:1](cccc1)[NH2:2]>>c1[c:1](cccc1)[N:2](~O)~O", Smarts.Generate(mol));
        }
Example #15
0
        public void CompGrouping()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "([Na+].[Cl-]).c1ccccc1"));
            Assert.AreEqual("c1ccccc1.([Na+].[Cl-])", Smarts.Generate(mol));
        }
Example #16
0
        public void NotTripleBond()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C!#C"));
            Assert.AreEqual("C!#C", Smarts.Generate(mol));
        }
Example #17
0
        public void Reaction()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "c1ccccc1[NH2]>>c1ccccc1N(~O)~O"));
            Assert.AreEqual("c1c(cccc1)[NH2]>>c1c(cccc1)N(~O)~O", Smarts.Generate(mol));
        }
Example #18
0
        static IAtomContainer Sma(string smarts)
        {
            var query = new QueryAtomContainer(null);

            Smarts.Parse(query, smarts);
            return(query);
        }
Example #19
0
        public void BondInRing()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C@C"));
            Assert.AreEqual("C@C", Smarts.Generate(mol));
        }
Example #20
0
        static Expr GetBondExpr(string sma, SmartsFlaver flav)
        {
            var mol = new AtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, sma, flav));
            return(GetBondExpr(mol.Bonds[0]));
        }
Example #21
0
        public void BondStereoCisThenTransWithNbr()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C/C=C(C)\\C=C\\C"));
            Assert.AreEqual("C/C=C(C)\\C=C\\C", Smarts.Generate(mol));
        }
Example #22
0
        public void AtomMaps()
        {
            var mol = new QueryAtomContainer();

            Assert.IsFalse(Smarts.Parse(mol, "[:10]"));
            Assert.IsTrue(Smarts.Parse(mol, "[*:10]"));
            Assert.AreEqual(10, mol.Atoms[0].GetProperty <int>(CDKPropertyName.AtomAtomMapping));
        }
Example #23
0
        public void MultipleReads()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C/C=C/C"));
            Assert.IsTrue(Smarts.Parse(mol, "C/C=C\\C"));
            Assert.AreEqual("C/C=C/C.C/C=C\\C", Smarts.Generate(mol));
        }
Example #24
0
 public void TestRecursive()
 {
     Assert.IsTrue(Smarts.Parse(new QueryAtomContainer(), "[$(*OC)]"));
     Assert.IsFalse(Smarts.Parse(new QueryAtomContainer(), "[$*OC)]"));
     Assert.IsFalse(Smarts.Parse(new QueryAtomContainer(), "[$(*OC]"));
     Assert.IsTrue(Smarts.Parse(new QueryAtomContainer(), "[$((*[O-].[Na+]))]"));
     Assert.IsFalse(Smarts.Parse(new QueryAtomContainer(), "[$([J])]"));
 }
Example #25
0
        public void IndoleWithExprRoundTrip()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "[n;$(*C),$(*OC)]1ccc2c1cccc2"));
            // CDK choice of data structures lose local arrangement but
            // output is still indole
            Assert.AreEqual("[n;$(*C),$(*OC)]1c2c(cc1)cccc2", Smarts.Generate(mol));
        }
Example #26
0
        public void TrailingOperator()
        {
            var mol = new AtomContainer();

            Assert.IsFalse(Smarts.Parse(mol, "[a#6,]"));
            Assert.IsFalse(Smarts.Parse(mol, "[a#6;]"));
            Assert.IsFalse(Smarts.Parse(mol, "[a#6&]"));
            Assert.IsFalse(Smarts.Parse(mol, "[a#6!]"));
        }
Example #27
0
        public void LeadingBondOperator()
        {
            var mol = new AtomContainer();

            Assert.IsFalse(Smarts.Parse(mol, "*,-*"));
            Assert.IsFalse(Smarts.Parse(mol, "*;-*"));
            Assert.IsFalse(Smarts.Parse(mol, "*&-*"));
            Assert.IsTrue(Smarts.Parse(mol, "*!-*"));
        }
Example #28
0
        public void RingSmallestInvalid()
        {
            var mol = new AtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "[r0]")); // not in ring
            Assert.IsFalse(Smarts.Parse(mol, "[r1]"));
            Assert.IsFalse(Smarts.Parse(mol, "[r2]"));
            Assert.IsTrue(Smarts.Parse(mol, "[r3]"));
        }
Example #29
0
        public void LeadingOperator()
        {
            var mol = new AtomContainer();

            Assert.IsFalse(Smarts.Parse(mol, "[,a#6]"));
            Assert.IsFalse(Smarts.Parse(mol, "[;a#6]"));
            Assert.IsFalse(Smarts.Parse(mol, "[&a#6]"));
            Assert.IsTrue(Smarts.Parse(mol, "[!a#6]"));
        }
Example #30
0
        public void TrailingBondOperator()
        {
            var mol = new AtomContainer();

            Assert.IsFalse(Smarts.Parse(mol, "*-,*"));
            Assert.IsFalse(Smarts.Parse(mol, "*-;*"));
            Assert.IsFalse(Smarts.Parse(mol, "*-&*"));
            Assert.IsFalse(Smarts.Parse(mol, "*-!*"));
        }