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
> <t.nak...@mail.mfour.med.kyoto-u.ac.jp>  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

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
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

Reply via email to