Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRhiem committed Oct 24, 2014
1 parent 8146806 commit cec10e2
Show file tree
Hide file tree
Showing 6 changed files with 1,028 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.*
!.gitignore
*.pyc
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
mogli
=====
# mogli

simple visualization of molecules in python
mogli is python module for easily rendering molecules.

The fastest way to get started is using mogli.py in the command line:
```
% python -m mogli <file_name>
```

This will open a new window in which the molecule will be rendered. You can then rotate the molecule using your mouse.

In python, you can achieve something similar with three lines of code:
```
>>> import mogli
>>> molecules = mogli.read('examples/dna.xyz')
>>> mogli.show(molecules[0])
```

## Atomic bonds
You might notice that the atomic bonds between the atoms don't look right. You can hide the bonds by adding the `show_bonds=False` to your `show()` call, but of course there's a a better way to fix the missing bonds here.

For the example above, adding `bond_param=1.15` to `show()` will do the trick. mogli currently offers two ways of calculating atomic bonds. The first method compares the distance between every two atoms with the sum of their valence radii. If they are further apart, no bond is formed. To allow a bit of adjustment, this radii sum is multiplied with a factor that can be set using the `bond_param` parameter to `show()` and `draw()`. By default, `1.0` is used.

The second method uses a constant maximum distance instead. If you use this method by passing `bond_method='constant_delta'` to `show()` or `draw()`, you can set the constant distance with the `bond_param` parameter.

## Drawing with GR
In case you use the GR framework, you can use mogli to draw molecules into your GR graphics. To do so, just call `draw()`. You can use the parameters `xmin`, `xmax`, `ymin`, `ymax`, `width` and `height` just like you would when using `gr.drawimage()`.

```
>>> import gr
>>> import mogli
>>> molecules = mogli.read('examples/dna.xyz')
>>> mogli.draw(molecules[0])
>>> gr.updatews()
```

## Dependencies
mogli depends on GR3, which is included in the [GR framework](http://gr-framework.org/) ([PyPI]( https://pypi.python.org/pypi/gr), [GitHub](https://github.com/jheinen/gr)), on [glfw3](http://www.glfw.org/) ([GitHub](https://github.com/glfw/glfw)) and python bindings for glfw3 ([PyPI](https://pypi.python.org/pypi/glfw), [GitHub](https://github.com/FlorianRhiem/pyGLFW)).

Additionally, [Pybel](http://openbabel.org/docs/dev/UseTheLibrary/Python_Pybel.html) should be installed; mogli will work without it, but only for xyz files.
Loading

0 comments on commit cec10e2

Please sign in to comment.