Skip to content

Instantly share code, notes, and snippets.

@rmcgibbo
Created November 15, 2012 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save rmcgibbo/4075730 to your computer and use it in GitHub Desktop.
Save rmcgibbo/4075730 to your computer and use it in GitHub Desktop.
make an empty list called medoids
for cluster i:
let t be a trajectory containing all of the structures assigned to cluster i
let D = the full len(t) x len(t) pairwise RMSD distance matrix
set medoid[i] = argmin( rowsums (D) )
@dvanatta
Copy link

Gens = Serializer.LoadFromHDF('Fake_Gens.lh5') # Dummy Generator file, make sure this has more states than Hierarchical system
num_states = np.max(assignments['Data']) + 1
for i in range(num_states):
state = np.where(assignments['Data']==i)
state = np.array(state).T
state_traj = Project.GetConformations(project,state)
metric = RMSD(atom_indices)
ppdb = metric.prepare_trajectory(pdb)
ptraj = metric.prepare_trajectory(state_traj)
distances = metric.one_to_all(ppdb, ptraj, 0)
centroid = state_traj['XYZList'][np.where(distances==distances.min())[0][0]]
Gens['XYZList'][i] = centroid*1000
Gens['XYZList'] = Gens['XYZList'][0:num_states] #trims extra states from Dummy Gens
Serializer.SaveToHDF(Gens, 'HGens.lh5')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment