Clustering by particle coordinates RMSD

analyze_foldamers.ensembles.cluster.align_structures(reference_traj, target_traj)[source]

Given a reference trajectory, this function performs a structural alignment for a second input trajectory, with respect to the reference.

Parameters
  • reference_traj (MDTraj() trajectory) – The trajectory to use as a reference for alignment.

  • target_traj – The trajectory to align with the reference.

Returns

analyze_foldamers.ensembles.cluster.concatenate_trajectories(pdb_file_list, combined_pdb_file='combined.pdb')[source]

Given a list of PDB files, this function reads their coordinates, concatenates them, and saves the combined coordinates to a new file (useful for clustering with MSMBuilder).

Parameters
  • pdb_file_list (List( str )) – A list of PDB files to read and concatenate

  • combined_pdb_file (str) – The name of file/path in which to save a combined version of the PDB files, default = “combined.pdb”

Returns

  • combined_pdb_file ( str ) - The name/path for a file within which the concatenated coordinates will be written.

analyze_foldamers.ensembles.cluster.filter_distances(distances, filter_ratio=0.25, return_original_indices=False, original_indices=None, filter_brute_step=0.05)[source]

Function for filtering out data points with few neighbors within a cutoff radius

Parameters
  • distances (2d numpy array) – square matrix of pairwise RMSD distances

  • filter_ratio (float) – desired fraction of data remaining after neighborhood radius filtering

  • filter_brute_step (float) – step size in distance units for brute force filter radius optimization (final optimization searches between intervals) (default=0.05)

Returns

  • distances_filtered (2d numpy array) - distance matrix of data points satisfying filter parameters

  • neighbors_dense (1d numpy array) - indices of the original dataset which satisfy filter parameters

  • filter_ratio (float) - fraction of data remaining after filtering

analyze_foldamers.ensembles.cluster.get_cluster_medoid_positions_DBSCAN(file_list, cgmodel, min_samples=5, eps=0.5, frame_start=0, frame_stride=1, frame_end=-1, output_format='pdb', output_dir='cluster_output', output_cluster_traj=False, plot_silhouette=True, plot_rmsd_hist=True, filter=True, filter_ratio=0.25, filter_brute_step=0.05, core_points_only=True, homopolymer_sym=False)[source]

Given PDB or DCD trajectory files and coarse grained model as input, this function performs DBSCAN clustering on the poses in the trajectory, and returns a list of the coordinates for the medoid pose of each cluster.

Parameters
  • file_list (List( str )) – A list of PDB or DCD files to read and concatenate

  • cgmodel (class) – A CGModel() class object

  • min_samples (int) – minimum of number of samples in neighborhood of a point to be considered a core point (includes point itself)

  • eps (float) – DBSCAN parameter neighborhood distance cutoff

  • frame_start (int) – First frame in trajectory file to use for clustering.

  • frame_stride (int) – Advance by this many frames when reading trajectories.

  • frame_end (int) – Last frame in trajectory file to use for clustering.

  • output_format (str) – file format extension to write medoid coordinates to (default=”pdb”), dcd also supported

  • output_dir (str) – directory to write clustering medoid and plot files

  • plot_silhouette (boolean) – option to create silhouette plot(default=True)

  • filter (boolean) – option to apply neighborhood radius filtering to remove low-density data (default=True)

  • filter_ratio (float) – fraction of data points which pass through the neighborhood radius filter (default=0.25)

  • filter_brute_step (float) – step size in distance units for brute force filter radius optimization (final optimization searches between intervals) (default=0.05)

  • core_points_only (boolean) – use only core points to calculate medoid structures (default=True)

  • homopolymer_sym (boolean) – if there is end-to-end symmetry, scan forwards and backwards sequences for lowest rmsd (default=False)

Returns

  • medoid_positions ( np.array( float * unit.angstrom ( n_clusters x num_particles x 3 ) ) ) - A 3D numpy array of poses corresponding to the medoids of all trajectory clusters.

  • cluster_sizes ( List ( int ) ) - A list of number of members in each cluster

  • cluster_rmsd( np.array ( float ) ) - A 1D numpy array of rmsd (in cluster distance space) of samples to cluster centers

  • n_noise ( int ) - number of points classified as noise

  • silhouette_avg - ( float ) - average silhouette score across all clusters

  • labels ( np.array ) - labels of frames taken from the original trajectory

  • original_indices ( np.array ) - original indices of labels in the overall trajectory fed into this function

analyze_foldamers.ensembles.cluster.get_cluster_medoid_positions_KMedoids(file_list, cgmodel, n_clusters=2, frame_start=0, frame_stride=1, frame_end=-1, output_format='pdb', output_dir='cluster_output', output_cluster_traj=False, plot_silhouette=True, plot_rmsd_hist=True, filter=False, filter_ratio=0.25, filter_brute_step=0.05, homopolymer_sym=False)[source]

Given PDB or DCD trajectory files and coarse grained model as input, this function performs K-medoids clustering on the poses in trajectory, and returns a list of the coordinates for the medoid pose of each cluster.

Parameters
  • file_list (List( str )) – A list of PDB or DCD files to read and concatenate

  • cgmodel (class) – A CGModel() class object

  • n_clusters (int) – The number of clusters for K-medoids algorithm.

  • frame_start (int) – First frame in pdb trajectory file to use for clustering.

  • frame_stride (int) – Advance by this many frames when reading pdb trajectories.

  • frame_end (int) – Last frame in trajectory file to use for clustering.

  • output_format (str) – file format extension to write medoid coordinates to (default=”pdb”), dcd also supported

  • output_dir (str) – path to which cluster medoid structures and silhouette plots will be saved

  • ouput_cluster_traj (boolean) – option to output the trajectory of each cluster along with each medoid

  • plot_silhouette (boolean) – option to create silhouette plot of clustering results (default=True)

  • plot_rmsd_hist (boolean) – option to plot a histogram of pairwise rmsd values (post-filtering)

  • filter (boolean) – option to apply neighborhood radius filtering to remove low-density data (default=False)

  • filter_ratio (float) – fraction of data points which pass through the neighborhood radius filter (default=0.25)

  • filter_brute_step (float) – step size in distance units for brute force filter radius optimization (final optimization searches between intervals) (default=0.05)

  • homopolymer_sym (boolean) – if there is end-to-end symmetry, scan forwards and backwards sequences for lowest rmsd (default=False)

Returns

  • medoid_positions ( np.array( float * unit.angstrom ( n_clusters x num_particles x 3 ) ) ) - A 3D numpy array of poses corresponding to the medoids of all trajectory clusters.

  • cluster_sizes ( List ( int ) ) - A list of number of members in each cluster

  • cluster_rmsd( np.array ( float ) ) - A 1D numpy array of rmsd (in cluster distance space) of samples to cluster centers

  • silhouette_avg - ( float ) - average silhouette score across all clusters

  • labels ( np.array ) - labels of frames taken from the original trajectory

  • original_indices ( np.array ) - original indices of labels in the overall trajectory fed into this function

analyze_foldamers.ensembles.cluster.get_cluster_medoid_positions_OPTICS(file_list, cgmodel, min_samples=5, xi=0.05, frame_start=0, frame_stride=1, frame_end=-1, output_format='pdb', output_dir='cluster_output', output_cluster_traj=False, plot_silhouette=True, plot_rmsd_hist=True, filter=True, filter_ratio=0.25, filter_brute_step=0.05, homopolymer_sym=False)[source]

Given PDB or DCD trajectory files and coarse grained model as input, this function performs OPTICS clustering on the poses in the trajectory, and returns a list of the coordinates for the medoid pose of each cluster.

