471,353 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

Python molecular viewer

Dear People,

I was wondering if people could recommend a simple molecular viewing
package written in python. I'm working in Theoretical chemistry and I'm
not after an all-singing dancing molecular rendering package(pymol does
that rather well) but a program which reads XYZ files and displays
simple structures which can be rotated in 3D

Thanks

Andy
Aug 29 '07 #1
3 3192
Andy Cheesman <An***********@bristol.ac.ukwrites:
>Dear People,
>I was wondering if people could recommend a simple molecular viewing
package written in python. I'm working in Theoretical chemistry and I'm
not after an all-singing dancing molecular rendering package(pymol does
that rather well) but a program which reads XYZ files and displays
simple structures which can be rotated in 3D
>Thanks
>Andy
Check out http://www.cgl.ucsf.edu/chimera/. Unlike PyMol, all of the
molecular data is accesible from Python. It still might be too much
of an all-singing dancing molecular rendering package for you though.

Greg Couch
UCSF Computer Graphics Lab
Aug 30 '07 #2
Andy Cheesman wrote:
Dear People,

I was wondering if people could recommend a simple molecular viewing
package written in python. I'm working in Theoretical chemistry and I'm
not after an all-singing dancing molecular rendering package(pymol does
that rather well) but a program which reads XYZ files and displays
simple structures which can be rotated in 3D
You could use VPython if you know how to convert XYZ files to ball and
stick locations to cartesian coordinates.
Aug 30 '07 #3
On Aug 29, 8:31 am, Andy Cheesman <Andy.chees...@bristol.ac.ukwrote:
Dear People,

I was wondering if people could recommend a simple molecular viewing
package written in python. I'm working in Theoretical chemistry and I'm
not after an all-singing dancing molecular rendering package(pymol does
that rather well) but a program which reads XYZ files and displays
simple structures which can be rotated in 3D

Thanks

Andy
slut is an OpenGL wrapper that I found to be very intuitive to use,
and comes with some simple "moving ball" animations, but the
animations also can be panned, zoomed, and rotated. In your case, you
wouldn't need to do the animation, just plot the balls in 3D and then
pan and zoom to your heart's content.

Here is a simple program that plots a series of points on a sphere:

from slut import *

# points on a sphere
data = [
(1.0, 0.0, 0.0),
(0.945, 0.0, -0.325),
(0.789, 0.0, -0.613),
(0.547, 0.0, -0.836),
(0.246, 0.0, -0.968),
(-0.083, 0.0, -0.997),
(-0.402, 0.0, -0.916),
(-0.677, 0.0, -0.735),
....
(-0.078, 0.027, 0.997),
(0.232, -0.080, 0.968),
(0.517, -0.177, 0.836),
(0.746, -0.256, 0.613),
(0.895, -0.307, 0.325),
(0.945, -0.325, 0.0) ]

from slut import *

class SphereViewer(World):
def onSetup(self):
self.width = 400
self.height = 400
self.name = "Points on a Sphere"

def onDraw(self):
# draw translucent sphere
glColor4f(0.7, 0.7, 0.7, 0.5)
sphere(0, 0, 0, 1.0)
glColor4f(0.3, 0.3, 0.4, 1.0)

# plot points on surface
glPointSize(4)
for d in data:
point(*d)

# connect points with path
glLineWidth(1.5)
lastd = data[-1]
for d in data:
line( *(lastd + d) )
lastd = d

viewer = SphereViewer()
viewer.run()

And here is a short Wink video showing me working with a simplified
version of this sphere: http://www.geocities.com/ptmcg/python/sphere1.htm.

If you have your molecules' 3D coordinates, you should be able to just
plot them, and then use slut to view the molecule.

-- Paul

Aug 30 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

699 posts views Thread by mike420 | last post: by
5 posts views Thread by Bats | last post: by
114 posts views Thread by Maurice LING | last post: by
8 posts views Thread by wen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.