Skip to content

Commit

Permalink
Print clusters found in each frame.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmcezar committed Mar 8, 2024
1 parent 78a18a2 commit c406ed1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions utils/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,19 @@ def aggregates_clustering(

n_clusters = []
all_sizes = []
total_clust_by_size = {}
clusters_per_frame = []
for c in clusters[0]:
# get the number of clusters and sizes
unique_clusts, clust_counts = np.unique(c, return_counts=True)
for size in clust_counts:
if size not in total_clust_by_size:
total_clust_by_size[size] = 1
else:
total_clust_by_size[size] += 1

n_clusters.append(len(unique_clusts))

clusters_per_frame.append(np.sort(clust_counts))
all_sizes += clust_counts.tolist()

# based on cluster sizes get occurence of each size
sizes, freq = np.unique(all_sizes, return_counts=True)
total_clust_by_size = dict(zip(sizes, freq))
freq = freq / len(u.trajectory[skip:end:stride])

# overall average number of aggregates
Expand Down Expand Up @@ -238,6 +236,12 @@ def aggregates_clustering(
for s, p in prob_mol_size.items():
of.write(f"{s}\t{p}\n")

of.write("\nClusters sizes in each analyzed frame:\n")
for c in clusters_per_frame:
for s in c:
of.write(f"{s}\t")
of.write("\n")

# plot results
_, axs = plt.subplots(2, 2, figsize=summary_fig_size)
plt.rcParams.update({"font.size": font_size})
Expand Down

0 comments on commit c406ed1

Please sign in to comment.