Parameters
  • file_list (List( str )) – A list of PDB or DCD files to read and concatenate

  • cgmodel (class) – A CGModel() class object

  • min_samples (int) – minimum of number of samples in neighborhood of a point to be considered a core point (includes point itself)

  • xi (float) – OPTICS parameter for minimum slope on reachability plot signifying a cluster boundary

  • frame_start (int) – First frame in trajectory file to use for clustering.

  • frame_stride (int) – Advance by this many frames when reading trajectories.

  • frame_end (int) – Last frame in trajectory file to use for clustering.

  • output_format (str) – file format extension to write medoid coordinates to (default=”pdb”), dcd also supported

  • output_dir (str) – directory to write clustering medoid and plot files

  • plot_silhouette (boolean) – option to create silhouette plot(default=True)

  • filter (boolean) – option to apply neighborhood radius filtering to remove low-density data (default=True)

  • filter_ratio (float) – fraction of data points which pass through the neighborhood radius filter (default=0.25)

  • filter_brute_step (float) – step size in distance units for brute force filter radius optimization (final optimization searches between intervals) (default=0.05)

  • homopolymer_sym (boolean) – if there is end-to-end symmetry, scan forwards and backwards sequences for lowest rmsd (default=False)

Returns

  • medoid_positions ( np.array( float * unit.angstrom ( n_clusters x num_particles x 3 ) ) ) - A 3D numpy array of poses corresponding to the medoids of all trajectory clusters.

  • cluster_sizes ( List ( int ) ) - A list of number of members in each cluster

  • cluster_rmsd( np.array ( float ) ) - A 1D numpy array of rmsd (in cluster distance space) of samples to cluster centers

  • n_noise ( int ) - number of points classified as noise

  • silhouette_avg - ( float ) - average silhouette score across all clusters

analyze_foldamers.ensembles.cluster.get_representative_structures(file_list, cgmodel, frame_start=0, frame_stride=1, frame_end=-1, output_format='pdb', output_dir='cluster_output', homopolymer_sym=False)[source]

Using the similarity matrix from RMSD distances, determine a representative structure for each file in file_list

Parameters
  • file_list (List( str )) – A list of PDB or DCD files to read and concatenate

  • cgmodel (class) – A CGModel() class object

  • frame_start (int) – First frame in pdb trajectory file to use for clustering.

  • frame_stride (int) – Advance by this many frames when reading trajectories.

  • frame_end (int) – Last frame in trajectory file to use for clustering.

  • homopolymer_sym (boolean) – if there is end-to-end symmetry, scan forwards and backwards sequences for lowest rmsd (default=False)

analyze_foldamers.ensembles.cluster.get_rmsd_matrix(file_list, cgmodel, frame_start, frame_stride, frame_end, return_original_indices=False, homopolymer_sym=False)[source]

Internal function for reading trajectory files and computing rmsd

analyze_foldamers.ensembles.cluster.make_cluster_distance_plots(n_clusters, cluster_fit, dist_to_centroids, plotfile)[source]

Internal function for creating cluster distance plots

analyze_foldamers.ensembles.cluster.make_silhouette_plot(cluster_fit, silhouette_sample_values, silhouette_avg, n_clusters, cluster_rmsd, cluster_sizes, plotfile)[source]

Internal function for creating silhouette plot

analyze_foldamers.ensembles.cluster.write_medoids_to_file(cgmodel, medoid_positions, output_dir, output_format, top_from_pdb=None)[source]

Internal function for writing medoid coordinates to file

Clustering by torsion angles

analyze_foldamers.ensembles.cluster_torsion.cluster_torsions_DBSCAN(file_list, cgmodel, min_samples=5, eps=0.5, frame_start=0, frame_stride=1, frame_end=-1, output_format='pdb', output_dir='cluster_output', backbone_torsion_type='bb_bb_bb_bb', core_points_only=True, filter=True, filter_ratio=0.25, plot_silhouette=True, plot_distance_hist=True)[source]

Given PDB or DCD trajectory files and coarse grained model as input, this function performs DBSCAN clustering on the poses in the trajectory, and returns a list of the coordinates for the medoid pose of each cluster.

