IMP logo

IMP.display examples

display_log.py

A simple example of how to use one of the IMP.display.LogOptimizerStates.

import IMP
import IMP.display
import IMP.core

m= IMP.Model()
c= IMP.container.ListSingletonContainer(IMP.core.create_xyzr_particles(m, 20, 5))

log= IMP.display.LogOptimizerState(IMP.display.PymolWriter(), "log_file.%04d.pym")
g= IMP.display.XYZRsGeometry(c, IMP.core.XYZR.get_default_radius_key())
g.set_name("my particles")
g.set_color(IMP.display.Color(1,0,0))
log.add_geometry(g)
log.write("initial.pym")

r= IMP.core.ExcludedVolumeRestraint(c)
m.add_restraint(r)

o= IMP.core.MonteCarlo(m)
mv= IMP.core.BallMover(c, 10)
o.add_mover(mv)
o.add_optimizer_state(log)

o.optimize(1000)

fragments/show_spheres.py

Write a bunch of IMP::core::XYZR particles to a Chimera input file. One could write to a pymol file simply by replacing the IMP::display::Writer.

w = IMP.display.ChimeraWriter("out.py")
g0= IMP.XYZRsGeometry(xyzrs0)
g0.set_name("my particles")
g0.set_color(IMP.display.Color(1,0,0))
g0.add_geometry(g0)
g1= IMP.XYZRsGeometry(xyzrs1)
g1.set_name("my other particles")
g1.set_color(IMP.display.Color(0,1,0))
g1.add_geometry(g1)
# make sure that the file is written
del w

Generated on Mon Mar 8 23:08:33 2010 for IMP by doxygen 1.5.8