Re: [PyMOL] drawing a bond between the same Calpha atom in different states

2012-12-14 Thread Tsjerk Wassenaar
Hey :)

Can't resist the challenge...
For any given ensemble, you can draw a trace through the C-alphas using the
following lines, illustrated here for the NMR ensemble '1NMR':

# Get the structure
fetch 1nmr

# Get the number of states
n = cmd.count_states('1nmr')

# Collect the C-alpha coordinates
# This calls get_model for every state and extracts the coordinates for
every model-state
# The resulting list is transposed, such that each list entry contains the
coordinates for one C-alpha over all states
x=zip(*[cmd.get_model('1nmr and n. ca',state=i+1).get_coord_list() for i in
range(n)] )

# Now draw the traces by building a CGO model
cmd.load_cgo([i for j in x for u,v,f in zip(j,j[1:],range(r)) for i in
[9.0]+u+v+[0.1,1,1-(1.*f)/r,1-(1.*f)/r,1,1-(1.+f)/r,1-(1.+f)/r]],trace)

The 9.0 is the CGO code for a cylinder (pymol.cgo.CYLINDER). The 0.1 is the
radius, and the following six values are the start and end RGB values,
which are related to the state number, such that they end up from white to
red. For more complex colors it would be nice to have a rgb() function that
would return a color according to some scheme, given a fraction, which
would make that last command

cmd.load_cgo([i for j in x for u,v,f in zip(j,j[1:],range(r)) for i in
[9.0]+u+v+[0.1]+rgb((1.*f)/r,scheme=...)+rgb((1.+f)/r,scheme=...)],trace)

Hope it helps,

Tsjerk


On Thu, Dec 13, 2012 at 10:54 PM, Robert Campbell 
robert.campb...@queensu.ca wrote:

 Hi,

 (replying to my own message)

 On Thu, 2012-12-13 15:52  EST,  Robert Campbell
 robert.campb...@queensu.ca wrote:

  Hi Jon,
 
  On Thu, 2012-12-13 16:09  EST,  Jonathan Grimes 
 jonat...@strubi.ox.ac.uk
  wrote:
 
 Hi All,
  
  I have 2 different states of the same molecule..different
   conformations generated from MD, so the same number of Calpha atoms,
   with a direct 1:1 mapping between Calphas with the same residue
   numbering.
  
  I would like to draw a bond between equivalent C-alpha atoms, and
 I
   will then ramp colour along the bond, say blue-white-red.
  
  Could I get advice how to draw a bond between 2 Calpha atoms (same
   resi) from different states
 
  I have a script for drawing a cylinder (you can specify the radius and
 the
  beginning and ending colors) between two atoms.  The script is at:
 
 
 http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/draw_cylinder_cgo.py
 
  First run the script via the File menu or via the command line:
 
  run draw_cylinder_cgo.py
 
  You will then have two new functions defined draw_cylinder and
  draw_cylinder_cgo.  The former allows you to pick two atoms to draw the
  cylinder between:
 
  draw_cylinder name, atom1, atom2, radius, start_color, end_color
 
  where each atom is a standard PyMOL selection (defaults to pk1 and
  pk2) and color is a 3-element RGB tuple defining the color
  of the cylinder (where each value of R, G and B is between 0 and 1
  inclusive).  The colors default to (1,1,0).
 
 
  Alternatively, draw_cylinder_cgo takes as arguments the start and end
  coordinates of the vector in place of atom1 and atom2.

 I could add more instructions here.  You can specify the colours by
 name and if you have picked the atoms with the mouse you can easily do
 something like:

   draw_cylinder dist1, start_color=red, end_color=yellow

 and it will default to using atom selections pk1 and pk2 and a radius
 of 0.1 A.

 Cheers,
 Rob
 --
 Robert L. Campbell, Ph.D.
 Senior Research Associate/Adjunct Assistant Professor
 Dept. of Biomedical  Molecular Sciences
 Botterell Hall Rm 644
 Queen's University,
 Kingston, ON K7L 3N6  Canada
 Tel: 613-533-6821
 robert.campb...@queensu.cahttp://pldserver1.biochem.queensu.ca/~rlc


 --
 LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
 Remotely access PCs and mobile devices and provide instant support
 Improve your efficiency, and focus on delivering more value-add services
 Discover what IT Professionals Know. Rescue delivers
 http://p.sf.net/sfu/logmein_12329d2d
 ___
 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




