Beispiel #1
0
        public void EscapedAtomLabels()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$R';;;;;;$|", state));
            Assert.IsTrue(state.atomLabels[0] == "R'");
        }
Beispiel #2
0
        public void HydrogenBondingTruncated()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreEqual(-1, CxSmilesParser.ProcessCx("|H:0.1,2.3", state));
            Assert.AreEqual(-1, CxSmilesParser.ProcessCx("|H:0.1,2.", state));
        }
Beispiel #3
0
        public void AtomLabelsEmpty()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$$|", state));
            Assert.AreEqual(0, state.atomLabels.Count);
        }
Beispiel #4
0
        public void EscapedAtomLabels2()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$;;;(C(R41)(R41))n;;R41;R41;R41;;_AP1;R41;R41;;_AP1$|", state));
            Assert.IsTrue(state.atomLabels[3] == "(C(R41)(R41))n");
        }
Beispiel #5
0
        public void AtomLabelsTruncated1()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreEqual(-1, CxSmilesParser.ProcessCx("|$;;;Het", state));
            Assert.AreEqual(-1, CxSmilesParser.ProcessCx("|$;;;Het;", state));
        }
Beispiel #6
0
        public void RemoveUnderscore()
        {
            CxSmilesState state = new CxSmilesState();

            CxSmilesParser.ProcessCx("|$;;;_R1;$|", state);
            Assert.AreEqual("R1", state.atomLabels[3]);
        }
Beispiel #7
0
        public void RelativeStereoMolecule()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|r|", state));
            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|r,$_R1$|", state));
            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$_R1$,r|", state));
        }
Beispiel #8
0
        public void AtomLabels()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$;;;Het;;;;;A$|", state));
            Assert.IsTrue(state.atomLabels.Contains(new KeyValuePair <int, string>(3, "Het")));
            Assert.IsTrue(state.atomLabels.Contains(new KeyValuePair <int, string>(8, "A")));
        }
Beispiel #9
0
        public void AtomValues()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$_AV:;;;5;;;;;8$|", state));
            Assert.IsTrue(state.atomValues.Contains(new KeyValuePair <int, string>(3, "5")));
            Assert.IsTrue(state.atomValues.Contains(new KeyValuePair <int, string>(8, "8")));
        }
Beispiel #10
0
        public void FragmentGrouping()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|f:0.1.2.3,4.5.6|", state));
            Assert.IsTrue(Compares.AreDeepEqual(
                              new[] { new[] { 0, 1, 2, 3 }, new[] { 4, 5, 6 } },
                              state.fragGroups));
        }
Beispiel #11
0
        public void MultiAtomSRU()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|Sg:n:1,2,3:m:ht|", state));
            Assert.IsTrue(Compares.DeepContains(
                              state.sgroups,
                              new CxSmilesState.PolymerSgroup("n", new[] { 1, 2, 3 }, "m", "ht")));
        }
Beispiel #12
0
        public void DataSgroups()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|SgD::cdk&#58;ReactionConditions:Heat&#10;Hv|", state));
            Assert.IsTrue(Compares.DeepContains(
                              state.dataSgroups,
                              new CxSmilesState.DataSgroup(new List <int>(), "cdk:ReactionConditions", "Heat\nHv", "", "", "")));
        }
Beispiel #13
0
        public void FragmentGroupingFollowedByAtomLabels()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|f:0.1.2.3,4.5.6,$;;;R$|", state));
            Assert.IsTrue(Compares.AreDeepEqual(
                              new[] { new[] { 0, 1, 2, 3 }, new[] { 4, 5, 6 } },
                              state.fragGroups));
            Assert.IsTrue(state.atomLabels.Contains(new KeyValuePair <int, string>(3, "R")));
        }
Beispiel #14
0
        public void Coords()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|(.0,-1.5,;-1.3,-.75,;-2.6,-1.5,;-3.9,-.75,;-3.9,.75,)|", state));
            Assert.IsTrue(new AprxDoubleArray(0, -1.5, 0).Matches(state.atomCoords[0]));
            Assert.IsTrue(new AprxDoubleArray(-1.3, -.75, 0).Matches(state.atomCoords[1]));
            Assert.IsTrue(new AprxDoubleArray(-2.6, -1.5, 0).Matches(state.atomCoords[2]));
            Assert.IsTrue(new AprxDoubleArray(-3.9, -.75, 0).Matches(state.atomCoords[3]));
            Assert.IsTrue(new AprxDoubleArray(-3.9, .75, 0).Matches(state.atomCoords[4]));
        }
