I tried that. that is actually how I found this is a way to color them according the CA color assigned in the spectrum.
Charles ________________________________ From: Olson, Linda <lol...@mcw.edu> Sent: Thursday, May 21, 2020 12:24 PM To: Chen, Qiang <q...@pitt.edu> Subject: Re: Consistent coloring between sticks of sidechains and cartoon backbones in spectrum coloring Have you tried going to the first option under the color by menu which colors c alpha by whatever they are asigned? Linda Olson, PhD Assistant Professor/ x-Ray Facility Manager Dept. Biochemistry Medical College of Wisconsin 8701 Watertown Plank Rd Milwaukee, WI 53226 phone 414-955-8545 fax 414-456-6510 ________________________________ From: Chen, Qiang <q...@pitt.edu> Sent: Thursday, May 21, 2020 10:20:11 AM To: Mooers, Blaine H.M. (HSC) <blaine-moo...@ouhsc.edu>; pymol-users@lists.sourceforge.net <pymol-users@lists.sourceforge.net> Subject: Re: [PyMOL] Consistent coloring between sticks of sidechains and cartoon backbones in spectrum coloring ATTENTION: This email originated from a sender outside of MCW. Use caution when clicking on links or opening attachments. ________________________________ Thanks, Prof. Mooers. I tried your script. It did not report any error. but the selected residues are colored as the default, green for carbon. Then I figured out I made things complicated. I created a new object (cnsp) for the cartoon representation colored with spectrum. Then I selected residues with chain A and resi 10+20+30, and showed them as sticks. I guess, the color info of CAs from the spectrum is missing at this step. If I selected the residues with cnsp and chain A and resi 10+20+30, then showed them with sticks, the color of sidechain is matching with CA color in the spectrum. All I need is just util.cnc. The working script is like the following select cnsp, chain A spectrum count, magenta_cyan, cnsp, byres=1 select sre, cnsp and resi 10+20+30 show sticks, sre, util.cnc sre Charles ________________________________ From: Mooers, Blaine H.M. (HSC) <blaine-moo...@ouhsc.edu> Sent: Thursday, May 21, 2020 9:19 AM To: Chen, Qiang <q...@pitt.edu>; pymol-users@lists.sourceforge.net <pymol-users@lists.sourceforge.net> Subject: RE: Consistent coloring between sticks of sidechains and cartoon backbones in spectrum coloring 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