Mercurial > repos > chemteam > biomd_neqgamma
annotate rmsd_clustering.py @ 1:afcb925def69 draft default tip
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit f1c3c88c7395f2e84cbc533199406aadb79c5c07"
author | chemteam |
---|---|
date | Fri, 13 Nov 2020 19:38:28 +0000 |
parents | 4f3222cb5cf6 |
children |
rev | line source |
---|---|
0
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
1 import argparse |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
2 import json |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
3 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
4 import matplotlib.pyplot as plt |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
5 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
6 import numpy as np |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
7 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
8 from scipy.cluster.hierarchy import cophenet, dendrogram, linkage |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
9 from scipy.spatial.distance import pdist |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
10 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
11 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
12 def json_to_np(fname, start=None, end=None): |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
13 """ |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
14 Load json file and convert to numpy array |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
15 """ |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
16 with open(fname) as f: |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
17 k = json.load(f) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
18 print(np.array(k)[:, :, start:end].shape) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
19 return np.array(k)[:, :, start:end] |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
20 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
21 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
22 def flatten_tensor(tensor, normalize=True): |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
23 """ |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
24 Flatten tensor to a 2D matrix along the time axis |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
25 """ |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
26 av = np.mean(tensor, axis=(0, 1)) if normalize else 1 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
27 return np.mean(tensor/av, axis=2) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
28 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
29 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
30 def get_cluster_linkage_array(mat, clustering_method='average'): |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
31 Z = linkage(mat, clustering_method) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
32 c, coph_dists = cophenet(Z, pdist(mat)) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
33 print('Cophenetic correlation coefficient: {}'.format(c)) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
34 return Z |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
35 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
36 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
37 def plot_dist_mat(mat, output, cmap='plasma'): |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
38 """ |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
39 Plot distance matrix as heatmap |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
40 """ |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
41 fig, ax = plt.subplots(1) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
42 p = ax.pcolormesh(mat, cmap=cmap) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
43 plt.xlabel('Trajectory number') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
44 plt.ylabel('Trajectory number') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
45 plt.colorbar(p) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
46 plt.draw() |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
47 plt.savefig(output, format='png') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
48 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
49 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
50 def plot_dendrogram(Z, output): |
1
afcb925def69
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit f1c3c88c7395f2e84cbc533199406aadb79c5c07"
chemteam
parents:
0
diff
changeset
|
51 # figure width scales with number of leaves |
afcb925def69
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit f1c3c88c7395f2e84cbc533199406aadb79c5c07"
chemteam
parents:
0
diff
changeset
|
52 plt.figure(figsize=(0.25 * Z.shape[0], 10)) |
0
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
53 plt.title('Hierarchical Clustering Dendrogram') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
54 plt.xlabel('Trajectory index') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
55 plt.ylabel('distance') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
56 dendrogram( |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
57 Z, |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
58 leaf_rotation=90., # rotates the x axis labels |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
59 leaf_font_size=8., # font size for the x axis labels |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
60 ) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
61 plt.savefig(output, format='png') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
62 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
63 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
64 def main(): |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
65 parser = argparse.ArgumentParser() |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
66 parser.add_argument('--json', help='JSON input file (for 3D tensor).') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
67 parser.add_argument('--mat', help='Input tabular file (for 2D matrix).') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
68 parser.add_argument('--outp-mat', help='Tabular output file.') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
69 parser.add_argument('--Z', required=True, |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
70 help='File for cluster linkage array.') |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
71 parser.add_argument('--dendrogram', |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
72 help="Path to the output dendrogram file") |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
73 parser.add_argument('--heatmap', |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
74 help="Path to the output distance matrix file") |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
75 parser.add_argument('--clustering-method', default='average', |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
76 choices=['single', 'complete', 'average', |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
77 'centroid', 'median', 'ward', 'weighted'], |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
78 help="Method to use for clustering.") |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
79 parser.add_argument('--cmap', type=str, default='plasma', |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
80 help="Matplotlib colormap to use" |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
81 "for plotting distance matrix.") |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
82 parser.add_argument('--start', type=int, |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
83 help="First trajectory frame to" |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
84 "calculate distance matrix") |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
85 parser.add_argument('--end', type=int, |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
86 help="Last trajectory frame to" |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
87 "calculate distance matrix") |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
88 parser.add_argument('--normalize', action="store_true", |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
89 help="Normalize the RMSD variation over" |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
90 "the trajectories before averaging.") |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
91 args = parser.parse_args() |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
92 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
93 print(args) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
94 if args.json: |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
95 tensor = json_to_np(args.json, args.start, args.end) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
96 mat = flatten_tensor(tensor, args.normalize) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
97 np.savetxt(args.outp_mat, mat) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
98 elif args.mat: |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
99 mat = np.loadtxt(args.mat) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
100 else: |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
101 print("Either --json or --mat must be specified.") |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
102 exit(1) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
103 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
104 Z = get_cluster_linkage_array(mat, args.clustering_method) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
105 np.savetxt(args.Z, Z) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
106 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
107 if args.heatmap: |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
108 plot_dist_mat(mat, args.heatmap, args.cmap) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
109 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
110 if args.dendrogram: |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
111 plot_dendrogram(Z, args.dendrogram) |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
112 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
113 |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
114 if __name__ == "__main__": |
4f3222cb5cf6
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 79589d149a8ff2791d4f71d28b155011672db827"
chemteam
parents:
diff
changeset
|
115 main() |