Skip to content

Commit

Permalink
Update distancetoatom.py
Browse files Browse the repository at this point in the history
added checking and/or accounting for alternative coordinates
  • Loading branch information
andwar committed Jun 21, 2014
1 parent 88a5e96 commit 90d082c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions distancetoatom.py
Expand Up @@ -40,6 +40,9 @@ def get_coord(v):
return cmd.get_atom_coords(v)
else:
# more than one atom --> use "center"
# alt check!
if cmd.count_atoms('(alt *) and not (alt "")')!=0:
print "distancetoatom: warning! alternative coordinates found for origin, using center!"
view_temp=cmd.get_view()
cmd.zoom(v)
v=cmd.get_position()
Expand All @@ -48,6 +51,7 @@ def get_coord(v):
except:
return False


def distancetoatom(
origin='pk1',
cutoff=10,
Expand Down Expand Up @@ -104,13 +108,13 @@ def distancetoatom(
'''
# keyword check
try:
selection = '(%s)'%selection
ori=get_coord(origin)
if not ori:
print "distancetoatom: aborting - check input for 'origin'!"
return False
cutoff = abs(float(cutoff))
filename = str(filename)
selection = '(%s)'%selection
state = abs(int(state))
if (not int(state)):
state=cmd.get_state()
Expand Down Expand Up @@ -159,7 +163,7 @@ def distancetoatom(

# atom list
stored.temp=[]
cmd.iterate(tempsel, 'stored.temp.append([model, segi, chain, resn, resi, name])')
cmd.iterate(tempsel, 'stored.temp.append([model, segi, chain, resn, resi, name, alt])')

# custom properties? # conditional disabling
if (property_name==''): property_name=False
Expand All @@ -171,7 +175,7 @@ def distancetoatom(
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'%(atom[0], atom[1], atom[2], atom[3], atom[4], atom[5]))
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])
Expand Down

0 comments on commit 90d082c

Please sign in to comment.