Beispiel #1
0
 public static void PerceiveDativeBonds(IReaction reaction)
 {
     foreach (var mol in ReactionManipulator.GetAllMolecules(reaction))
     {
         AtomContainerManipulator.PerceiveDativeBonds(mol);
     }
 }
        public void Generate(string text, string filename)
        {
            Depiction depict = null;

            if (IsReactionSmilees(text))
            {
                var rxn = parser.ParseReactionSmiles(text);
                ReactionManipulator.PerceiveDativeBonds(rxn);
                ReactionManipulator.PerceiveRadicals(rxn);
                depict = PictureGenerator.Depict(rxn);
            }
            else
            {
                var mol = NCDKExcel.Utility.Parse(text);
                AtomContainerManipulator.PerceiveDativeBonds(mol);
                AtomContainerManipulator.PerceiveRadicals(mol);
                depict = PictureGenerator.Depict(mol);
            }
            depict.WriteTo(filename);

            if (!filename.EndsWith(".svg"))
            {
                return;
            }

            string svg;

            using (var r = new StreamReader(filename))
            {
                svg = r.ReadToEnd();
            }
            using (var r = new StreamWriter(filename))
            {
                r.Write(_rect_transparent.Replace(svg, ""));
            }
        }