Search code examples
pythonpymol

Pymol: Using the cmd.color command for residue on specific chain


I have been unable to only color the residue of a specific chain in Pymol. Sorry, this seems to be a clear Beginner's question.

So far, I am only able to color in all the residues with a certain value (e.g. 141) on all the chains.

#I want to colour residue 141 on chain D blue.
first_res = 141
color("blue", 'resi ' + first_res)

Solution

  • To select a residue from a specific chain, you just need to add 'and chain ...', as shown below:

    cmd.color("blue", 'resi ' + first_res + ' and chain ' + first_chain))