Beispiel #15
0
        public void PositionalVariationImpliedLayer()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|m:2:5.6.7.8.9.10,4:5.6.7.8.9|", state));
            Assert.IsTrue(Compares.DeepContains(
                              state.positionVar,
                              new KeyValuePair <int, IList <int> >(2, new[] { 5, 6, 7, 8, 9, 10 })));
            Assert.IsTrue(Compares.DeepContains(
                              state.positionVar,
                              new KeyValuePair <int, IList <int> >(4, new[] { 5, 6, 7, 8, 9 })));
        }
Beispiel #16
0
        /// <summary>
        /// Parses CXSMILES layer and set attributes for atoms and bonds on the provided reaction.
        /// </summary>
        /// <param name="title">SMILES title field</param>
        /// <param name="rxn">parsed reaction</param>
        private void ParseRxnCXSMILES(string title, IReaction rxn)
        {
            if (title != null && title.StartsWithChar('|'))
            {
                int           pos;
                CxSmilesState cxstate;
                if ((pos = CxSmilesParser.ProcessCx(title, cxstate = new CxSmilesState())) >= 0)
                {
                    // set the correct title
                    rxn.SetProperty(CDKPropertyName.Title, title.Substring(pos));

                    var atomToMol = new Dictionary <IAtom, IAtomContainer>(100);
                    var atoms     = new List <IAtom>();
                    HandleFragmentGrouping(rxn, cxstate);

                    // merge all together
                    foreach (var mol in rxn.Reactants)
                    {
                        foreach (var atom in mol.Atoms)
                        {
                            atoms.Add(atom);
                            atomToMol[atom] = mol;
                        }
                    }
                    foreach (var mol in rxn.Agents)
                    {
                        foreach (var atom in mol.Atoms)
                        {
                            atoms.Add(atom);
                            atomToMol[atom] = mol;
                        }
                    }
                    foreach (var mol in rxn.Products)
                    {
                        foreach (var atom in mol.Atoms)
                        {
                            atoms.Add(atom);
                            atomToMol[atom] = mol;
                        }
                    }

                    AssignCxSmilesInfo(rxn.Builder, rxn, atoms, atomToMol, cxstate);
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// Parses CXSMILES layer and set attributes for atoms and bonds on the provided molecule.
        /// </summary>
        /// <param name="title">SMILES title field</param>
        /// <param name="mol">molecule</param>
        private void ParseMolCXSMILES(string title, IAtomContainer mol)
        {
            if (title != null && title.StartsWithChar('|'))
            {
                int           pos;
                CxSmilesState cxstate;
                if ((pos = CxSmilesParser.ProcessCx(title, cxstate = new CxSmilesState())) >= 0)
                {
                    // set the correct title
                    mol.Title = title.Substring(pos);

                    var atomToMol = new Dictionary <IAtom, IAtomContainer>(mol.Atoms.Count);
                    var atoms     = new List <IAtom>(mol.Atoms.Count);

                    foreach (var atom in mol.Atoms)
                    {
                        atoms.Add(atom);
                        atomToMol.Add(atom, mol);
                    }

                    AssignCxSmilesInfo(mol.Builder, mol, atoms, atomToMol, cxstate);
                }
            }
        }
Beispiel #18
0
        public void SkipCisTransUnspec()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|c:2,6,8,ctu:10,t:1,4,5|", state));
        }
Beispiel #19
0
        public void SkipLonePairDefinitions()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|c:6,8,t:4,lp:2:2,4:1,11:1,m:1:8.9|", state));
        }
Beispiel #20
0
        public void HydrogenBondingSkipped()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|H:0.1,2.3|", state));
        }
Beispiel #21
0
        public void HydrogenAndCoordinationBondingSkipped()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|H:0.1,2.3,C:6.7,3.4|", state));
        }
Beispiel #22
0
        public void RelativeStereoReaction()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|r:2,4,5|", state));
        }
Beispiel #23
0
 public void Unescape()
 {
     Assert.AreEqual("$", CxSmilesParser.Unescape("&#36;"));
     Assert.AreEqual("\u007F", CxSmilesParser.Unescape("&#127;")); // DEL
     Assert.AreEqual("\t", CxSmilesParser.Unescape("&#9;"));       // TAB
 }
Beispiel #24
0
        public void SkipTrans()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|t:1,4,5|", state));
        }