Skip to content

Commit f287c49

Browse files
committed
Made Alex's recommended changes NO_JIRA
1 parent 578bf32 commit f287c49

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

scripts/packing_similarity_dendrogram/packing_similarity_dendogram.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -187,26 +187,14 @@ def plot_tree(cluster, x_start_positions, y_start_positions, hs):
187187

188188
# Setup tree plotting by getting each terminal's height
189189
heights, count = assign_y_positions(cluster_list[0], 0, {})
190-
# print("got heights and counts from assigning y positions: ",heights,count)
191190
# Set start of the tree - middle of the plot and 1,1
192191
xpositions = [1, 1]
193192
ypositions = [1, get_midpoint(cluster_list[0], heights)]
194-
# print("calling plot_tree for the first time with the following settings", cluster_list[0])
195-
# print("\nxpositions:", xpositions)
196-
# print("\nypositions (midpoint)", ypositions)
197-
# print("\nheights", heights)
198193
# Plot tree
199194
plot_tree(cluster_list[0], xpositions, ypositions, heights)
200195

201196
# Plot formatting
202-
# ax = plt.axes() #IJS 06/09/22 turning this off, and every line with ax., because 2 axes are plotted using the current version of matplotlib
203-
# ax.set_frame_on(False) #plot covered up if left True
204-
# ax.axes.get_yaxis().set_visible(False)
205-
# ax.axes.get_xaxis().set_visible(False) # if left on, the graph is much less messy, only one axis printed, but ticks are slightly offset
206-
# ax.spines['top'].set_visible(False)
207-
# ax.spines['bottom'].set_visible(False)
208-
# ax.spines['left'].set_visible(False)
209-
# ax.spines['right'].set_visible(False) # this, and the previous 5, stop the y axis being printed twice and overlaying
197+
210198

211199
levels = range(n_ps_mols, -1, -1)
212200
highlighted_levels = range(n_ps_mols, -1, -1)
@@ -252,7 +240,7 @@ def main(input_file, matrix_file, n_ps_mols, output_ps_results, conf_threshold,
252240
ps.settings.distance_tolerance = ps_distances
253241
refcodes = []
254242

255-
input_name = input_file.rsplit("\\")[-1].rsplit(".")[0]
243+
input_name = os.path.basename(input_file).split(".")[0]
256244
print("--------------------------------------------------------")
257245

258246
if not matrix_file:
@@ -286,15 +274,11 @@ def main(input_file, matrix_file, n_ps_mols, output_ps_results, conf_threshold,
286274
if not os.path.exists(overlay_folder):
287275
os.makedirs(overlay_folder)
288276

289-
for i in range(0, structure_size):
290-
refcodes.append(str(i+1))
291-
# refcodes.append(str(structure_reader[i].identifier))#IJS 06/09/22 why are refcodes read in twice?
292-
293277
for i in range(0, structure_size):
294278
entry_i = structure_reader[i]
295279
crystal_i = entry_i.crystal
296280
refcodes.append(str(i+1))
297-
# refcodes.append(str(structure_reader[i].identifier))
281+
298282

299283
for j in range(i, structure_size):
300284
if i == j:
@@ -373,7 +357,6 @@ def main(input_file, matrix_file, n_ps_mols, output_ps_results, conf_threshold,
373357
# Generate a cluster hierarchy - populate it initially with every structure
374358
cluster_list = []
375359
for i in range(0, structure_size):
376-
# cluster_list.append({'level': n_ps_mols, 'identifiers': [i+1], 'children': []})
377360
cluster_list.append({'level': n_ps_mols, 'identifiers': [refcodes[i]], 'children': []})
378361

379362
# Merge the structures - getting best match for each structure
@@ -404,12 +387,11 @@ def main(input_file, matrix_file, n_ps_mols, output_ps_results, conf_threshold,
404387

405388
plot = plt.pcolor(x, y, matrix, cmap=plt.get_cmap('rainbow', (n_ps_mols - 1)), vmin=1, vmax=n_ps_mols)
406389
if structure_size < 10:
407-
plt.xticks([x -0.5 for x in list(range(1, structure_size+1))], list(range(1, structure_size+1)))
408-
plt.yticks([x -0.5 for x in list(range(1, structure_size+1))], list(range(1, structure_size+1)))
390+
plt.xticks(np.arange(0, structure_size + 1) - 0.5, np.arange(0, structure_size + 1))
391+
plt.yticks(np.arange(0, structure_size + 1) - 0.5, np.arange(0, structure_size + 1))
409392
else:
410393
plt.xticks(np.arange(0, structure_size + 1, 5) - 0.5, np.arange(0, structure_size + 1, 5))
411394
plt.yticks(np.arange(0, structure_size + 1, 5) - 0.5, np.arange(0, structure_size + 1, 5))
412-
#cb = plt.colorbar(plot, ticks=range(1, 16))
413395
cb = plt.colorbar(plot, ticks=range(1, n_ps_mols+1))
414396

415397

0 commit comments

Comments
 (0)