-- 
Tsjerk A. Wassenaar, Ph.D.

post-doctoral researcher
Biocomputing Group
Department of Biological Sciences
2500 University Drive NW
Calgary, AB T2N 1N4
Canada
--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)

Re: [PyMOL] drawing a bond between the same Calpha atom in different states

2012-12-14 Thread Tsjerk Wassenaar
Hi Jon,

You also have to update the three numbers before. So to go from white to
blue is

cmd.load_cgo([i for j in x for u,v,f in zip(j,j[1:],range(n)) for i in
[9.0]+u+v+[1.3,  1-(1.*f)/n,1-(1.*f)/n,1,   1-(1.+f)/n,1-(1.+f)/n,1
 ]],trace)

If you want to go from blue to white to red, it's probably easiest to split
it in two:

a=n/2
b=n-n/2
cmd.load_cgo([i for j in x for u,v,f in zip(j,j[1:],range(n))[:a] for i in
[9.0]+u+v+[1.3,  (1.*f)/a,(1.*f)/a,1,   (1.+f)/a,(1.+f)/a,1  ]],trace_a)
cmd.load_cgo([i for j in x for u,v,f in zip(j,j[1:],range(n))[a:] for i in
[9.0]+u+v+[1.3,  1,1-(1.*f-a)/b,1-(1.*f-a)/b,
1,1-(1.+f-a)/b,1-(1.+f-a)/b  ]],trace_b)

For the capping, you can use spheres:

cmd.load_cgo([i for j in x for u,f in zip(j,range(n))[:a] for i in [6.0,
(1.*f)/a,(1.*f)/a,1,  7.0]+u+[1.3]],spheres_a)
cmd.load_cgo([i for j in x for u,f in zip(j,range(n))[a:] for i in [6.0,
1,1-(1.*f-a)/b,1-(1.*f-a)/b,  7.0]+u+[1.3]],spheres_b)

For more complex color schemes, you would definitely want a rgb function.

Hope it helps,

Tsjerk


On Fri, Dec 14, 2012 at 12:25 PM, Jonathan Grimes
jonat...@strubi.ox.ac.ukwrote:


   thanks  tsjerk

ive been playing with the values at the end..and i can,t change it
 to go from
white to blueor even red to blue

i triedwhite to blueso 1,1,1 to 0,0, 1

 cmd.load_cgo([i for j in x for u,v,f in zip(j,j[1:],range(n)) for i in
 [9.0]+u+v+[1.3,1,1-(1.*f)/n,1-(1.*f)/n, 1-(1.+f)/n,1-(1.+f)/n,1  ]],trace)

so 1,1-(1.*f)/n,1-(1.*f)/n,  corresponds to 1,1,1where f/n is the
 fraction along the cylinder.

   and then i changed the last 3 numbers to 1-(1.+f)/n,1-(1.+f)/n,1which
 i thought would go to 0 , 0 ,1

but i get a bond but the color doesnt go smoothly from white to blue ??

is there also a nice way to cap the cylinder so it had a rounded end ??

