public void BondStereoUnspec()
        {
            var mol = new QueryAtomContainer(null);

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

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

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

            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));
        }
        public void CompGrouping()
        {
            var mol = new QueryAtomContainer(null);

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

            Assert.IsTrue(Smarts.Parse(mol, "C1-,=CCCC1"));
            Assert.AreEqual("C1CCCC-,=1", Smarts.Generate(mol));
        }
        public void Reaction()
        {
            var mol = new QueryAtomContainer(null);

            Assert.IsTrue(Smarts.Parse(mol, "c1ccccc1[NH2]>>c1ccccc1N(~O)~O"));
            Assert.AreEqual("c1c(cccc1)[NH2]>>c1c(cccc1)N(~O)~O", Smarts.Generate(mol));
        }
        public void NotTripleBond()
        {
            var mol = new QueryAtomContainer(null);

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

            Assert.IsTrue(Smarts.Parse(mol, "[#6]:[#6]"));
            Assert.AreEqual("[#6]:[#6]", Smarts.Generate(mol));
        }
        public void BondFalse()
        {
            var mol = new QueryAtomContainer(null);

            Assert.IsTrue(Smarts.Parse(mol, "C!~C"));
            Assert.AreEqual("C!~C", Smarts.Generate(mol));
        }
Exemple #11
0
        public override int GetHashCode()
        {
            int result = Smarts != null?Smarts.GetHashCode() : 0;

            result = 31 * result + (matchingAtoms != null ? Arrays.GetHashCode(matchingAtoms) : 0);
            return(result);
        }
Exemple #12
0
        static IAtomContainer Sma(string smarts)
        {
            var query = new QueryAtomContainer(null);

            Smarts.Parse(query, smarts);
            return(query);
        }
        public void BondStereoCisThenTransWithNbr()
        {
            var mol = new QueryAtomContainer(null);

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

            Assert.IsTrue(Smarts.Parse(mol, "C/?C=C(C)\\C=C\\O"));
            Assert.AreEqual("C/?C=C(C)/C=C/O", Smarts.Generate(mol));
        }
Exemple #15
0
        public static IAtomContainer MolFromSmarts(string smarts)
        {
            var mol = CDK.Builder.NewAtomContainer();

            Smarts.Parse(mol, smarts, SmartsFlaver.Daylight);
            return(mol);
        }
Exemple #16
0
        public void BondInRing()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C@C"));
            Assert.AreEqual("C@C", Smarts.Generate(mol));
        }
Exemple #17
0
        public void SingleOrDouble()
        {
            var expr = new Expr(ExprType.AliphaticOrder, 1)
                       .Or(new Expr(ExprType.AliphaticOrder, 2));

            Assert.AreEqual("-,=", Smarts.GenerateBond(expr));
        }
Exemple #18
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));
        }
Exemple #19
0
        public void SingleOrDoubleInRing2()
        {
            var expr = new Expr(ExprType.IsInRing)
                       .And(new Expr(ExprType.SingleOrDouble));

            Assert.AreEqual("@;-,=", Smarts.GenerateBond(expr));
        }
        static Expr GetBondExpr(string sma, SmartsFlaver flav)
        {
            var mol = new AtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, sma, flav));
            return(GetBondExpr(mol.Bonds[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;
                }
            }
        }
        public void RoundTripStereo()
        {
            var mol = new QueryAtomContainer(null);

            Smarts.Parse(mol, "O1.[S@]=1(C)CC");
            Assert.AreEqual("O=[S@@](C)CC", Smarts.Generate(mol));
        }
Exemple #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));
        }
Exemple #24
0
 public void FormalCharges()
 {
     Assert.AreEqual("[-2]", Smarts.GenerateAtom(GetExpr(ExprType.FormalCharge, -2)));
     Assert.AreEqual("[-]", Smarts.GenerateAtom(GetExpr(ExprType.FormalCharge, -1)));
     Assert.AreEqual("[+0]", Smarts.GenerateAtom(GetExpr(ExprType.FormalCharge, 0)));
     Assert.AreEqual("[+]", Smarts.GenerateAtom(GetExpr(ExprType.FormalCharge, 1)));
     Assert.AreEqual("[+2]", Smarts.GenerateAtom(GetExpr(ExprType.FormalCharge, 2)));
 }
        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));
        }
 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])]"));
 }
Exemple #27
0
        public void PrintData()
        {
            PrintMessage("Beauty", Beauty.ToString(), Utilities.Getmark(1, Beauty));
            PrintMessage("Smarts", Smarts.ToString(), Utilities.Getmark(4, Smarts));
            PrintMessage("Phisics", Phisics.ToString(), Utilities.Getmark(7, Phisics));

            PrintAllData(arr);
        }
Exemple #28
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));
        }
Exemple #29
0
        public void UsrRecrNot()
        {
            var expr = new Expr(ExprType.Element, 9)
                       .Or(new Expr(ExprType.Element, 17))
                       .Or(new Expr(ExprType.Element, 35))
                       .Negate();

            Assert.AreEqual("[!$([F,Cl,Br])]", Smarts.GenerateAtom(expr));
        }
Exemple #30
0
 public void AtomicNumHighWeightElements()
 {
     Assert.AreEqual("[#110]", Smarts.GenerateAtom(GetExpr(ExprType.Element, AtomicNumbers.Darmstadtium)));
     Assert.AreEqual("[#117]", Smarts.GenerateAtom(GetExpr(ExprType.Element, AtomicNumbers.Tennessine)));
     Assert.AreEqual("[#113]", Smarts.GenerateAtom(GetExpr(ExprType.Element, AtomicNumbers.Nihonium)));
     Assert.AreEqual("[#110]", Smarts.GenerateAtom(GetExpr(ExprType.AliphaticElement, AtomicNumbers.Darmstadtium)));
     Assert.AreEqual("[#117]", Smarts.GenerateAtom(GetExpr(ExprType.AliphaticElement, AtomicNumbers.Tennessine)));
     Assert.AreEqual("[#113]", Smarts.GenerateAtom(GetExpr(ExprType.AliphaticElement, AtomicNumbers.Nihonium)));
 }