## [PyMOL] distances

 [PyMOL] distances From: Krisztina Feher - 2012-07-30 23:46:22 Attachments: Message as HTML ```HI Thomas, the selection works now with "near_to", also the get_raw_distances module is doing the job, see below. The only nag is how to convert atom IDs in i1 and i2 into atom names? Thanks a lot, Krisztina from pymol import cmd #import get_raw_distances from get_raw_distances import get_raw_distances, select_distances f=open('dist.txt','w') hcpl1=cmd.select('hcpl1', 'resi 1-10 and hydro') hcpl2=cmd.select('hcpl2', 'resi 11-20 and hydro') inoe12=cmd.select('inoe12', 'hcpl1 near_to 5 of hcpl2') inoe21=cmd.select('inoe21', 'hcpl2 near_to 5 of hcpl1') cmd.distance('tmp', 'inoe12' ,'inoe21', 5, mode=0) #for (i1, i2, dst) in get_raw_distances.get_raw_distances('tmp'): dist= get_raw_distances('tmp') for (i1, i2, dist) in dist:   print i1, i2, dst   n1=i1[1]   print n1   f.write("%8.3f\n"%dst) f.close() Re: [PyMOL] distances Thomas Holder Mon, 30 Jul 2012 11:31:54 -0700 Hi Krisztina, the syntax for the "around" operator is wrong, there is no "of" keyword. One of these would be correct: hcpl1 within 5 of hcpl2 hcpl2 around 5 and hcpl1 See also: http://pymolwiki.org/index.php/Selection_Algebra#Comparison_of_distance_operators To iterate over atoms of a selection, you can use "cmd.pop". There is no PyMOLWiki page, but you'll get a nice example from: PyMOL> help pop Also very powerful for iteration over atoms: http://pymolwiki.org/index.php/Iterate What you actually want is to iterate over distances, not atoms. There is a script on the PyMOLWiki which provides that: http://pymolwiki.org/index.php/Get_raw_distances cmd.distance('tmp', 'hcpl1' ,'hcpl2', 5.0) for (i1, i2, dst) in get_raw_distances('tmp'): f.write("%8.3f\n" % dst) Hope that helps. Cheers, Thomas On 30.07.2012 19:34, Krisztina Feher wrote: > Hi Everyone, > > I would like to write a script, which writes out intermolecular > distances shorter than 5A between hydrogens into a text file. Here is > what I made so far on the basis of the Measure distance script in the > respository: > > from pymol import cmd > > # open dist.txt for writing > f=open('dist.txt','w') > > hcpl1=cmd.select('hcpl1', 'resi 1-10 and hydro') > hcpl2=cmd.select('hcpl2', 'resi 11-20 and hydro') > inoe12=cmd.select('inoe12', 'hcpl1 around 5 of hcpl2') > > for i in range(len(hcpl1)): > dst=cmd.distance('tmp', 'hcpl1' ,'hcpl2') > f.write("%8.3f\n"%dst) > f.close() > > What do not understand is the following: > - why inoe12 selection is not being made (it works from pymol command > line as > "select inoe12, hcpl1 around 5 of hcpl2" ) > - how can I loop over the atoms of a selection (hcpl1 seems to be not a > list, but a single interger) > > Thanks for any help in advance! > Krisztina -- 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@...) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@... ```

 [PyMOL] distances From: Krisztina Feher - 2012-07-30 17:34:37 Attachments: Message as HTML ```Hi Everyone, I would like to write a script, which writes out intermolecular distances shorter than 5A between hydrogens into a text file. Here is what I made so far on the basis of the Measure distance script in the respository: from pymol import cmd # open dist.txt for writing f=open('dist.txt','w') hcpl1=cmd.select('hcpl1', 'resi 1-10 and hydro') hcpl2=cmd.select('hcpl2', 'resi 11-20 and hydro') inoe12=cmd.select('inoe12', 'hcpl1 around 5 of hcpl2') for i in range(len(hcpl1)):   dst=cmd.distance('tmp', 'hcpl1' ,'hcpl2')   f.write("%8.3f\n"%dst) f.close() What do not understand is the following: - why inoe12 selection is not being made (it works from pymol command line as "select inoe12, hcpl1 around 5 of hcpl2" ) - how can I loop over the atoms of a selection (hcpl1 seems to be not a list, but a single interger) Thanks for any help in advance! Krisztina ```
 [PyMOL] distances From: Krisztina Feher - 2012-07-30 23:46:22 Attachments: Message as HTML ```HI Thomas, the selection works now with "near_to", also the get_raw_distances module is doing the job, see below. The only nag is how to convert atom IDs in i1 and i2 into atom names? Thanks a lot, Krisztina from pymol import cmd #import get_raw_distances from get_raw_distances import get_raw_distances, select_distances f=open('dist.txt','w') hcpl1=cmd.select('hcpl1', 'resi 1-10 and hydro') hcpl2=cmd.select('hcpl2', 'resi 11-20 and hydro') inoe12=cmd.select('inoe12', 'hcpl1 near_to 5 of hcpl2') inoe21=cmd.select('inoe21', 'hcpl2 near_to 5 of hcpl1') cmd.distance('tmp', 'inoe12' ,'inoe21', 5, mode=0) #for (i1, i2, dst) in get_raw_distances.get_raw_distances('tmp'): dist= get_raw_distances('tmp') for (i1, i2, dist) in dist:   print i1, i2, dst   n1=i1[1]   print n1   f.write("%8.3f\n"%dst) f.close() Re: [PyMOL] distances Thomas Holder Mon, 30 Jul 2012 11:31:54 -0700 Hi Krisztina, the syntax for the "around" operator is wrong, there is no "of" keyword. One of these would be correct: hcpl1 within 5 of hcpl2 hcpl2 around 5 and hcpl1 See also: http://pymolwiki.org/index.php/Selection_Algebra#Comparison_of_distance_operators To iterate over atoms of a selection, you can use "cmd.pop". There is no PyMOLWiki page, but you'll get a nice example from: PyMOL> help pop Also very powerful for iteration over atoms: http://pymolwiki.org/index.php/Iterate What you actually want is to iterate over distances, not atoms. There is a script on the PyMOLWiki which provides that: http://pymolwiki.org/index.php/Get_raw_distances cmd.distance('tmp', 'hcpl1' ,'hcpl2', 5.0) for (i1, i2, dst) in get_raw_distances('tmp'): f.write("%8.3f\n" % dst) Hope that helps. Cheers, Thomas On 30.07.2012 19:34, Krisztina Feher wrote: > Hi Everyone, > > I would like to write a script, which writes out intermolecular > distances shorter than 5A between hydrogens into a text file. Here is > what I made so far on the basis of the Measure distance script in the > respository: > > from pymol import cmd > > # open dist.txt for writing > f=open('dist.txt','w') > > hcpl1=cmd.select('hcpl1', 'resi 1-10 and hydro') > hcpl2=cmd.select('hcpl2', 'resi 11-20 and hydro') > inoe12=cmd.select('inoe12', 'hcpl1 around 5 of hcpl2') > > for i in range(len(hcpl1)): > dst=cmd.distance('tmp', 'hcpl1' ,'hcpl2') > f.write("%8.3f\n"%dst) > f.close() > > What do not understand is the following: > - why inoe12 selection is not being made (it works from pymol command > line as > "select inoe12, hcpl1 around 5 of hcpl2" ) > - how can I loop over the atoms of a selection (hcpl1 seems to be not a > list, but a single interger) > > Thanks for any help in advance! > Krisztina -- 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@...) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@... ```
 Re: [PyMOL] distances From: Thomas Holder - 2012-07-31 06:59:46 ```Hi Krisztina, > [...] The only nag is how to convert atom IDs in i1 and i2 into > atom names? I usually first prepare an id-to-something map where I later on can look up the desired atom properties (like the name). from pymol import cmd, stored stored.i2n = dict() cmd.iterate('hcpl1 or hcpl2', \ 'stored.i2n[model,index] = (resi,resn,name)') for (i1, i2, dist) in get_raw_distances('tmp'): print stored.i2n[i1], stored.i2n[i2] Cheers, Thomas -- Thomas Holder MPI for Developmental Biology Spemannstr. 35 D-72076 Tübingen ```
 Re: [PyMOL] distances From: Thomas Holder - 2012-07-30 18:31:24 ```Hi Krisztina, the syntax for the "around" operator is wrong, there is no "of" keyword. One of these would be correct: hcpl1 within 5 of hcpl2 hcpl2 around 5 and hcpl1 See also: http://pymolwiki.org/index.php/Selection_Algebra#Comparison_of_distance_operators To iterate over atoms of a selection, you can use "cmd.pop". There is no PyMOLWiki page, but you'll get a nice example from: PyMOL> help pop Also very powerful for iteration over atoms: http://pymolwiki.org/index.php/Iterate What you actually want is to iterate over distances, not atoms. There is a script on the PyMOLWiki which provides that: http://pymolwiki.org/index.php/Get_raw_distances cmd.distance('tmp', 'hcpl1' ,'hcpl2', 5.0) for (i1, i2, dst) in get_raw_distances('tmp'): f.write("%8.3f\n" % dst) Hope that helps. Cheers, Thomas On 30.07.2012 19:34, Krisztina Feher wrote: > Hi Everyone, > > I would like to write a script, which writes out intermolecular > distances shorter than 5A between hydrogens into a text file. Here is > what I made so far on the basis of the Measure distance script in the > respository: > > from pymol import cmd > > # open dist.txt for writing > f=open('dist.txt','w') > > hcpl1=cmd.select('hcpl1', 'resi 1-10 and hydro') > hcpl2=cmd.select('hcpl2', 'resi 11-20 and hydro') > inoe12=cmd.select('inoe12', 'hcpl1 around 5 of hcpl2') > > for i in range(len(hcpl1)): > dst=cmd.distance('tmp', 'hcpl1' ,'hcpl2') > f.write("%8.3f\n"%dst) > f.close() > > What do not understand is the following: > - why inoe12 selection is not being made (it works from pymol command > line as > "select inoe12, hcpl1 around 5 of hcpl2" ) > - how can I loop over the atoms of a selection (hcpl1 seems to be not a > list, but a single interger) > > Thanks for any help in advance! > Krisztina -- Thomas Holder MPI for Developmental Biology Spemannstr. 35 D-72076 Tübingen ```