Discussion:
[PyMOL] Creating coloured and transparent polyhedra
Timo Stein
2013-07-12 20:39:07 UTC
Permalink
Hello PyMOL users,

I'm using PyMOL to create fancy images of Metal-Organic Framework
structural units. They feature metal ions of different coordination
spheres. The structural features of these units can be clarified by
showing the corresponding coordination polyhedron (for example of the
metal ions colour) with the coordinating atoms sitting on the
polyhedron's corners. The polyhedron should be quite transparent. How
can you draw such polyhedrons with PyMOL? The Google image search for
MOF-5 gives some examples of structures showing these coordination
polyhedra.

Thank you very much!

Timo Stein
Schubert, Carsten [JRDUS]
2013-07-14 19:52:55 UTC
Permalink
Hi Timo,

That is best approached with CGO objects. You can find some examples in \PyMOL\PyMOL\modules\pymol\cgo.py

Here is a bit of a write-up I attempted a while ago. BTW transparency of CGO objects can be controlled via the "setting cgo_transparency"

HTH

Carsten

----------------------------------------------------------------------------------------------------
Lines
=====

The LINES command draws a lines between a set of coordinates defined by the
VERTEX command. The colour of the lines can be changed at any time even
between vertices, so that the start and end line color can be different. The
color of the line will be interpolated between the start and end color. The
thickness of the line is set by LINEWIDTH. However there is a bug in the
implementation. The GL renderer accepts the LINEWIDTH statement only before a
BEGIN statement. The internal renderer honors the change of the linewidth
before every VERTEX pair. Note: Tapered lines are not supported by either
implementation. LINEWIDTH and COLOR are optional commands.

LINEWIDTH, w,
BEGIN, LINES,
COLOR, r, g, b,
VERTEX, x1,y1,z1,
VERTEX, x2,y2,z2,
END

Line Strips
============

The LINE_STRIP command draws a continuous line between sets of coordinates
defined by the VERTEX command. The main difference to the LINES command is
that the endpoint of the first line is automatically the start of the next
line, but the first and last point are NOT connected, see LINE_LOOP instead.
The colour of the lines can be changed at any time even between vertices, so
that the start and end line color can be different. The color of the line
will be interpolated between the start and end color. The thickness of the
line is set by LINEWIDTH. However there is a bug in the implementation. The
GL renderer accepts the LINEWIDTH statement only before a BEGIN statement.
The internal renderer honors the change of the linewidth before every VERTEX
pair. Note: Tapered lines are not supported by either implementation.
LINEWIDTH and COLOR are optional commands.

LINEWIDTH, w,
BEGIN, LINE_STRIP,
COLOR, r, g, b,
VERTEX, x1,y1,z1,
VERTEX, x2,y2,z2, ...
VERTEX, xn,yn,zn
END

-----Original Message-----
From: Timo Stein [mailto:***@timo-stein.com]
Sent: Friday, July 12, 2013 4:39 PM
To: pymol-***@lists.sourceforge.net
Subject: [PyMOL] Creating coloured and transparent polyhedra

Hello PyMOL users,

I'm using PyMOL to create fancy images of Metal-Organic Framework structural units. They feature metal ions of different coordination spheres. The structural features of these units can be clarified by showing the corresponding coordination polyhedron (for example of the metal ions colour) with the coordinating atoms sitting on the polyhedron's corners. The polyhedron should be quite transparent. How can you draw such polyhedrons with PyMOL? The Google image search for
MOF-5 gives some examples of structures showing these coordination polyhedra.

Thank you very much!

Timo Stein
Tsjerk Wassenaar
2013-07-15 15:41:35 UTC
Permalink
Hey :)

Nice summary...
There is also the keyword ALPHA for setting the cgo transparency, allowing
per element control. Just set

ALPHA, value,

before the element.

Cheers,

Tsjerk

On Jul 14, 2013 10:28 PM, "Schubert, Carsten [JRDUS]" <***@its.jnj.com>
wrote:

Hi Timo,

That is best approached with CGO objects. You can find some examples in
\PyMOL\PyMOL\modules\pymol\cgo.py

