Exemplo n.º 1
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));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        public void BondInRing()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C@C"));
            Assert.AreEqual("C@C", Smarts.Generate(mol));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
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));
        }
Exemplo n.º 6
0
        public void CompGrouping()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "([Na+].[Cl-]).c1ccccc1"));
            Assert.AreEqual("c1ccccc1.([Na+].[Cl-])", Smarts.Generate(mol));
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
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));
        }
Exemplo n.º 10
0
        public void AromaticBond()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "[#6]:[#6]"));
            Assert.AreEqual("[#6]:[#6]", Smarts.Generate(mol));
        }
Exemplo n.º 11
0
        public void RingClosureExprs3()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C1-,=CCCC1"));
            Assert.AreEqual("C1CCCC-,=1", Smarts.Generate(mol));
        }
Exemplo n.º 12
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));
        }
Exemplo n.º 13
0
        public void NotTripleBond()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C!#C"));
            Assert.AreEqual("C!#C", Smarts.Generate(mol));
        }
Exemplo n.º 14
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));
        }
Exemplo n.º 15
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));
        }
Exemplo n.º 16
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));
        }
Exemplo n.º 17
0
        public void BondFalse()
        {
            var mol = new QueryAtomContainer(null);

            Assert.IsTrue(Smarts.Parse(mol, "C!~C"));
            Assert.AreEqual("C!~C", Smarts.Generate(mol));
        }
Exemplo n.º 18
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));
        }
Exemplo n.º 19
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));
        }
Exemplo n.º 20
0
        public void IndoleRoundTrip()
        {
            var mol = new QueryAtomContainer(null);

            Assert.IsTrue(Smarts.Parse(mol, "n1cnc2c1cccc2"));
            // CDK choice of data structures lose local arrangement but
            // output is still indole
            Assert.AreEqual("n1c2c(nc1)cccc2", Smarts.Generate(mol));
        }
Exemplo n.º 21
0
        private static void Test(string smaexp, string smainp)
        {
            var qry = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(qry, smainp));
            var sup    = QueryAtomContainerCreator.SuppressQueryHydrogens(qry);
            var smaact = Smarts.Generate(sup);

            Assert.AreEqual(smaexp, smaact);
        }
Exemplo n.º 22
0
        private void Test(string expected, string smi, params ExprType[] opts)
        {
            var mol = smipar.ParseSmiles(smi);

            Cycles.MarkRingAtomsAndBonds(mol);
            var query  = QueryAtomContainer.Create(mol, opts);
            var actual = Smarts.Generate(query);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 23
0
        public void BondStereoCisUnspec()
        {
            var mol = new QueryAtomContainer(null);

            Assert.IsTrue(Smarts.Parse(mol, "C/C=C\\?C"));
            Assert.AreEqual("C/C=C\\?C", Smarts.Generate(mol));
            // not trans same as cis/unspec
            mol.RemoveAllElements();
            Assert.IsTrue(Smarts.Parse(mol, "C/C=C!/C"));
            Assert.AreEqual("C/C=C\\?C", Smarts.Generate(mol));
        }
Exemplo n.º 24
0
        public void AtomStereoReordered()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C[C@H](O)CC"));
            var bonds = mol.Bonds.ToArray();

            Swap(bonds, 1, 2);
            mol.SetBonds(bonds);
            Assert.AreEqual("C[C@@H1](CC)O", Smarts.Generate(mol));
        }
Exemplo n.º 25
0
        public void BondStereoTransUnspec()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C/?C=C/C"));
            Assert.AreEqual("C/C=C/?C", Smarts.Generate(mol));
            // not cis same as trans/unspec
            mol.RemoveAllElements();
            Assert.IsTrue(Smarts.Parse(mol, "C/C=C!\\C"));
            Assert.AreEqual("C/C=C/?C", Smarts.Generate(mol));
        }
Exemplo n.º 26
0
        public void AtomStereoReordered3()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "[C@H](C)(O)CC"));
            var atoms = mol.Atoms.ToArray();

            Swap(atoms, 0, 1);
            mol.SetAtoms(atoms);
            Assert.AreEqual("C[C@@H1](O)CC", Smarts.Generate(mol));
        }
Exemplo n.º 27
0
        public void BondStereoCisThenTransUnspecWithNbr()
        {
            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));
            var atoms = mol.Atoms.ToArray();

            Swap(atoms, 0, atoms.Length - 1);
            mol.SetAtoms(atoms);
            Assert.AreEqual("O/?C=C/C(=C\\C)C", Smarts.Generate(mol));
        }
Exemplo n.º 28
0
        public void BondStereoTrans()
        {
            var mol = new QueryAtomContainer();

            Assert.IsTrue(Smarts.Parse(mol, "C/C=C/C"));
            Assert.AreEqual("C/C=C/C", Smarts.Generate(mol));
            var atoms = mol.Atoms.ToArray();

            Swap(atoms, 0, 1);
            mol.SetAtoms(atoms);
            Assert.AreEqual("C(\\C)=C/C", Smarts.Generate(mol));
        }
Exemplo n.º 29
0
        static void Main()
        {
            IAtomContainer mol = null;

            #region 1
            if (Smarts.Parse(mol, "[aD3]a-a([aD3])[aD3]"))
            {
                var smarts = Smarts.Generate(mol);
            }
            #endregion

            {
                #region GenerateAtom
                var expr = new Expr(ExprType.Degree, 4).And(
                    new Expr(ExprType.IsAromatic));
                var aExpr = Smarts.GenerateAtom(expr);
                // aExpr = "[D4a]"
                #endregion
            }

            {
                #region GenerateBond
                var expr  = new Expr(ExprType.True);
                var bExpr = Smarts.GenerateBond(expr);
                // // bExpr='~'
                #endregion
            }

            {
                #region Generate
                var qatom1 = new QueryAtom();
                var qatom2 = new QueryAtom();
                var qbond  = new QueryBond();
                qatom1.Expression = new Expr(ExprType.IsAromatic);
                qatom2.Expression = new Expr(ExprType.IsAromatic);
                qbond.Expression  = new Expr(ExprType.IsAliphatic);
                qbond.SetAtoms(new IAtom[] { qatom1, qatom2 });
                mol.Atoms.Add(qatom1);
                mol.Atoms.Add(qatom2);
                mol.Bonds.Add(qbond);
                var smartsStr = Smarts.Generate(mol);
                // smartsStr = 'a!:a'
                #endregion
            }
        }
Exemplo n.º 30
0
 public static string MolToSmarts(IAtomContainer mol)
 {
     return(Smarts.Generate(mol));
 }