/// <summary> /// Generates a drawing of a molecule and writes it to a file. /// </summary> /// <seealso href="https://github.com/rdkit/rdkit/blob/1649029367a8e517cf1913a5b80b91813874e002/rdkit/Chem/Draw/__init__.py#L265-L300"/> public static void MolToFile( RWMol mol, string filename, Tuple <int, int> size = null, bool kekulize = true, bool wedgeBonds = true, string imageType = null, bool fitImage = false, string legend = "", Int_Vect highlight_atoms = null, Int_Vect highlight_bonds = null, DrawColour highlightColor = null ) { if (size == null) { size = new Tuple <int, int>(300, 300); } if (imageType == null) { imageType = Path.GetExtension(filename).Substring(1).ToLowerInvariant(); } try { RdMolDraw2D.PrepareMolForDrawing(mol, kekulize: kekulize, wedgeBonds: wedgeBonds); } catch (Exception) { RdMolDraw2D.PrepareMolForDrawing(mol, kekulize: false, wedgeBonds: wedgeBonds); } MolDraw2D d2d; switch (imageType) { case "png": d2d = new MolDraw2DCairo(size.Item1, size.Item2); break; case "svg": d2d = new MolDraw2DSVG(size.Item1, size.Item2); break; default: throw new Exception($"{imageType} is not supported."); } if (highlightColor != null) { d2d.DrawOptions().highlightColour = highlightColor; } d2d.DrawOptions().prepareMolsBeforeDrawing = false; d2d.DrawMolecule(mol, legend, highlight_atoms, highlight_bonds); d2d.FinishDrawing(); switch (d2d) { case MolDraw2DCairo d: d.WriteDrawingText(filename); break; case MolDraw2DSVG d: using (var w = new StreamWriter(filename)) { w.Write(d.GetDrawingText()); } break; } }
public static void SetColor(this MolDraw2D view, DrawColour color) => view.setColour(color);
public void DrawRectangle(DrawColour colour, int left, int top, int right, int bottom) { throw new NotImplementedException(); }
public void DrawCircle(DrawColour colour, int centreX, int centreY, int radius) { throw new NotImplementedException(); }
public void DrawLine(DrawColour colour, int x, int y) { throw new NotImplementedException(); }