[PyMOL] colouring states independently

2012-08-31 Thread John Russo
Hi,
I have been fighting with this problem for some time now,
and I think it is time to try to ask to more experienced users.

What I want to achieve is really simple. I want to make a movie
with only spheres. At every frame each sphere has also a scalar
property (e.g. local density) which is used to color the sphere
accordingly.

So my input are a series of xyz files, and a corresponding series
of files holding the value of that scalar for each particle.

What I'm doing now is:

*) loading all the xyz file into different states
*) creating a frame from each of these states
*) loop on the different frames and color the spheres
according to the field

My problem is in this last point, as I cannot find a way to
tell pymol to colour each sphere only for that frame, and
I always end up with a movie where the colour of the spheres
is fixed by the last frame.

Here is some pseudo code for what I'm doing:


for file in file_list:
 cmd.load(file,movie)

cmd.mset(1 -%d % cmd.count_states())

for i in range(1,cmd.count_states()+1):
 name=%d % (i)

 cmd.frame(i)

 scalar=readField(scalar_field[i])

 for particle_index,s in enumerate(scalar):

 cmd.select(particle,id +str(particle_index+1))
 cmd.color(custom_color[s],particle)


 cmd.scene(name,store)
 cmd.mview('store',name)


One last thing, the number of particles is not the same for every state.

I hope somebody can help me. Thanks,

   John

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
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] colouring states independently

2012-08-31 Thread Thomas Holder
Hi John,

what you need is a discrete object, not only because of the coloring, 
but also because you say the number of particles is not the same for 
each state.

Try to apply two modifications:

  1) discrete argument for load:
  cmd.load(file, movie, discrete=1)

  2) state argument for select:
  cmd.select(particle, id +str(particle_index+1), state=i)

I hope this will work :)

Cheers,
   Thomas

John Russo wrote, On 08/31/12 09:14:
 Hi,
 I have been fighting with this problem for some time now,
 and I think it is time to try to ask to more experienced users.
 
 What I want to achieve is really simple. I want to make a movie
 with only spheres. At every frame each sphere has also a scalar
 property (e.g. local density) which is used to color the sphere
 accordingly.
 
 So my input are a series of xyz files, and a corresponding series
 of files holding the value of that scalar for each particle.
 
 What I'm doing now is:
 
 *) loading all the xyz file into different states
 *) creating a frame from each of these states
 *) loop on the different frames and color the spheres
 according to the field
 
 My problem is in this last point, as I cannot find a way to
 tell pymol to colour each sphere only for that frame, and
 I always end up with a movie where the colour of the spheres
 is fixed by the last frame.
 
 Here is some pseudo code for what I'm doing:
 
 
 for file in file_list:
  cmd.load(file,movie)
 
 cmd.mset(1 -%d % cmd.count_states())
 
 for i in range(1,cmd.count_states()+1):
  name=%d % (i)
 
  cmd.frame(i)
 
  scalar=readField(scalar_field[i])
 
  for particle_index,s in enumerate(scalar):
 
  cmd.select(particle,id +str(particle_index+1))
  cmd.color(custom_color[s],particle)
 
 
  cmd.scene(name,store)
  cmd.mview('store',name)
 
 
 One last thing, the number of particles is not the same for every state.
 
 I hope somebody can help me. Thanks,
 
John

-- 
Thomas Holder
MPI for Developmental Biology
Spemannstr. 35
D-72076 Tübingen

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
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] colouring states independently

2012-08-31 Thread John Russo
Thank you,
I didn't know that select has also a state option. That solved the
problem.

   John


On 08/31/2012 04:57 PM, Thomas Holder wrote:
 Hi John,

 what you need is a discrete object, not only because of the 
 coloring, but also because you say the number of particles is not the 
 same for each state.

 Try to apply two modifications:

  1) discrete argument for load:
  cmd.load(file, movie, discrete=1)

  2) state argument for select:
  cmd.select(particle, id +str(particle_index+1), state=i)

 I hope this will work :)

 Cheers,
   Thomas

 John Russo wrote, On 08/31/12 09:14:
 Hi,
 I have been fighting with this problem for some time now,
 and I think it is time to try to ask to more experienced users.

 What I want to achieve is really simple. I want to make a movie
 with only spheres. At every frame each sphere has also a scalar
 property (e.g. local density) which is used to color the sphere
 accordingly.

 So my input are a series of xyz files, and a corresponding series
 of files holding the value of that scalar for each particle.

 What I'm doing now is:

 *) loading all the xyz file into different states
 *) creating a frame from each of these states
 *) loop on the different frames and color the spheres
 according to the field

 My problem is in this last point, as I cannot find a way to
 tell pymol to colour each sphere only for that frame, and
 I always end up with a movie where the colour of the spheres
 is fixed by the last frame.

 Here is some pseudo code for what I'm doing:


 for file in file_list:
  cmd.load(file,movie)

 cmd.mset(1 -%d % cmd.count_states())

 for i in range(1,cmd.count_states()+1):
  name=%d % (i)

  cmd.frame(i)

  scalar=readField(scalar_field[i])

  for particle_index,s in enumerate(scalar):

  cmd.select(particle,id +str(particle_index+1))
  cmd.color(custom_color[s],particle)


  cmd.scene(name,store)
  cmd.mview('store',name)


 One last thing, the number of particles is not the same for every state.

 I hope somebody can help me. Thanks,

John



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
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