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@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net