Skip to main content

A simple molecular renderer for the terminal using RDKit.

Project description

TerMol

A simple molecular renderer for the terminal using RDKit.

molecules

Table of Contents

  1. Overview
  2. Installation
  3. Usage
  4. License
  5. Contact

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)

image

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 displayed
  • width, 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:

Nicholas Freitas

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

termol-0.1.3.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

termol-0.1.3-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file termol-0.1.3.tar.gz.

File metadata

  • Download URL: termol-0.1.3.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for termol-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0ec46b7c98009586f58891a17a631a74f9aac7f299e27ecdb856ca000ec82a67
MD5 843f962d0a9fe1ff06c853ae8f34f2ee
BLAKE2b-256 987c7e817094af4ed6f2c6ded2484d2c50691005e81e67c6464559338bca4d8f

See more details on using hashes here.

File details

Details for the file termol-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: termol-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for termol-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a1de8a9d2aa3e34d63cf0825dece3e431b10608c168c24887097c1545a288b79
MD5 0b5281cd6411539b6ff04976715efbcd
BLAKE2b-256 164d9ce563b83bb9443d950e392784190a18339f8f37d4f298709270f7c4b3ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page