public void FragmentGroupingProducts() { IReaction reaction = smipar.ParseReactionSmiles("CC1=NC2=C(O)C=CC=C2C=C1.CC(Cl)=O>[O-][N+](=O)C1=CC=CC=C1>CC(=O)C1=C2C=CC(C)=NC2=C(O)C=C1.[Al+3].[Cl-].[Cl-].[Cl-] |f:3.4.5.6|"); Assert.AreEqual(2, reaction.Reactants.Count); Assert.AreEqual(1, reaction.Agents.Count); Assert.AreEqual(2, reaction.Products.Count); Assert.AreEqual("", reaction.GetProperty <string>(CDKPropertyName.Title)); }
private Bounds GenerateReactionConditions(IReaction chemObj, Color fg, double scale) { var title = chemObj.GetProperty <string>(CDKPropertyName.ReactionConditions); if (string.IsNullOrEmpty(title)) { return(new Bounds()); } return(new Bounds(MarkedElement.Markup(StandardGenerator.EmbedText(font, emSize, title, fg, 1 / scale), "conditions"))); }
public void TestReactionProperties() { var filename = "NCDK.Data.CML.reaction.2.cml"; var ins = ResourceLoader.GetAsStream(filename); var reader = new CMLReader(ins); var chemFile = builder.NewChemFile(); chemFile = (IChemFile)reader.Read(chemFile); reader.Close(); IReaction reaction = chemFile[0][0].ReactionSet[0]; Assert.AreEqual("3", reaction.GetProperty <string>("Ka")); }
public static Tuple <string, string, string> GetInchiKeyPair(IReaction edge) { var rctInchi = GenerateInchi(edge.Reactants[0]); var prdInchi = GenerateInchi(edge.Products[0]); if (rctInchi == null || prdInchi == null) { return(null); } else { return(Tuple.Create(rctInchi, prdInchi, edge.GetProperty <string>(CDKPropertyName.SMILES))); } }
public void EmptyCXSMILES() { IReaction reaction = smipar.ParseReactionSmiles("CC1=NC2=C(O)C=CC=C2C=C1.CC(Cl)=O>[Al+3].[Cl-].[Cl-].[Cl-].[O-][N+](=O)C1=CC=CC=C1>CC(=O)C1=C2C=CC(C)=NC2=C(O)C=C1 ||"); Assert.AreEqual("", reaction.GetProperty <string>(CDKPropertyName.Title)); }
/// <summary> /// Writes a Reaction to an Stream in MDL sdf format. /// </summary> /// <param name="reaction">A Reaction that is written to an Stream</param> private void WriteReaction(IReaction reaction) { int reactantCount = reaction.Reactants.Count; int productCount = reaction.Products.Count; if (reactantCount <= 0 || productCount <= 0) { throw new CDKException("Either no reactants or no products present."); } try { // taking care of the $$$$ signs: // we do not write such a sign at the end of the first reaction, thus we have to write on BEFORE the second reaction if (reactionNumber == 2) { writer.Write("$$$$"); writer.Write('\n'); } writer.Write("$RXN"); writer.Write('\n'); // reaction name string line = reaction.GetProperty <string>(CDKPropertyName.Title); if (line == null) { line = ""; } if (line.Length > 80) { line = line.Substring(0, 80); } writer.Write(line); writer.Write('\n'); // user/program/date&time/reaction registry no. line writer.Write('\n'); // comment line line = reaction.GetProperty <string>(CDKPropertyName.Remark); if (line == null) { line = ""; } if (line.Length > 80) { line = line.Substring(0, 80); } writer.Write(line); writer.Write('\n'); line = ""; line += FormatMDLInt(reactantCount, 3); line += FormatMDLInt(productCount, 3); writer.Write(line); writer.Write('\n'); int i = 0; foreach (var mapping in reaction.Mappings) { var it = mapping.GetRelatedChemObjects().ToReadOnlyList(); it[0].SetProperty(CDKPropertyName.AtomAtomMapping, i + 1); it[1].SetProperty(CDKPropertyName.AtomAtomMapping, i + 1); i++; } WriteAtomContainerSet(reaction.Reactants); WriteAtomContainerSet(reaction.Products); //write sdfields, if any if (rdFields != null) { var set = rdFields.Keys; foreach (var element in set) { writer.Write("> <" + (string)element + ">"); writer.Write('\n'); writer.Write(rdFields[element].ToString()); writer.Write('\n'); writer.Write('\n'); } } // taking care of the $$$$ signs: // we write such a sign at the end of all except the first molecule if (reactionNumber != 1) { writer.Write("$$$$"); writer.Write('\n'); } reactionNumber++; } catch (IOException ex) { Trace.TraceError(ex.Message); Debug.WriteLine(ex); throw new CDKException("Exception while writing MDL file: " + ex.Message, ex); } }