Difference between revisions of "List dist"

From PyMOLWiki
Jump to: navigation, search
(Created page with "= Overview = This script finds atoms involved in polar contacts and lists their information. Author: :: Takanori Nakane Warning: :: the atoms are hashed by coordinates; this c...")
 
Line 44: Line 44:
  
 
[[Category:Script_Library]]
 
[[Category:Script_Library]]
 +
[[Category:ObjSel_Scripts]]

Revision as of 11:06, 1 February 2012

Overview

This script finds atoms involved in polar contacts and lists their information.

Author:

Takanori Nakane

Warning:

the atoms are hashed by coordinates; this could cause issues with multi-state MD trajectories -- use caution!
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)