Re: [PyMOL] color each polymer chain differently

2014-03-18 Thread Sampson, Jared
Hi Chandan - Back in the lab today.  I took a look at the code I sent and 
realized that one can’t simply pass a tuple to cmd.color(), as it only accepts 
named colors, so you have to use cmd.set_color().

So here (below) is a modified, fleshed-out version of what I sent yesterday, 
with the protein components of the T. thermophilus ribosome asymmetric unit 
(110 chains) as an example.  For a larger number of colors, you would simply 
have to increase the ranges for i, j, and k in the loop that creates the RGB 
tuples.

Some of the colors turn out to be fairly similar (e.g. those differing by only 
one RGB component), so also maybe check out, e.g., this SO question and its 
answers for alternative approaches: 
http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors.

Cheers,
Jared

###

from pymol import cmd
from random import shuffle

cmd.fetch(2wdk, async=0)
cmd.fetch(2wdl, async=0)
cmd.fetch(2wdm, async=0)
cmd.fetch(2wdn, async=0)

# remove non-polymer components so we can just view the cartoon
cmd.remove(all and not polymer)

# remove RNA chains to get a better view of individual protein chains
cmd.remove(chain A)

my_chains = []

for obj in cmd.get_names():
for ch in cmd.get_chains(obj):
my_chains.append((obj, ch))

print There are currently %s chains to be colored. % len(my_chains)

my_colors = []

# 5^3  100
for i in range (0, 5):
r = 0.25 * i
for j in range (0, 5):
g = 0.25 * j
for k in range (0, 5):
b = 0.25 * k
my_colors.append([r, g, b])

# randomize list (optional)
shuffle(my_colors)
print shuffled the colors

# name the colors
for i, tup in enumerate(my_colors):
cmd.set_color(mycolor_%s % i, %s % tup)
print set color mycolor_%s to %s % (i, tup)

# color your chains
for i, ch in enumerate(my_chains):
sel = %s and chain %s % (ch[0], ch[1])
color = mycolor_%s % i
color_tuple = my_colors[i]
print %s will be colored %s (%s) % (sel, color, color_tuple)
cmd.color(%s % color, sel)

###

--
Jared Sampson
Xiangpeng Kong Lab
NYU Langone Medical Center
550 First Avenue
New York, NY 10016
212-263-7898
http://kong.med.nyu.edu/






On Mar 17, 2014, at 2:07 PM, Sampson, Jared 
jared.samp...@nyumc.orgmailto:jared.samp...@nyumc.org wrote:

Hi Chandan -

