Re: [PyMOL] print out distance From: Jason Vertrees - 2010-07-15 03:03:06 ```Hi Elsa, Good first attempt. "cmd.distance" will return the distance between two atoms or the average distance if you give it more than two. Most surely your "chain A" and "chain C" each have more than one atom each. So, you just get the average distance. I'm not sure what exact distances you want to measure: all atoms; alpha carbons; average chain? If you want to measure the distances between all M atoms in chain A and all N atoms in chain B, you get an MxN matrix of distances by the following code: python from pymol import stored stored.a, stored.b = [], [] cmd.iterate_state(1, "chain A", "stored.a.append(ID)") cmd.iterate_state(1, "chain B", "stored.b.append(ID)") outFile = open("/tmp/distances", 'w') for a in stored.a: for b in stored.b: outFile.write( "distance from %s to %s is %s\n" % (a, b, cmd.distance( "id %s" % a, "id %s" % b))) outFile.close() python end Now read your file, "/tmp/distances". If you want average positions between chain A and B, then you need to compute the center of mass (http://pymolwiki.org/index.php/Center_Of_Mass), create two pseudoatoms (http://pymolwiki.org/index.php/Pseudoatom) at the centers of mass, and calculate that distance. Cheers, -- Jason On Wed, Jul 14, 2010 at 8:26 AM, wrote: > Hello, > I used  a simple script to calculate the distance between > two objects called chain_a and chain_c in the range of 1 > A, > graphically the script works and in the monitor is > possible observe the distance and the residues involved, > I have some problems to print out the distance values and > the residues involved in a .txt file. > The script that I used > is very simple, the txt file is created but inside there > is just one distance and I don't know how insert also > the residues involved, > do you have some idea or suggestion > the script is: > > # import PyMOL's command namespace > from pymol import cmd > > # open dist.txt for writing > f=open('dist.txt','w') > > # calculate the distance and store it in dst > dst=cmd.distance('tmp','chain_a','chain_c',1) > > # write the formatted value of the distance (dst) > # to the output file > f.write("%8.3f\n"%dst) > > # close the output file. > f.close() > > Thanks a lot > Elsa > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > PyMOL-users mailing list (PyMOL-users@...) > Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users > Archives: http://www.mail-archive.com/pymol-users@... > -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) Jason.Vertrees@... (o) +1 (603) 374-7120 ```
 [PyMOL] print out distance From: - 2010-07-14 13:29:17 ```Hello, I used a simple script to calculate the distance between two objects called chain_a and chain_c in the range of 1 A, graphically the script works and in the monitor is possible observe the distance and the residues involved, I have some problems to print out the distance values and the residues involved in a .txt file. The script that I used is very simple, the txt file is created but inside there is just one distance and I don't know how insert also the residues involved, do you have some idea or suggestion the script is: # import PyMOL's command namespace from pymol import cmd # open dist.txt for writing f=open('dist.txt','w') # calculate the distance and store it in dst dst=cmd.distance('tmp','chain_a','chain_c',1) # write the formatted value of the distance (dst) # to the output file f.write("%8.3f\n"%dst) # close the output file. f.close() Thanks a lot Elsa ```
 Re: [PyMOL] print out distance From: Jason Vertrees - 2010-07-15 03:03:06 ```Hi Elsa, Good first attempt. "cmd.distance" will return the distance between two atoms or the average distance if you give it more than two. Most surely your "chain A" and "chain C" each have more than one atom each. So, you just get the average distance. I'm not sure what exact distances you want to measure: all atoms; alpha carbons; average chain? If you want to measure the distances between all M atoms in chain A and all N atoms in chain B, you get an MxN matrix of distances by the following code: python from pymol import stored stored.a, stored.b = [], [] cmd.iterate_state(1, "chain A", "stored.a.append(ID)") cmd.iterate_state(1, "chain B", "stored.b.append(ID)") outFile = open("/tmp/distances", 'w') for a in stored.a: for b in stored.b: outFile.write( "distance from %s to %s is %s\n" % (a, b, cmd.distance( "id %s" % a, "id %s" % b))) outFile.close() python end Now read your file, "/tmp/distances". If you want average positions between chain A and B, then you need to compute the center of mass (http://pymolwiki.org/index.php/Center_Of_Mass), create two pseudoatoms (http://pymolwiki.org/index.php/Pseudoatom) at the centers of mass, and calculate that distance. Cheers, -- Jason On Wed, Jul 14, 2010 at 8:26 AM, wrote: > Hello, > I used  a simple script to calculate the distance between > two objects called chain_a and chain_c in the range of 1 > A, > graphically the script works and in the monitor is > possible observe the distance and the residues involved, > I have some problems to print out the distance values and > the residues involved in a .txt file. > The script that I used > is very simple, the txt file is created but inside there > is just one distance and I don't know how insert also > the residues involved, > do you have some idea or suggestion > the script is: > > # import PyMOL's command namespace > from pymol import cmd > > # open dist.txt for writing > f=open('dist.txt','w') > > # calculate the distance and store it in dst > dst=cmd.distance('tmp','chain_a','chain_c',1) > > # write the formatted value of the distance (dst) > # to the output file > f.write("%8.3f\n"%dst) > > # close the output file. > f.close() > > Thanks a lot > Elsa > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > PyMOL-users mailing list (PyMOL-users@...) > Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users > Archives: http://www.mail-archive.com/pymol-users@... > -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) Jason.Vertrees@... (o) +1 (603) 374-7120 ```