Hi Charles, This pml script does want you want,
# Color the carvons atoms of the sidechain the same as the color of the CA atom col=[] # >>>> edit resi here iterate resi 10+20+30 and name ca, col.append((chain,resi,name,cmd.get_color_tuple(color))) # Define the colors ca10, ca20, and ca40 [cmd.set_color('ca'+co[1],list(co[3]) ) for co in col] # >>>>>>Edit color names here colorList =['ca10','ca20','ca30'] # Check this list [print(cmd.get_color_tuple(co)) for co in colorList] #make a list of residues resList = [co[1] for co in col] # Check the list print(resList) # Now zip the list of colors and the list of residues pairs = list(zip(colorList,resList)) # Check the list of lists print(pairs) # Check the atom selection syntax [print('resi ' + str(pairs[i][1]) + ' and (sidechain and name c*)') for i in range(0,len(pairs))] # Apply the pairs after defining the indices [cmd.color(pairs[i][0], 'resi ' + str(pairs[i][1]) + ' and (sidechain and name c*)') for i in range(0,len(pairs))] The print statements are sanity checks. You can delete them and the comments if you want a more concise script. You can also copy and paste this compound command onto the command line to get the get effect. You the up arrow key to get back the command and edit the list of residues and the colorList. col=[];iterate resi 10+20+30 and name ca, col.append((chain,resi,name,cmd.get_color_tuple(color)));colorList =['ca10','ca20','ca30'];resList = [co[1] for co in col];pairs = list(zip(colorList,resList));[cmd.color(pairs[i][0], 'resi ' + str(pairs[i][1]) + ' and (sidechain and name c*)') for i in range(0,len(pairs))] When you enter help color, you will see that the first argument of color is the color, which is a string. That string is a name or number. The number is an integer that is internally mapped to a color name. You can see these by entering the following: print(cmd.get_color_indices()). Your col object is a list of tuples. This is not of the data type that the color command expects. The third line of your code returns an error because col is a list of tuples and not a string. That number is not the same as your color tuple. You want to apply your color tuple. I am not sure how to do apply the color tuple because PyMOL will take the RGB values as list of integers, not as a tuple. The returned tuple is for use in an external program. The above script converts the tuple into a list of integers that PyMOL can work with. Best regards, Blaine Blaine Mooers, Ph.D. Associate Professor Department of Biochemistry and Molecular Biology College of Medicine University of Oklahoma Health Sciences Center S.L. Young Biomedical Research Center (BRC) Rm. 466 975 NE 10th Street, BRC 466 Oklahoma City, OK 73104-5419 ________________________________________ From: Chen, Qiang [q...@pitt.edu] Sent: Wednesday, May 20, 2020 7:50 PM To: pymol-users@lists.sourceforge.net Subject: [EXTERNAL] [PyMOL] Consistent coloring between sticks of sidechains and cartoon backbones in spectrum coloring Hi, Pymol-users I have my protein shown as cartoon and colored with spectrum. Now I would like to show several residues at different places with sticks representation. when I tried, I can not get the color consistent between the backbone CA and the carbons on the sidechain. I searched the archives, and tried something like this. col=[] iterate resi 10+20+30 and name ca, col.append((chain,resi,name,cmd.get_color_tuple(color))) cmd.color(col,"all") util.cnc("all") The first two lines will get me a color_tuple of the selected residues (CA) The third line will color all atoms as the same color of CA. The fourth line will color all none carbon atoms with the default colors. However, this does not work as I thought. Would anyone point out what mistakes I made here? Or any other solution to get the consistence between CA and the sidechain? Your help is high appreciated! Thanks! Charles _______________________________________________ PyMOL-users mailing list Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net Unsubscribe: https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe