"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "data/chempy/sidechains/generate2.py" between
pymol-v1.8.6.0.tar.bz2 and pymol-v2.1.0.tar.bz2

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

generate2.py  (pymol-v1.8.6.0.tar.bz2):generate2.py  (pymol-v2.1.0.tar.bz2)
# pymol -c generate2.py # pymol -c generate2.py
# NOTE: obsolete -- PyMOL now uses Dunbrack rotamers by default # NOTE: obsolete -- PyMOL now uses Dunbrack rotamers by default
from __future__ import print_function
from chempy import io from chempy import io
from glob import glob from glob import glob
from copy import deepcopy from copy import deepcopy
sys.path.append(".") sys.path.append(".")
sc_raw = io.pkl.fromFile("sc_raw.pkl") sc_raw = io.pkl.fromFile("sc_raw.pkl")
cutoff_angle = 35.0 cutoff_angle = 35.0
sc_clus = {} sc_clus = {}
# this loop clusters and averages sidechain conformations # this loop clusters and averages sidechain conformations
for resn in sc_raw.keys(): for resn in sc_raw.keys():
resn_list = sc_raw[resn] resn_list = sc_raw[resn]
resn_key_dict = {} resn_key_dict = {}
# find the most commonly encountered set of torsions # find the most commonly encountered set of torsions
# (it is most likely to be correct) # (it is most likely to be correct)
for set in resn_list: for set in resn_list:
lst = deepcopy(set.keys()) lst = deepcopy(list(set.keys()))
lst.sort() lst.sort()
tup = tuple(lst) tup = tuple(lst)
if resn_key_dict.has_key(tup): if tup in resn_key_dict:
resn_key_dict[tup] = resn_key_dict[tup] + 1 resn_key_dict[tup] = resn_key_dict[tup] + 1
else: else:
resn_key_dict[tup] = 1 resn_key_dict[tup] = 1
key_lst = [] key_lst = []
for a in resn_key_dict.keys(): for a in resn_key_dict.keys():
key_lst.append((resn_key_dict[a],a)) key_lst.append((resn_key_dict[a],a))
key_lst.sort() key_lst.sort()
resn_key = list(key_lst[-1][1]) resn_key = list(key_lst[-1][1])
resn_key.sort() resn_key.sort()
print resn,resn_key print(resn,resn_key)
n_dihe = len(resn_key) n_dihe = len(resn_key)
print resn,len(sc_raw[resn])#,resn_key print(resn,len(sc_raw[resn]))#,resn_key
if n_dihe: # not glycine or alanine if n_dihe: # not glycine or alanine
# list of dictionaries # list of dictionaries
# [ {(...)=avg1, (...)=avg2, ... }, {(..)=avg1, ... }, ... ] # [ {(...)=avg1, (...)=avg2, ... }, {(..)=avg1, ... }, ... ]
avg_ang = [] avg_ang = []
# list of list of dictionaries: # list of list of dictionaries:
# [ [ {(...)=ang1, (...)=ang2, ... }, {(..)=ang1, ... }, ... ] ] # [ [ {(...)=ang1, (...)=ang2, ... }, {(..)=ang1, ... }, ... ] ]
# where each row corresponds to the # where each row corresponds to the
# averages used to generate the avg_ang [ [ {(..)=}, # averages used to generate the avg_ang [ [ {(..)=},
all_ang = [] all_ang = []
while len(resn_list): # do we have any more cases to consider? while len(resn_list): # do we have any more cases to consider?
# yes, lets consider the conformation "cur" # yes, lets consider the conformation "cur"
cur = resn_list.pop() cur = resn_list.pop()
if len(cur)!=n_dihe: if len(cur)!=n_dihe:
# print "skipping...",cur # print "skipping...",cur
continue continue
flag=1 flag=1
for k in resn_key: for k in resn_key:
if not cur.has_key(k): if k not in cur:
flag=0 flag=0
if not flag: if not flag:
continue continue
recomp_avg = None recomp_avg = None
closest = None closest = None
min_dev = 361.00 min_dev = 361.00
cnt = 0 cnt = 0
for a in avg_ang: # we're going to compare it against all knowns for a in avg_ang: # we're going to compare it against all knowns
max_dev = 0.0 max_dev = 0.0
avg_dev = 0.0 avg_dev = 0.0
skipping to change at line 124 skipping to change at line 126
a['FREQ'] = freq a['FREQ'] = freq
sort_ang.append((freq,a)) sort_ang.append((freq,a))
cnt = cnt + 1 cnt = cnt + 1
sort_ang.sort() sort_ang.sort()
avg_ang = [] avg_ang = []
for a in sort_ang: for a in sort_ang:
avg_ang.insert(0,a[1]) avg_ang.insert(0,a[1])
# at this point, we have a list of clustered, averaged torsions # at this point, we have a list of clustered, averaged torsions
# which can be used by the sidechain placement algorithm # which can be used by the sidechain placement algorithm
sc_clus[resn] = avg_ang sc_clus[resn] = avg_ang
print " reduced to:",len(sc_clus[resn]) print(" reduced to:",len(sc_clus[resn]))
io.pkl.toFile(sc_clus,"sc_library.pkl") io.pkl.toFile(sc_clus,"sc_library.pkl")
 End of changes. 7 change blocks. 
6 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)