thanks
jon


 Dr. Jonathan M. Grimes,
 NDM Senior Reseach Fellow
 University Research Lecturer
 Division of Structural Biology
 Wellcome Trust Centre for Human Genetics
 University of Oxford
 Roosevelt Drive,
 Oxford OX3 7BN, UK

 Email: jonat...@strubi.ox.ac.uk, Web: www.strubi.ox.ac.uk
 Tel: (+44) - 1865 - 287561, FAX: (+44) - 1865 - 287547



 On 14 Dec 2012, at 09:13, Tsjerk Wassenaar wrote:

 Hey :)

 Can't resist the challenge...
 For any given ensemble, you can draw a trace through the C-alphas using
 the following lines, illustrated here for the NMR ensemble '1NMR':

 # Get the structure
 fetch 1nmr

 # Get the number of states
 n = cmd.count_states('1nmr')

 # Collect the C-alpha coordinates
 # This calls get_model for every state and extracts the coordinates for
 every model-state
 # The resulting list is transposed, such that each list entry contains the
 coordinates for one C-alpha over all states
 x=zip(*[cmd.get_model('1nmr and n. ca',state=i+1).get_coord_list() for i
 in range(n)] )

 # Now draw the traces by building a CGO model
 cmd.load_cgo([i for j in x for u,v,f in zip(j,j[1:],range(r)) for i in
 [9.0]+u+v+[0.1,1,1-(1.*f)/r,1-(1.*f)/r,1,1-(1.+f)/r,1-(1.+f)/r]],trace)

 The 9.0 is the CGO code for a cylinder (pymol.cgo.CYLINDER). The 0.1 is
 the radius, and the following six values are the start and end RGB values,
 which are related to the state number, such that they end up from white to
 red. For more complex colors it would be nice to have a rgb() function that
 would return a color according to some scheme, given a fraction, which
 would make that last command

 cmd.load_cgo([i for j in x for u,v,f in zip(j,j[1:],range(r)) for i in
 [9.0]+u+v+[0.1]+rgb((1.*f)/r,scheme=...)+rgb((1.+f)/r,scheme=...)],trace)

 Hope it helps,

 Tsjerk


 On Thu, Dec 13, 2012 at 10:54 PM, Robert Campbell 
 robert.campb...@queensu.ca wrote:

 Hi,

 (replying to my own message)

 On Thu, 2012-12-13 15:52  EST,  Robert Campbell
 robert.campb...@queensu.ca wrote:

  Hi Jon,
 
  On Thu, 2012-12-13 16:09  EST,  Jonathan Grimes 
 jonat...@strubi.ox.ac.uk
  wrote:
 
 Hi All,
  
  I have 2 different states of the same molecule..different
   conformations generated from MD, so the same number of Calpha atoms,
   with a direct 1:1 mapping between Calphas with the same residue
   numbering.
  
  I would like to draw a bond between equivalent C-alpha atoms,
 and I
   will then ramp colour along the bond, say blue-white-red.
  
  Could I get advice how to draw a bond between 2 Calpha atoms (same
   resi) from different states
 
  I have a script for drawing a cylinder (you can specify the radius and
 the
  beginning and ending colors) between two atoms.  The script is at:
 
 
 http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/draw_cylinder_cgo.py
 
  First run the script via the File menu or via the command line:
 
  run draw_cylinder_cgo.py
 
  You will then have two new functions defined draw_cylinder and
  draw_cylinder_cgo.  The former allows you to pick two atoms to draw
 the
  cylinder between:
 
  draw_cylinder name, atom1, atom2, radius, start_color, 

[PyMOL] drawing a bond between the same Calpha atom in different states

2012-12-13 Thread Jonathan Grimes

  Hi All,

   I have 2 different states of the same molecule..different conformations 
generated from
   MD, so the same number of Calpha atoms, with a direct 1:1 mapping between 
Calphas 
   with the same residue numbering.

   I would like to draw a bond between equivalent C-alpha atoms, and I will 
then ramp
   colour along the bond, say blue-white-red.

   Could I get advice how to draw a bond between 2 Calpha atoms (same resi) 
from different
   states

  Many thanks for the help.

   Jon



Dr. Jonathan M. Grimes, 
NDM Senior Reseach Fellow
University Research Lecturer
Division of Structural Biology
Wellcome Trust Centre for Human Genetics
University of Oxford
Roosevelt Drive,
Oxford OX3 7BN, UK

Email: jonat...@strubi.ox.ac.uk, Web: www.strubi.ox.ac.uk 
Tel: (+44) - 1865 - 287561, FAX: (+44) - 1865 - 287547   




--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
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] drawing a bond between the same Calpha atom in different states

2012-12-13 Thread Robert Campbell
Hi Jon,

On Thu, 2012-12-13 16:09  EST,  Jonathan Grimes jonat...@strubi.ox.ac.uk
wrote:

   Hi All,
 
