-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMdTrajectory.m
90 lines (54 loc) · 1.88 KB
/
MdTrajectory.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
classdef MdTrajectory < handle
properties
traj
mass
time
best_frame
rmsd_mean
end
methods
function this = MdTrajectory(file, time)
this.traj = readdcd(file);
if nargin == 1
time = 1 : size(this.traj, 1);
end
this.time = time;
end
function getMeanRmsd(this)
n = this.length();
trj = this.traj;
mat = zeros(n, n);
parfor i = 1 : n
mat(:, i) = superimpose(trj(i, :), trj);
end
this.rmsd_mean = mean(mat, 2)';
end
function n = getBestFrame(this)
if isempty(this.rmsd_mean)
this.getMeanRmsd();
end
n = find(this.rmsd_mean == min(this.rmsd_mean));
end
function n = getMostSimilarFrame(this, trj)
rmsd = superimpose(trj, this.traj);
n = find(rmsd == min(rmsd), 1);
end
% plot
function plotMeanRmsd(this)
if isempty(this.rmsd_mean)
this.getMeanRmsd();
end
figure;
plot(this.time, this.rmsd_mean, '-', 'linewidth', 2.4);
xlabel('Time (ns)', 'fontsize', 16);
ylabel('RMSD (\AA)', 'fontsize', 16, 'interpreter', 'latex');
set(gca, 'fontsize', 14);
end
% utility
function n = length(this)
n = size(this.traj, 1);
end
end
methods (Static)
end
end