public void EscapedAtomLabels() { CxSmilesState state = new CxSmilesState(); Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$R';;;;;;$|", state)); Assert.IsTrue(state.atomLabels[0] == "R'"); }
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)); }
public void AtomLabelsEmpty() { CxSmilesState state = new CxSmilesState(); Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|$$|", state)); Assert.AreEqual(0, state.atomLabels.Count); }
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"); }
public void AtomLabelsTruncated1() { CxSmilesState state = new CxSmilesState(); Assert.AreEqual(-1, CxSmilesParser.ProcessCx("|$;;;Het", state)); Assert.AreEqual(-1, CxSmilesParser.ProcessCx("|$;;;Het;", state)); }
public void RemoveUnderscore() { CxSmilesState state = new CxSmilesState(); CxSmilesParser.ProcessCx("|$;;;_R1;$|", state); Assert.AreEqual("R1", state.atomLabels[3]); }
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)); }
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"))); }
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"))); }
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)); }
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"))); }
public void DataSgroups() { CxSmilesState state = new CxSmilesState(); Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|SgD::cdk:ReactionConditions:Heat Hv|", state)); Assert.IsTrue(Compares.DeepContains( state.dataSgroups, new CxSmilesState.DataSgroup(new List <int>(), "cdk:ReactionConditions", "Heat\nHv", "", "", ""))); }
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"))); }
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])); }
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 }))); }
/// <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); } } }
/// <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); } } }
public void SkipCisTransUnspec() { CxSmilesState state = new CxSmilesState(); Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|c:2,6,8,ctu:10,t:1,4,5|", state)); }
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)); }
public void HydrogenBondingSkipped() { CxSmilesState state = new CxSmilesState(); Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|H:0.1,2.3|", state)); }
public void HydrogenAndCoordinationBondingSkipped() { CxSmilesState state = new CxSmilesState(); Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|H:0.1,2.3,C:6.7,3.4|", state)); }
public void RelativeStereoReaction() { CxSmilesState state = new CxSmilesState(); Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|r:2,4,5|", state)); }
public void Unescape() { Assert.AreEqual("$", CxSmilesParser.Unescape("$")); Assert.AreEqual("\u007F", CxSmilesParser.Unescape("")); // DEL Assert.AreEqual("\t", CxSmilesParser.Unescape("	")); // TAB }
public void SkipTrans() { CxSmilesState state = new CxSmilesState(); Assert.AreNotEqual(-1, CxSmilesParser.ProcessCx("|t:1,4,5|", state)); }