I have 2 different states of the same molecule..different
 conformations generated from MD, so the same number of Calpha atoms, with
 a direct 1:1 mapping between Calphas with the same residue numbering.
 
I would like to draw a bond between equivalent C-alpha atoms, and I
 will then ramp colour along the bond, say blue-white-red.
 
Could I get advice how to draw a bond between 2 Calpha atoms (same
 resi) from different states

I have a script for drawing a cylinder (you can specify the radius and the
beginning and ending colors) between two atoms.  The script is at:

http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/draw_cylinder_cgo.py

First run the script via the File menu or via the command line:

run draw_cylinder_cgo.py

You will then have two new functions defined draw_cylinder and
draw_cylinder_cgo.  The former allows you to pick two atoms to draw the
cylinder between:

draw_cylinder name, atom1, atom2, radius, start_color, end_color

where each atom is a standard PyMOL selection (defaults to pk1 and pk2)
and color is a 3-element RGB tuple defining the color
of the cylinder (where each value of R, G and B is between 0 and 1
inclusive).  The colors default to (1,1,0).


Alternatively, draw_cylinder_cgo takes as arguments the start and end
coordinates of the vector in place of atom1 and atom2.

Hope that helps.

Cheers,
Rob

-- 
Robert L. Campbell, Ph.D.
Senior Research Associate/Adjunct Assistant Professor
Dept. of Biomedical  Molecular Sciences
Botterell Hall Rm 644
Queen's University, 
Kingston, ON K7L 3N6  Canada
Tel: 613-533-6821
robert.campb...@queensu.cahttp://pldserver1.biochem.queensu.ca/~rlc

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
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] drawing a bond between the same Calpha atom in different states

2012-12-13 Thread Robert Campbell
Hi,

(replying to my own message)

On Thu, 2012-12-13 15:52  EST,  Robert Campbell
robert.campb...@queensu.ca wrote:

 Hi Jon,
 
 On Thu, 2012-12-13 16:09  EST,  Jonathan Grimes jonat...@strubi.ox.ac.uk
 wrote:
 
Hi All,
  
 I have 2 different states of the same molecule..different
  conformations generated from MD, so the same number of Calpha atoms,
  with a direct 1:1 mapping between Calphas with the same residue
  numbering.
  
 I would like to draw a bond between equivalent C-alpha atoms, and I
  will then ramp colour along the bond, say blue-white-red.
  
 Could I get advice how to draw a bond between 2 Calpha atoms (same
  resi) from different states
 
 I have a script for drawing a cylinder (you can specify the radius and the
 beginning and ending colors) between two atoms.  The script is at:
 
 http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/draw_cylinder_cgo.py
 
 First run the script via the File menu or via the command line:
 
 run draw_cylinder_cgo.py
 
 You will then have two new functions defined draw_cylinder and
 draw_cylinder_cgo.  The former allows you to pick two atoms to draw the
 cylinder between:
 
 draw_cylinder name, atom1, atom2, radius, start_color, end_color
 
 where each atom is a standard PyMOL selection (defaults to pk1 and
 pk2) and color is a 3-element RGB tuple defining the color
 of the cylinder (where each value of R, G and B is between 0 and 1
 inclusive).  The colors default to (1,1,0).
 
 
 Alternatively, draw_cylinder_cgo takes as arguments the start and end
 coordinates of the vector in place of atom1 and atom2.

I could add more instructions here.  You can specify the colours by
name and if you have picked the atoms with the mouse you can easily do
something like:

  draw_cylinder dist1, start_color=red, end_color=yellow

and it will default to using atom selections pk1 and pk2 and a radius
of 0.1 A.

Cheers,
Rob
-- 
Robert L. Campbell, Ph.D.
Senior Research Associate/Adjunct Assistant Professor
Dept. of Biomedical  Molecular Sciences
Botterell Hall Rm 644
Queen's University, 
Kingston, ON K7L 3N6  Canada
Tel: 613-533-6821
robert.campb...@queensu.cahttp://pldserver1.biochem.queensu.ca/~rlc

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
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