Skip to main content

Simple visualizer for molecules and isosurfaces with Plotly

Project description

cotwo

(like, carbon dioxide)

Render molecules with Plotly.

Installation

pip install cotwo

or

uv add cotwo

Features

  • Read and display structures from XYZ files
  • Read and display structures from SMILES strings
  • Plot smooth isosurfaces from cube files

image

Usage

Use the "Molecule" class to instanciate an object from either an XYZ file (give the path) or a SMILES string:

from cotwo import Molecule

xyz = Molecule.from_xyz("path/to/file.xyz")

smiles = Molecule.from_smiles("CCC(=O)C")

To add an isosurface from a density, you need a corresponding .cube file.

xyz.add_density("path/to/density.cube", isovalue=0.005, colors=("#909090", "#FF8000"))

Then you can either obtain the Plotly go.Figure:

fig = xyz.create_fig()

or display the plot directly:

xyz.show()

Roadmap

Since creating the meshes and the isosurfaces is computationally heavy, a neat feature would be the possibility to precompute several isosurfaces and keep them in memory. This way multiple densities can be inspected in short succession without the computational overhead.

In the same vein, it would be cool to load a directory and then be able to select from the available .cube files. One could also compute the verticies and faces of the isosurfaces and store them separately, then loading would be much faster. That said, it's kind of beyond the scope of this project - best to keep it lightweigth and focused on only the actual rendering.

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

cotwo-1.0.2.tar.gz (201.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cotwo-1.0.2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file cotwo-1.0.2.tar.gz.

File metadata

  • Download URL: cotwo-1.0.2.tar.gz
  • Upload date:
  • Size: 201.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.20

File hashes

Hashes for cotwo-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4ea253cf27c6d2d396919953ae4ba0e50cbc69c616a46f8011b5d46a1c6c8f9c
MD5 e33aceab3d62054b65ef33eeb0e3d7ba
BLAKE2b-256 2c84030319b714c9cf7b9abb81f2ecff457ab4c71bf0a9c9bb60b67c9e292157

See more details on using hashes here.

File details

Details for the file cotwo-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: cotwo-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.20

File hashes

Hashes for cotwo-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1e1ef9f446d85f0cf5d474e3caf1832ac02f3987b593c3a9d9f8f57297ed63e
MD5 2cf17d39f31e90b432b5f9945f38800a
BLAKE2b-256 9181e6c7a96b21c7ead857d4ea8ea24d0f53c14a1e101c1f38fcb34e946cfe47

See more details on using hashes here.

Supported by

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