[chimera-dev] Coloring chains from Python

Eric Pettersen pett at cgl.ucsf.edu
Fri Jan 31 13:16:31 PST 2020


Hi Jan!
	Depending on whether you want to color all atoms with a particular chain ID, or atoms in the peptide/nucleic acid chain with that ID but not waters, etc. there are two routes:

In the code below I am going to assume you have your color in a variable named color, and the model in a variable named m and that you are coloring chain A.

All atoms with that chain ID
for a in m.atoms:
	if a.residue.id <http://a.residue.id/>.chainId == ‘A’:
		a.color = color

All polymer atoms in that chain
seq = m.sequence(‘A’)
for r in seq.residues:
	if r:
		for a in r.atoms:
			a.color = color

Chimera just doesn’t have the data structures to do this efficiently that ChimeraX has.  If the chain is being depicted as ribbon, you would actually set the residue’s color rather than the atom colors.

—Eric

	Eric Pettersen
	UCSF Computer Graphics Lab

> On Jan 31, 2020, at 5:54 AM, Jan Kosinski <jan.kosinski at embl.de> wrote:
> 
> Hi,
> 
> In the “old” Chimera, is there an efficient way of coloring an entire chain with a single defined color from the Python interface without resorting to runCommand(‘color …') and atom_spec ? The runCommand(‘color …atom_spec ’) makes some issues when special characters are used as chain ids in the atom_spec. I guess I could loop through all atoms of chain but that might be slow for big structures.
> 
> Best,
> Jan
> _______________________________________________
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20200131/c81216bc/attachment.html>


More information about the Chimera-dev mailing list