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

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$R';;;;;;$|", state));
            Assert.IsTrue(state.atomLabels[0] == "R'");
        }
Exemple #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));
        }
Exemple #3
0
        public void AtomLabelsEmpty()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$$|", state));
            Assert.AreEqual(0, state.atomLabels.Count);
        }
Exemple #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");
        }
Exemple #5
0
        public void AtomLabelsTruncated1()
        {
            CxSmilesState state = new CxSmilesState();

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

            CxSmilesParser.ProcessCx("|$;;;_R1;$|", state);
            Assert.AreEqual("R1", state.atomLabels[3]);
        }
Exemple #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));
        }
Exemple #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")));
        }
Exemple #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")));
        }
Exemple #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));
        }
Exemple #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")));
        }
Exemple #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", "", "", "")));
        }
Exemple #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")));
        }
Exemple #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]));
        }
Exemple #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 })));
        }
Exemple #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);
                }
            }
        }
Exemple #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);
                }
            }
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #20
0
        public void HydrogenBondingSkipped()
        {
            CxSmilesState state = new CxSmilesState();

            Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|H:0.1,2.3|", state));
        }
Exemple #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));
        }
Exemple #22
0
        public void RelativeStereoReaction()
        {
            CxSmilesState state = new CxSmilesState();

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

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