A simple molecular renderer for the terminal using RDKit.
Project description
TerMol
A simple molecular renderer for the terminal using RDKit.
Table of Contents
Overview
This python package allows for the 2D or 3D rendering of molecules in the terminal, using RDKit and Curses.
Installation
Install TerMol with:
pip install termol
On Windows only, the Curses python package must be installed manually.
Usage:
3D Rendering:
Import the package and call the draw function as shown:
import termol
smiles = "c1cc2c(cc1[N+](=O)[O-])[nH]nn2"
name = "Nitrobenzotriazole"
termol.draw(smiles, name=name)
The molecule input can be a smiles string or an RDKit-compatible filepath (.mol2, .sdf, etc).
Controlling the viewer
In the 3D viewer, the molecule will initially rotate about the Y-axis. To change the direction of the rotation, use the arrow keys, or WASD+QE. To pause rotation, hit the spacebar.
To make the molecule smaller or larger, you can use the R and F keys, respectively.
To exit the 3D viewer, hit any other key.
2D Rendering:
Sometimes, a simple 2D graphic is sufficient. To render in 2D, use the flag three_d=False
:
termol.draw(smiles, name=name, three_d=False)
Showcase:
To display a showcase of termol's capabilities, you may run:
import termol
termol.showcase()
Want a fun screensaver? Use the timeout=60
argument to cycle through a random molecule every 60 seconds.
Other Options
The draw function only requires the molecule SMILES/file as input. Other options include:
name
: A molecule name to be displayedwidth, height
: The size of the 'screen' (in number of characters) Default 80x40.three_d
: defaults to True to display in 3D. Set to False to print a 2D view.add_hydrogens
: Have RDKit attempt to add hydrogens automatically. Default False.timeout
: In the 3D viewer, this will automatically close after this number of seconds. Default None, which allows the viewer to stay open indefinitely.
termol.draw(input_mol, name=None, width=80, height=40, three_d=True, add_hydrogens=False, timeout=None)
Drawing Many Molecules
The termol.draw_multi()
function takes as input a list of SMILES or molecule files as input, and displays them in succession (In 2D or 3D). If the optional argument names
is provided, it must be the same length as the number of inputs. All other arguments are the same.
License:
This software is provided under the MIT License.
Contact:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file termol-0.1.2.tar.gz
.
File metadata
- Download URL: termol-0.1.2.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fe2e45d2978a706eb8a005509b31a878a55c87be1135d1dc1346954c1f3a8c0 |
|
MD5 | b1602105be05576a435ea63223a75a14 |
|
BLAKE2b-256 | 0b69584cf014f8ffa394eda407bda7c16b72e05bd993cfd3ed1ae752f609ec95 |
File details
Details for the file termol-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: termol-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b405682cee4fea04f240d3eb37aa742c04daf7cdc89e82ce2d6481bf9a8bca18 |
|
MD5 | d1931d1984b6276938971da6a7ed07bb |
|
BLAKE2b-256 | d98796d543b1ae9afad236d6b0d76840f3d1cc37ce2342eb9d5cc652ef79c4a6 |