![]() |
RDKitDrawMolecules.py - Draw molecules and generate an image or HTML file
RDKitDrawMolecules.py [--alignmentSMARTS <SMARTS>] [--atomLabelFontSize <number>] [--bondLineWidth <number>] [--compute2DCoords <yes | no>] [--counterCol <yes or no>] [--colVisibility <yes or no>] [--fontBold <yes or no>] [--footer <text>] [--footerClass <text>] [--header <text>] [--headerStyle <text>] [--highlightSMARTS <SMARTS>] [--infileParams <Name,Value,...>] [--kekulize <yes or no>] [--keysNavigation <yes or no>] [--molImageSize <width,height>] [--molImageEncoded <yes or no> ] [--numOfMolsPerRow <number>] [--overwrite] [--paging <yes or no>] [--pagingType <numbers, simple, ...>] [--pageLength <number>] [--popover <yes or no>] [--popoverDataCount <number>] [--popoverTextWidth <number>] [--showMolName <yes or no>] [--scrollX <yes or no>] [--scrollY <yes or no>] [--scrollYSize <number>] [--tableFooter <yes or no>] [--tableHeader <yes or no>] [--tableHeaderStyle <thead-dark,thead-light,...>] [--tableStyle <table,table-striped,...>] [-w <dir>] -i <infile> -o <outfile>
RDKitDrawMolecules.py -h | --help | -e | --examples
Draw molecules in a grid and write them out as an image file or a HTML table file. The SVG image or HTML table file appears to be the best among all the available image file options, as rendered in a browser. The Python modules aggdraw/cairo are required to generate high quality PNG images.
The drawing of the molecules are embedded in HTML table columns as in line SVG images. The HTML table is an interactive table and requires internet access for viewing in a browser. It employs he following frameworks: JQuery, Bootstrap, and DataTable.
The options '--atomLabelFontSize' and '--bondLineWidth' don't appear to work during the generation of a SVG image. In addition, these may not work for other image types in the latest version of RDKIT.
The supported input file formats are: Mol (.mol), SD (.sdf, .sd), SMILES (.smi, .txt, .csv, .tsv)
The output image file can be saved in any format supported by the Python Image Library (PIL). The image format is automatically detected from the output file extension.
Some of the most common output image file formats are: GIF (.gif), JPEG (.jpg), PNG (.png), SVG (.svg), TIFF (.tif). In addition, a HTML (.html) file format containing a table is supported.
SMARTS pattern for aligning molecules to a common template.
Font size for drawing atom labels. This option is ignored during the generation of a SVG and HTML output file. This option may not work in the latest version of RDKit.
Line width for drawing bonds. This option is ignored during the generation of a SVG and HTML output file. This option may not work in the latest version of RDKit.
Compute 2D coordinates of molecules before drawing. Default: yes for all file formats.
Show a counter column as the first column in the table. It contains the position for each row in the HTML table. This option is only used during the generation of a HTML table file.
Show a dropdown button to toggle visibility of columns in the table. This option is only used during the generation of a HTML table file.
Print examples.
Make all text fonts bold during the generation of a SVG and HTML output file. This option is ignored for all other output files. This option may not work in the latest version of RDKit.
Footer text to insert at the bottom of the HTML page after the table. This option is only used during the generation of a HTML table file.
Footer class style to use with <p> tag. This option is only used during the generation of a HTML table file.
Print this help message.
Header text to insert at the top of the HTML page before the table. This option is only used during the generation of a HTML table file.
Header style to use. Possible values: h1 to h6. This option is only used during the generation of a HTML table file.
SMARTS pattern for highlighting atoms and bonds in molecules. All matched substructures are highlighted.
Input file name.
A comma delimited list of parameter name and value pairs for reading molecules from files. The supported parameter names for different file formats, along with their default values, are shown below:
Possible values for smilesDelimiter: space, comma or tab.
Perform kekulization on molecules. This option is ignored during the generation of a SVG and HTML output file.
Provide Excel like keyboard cell navigation for the table. This option is only used during the generation of a HTML table file.
Image size of a molecule in pixels.
Base64 encode SVG image of a molecule for inline embedding in a HTML page. The inline SVG image may fail to display in browsers without encoding.
Number of molecules to draw in a row.
Output file name.
Overwrite existing files.
Provide page navigation for browsing data in the table. This option is only used during the generation of a HTML table file.
Type of page navigation. Possible values: numbers, simple, simple_numbers, full, full_numbers, or first_last_numbers.
This option is only used during the generation of a HTML table file.
Number of rows to show per page. This option is only used during the generation of a HTML table file.
Display a popover window containing additional information about the molecule. The popover is opened after a click on the drawing of a molecule. A subsequent click on the same drawing closes the popover. This option is only used during the generation of a HTML table file.
Maximum number of data fields to show in a popover window. This option is only used during the generation of a HTML table file.
Maximum width in characters for text display in a popover window before truncating the text. This option is only used during the generation of a HTML table file.
Show molecule names under the images.This option is only used during the generation of a HTML table file.
Provide horizontal scroll bar in the table as needed.This option is only used during the generation of a HTML table file.
Provide vertical scroll bar in the table as needed.This option is only used during the generation of a HTML table file.
Maximum height of table viewport either in pixels or percentage of the browser window height before providing a vertical scroll bar. Default: 75% of the height of browser window.This option is only used during the generation of a HTML table file.
Style of table. Possible values: table, table-striped, table-bordered, table-hover, table-dark, table-sm, none, or All. Default: 'table,table-hover'. A comma delimited list of any valid Bootstrap table styles is also supported
This option is only used during the generation of a HTML table file.
Show Excel style column headers at the end of the table. This option is only used during the generation of a HTML table file.
Show Excel style column headers in the table. This option is only used during the generation of a HTML table file.
Style of table header. Possible values: thead-dark, thead-light, or none. The names of the following contextual color classes are also supported: table-primary (Blue), table-success (Green), table-danger (Red), table-info (Light blue), table-warning (Orange), table-active (Grey), table-light (Light grey), and table-dark (Dark grey).
This option is only used during the generation of a HTML table file.
Location of working directory which defaults to the current directory.
To automatically compute 2D coordinates for molecules in a SMILES file and generate a SVG image file containing 4 molecules per row in a grid with cell size of 250 x 200 pixels, type:
To automatically compute 2D coordinates for molecules in a SMILES file and generate a SVG image file containing 2 molecules per row in a grid with cell size of 400 x 300 pixels and without any keulization along with highlighting a specific set of atoms and bonds indicated by a SMARTS pattern, type:
To generate a PNG image file for molecules in a SD file using existing 2D coordinates, type
To automatically compute 2D coordinates for molecules in a SD file and generate a HTML file containing 4 molecules per row in a table, along with all the bells and whistles to interact with the table, type:
To automatically compute 2D coordinates for molecules in a SD file and generate a HTML file containing 4 molecules per row in a table without any bells and whistles to interact with the table, type:
To automatically compute 2D coordinates for molecules in a CSV SMILES file with column headers, SMILES strings in column 1, and name in column 2 and generate a PDF image file, type:
RDKitConvertFileFormat.py, RDKitDrawMoleculesAndDataTable.py, RDKitRemoveDuplicateMolecules.py, RDKitSearchFunctionalGroups.py, RDKitSearchSMARTS.py
Copyright (C) 2024 Manish Sud. All rights reserved.
The functionality available in this script is implemented using RDKit, an open source toolkit for cheminformatics developed by Greg Landrum.
This file is part of MayaChemTools.
MayaChemTools is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.