Here is a bit of a write-up I attempted a while ago. BTW transparency of
CGO objects can be controlled via the "setting cgo_transparency"

HTH

Carsten

----------------------------------------------------------------------------------------------------
Lines
=====

The LINES command draws a lines between a set of coordinates defined by the
VERTEX command. The colour of the lines can be changed at any time even
between vertices, so that the start and end line color can be different. The
color of the line will be interpolated between the start and end color. The
thickness of the line is set by LINEWIDTH. However there is a bug in the
implementation. The GL renderer accepts the LINEWIDTH statement only before
a
BEGIN statement. The internal renderer honors the change of the linewidth
before every VERTEX pair. Note: Tapered lines are not supported by either
implementation. LINEWIDTH and COLOR are optional commands.

LINEWIDTH, w,
BEGIN, LINES,
COLOR, r, g, b,
VERTEX, x1,y1,z1,
VERTEX, x2,y2,z2,
END

Line Strips
============

The LINE_STRIP command draws a continuous line between sets of coordinates
defined by the VERTEX command. The main difference to the LINES command is
that the endpoint of the first line is automatically the start of the next
line, but the first and last point are NOT connected, see LINE_LOOP instead.
The colour of the lines can be changed at any time even between vertices, so
that the start and end line color can be different. The color of the line
will be interpolated between the start and end color. The thickness of the
line is set by LINEWIDTH. However there is a bug in the implementation. The
GL renderer accepts the LINEWIDTH statement only before a BEGIN statement.
The internal renderer honors the change of the linewidth before every VERTEX
pair. Note: Tapered lines are not supported by either implementation.
LINEWIDTH and COLOR are optional commands.

LINEWIDTH, w,
BEGIN, LINE_STRIP,
COLOR, r, g, b,
VERTEX, x1,y1,z1,
VERTEX, x2,y2,z2, ...
VERTEX, xn,yn,zn
END

-----Original Message----- From: Timo Stein [mailto:***@timo-stein.com]
Sent: Friday, July 12, 20...
Schubert, Carsten [JRDUS]
2013-07-15 20:35:50 UTC
Permalink
Hey Tsjerk,

Good to know, I missed that feature. Wonder what else is hidden


Cheers,

Carsten

From: Tsjerk Wassenaar [mailto:***@gmail.com]
Sent: Monday, July 15, 2013 11:42 AM
To: Schubert, Carsten [JRDUS]
Cc: pymol-***@lists.sourceforge.net; Timo Stein
Subject: Re: [PyMOL] Creating coloured and transparent polyhedra


Hey :)

Nice summary...
There is also the keyword ALPHA for setting the cgo transparency, allowing per element control. Just set

ALPHA, value,

before the element.

Cheers,

Tsjerk
On Jul 14, 2013 10:28 PM, "Schubert, Carsten [JRDUS]" <***@its.jnj.com<mailto:***@its.jnj.com>> wrote:

Hi Timo,

That is best approached with CGO objects. You can find some examples in \PyMOL\PyMOL\modules\pymol\cgo.py

Here is a bit of a write-up I attempted a while ago. BTW transparency of CGO objects can be controlled via the "setting cgo_transparency"

HTH

Carsten

----------------------------------------------------------------------------------------------------
Lines
=====

The LINES command draws a lines between a set of coordinates defined by the
VERTEX command. The colour of the lines can be changed at any time even
between vertices, so that the start and end line color can be different. The
color of the line will be interpolated between the start and end color. The
thickness of the line is set by LINEWIDTH. However there is a bug in the
implementation. The GL renderer accepts the LINEWIDTH statement only before a
BEGIN statement. The internal renderer honors the change of the linewidth
before every VERTEX pair. Note: Tapered lines are not supported by either
implementation. LINEWIDTH and COLOR are optional commands.

LINEWIDTH, w,
BEGIN, LINES,
COLOR, r, g, b,
VERTEX, x1,y1,z1,
VERTEX, x2,y2,z2,
END

Line Strips
============

