<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 In this example, we cluster our alanine dipeptide trajectory using the RMSD distance metric and Ward's method.
Step1:  Let's load up our trajectory. This is the trajectory that we generated in the "Running a simulation in OpenMM and analyzing the results with mdtraj" example. The first step is to build the rmsd cache, which precalculates some values for the RMSD computation.
Step2:  Lets compute all pairwise rmsds between conformations.
Step3:  scipy.cluster implements the ward linkage algorithm (among others)
Step4:  Lets plot the resulting dendrogram.
<ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
%matplotlib inline
import mdtraj as md
import numpy as np
import matplotlib.pyplot as plt
import scipy.cluster.hierarchy
Explanation: In this example, we cluster our alanine dipeptide trajectory using the RMSD distance metric and Ward's method.
End of explanation
traj = md.load('ala2.h5')
Explanation: Let's load up our trajectory. This is the trajectory that we generated in the "Running a simulation in OpenMM and analyzing the results with mdtraj" example. The first step is to build the rmsd cache, which precalculates some values for the RMSD computation.
End of explanation
distances = np.empty((traj.n_frames, traj.n_frames))
for i in range(traj.n_frames):
    distances[i] = md.rmsd(traj, traj, i)
print('Max pairwise rmsd: %f nm' % np.max(distances))
Explanation: Lets compute all pairwise rmsds between conformations.
End of explanation
linkage = scipy.cluster.hierarchy.ward(distances)
Explanation: scipy.cluster implements the ward linkage algorithm (among others)
End of explanation
plt.title('RMSD Ward hierarchical clustering')
scipy.cluster.hierarchy.dendrogram(linkage, no_labels=True, count_sort='descendent')
None
Explanation: Lets plot the resulting dendrogram.
End of explanation
<END_TASK>