Parameters
  • file_list (List( str )) – A list of PDB or DCD files to read and concatenate

  • cgmodel (class) – A CGModel() class object

  • min_samples (int) – minimum of number of samples in neighborhood of a point to be considered a core point (includes point itself)

  • eps (float) – DBSCAN parameter neighborhood distance cutoff

  • frame_start (int) – First frame in trajectory file to use for clustering.

  • frame_stride (int) – Advance by this many frames when reading trajectories.

  • frame_end (int) – Last frame in trajectory file to use for clustering.

  • output_format (str) – file format extension to write medoid coordinates to (default=”pdb”), dcd also supported

  • output_dir (str) – directory to write clustering medoid and plot files

  • backbone_torsion_type (str) – particle sequence of the backbone torsions (default=”bb_bb_bb_bb”) - for now only single sequence permitted

  • core_points_only (boolean) – use only core points to calculate medoid structures (default=True)

  • filter (boolean) – option to apply neighborhood radius filtering to remove low-density data (default=True)

  • filter_ratio (float) – fraction of data points which pass through the neighborhood radius filter (default=0.05)

  • plot_silhouette (boolean) – option to create silhouette plot of clustering results (default=True)

  • plot_torsion_hist (boolean) – option to plot a histogram of torsion euclidean distances (post-filtering)

Returns

  • medoid_positions ( np.array( float * unit.angstrom ( n_clusters x num_particles x 3 ) ) ) - A 3D numpy array of poses corresponding to the medoids of all trajectory clusters.

  • medoid torsions ( np.array ( float * unit.degrees ( n_clusters x n_torsion ) - A 2D numpy array of the backbone torsion angles for each cluster medoid

  • cluster_sizes ( List ( int ) ) - A list of number of members in each cluster

  • cluster_rmsd( np.array ( float ) ) - A 1D numpy array of rmsd (in cluster distance space) of samples to cluster centers

  • n_noise ( int ) - number of points classified as noise

  • silhouette_avg - ( float ) - average silhouette score across all clusters

analyze_foldamers.ensembles.cluster_torsion.cluster_torsions_KMedoids(file_list, cgmodel, n_clusters=2, frame_start=0, frame_stride=1, frame_end=-1, output_format='pdb', output_dir='cluster_output', backbone_torsion_type='bb_bb_bb_bb', filter=False, filter_ratio=0.25, plot_silhouette=True, plot_distance_hist=True)[source]

Given PDB or DCD trajectory files and coarse grained model as input, this function performs K-medoids clustering on the poses in trajectory, and returns a list of the coordinates for the medoid pose of each cluster.

Parameters
  • file_list (List( str )) – A list of PDB or DCD files to read and concatenate

  • cgmodel (class) – A CGModel() class object

  • n_clusters (int) – The number of clusters for K-medoids algorithm.

  • frame_start (int) – First frame in pdb trajectory file to use for clustering.

  • frame_stride (int) – Advance by this many frames when reading pdb trajectories.

  • frame_end (int) – Last frame in trajectory file to use for clustering.

  • output_format (str) – file format extension to write medoid coordinates to (default=”pdb”), dcd also supported

  • output_dir (str) – path to which cluster medoid structures and silhouette plots will be saved

  • backbone_torsion_type (str) – particle sequence of the backbone torsions (default=”bb_bb_bb_bb”) - for now only single sequence permitted

  • filter (boolean) – option to apply neighborhood radius filtering to remove low-density data (default=False)

  • filter_ratio (float) – fraction of data points which pass through the neighborhood radius filter (default=0.05)

  • plot_silhouette (boolean) – option to create silhouette plot of clustering results (default=True)

  • plot_torsion_hist (boolean) – option to plot a histogram of torsion euclidean distances (post-filtering)

Returns

  • medoid_positions ( np.array( float * unit.angstrom ( n_clusters x num_particles x 3 ) ) ) - A 3D numpy array of poses corresponding to the medoids of all trajectory clusters.

  • medoid torsions ( np.array ( float * unit.degrees ( n_clusters x n_torsion ) - A 2D numpy array of the backbone torsion angles for each cluster medoid

  • cluster_sizes ( List ( int ) ) - A list of number of members in each cluster

  • cluster_rmsd( np.array ( float ) ) - A 1D numpy array of rmsd (in cluster distance space) of samples to cluster centers

  • silhouette_avg - ( float ) - average silhouette score across all clusters

analyze_foldamers.ensembles.cluster_torsion.get_torsion_matrix(file_list, cgmodel, frame_start, frame_stride, frame_end, backbone_torsion_type)[source]

Internal function for reading trajectory files and computing torsions