Created
November 15, 2012 00:00
-
-
Save rmcgibbo/4075730 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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')