The LINE_STRIP command draws a continuous line between sets of coordinates
defined by the VERTEX command. The main difference to the LINES command is
that the endpoint of the first line is automatically the start of the next
line, but the first and last point are NOT connected, see LINE_LOOP instead.
The colour of the lines can be changed at any time even between vertices, so
that the start and end line color can be different. The color of the line
will be interpolated between the start and end color. The thickness of the
line is set by LINEWIDTH. However there is a bug in the implementation. The
GL renderer accepts the LINEWIDTH statement only before a BEGIN statement.
The internal renderer honors the change of the linewidth before every VERTEX
pair. Note: Tapered lines are not supported by either implementation.
LINEWIDTH and COLOR are optional commands.

LINEWIDTH, w,
BEGIN, LINE_STRIP,
COLOR, r, g, b,
VERTEX, x1,y1,z1,
VERTEX, x2,y2,z2, ...
VERTEX, xn,yn,zn
END

-----Original Message----- From: Timo Stein [mailto:***@timo-stein.com<mailto:***@timo-stein.com>] Sent: Friday, July 12, 20...
Timo Stein
2013-07-17 11:21:28 UTC
Permalink
Hi PyMOL users,

thank you for your help. I tried to apply Carsten's suggestions using
the LINE_STRIP approach. This is what I tested:

from pymol.cgo import * # get constants
from pymol import cmd

obj = [
LINEWIDTH, 50,
BEGIN, LINE_STRIP,
COLOR, 255, 0, 0,
VERTEX, 11.335700035095215, 7.798659801483154, 7.798659801483154,
VERTEX, 11.335700035095215, 5.352089881896973, 5.352089881896973,
VERTEX, 14.965800285339355, 5.352089881896973, 5.352089881896973,
VERTEX, 14.965800285339355, 7.798659801483154, 7.798659801483154,
VERTEX, 11.335700035095215, 7.798659801483154, 7.798659801483154,
END
]

cmd.load_cgo(obj,'cgo01')

where four atoms make up a square. This snippet creates - when called by
"run <path-to-script>" - four lines between these coordinates I got by
using "print cmd.get_model('<selection-name>', 1).get_coord_list()". How
can I have the the area between those four points filled with a colour
of my choice and have it be partly transparent? The next step would be
to create polyhedra with corresponding surfaces with atoms spanning a
three dimensional object.

Thanks in advance
Timo
Schubert, Carsten [JRDUS]
2013-07-17 14:37:33 UTC
Permalink
Hi Timo,

I think you may have to switch to a different drawing primitive like TRIANGLES or TRIANGLE_STRIP. Since these are closed objects I assume that the enclosing area should be fillable with a color of choice. Unfortunately I have not actually had a chance to play with these primitives, so I can't provide any docs. Check out \PyMOL\PyMOL\examples\devel\cgo08.py and/or cgo07.py for examples of TRIANGLE_STRIPS.

HTH

Carsten

From: Timo Stein [mailto:***@timo-stein.com]
Sent: Wednesday, July 17, 2013 7:21 AM
To: pymol-***@lists.sourceforge.net
Subject: Re: [PyMOL] Creating coloured and transparent polyhedra

Hi PyMOL users,

thank you for your help. I tried to apply Carsten's suggestions using the LINE_STRIP approach. This is what I tested:
from pymol.cgo import * # get constants
from pymol import cmd

obj = [
LINEWIDTH, 50,
BEGIN, LINE_STRIP,
COLOR, 255, 0, 0,
VERTEX, 11.335700035095215, 7.798659801483154, 7.798659801483154,
VERTEX, 11.335700035095215, 5.352089881896973, 5.352089881896973,
VERTEX, 14.965800285339355, 5.352089881896973, 5.352089881896973,
VERTEX, 14.965800285339355, 7.798659801483154, 7.798659801483154,
VERTEX, 11.335700035095215, 7.798659801483154, 7.798659801483154,
END
]

cmd.load_cgo(obj,'cgo01')
where four atoms make up a square. This snippet creates - when called by "run <path-to-script>" - four lines between these coordinates I got by using "print cmd.get_model('<selection-name>', 1).get_coord_list()". How can I have the the area between those four points filled with a colour of my choice and have it be partly transparent? The next step would be to create polyhedra with corresponding surfaces with atoms spanning a three dimensional object.

Thanks in advance
Timo

Loading...