Beispiel #1
0
 public static string MolFragmentToSmiles(ROMol mol, Int_Vect atomsToUse, Int_Vect bondsToUse = null,
                                          Str_Vect atomSymbols  = null, Str_Vect bondSymbols = null,
                                          bool isomericSmiles   = true, bool kekuleSmiles    = false, int rootedAtAtom = -1, bool canonical = true,
                                          bool allBondsExplicit = false, bool allHsExplicit  = false)
 {
     return(RDKFuncs.MolFragmentToSmiles(mol, atomsToUse, bondsToUse, atomSymbols, bondSymbols, isomericSmiles, kekuleSmiles, rootedAtAtom, canonical));
 }
Beispiel #2
0
        public static string MolToSVG(ROMol mol, int width    = 300, int height     = 300,
                                      Int_Vect highlightAtoms = null, bool kekulize = true, int lineWidthMult = 1, int fontSize = 12,
                                      bool includeAtomCircles = true, int confId    = -1)
        {
            // See Code\GraphMol\Wrap\MolOps.cpp
            var drawer = new MolDraw2DSVG(width, height);

            drawer.setFontSize(fontSize / 24.0);
            drawer.setLineWidth(drawer.lineWidth() * lineWidthMult);
            drawer.drawOptions().circleAtoms = includeAtomCircles;
            drawer.drawMolecule(mol, highlightAtoms, null, null, confId);
            drawer.finishDrawing();
            return(drawer.getDrawingText());
        }
Beispiel #3
0
 public static string MolFragmentToSmarts(ROMol mol, Int_Vect atomsToUse, Int_Vect bondsToUse = null, bool isomericSmiles = true)
 {
     return(RDKFuncs.MolFragmentToSmarts(mol, atomsToUse, bondsToUse, isomericSmiles));
 }
Beispiel #4
0
 public static ROMol PathToSubmol(ROMol mol, Int_Vect path, bool useQuery = false, Int_Int_Map atomIdxMap = null)
 {
     return(RDKFuncs.pathToSubmol(mol, path, useQuery, atomIdxMap));
 }
Beispiel #5
0
 public static ROMol_Vect GetMolFrags(ROMol mol,
                                      bool sanitizeFrags = false, Int_Vect frags = null, Int_Vect_Vect fragsMolAtomMapping = null)
 {
     return(RDKFuncs.getMolFrags(mol, sanitizeFrags, frags, fragsMolAtomMapping));
 }
Beispiel #6
0
            /// <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;
                }
            }
Beispiel #7
0
 public static void GetOnBits(this BitVect bv, Int_Vect v)
 => bv.getOnBits(v);
Beispiel #8
0
 public static void DrawMolecule(this MolDraw2D view, ROMol mol, string legend = "", Int_Vect highlight_atoms = null, Int_Vect highlight_bonds = null)
 => view.drawMolecule(mol, legend, highlight_atoms, highlight_bonds);
 public static void PrepareAndDrawMolecule(MolDraw2D drawer, ROMol mol, string legend = "", Int_Vect highlight_atoms = null, Int_Vect highlight_bonds = null)
 {
     RDKFuncs.prepareAndDrawMolecule(drawer, mol, legend, highlight_atoms, highlight_bonds);
 }