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

 Re: [PyMOL] drawing a bond between the same Calpha atom in different states From: Tsjerk Wassenaar - 2012-12-14 09:14:01 Attachments: Message as HTML ```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.campbell@...> wrote: > Hi, > > (replying to my own message) > > On Thu, 2012-12-13 15:52 EST, Robert Campbell > wrote: > > > Hi Jon, > > > > On Thu, 2012-12-13 16:09 EST, Jonathan Grimes < > jonathan@...> > > 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 > http://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@...) > Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users > Archives: http://www.mail-archive.com/pymol-users@... > -- Tsjerk A. Wassenaar, Ph.D. post-doctoral researcher Biocomputing Group Department of Biological Sciences 2500 University Drive NW Calgary, AB T2N 1N4 Canada ```