Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
COLOR,
]
obj.extend(cmd.get_color_tuple(color))
for res in range(0, len(stored.AAs)-1):
curIdx, nextIdx = str(stored.AAs[res]), str(stored.AAs[res+1])
# populate the position array
pos = [coords[curIdx][0], coords[curIdx][1], coords[nextIdx][2], coords[nextIdx][0]]
# if the data are incomplete for any residues, ignore
if None in pos:
print 'peptide bond %s -> %s incomplete' % (curIdx, nextIdx)
continue
if cpv.distance(pos[0], pos[3]) > 4.0:
print '%s and %s not adjacent' % (curIdx, nextIdx)
continue
# fill in the vertex data for the triangles;
for i in [0,1,2,3,2,1]:
obj.append(VERTEX)
obj.extend(pos[i])
# finish the CGO
obj.append(END)
# update the UI
newName = cmd.get_unused_name("backbonePlane")
cmd.load_cgo(obj, newName)
cmd.set("cgo_transparency", transp, newName)
Print sequence in PIR format
SEE ALSO
fasta
'''
from . import one_letter
from chempy import cpv
wrap = int(wrap)
for obj in cmd.get_object_list('(' + selection + ')'):
seq = []
prev_coord = None
model = cmd.get_model('/%s////CA and guide and (%s)' % (obj, selection))
for atom in model.atom:
if prev_coord is not None and cpv.distance(atom.coord, prev_coord) > 4.0:
seq.append('/\n')
prev_coord = atom.coord
seq.append(one_letter.get(atom.resn, 'X'))
seq.append('*')
print('>P1;%s' % (obj))
print('structure:%s:%s:%s:%s:%s::::' % (obj,
model.atom[0].resi,model.atom[0].chain,
model.atom[-1].resi,model.atom[-1].chain))
if wrap < 1:
print(''.join(seq))
continue
for i in range(0, len(seq), wrap):
print(''.join(seq[i:i+wrap]))
def _common_orientation(selection, vec, visualize=1, quiet=0):
'''
Common part of different helix orientation functions. Does calculate
the center of mass and does the visual feedback.
'''
stored.x = []
cmd.iterate_state(STATE, '(%s) and name CA' % (selection),
'stored.x.append([x,y,z])')
if len(stored.x) < 2:
print('warning: count(CA) < 2')
raise CmdException
center = cpv.scale(_vec_sum(stored.x), 1. / len(stored.x))
if visualize:
scale = cpv.distance(stored.x[0], stored.x[-1])
visualize_orientation(vec, center, scale, True)
cmd.zoom(selection, buffer=2)
if not quiet:
print('Center: (%.2f, %.2f, %.2f) Direction: (%.2f, %.2f, %.2f)' % tuple(center + vec))
return center, vec
def _common_orientation(selection, vec, visualize=1, quiet=0):
'''
Common part of different helix orientation functions. Does calculate
the center of mass and does the visual feedback.
'''
stored.x = []
cmd.iterate_state(-1, '(%s) and name CA' % (selection),
'stored.x.append([x,y,z])')
if len(stored.x) < 2:
print 'warning: count(CA) < 2'
raise CmdException
center = cpv.scale(_vec_sum(stored.x), 1./len(stored.x))
if visualize:
scale = cpv.distance(stored.x[0], stored.x[-1])
visualize_orientation(vec, center, scale, True)
cmd.zoom(selection, buffer=2)
if not quiet:
print 'Center: (%.2f, %.2f, %.2f) Direction: (%.2f, %.2f, %.2f)' % tuple(center + vec)
return center, vec
print(' Error: Alignment with method %s failed' % (method))
raise CmdException
cmd.select(seleboth, '(%s) or (%s)' % (mobile, target))
idx2coords = dict()
cmd.iterate_state(-1, seleboth, 'idx2coords[model,index] = (x,y,z)', space=locals())
if cmd.count_atoms('?' + aln, 1, 1) == 0:
# this should ensure that "aln" will be available as selectable object
cmd.refresh()
b_dict = dict()
for col in cmd.get_raw_alignment(aln):
assert len(col) == 2
b = cpv.distance(idx2coords[col[0]], idx2coords[col[1]])
for idx in col:
b_dict[idx] = b
cmd.alter(seleboth, 'b = b_dict.get((model, index), -1)', space=locals())
if doPretty:
cmd.orient(seleboth)
cmd.show_as('cartoon', 'byobj ' + seleboth)
cmd.color('gray', seleboth)
cmd.spectrum('b', 'blue_red', seleboth + ' and b > -0.5')
if not quiet:
print(" ColorByRMSD: Minimum Distance: %.2f" % (min(b_dict.values())))
print(" ColorByRMSD: Maximum Distance: %.2f" % (max(b_dict.values())))
print(" ColorByRMSD: Average Distance: %.2f" % (sum(b_dict.values()) / len(b_dict)))
stored.temp=[]
cmd.iterate(tempsel, 'stored.temp.append([model, segi, chain, resn, resi, name, alt])')
# custom properties? # conditional disabling
if (property_name==''): property_name=False
if ((cmd.get_version()[1]<1.7) and (property_name not in ['b','q'])):
property_name=False
# calculate the distances, creating list
distance_list=[]
if (not single_atom_ori):
distance_list.append(['ORIGIN: '+str(origin), ori[0], ori[1], ori[2], 0.0])
for atom in stored.temp:
atom_name = ('/%s/%s/%s/%s`%s/%s`%s'%(atom[0], atom[1], atom[2], atom[3], atom[4], atom[5], atom[6]))
atom_xyz = [round(x, decimals) for x in cmd.get_atom_coords(atom_name)]
atom_dist = round(cpv.distance(ori, atom_xyz), decimals)
distance_list.append([atom_name,atom_xyz[0],atom_xyz[1],atom_xyz[2], atom_dist])
# create property with distance (can be used for coloring, labeling etc)
if property_name:
try:
cmd.alter(atom_name, '%s=%f'%(property_name, atom_dist))
except:
# I'm not sure alter raises exceptions if the property is illegal
property_name=False
# sort list, if selected
if sort>0: distance_list.sort(key=lambda dist: dist[4])
elif sort<0: distance_list.sort(key=lambda dist: dist[4], reverse=True)
# add header
distance_list=[['Atom Macro ID',
'x-coord',
'y-coord',
def callback(model, index, resn, coord):
if cpv.distance(coord, prev) > cutoff:
seq_list.append('#')
idx_list.append(None)
seq_list.append(one_letter.get(resn, '#'))
idx_list.append((model,index))
prev[:] = coord