https://github.com/fogleman/mol
Render ball-and-stick models of molecules.
https://github.com/fogleman/mol
Last synced: 11 months ago
JSON representation
Render ball-and-stick models of molecules.
- Host: GitHub
- URL: https://github.com/fogleman/mol
- Owner: fogleman
- License: mit
- Created: 2016-02-11T22:16:34.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-23T12:49:16.000Z (over 9 years ago)
- Last Synced: 2024-06-19T00:19:46.757Z (almost 2 years ago)
- Language: Go
- Size: 56.6 KB
- Stars: 58
- Watchers: 5
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# `mol` The Molecule Renderer

## Installation
go get github.com/fogleman/mol
## Usage
The program parses MDL Molfiles or SDF files and generates PNGs.
mol input.sdf
mol examples/*
There are no other command line options as of yet, though one can imagine several possibilities. Output resolution, output format (SVG), camera position, animations, etc. Quality pull requests are welcome. Also, I know very little about chemistry, so if something doesn't look right, let me know!
## Input Files
You can search for molecules here:
https://www.ncbi.nlm.nih.gov/pccompound/?term=benzene
Select a result and click `Download > 3D Conformer > SDF`.
There are also several examples in the `examples` folder.
## How it Works
`mol` uses another library I created called `ln`. `ln` is a 3D vector renderer that works somewhat like a ray tracer. `mol` simply constructs spheres and cylinders in the right places and uses `ln` to render.
https://github.com/fogleman/ln
## Camera Placement
The program automatically positions the camera to maximize visibility of all atoms in the molecule.

The two molecules shown above are the same (testosterone). One is shown from the most optimal point of view while the other is shown from the least optimal point of view. See [camera.go](https://github.com/fogleman/mol/blob/master/mol/camera.go) to see how this works. It's pretty straightforward.