## Re: [PyMOL] list of polar contacts

 Re: [PyMOL] list of polar contacts From: Jason Vertrees - 2012-02-01 16:47:04 ```Thomas, When you hash by coordinates you could get odd results from alternate locations and multi-state objects. I like how Takanori solved the problem, but it's not a strictly perfect solution. What I need to do is provide access to the C-object for real. We plan to provide something for this soon. Cheers, -- Jason On Wed, Feb 1, 2012 at 10:41 AM, Thomas Holder wrote: > Jason, what pitfalls? Are they still present in this script? > > http://pymolwiki.org/index.php/Get_raw_distances > > Cheers, >  Thomas > > > On 02/01/2012 04:01 PM, Jason Vertrees wrote: >> >> Takanori, >> >> This is a very clever script -- well done! There are some pitfalls, >> but in general this should work well. >> >> Cheers, >> >> -- Jason >> >> On Tue, Jan 31, 2012 at 6:01 PM, Takanori Nakane >>  wrote: >>> >>> Hi Abhinav and Jason, >>> >>>> The underlying C-object for a measurement does not support >>>> iterate/alter. This is rather silly; PyMOL should be able to tell you >>>> what's in the object. >>> >>> >>> As an ad-hoc hack, I wrote a Python script to access internal C-object >>> of distance representation and convert it to atom name. >>> >>> Save the script to somewhere and >>> >>>  run script_name.py >>>  list_dist >>> >>> will do the job. >>> >>> Takanori Nakane >>> >>> === Script start === >>> >>> from pymol import cmd >>> >>> def parseDistObj(obj): >>>     if (obj[5][0][3][10] != 1): # 'show dashed' flag >>>         return "" >>>     points = obj[5][2][0][1] >>>     ret = [] >>>     for i in range(len(points) / 6): >>>         ret.append([(points[i * 6], points[i * 6 + 1], points[i * 6 + >>> 2]), >>>                     (points[i * 6 + 3], points[i * 6 + 4], points[i * 6 >>> + 5])]) >>>     return ret >>> >>> def list_dist(): >>>     names = cmd.get_session()['names'] >>> >>>     dist_pairs = [] >>>     for obj in names: >>>         if (obj == None): >>>             continue >>>         if (obj[1] == 0 and obj[4] == 4): >>>             dist_pairs += parseDistObj(obj) >>> >>>     namespace = {'dict': {}, 'a': 1} >>>     dict = {} >>>     cmd.iterate_state(1, 'all', 'dict[x,y,z] = >>> chain+"/"+resn+resi+"/"+name' , space=namespace) >>> >>>     dict = namespace['dict'] >>>     for pair in dist_pairs: >>>         print dict.get(pair[0], '?') + " - " + dict.get(pair[1], '?') >>> >>> cmd.extend('list_dist', list_dist) > > > -- > Thomas Holder > MPI for Developmental Biology > Spemannstr. 35 > D-72076 Tübingen -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) Jason.Vertrees@... (o) +1 (603) 374-7120 ```