It seems like you're being limited by the 26 numbered colors in the util.cbc 
function. You could create your own randomized list of evenly-spaced colors, 
something like the following (untested, but should be approximately 
usable--sorry, I'm away from my computer today):

from pymol import cmd
from random import shuffle

my_colors = []

# 5^3  100
for i in range (0, 5):
   r = 0.25 * i
   for j in range (0, 5):
   g = 0.25 * j
   for k in range (0, 5):
   b = 0.25 * k
   my_colors.append([r, g, b])

# randomize list
shuffle(my_colors)

# color your chains
for x, c in enumerate(my_chain_list):
   cmd.color(my_colors[x], c)

Hope that helps.

Cheers,
Jared

--
Jared Sampson
Kong Lab
NYU Medical Center
kong.med.nyu.eduhttp://kong.med.nyu.edu
212-263-7898

Sent from my iPhone

On Mar 17, 2014, at 8:37 AM, Thomas Holder thomas.hol...@schrodinger.com 
wrote:

Hi Chandan,

in Incentive PyMOL 1.6 you can use the spectrum command to color by chain (will 
be enumerated) or by residue number. http://pymolwiki.org/index.php/Spectrum

In open-source PyMOL, you could use the spectrumany script to color by residue 
number: http://pymolwiki.org/index.php/Spectrumany

Cheers,
Thomas

On 13 Mar 2014, at 03:19, Chandan Choudhury iitd...@gmail.com wrote:
On Thu, Mar 13, 2014 at 10:21 AM, Jordan Willis jwillis0...@gmail.com wrote:
I think...

What is happening is that the color command should take in a name like “color 
yellow, i. 1 or a CMYK color vector. When you are saying “color 1” it is just 
starting at the first index of CMYK which is black.

There is a command for your problem though. Just say util.color_chains() and it 
will color all individual chains a different color.

Thanks Jordon for the reply.

I tried using util.color_chains(). It colors differently upto chain no. 26. 
After 26 all the chains are of same color, as I donot have chain no after that.
Some utility which can color by residue number would be very useful.

Chandan

On Mar 12, 2014, at 11:15 PM, Chandan Choudhury iitd...@gmail.com wrote:

Dear PyMOL users,

I build 100 chains of polymer in a box. Residue number is different for every 
chain. Chain 1 hasresidue no. 1, chain 2 has residue no. 2 and so on. I want to 
color each chain differently.
So, I wrote a script which generates a pml file, and opening this pml file with 
PyMOL should color each chain differently.

##color.pml
load 128md_c.pdb
select 1, i. 1
color  1, i. 1
select 2, i. 2
color  2, i. 2
select 3, i. 3
color  3, i. 3
select 4, i. 4
color  4, i. 4
select 5, i. 5
color  5, i. 5
select 6, i. 6
color  6, i. 6
select 7, i. 7
...
...
color  125, i. 125
select 126, i. 126
color  126, i. 126
select 

Re: [PyMOL] color each polymer chain differently

2014-03-17 Thread Thomas Holder
Hi Chandan,

in Incentive PyMOL 1.6 you can use the spectrum command to color by chain (will 
be enumerated) or by residue number. http://pymolwiki.org/index.php/Spectrum

In open-source PyMOL, you could use the spectrumany script to color by residue 
number: http://pymolwiki.org/index.php/Spectrumany

Cheers,
  Thomas

On 13 Mar 2014, at 03:19, Chandan Choudhury iitd...@gmail.com wrote:
 On Thu, Mar 13, 2014 at 10:21 AM, Jordan Willis jwillis0...@gmail.com wrote:
 I think...
 
 What is happening is that the color command should take in a name like “color 
 yellow, i. 1 or a CMYK color vector. When you are saying “color 1” it is 
 just starting at the first index of CMYK which is black.
 
 There is a command for your problem though. Just say util.color_chains() and 
 it will color all individual chains a different color.
  
 Thanks Jordon for the reply. 
 
 I tried using util.color_chains(). It colors differently upto chain no. 26. 
 After 26 all the chains are of same color, as I donot have chain no after 
 that.
 Some utility which can color by residue number would be very useful.
 
 Chandan
 
 On Mar 12, 2014, at 11:15 PM, Chandan Choudhury iitd...@gmail.com wrote:
 
  Dear PyMOL users,
 
  I build 100 chains of polymer in a box. Residue number is different for 
  every chain. Chain 1 hasresidue no. 1, chain 2 has residue no. 2 and so on. 
  I want to color each chain differently.
  So, I wrote a script which generates a pml file, and opening this pml file 
  with PyMOL should color each chain differently.
 
  ##color.pml
  load 128md_c.pdb
  select 1, i. 1
  color  1, i. 1
  select 2, i. 2
  color  2, i. 2
  select 3, i. 3
  color  3, i. 3
  select 4, i. 4
  color  4, i. 4
  select 5, i. 5
  color  5, i. 5
  select 6, i. 6
  color  6, i. 6
  select 7, i. 7
  ...
  ...
  color  125, i. 125
  select 126, i. 126
  color  126, i. 126
  select 127, i. 127
  color  127, i. 127
  select 128, i. 128
  color  128, i. 128
 
  I have 128 chains.
 
  What I find that mostly green or black dominates the coloring.
  While displaying color by the numeric code, what is the maximum no, after 
  which the color repeats?
 
  Chandan
 
  --
  Chandan Kumar Choudhury
  National Chemical Laboratory, Pune
  India

-- 
Thomas Holder
PyMOL Developer
Schrödinger, Inc.


--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net


Re: [PyMOL] color each polymer chain differently

2014-03-17 Thread Sampson, Jared
Hi Chandan -

It seems like you're being limited by the 26 numbered colors in the util.cbc 
function. You could create your own randomized list of evenly-spaced colors, 
something like the following (untested, but should be approximately 
usable--sorry, I'm away from my computer today):

from pymol import cmd
from random import shuffle

my_colors = []

# 5^3  100
for i in range (0, 5):
r = 0.25 * i
for j in range (0, 5):
g = 0.25 * j
for k in range (0, 5):
b = 0.25 * k
my_colors.append([r, g, b])

# randomize list
shuffle(my_colors)

# color your chains
for x, c in enumerate(my_chain_list):
cmd.color(my_colors[x], c)

Hope that helps. 

Cheers,
Jared

--
Jared Sampson
Kong Lab
NYU Medical Center
kong.med.nyu.edu
212-263-7898

Sent from my iPhone

 On Mar 17, 2014, at 8:37 AM, Thomas Holder thomas.hol...@schrodinger.com 
 wrote:
 
 Hi Chandan,
 
 in Incentive PyMOL 1.6 you can use the spectrum command to color by chain 
 (will be enumerated) or by residue number. 
 http://pymolwiki.org/index.php/Spectrum
 
 In open-source PyMOL, you could use the spectrumany script to color by 
 residue number: http://pymolwiki.org/index.php/Spectrumany
 
 Cheers,
  Thomas
 
 On 13 Mar 2014, at 03:19, Chandan Choudhury iitd...@gmail.com wrote:
 On Thu, Mar 13, 2014 at 10:21 AM, Jordan Willis jwillis0...@gmail.com 
 wrote:
 I think...
 
 What is happening is that the color command should take in a name like 
 “color yellow, i. 1 or a CMYK color vector. When you are saying “color 1” 
 it is just starting at the first index of CMYK which is black.
 
 There is a command for your problem though. Just say util.color_chains() and 
 it will color all individual chains a different color.
 
 Thanks Jordon for the reply. 
 
 I tried using util.color_chains(). It colors differently upto chain no. 26. 
 After 26 all the chains are of same color, as I donot have chain no after 
 that.
 Some utility which can color by residue number would be very useful.
 
 Chandan
 
 On Mar 12, 2014, at 11:15 PM, Chandan Choudhury iitd...@gmail.com wrote:
 
 Dear PyMOL users,
 
 I build 100 chains of polymer in a box. Residue number is different for 
 every chain. Chain 1 hasresidue no. 1, chain 2 has residue no. 2 and so on. 
 I want to color each chain differently.
 So, I wrote a script which generates a pml file, and opening this pml file 
 with PyMOL should color each chain differently.
 
 ##color.pml
 load 128md_c.pdb
 select 1, i. 1
 color  1, i. 1
 select 2, i. 2
 color  2, i. 2
 select 3, i. 3
 color  3, i. 3
 select 4, i. 4
 color  4, i. 4
 select 5, i. 5
 color  5, i. 5
 select 6, i. 6
 color  6, i. 6
 select 7, i. 7
 ...
 ...
 color  125, i. 125
 select 126, i. 126
 color  126, i. 126
 select 127, i. 127
 color  127, i. 127
 select 128, i. 128
 color  128, i. 128
 
 I have 128 chains.
 
 What I find that mostly green or black dominates the coloring.
 While displaying color by the numeric code, what is the maximum no, after 
 which the color repeats?
 
 Chandan
 
 --
 Chandan Kumar Choudhury
 National Chemical Laboratory, Pune
 India
 
 -- 
 Thomas Holder
 PyMOL Developer
 Schrödinger, Inc.
 
 
 --
 Learn Graph Databases - Download FREE O'Reilly Book
 Graph Databases is the definitive new guide to graph databases and their
 applications. Written by three acclaimed leaders in the field,
 this first edition is now available. Download your free book today!
 http://p.sf.net/sfu/13534_NeoTech
 ___
 PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
 Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
 Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net


This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain information that is proprietary, 
confidential, and exempt from disclosure under applicable law. Any unauthorized 
review, use, disclosure, or distribution is prohibited. If you have received 
this email in error please notify the sender by return email and delete the 
original message. Please note, the recipient should check this email and any 
attachments for the presence of viruses. The organization accepts no liability 
for any damage caused by any virus transmitted by this email.
=


--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: 

Re: [PyMOL] color each polymer chain differently

2014-03-13 Thread Chandan Choudhury
On Thu, Mar 13, 2014 at 10:21 AM, Jordan Willis jwillis0...@gmail.comwrote:

 I think...

 What is happening is that the color command should take in a name like
 color yellow, i. 1 or a CMYK color vector. When you are saying color
 1 it is just starting at the first index of CMYK which is black.

 There is a command for your problem though. Just say util.color_chains()
 and it will color all individual chains a different color.


Thanks Jordon for the reply.

I tried using util.color_chains(). It colors differently upto chain no. 26.
After 26 all the chains are of same color, as I donot have chain no after
that.
Some utility which can color by residue number would be very useful.

Chandan




 On Mar 12, 2014, at 11:15 PM, Chandan Choudhury iitd...@gmail.com wrote:

 
  Dear PyMOL users,
 
  I build 100 chains of polymer in a box. Residue number is different for
 every chain. Chain 1 has residue no. 1, chain 2 has residue no. 2 and so
 on. I want to color each chain differently.
  So, I wrote a script which generates a pml file, and opening this pmlfile 
  with PyMOL should color each chain differently.
 
  ##color.pml
  load 128md_c.pdb
  select 1, i. 1
  color  1, i. 1
  select 2, i. 2
  color  2, i. 2
  select 3, i. 3
  color  3, i. 3
  select 4, i. 4
  color  4, i. 4
  select 5, i. 5
  color  5, i. 5
  select 6, i. 6
  color  6, i. 6
  select 7, i. 7
  ...
  ...
  color  125, i. 125
  select 126, i. 126
  color  126, i. 126
  select 127, i. 127
  color  127, i. 127
  select 128, i. 128
  color  128, i. 128
 
  I have 128 chains.
 
  What I find that mostly green or black dominates the coloring.
  While displaying color by the numeric code, what is the maximum no,
 after which the color repeats?
 
  Chandan
 
  --
  Chandan Kumar Choudhury
  National Chemical Laboratory, Pune
  India
 
 
 --
  Learn Graph Databases - Download FREE O'Reilly Book
  Graph Databases is the definitive new guide to graph databases and
 their
  applications. Written by three acclaimed leaders in the field,
  this first edition is now available. Download your free book today!
 
 http://p.sf.net/sfu/13534_NeoTech___
  PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
  Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
  Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net




-- 

--
Chandan Kumar Choudhury
National Chemical Laboratory, Pune
India
--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

[PyMOL] color each polymer chain differently

2014-03-12 Thread Chandan Choudhury
Dear PyMOL users,

I build 100 chains of polymer in a box. Residue number is different for
every chain. Chain 1 has residue no. 1, chain 2 has residue no. 2 and so
on. I want to color each chain differently.
So, I wrote a script which generates a pml file, and opening this pml file
with PyMOL should color each chain differently.

##color.pml
load 128md_c.pdb
select 1, i. 1
color  1, i. 1
select 2, i. 2
color  2, i. 2
select 3, i. 3
color  3, i. 3
select 4, i. 4
color  4, i. 4
select 5, i. 5
color  5, i. 5
select 6, i. 6
color  6, i. 6
select 7, i. 7
...
...
color  125, i. 125
select 126, i. 126
color  126, i. 126
select 127, i. 127
color  127, i. 127
select 128, i. 128
color  128, i. 128

I have 128 chains.

What I find that mostly green or black dominates the coloring.
While displaying color by the numeric code, what is the maximum no, after
which the color repeats?

Chandan

--
Chandan Kumar Choudhury
National Chemical Laboratory, Pune
India
--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Re: [PyMOL] color each polymer chain differently

2014-03-12 Thread Jordan Willis
I think...

What is happening is that the color command should take in a name like “color 
yellow, i. 1 or a CMYK color vector. When you are saying “color 1” it is just 
starting at the first index of CMYK which is black.

There is a command for your problem though. Just say util.color_chains() and it 
will color all individual chains a different color. 



On Mar 12, 2014, at 11:15 PM, Chandan Choudhury iitd...@gmail.com wrote:

 
 Dear PyMOL users,
 
 I build 100 chains of polymer in a box. Residue number is different for every 
 chain. Chain 1 has residue no. 1, chain 2 has residue no. 2 and so on. I want 
 to color each chain differently.
 So, I wrote a script which generates a pml file, and opening this pml file 
 with PyMOL should color each chain differently.
 
 ##color.pml
 load 128md_c.pdb
 select 1, i. 1
 color  1, i. 1
 select 2, i. 2
 color  2, i. 2
 select 3, i. 3
 color  3, i. 3
 select 4, i. 4
 color  4, i. 4
 select 5, i. 5
 color  5, i. 5
 select 6, i. 6
 color  6, i. 6
 select 7, i. 7
 ...
 ...
 color  125, i. 125
 select 126, i. 126
 color  126, i. 126
 select 127, i. 127
 color  127, i. 127
 select 128, i. 128
 color  128, i. 128
 
 I have 128 chains.
 
 What I find that mostly green or black dominates the coloring. 
 While displaying color by the numeric code, what is the maximum no, after 
 which the color repeats?
 
 Chandan
 
 --
 Chandan Kumar Choudhury
 National Chemical Laboratory, Pune
 India
 
 --
 Learn Graph Databases - Download FREE O'Reilly Book
 Graph Databases is the definitive new guide to graph databases and their
 applications. Written by three acclaimed leaders in the field,
 this first edition is now available. Download your free book today!
 http://p.sf.net/sfu/13534_NeoTech___
 PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
 Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
 Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net


--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net