Hi all,
this script below runs well in pymol. It loads pdb files and
calculates the distance of some atoms contained in the fileAmb whose
format is:
26,O11:HN
28,*:HE1
...............
With * I select whole ligand (segi B) and pymol returns only one
value, the average distance for all atoms to the HE1 atoms. I need to
print out all the distances, atom by atom.
any helps??
thanks a lot
andrea

----------------------
from pymol import cmd
import string, sys, os

def viol(fileAmb,deep):
    cmd.reinitialize()
    if ("dist.out"):
        os.system("rm -f dist.out")
    nam = open("file.nam",'r')
    KeepStruc = []
    readnam = nam.readlines()
    deep = int(deep)
    for j in range(0,deep):
        readnam[j] = string.strip(readnam[j])
        KeepStruc.append(readnam[j])

    for i in KeepStruc:
        cmd.load(i,i)
        cmd.select("lig","segi B")
        cmd.select("pro","all and not segi B")
        amb = open(fileAmb,'r')
        out = open("dist.out","a")
        out.write("%4s\n"%(i))
        for lines in amb.readlines():
            lines = string.strip(lines)
            tmp = string.split(lines,",")
            resname = tmp[0]
            atomtypes = tmp[1]
            tmp1 =string.split(atomtypes,":")
            atomlig = tmp1[0]
            atompro = tmp1[1]
            p = cmd.select("p","resi "+resname+" and name "+atompro+" and "+i)
            l = cmd.select("l","name "+atomlig+" and segi B and "+i)
            d = cmd.distance("dist_"+str(i),"p","l")
            if (d > 5):
                print resname,":",atompro,"->",atomlig,d
                out.write("%4s%8s%8s%8.3f\n"%(resname,atompro,atomlig,d))

    out.close()

cmd.extend('viol',viol)

----------------------------------------
--
"La conoscenza libera il genere umano dalla superstizione"
J. Watson

Reply via email to