Skip to content

Commit f75da76

Browse files
committed
plotting
1 parent 20e1d15 commit f75da76

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

PyCEC/analysis/analysis.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,11 @@ def get_residence_times(self):
196196

197197
# Directory and title
198198
dir1 = '/biggin/b222/catz0163/pept/dynamics/pept_holo/pept_AF_H87P_D342P_v2/qmmm'
199+
dir1 = '/Users/nfo24278/Documents/dphil/proton_transfer/PyCEC/simulations/pept_AF_H87P_D342P'
199200
title1 = 'PepT2 with AF H87P D342P'
200201

201202
# Load the universe
202-
u1 = mda.Universe(f'{dir1}/prod-s100.pdb', f'{dir1}/prod-s100.xtc')
203+
u1 = mda.Universe(f'{dir1}/prod-s200.pdb', f'{dir1}/prod-s200.xtc')
203204

204205
# # Initialise class
205206
# cv = CVAnalysis(u1, initial_resid=342, target_resid=56,

PyCEC/analysis/plotting.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def plot_water_counts(self, save=False):
3737
plt.show()
3838

3939
def plot_water_counts_line(self, save=False,
40-
filename='water_counts_line_hist',
40+
filename='water_counts_line_hist.png',
4141
test=False, show=False):
4242
"""
4343
Plot the water counts over time, with a histogram of frequency to the\
@@ -75,7 +75,7 @@ def plot_water_counts_line(self, save=False,
7575

7676
# Save the plot
7777
if save:
78-
fig.savefig("water_counts2.png", dpi=300)
78+
fig.savefig(filename, dpi=300)
7979

8080
# Show the plot
8181
if show:
@@ -118,7 +118,8 @@ def plot_water_counts_violinplot(self, save=False):
118118

119119
if __name__ == "__main__":
120120
# Directory and title
121-
dir1 = '/biggin/b222/catz0163/pept/dynamics/pept_holo/pept_AF_H87P_D342P_v2'
121+
# dir1 = '/biggin/b222/catz0163/pept/dynamics/pept_holo/pept_AF_H87P_D342P_v2'
122+
dir1 = '/Users/nfo24278/Documents/dphil/proton_transfer/PyCEC/simulations/pept_AF_H87P_D342P'
122123
title1 = 'PepT2 with AF H87P D342P'
123124

124125
# Load the universe

PyCEC/analysis/residue_analysis.py

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import MDAnalysis as mda
2+
import matplotlib.pyplot as plt
3+
plt.rcParams["font.family"] = "serif"
4+
plt.rcParams["mathtext.fontset"] = "dejavuserif"
5+
26

37
class ResidueAnalysis:
48
"""
@@ -64,13 +68,28 @@ def get_two_torsions(self, dihedral1=[], dihedral2=[], verbose=False):
6468
for ts in self.u.trajectory:
6569
torsions1.append(selection1.dihedral.value())
6670
torsions2.append(selection2.dihedral.value())
71+
72+
# Combine the index numbers, times, and torsions
73+
torsions_h = []
74+
steps = []
75+
for i, t, d1, d2 in zip(range(self.n_frames), self.times, torsions1, torsions2):
76+
torsions_h.append([i, t, d1, d2])
77+
steps.append(i)
78+
79+
# Plot the torsions on a 2D plot
80+
fig, ax = plt.subplots(figsize=(7,5), dpi=200)
81+
sca = ax.scatter(torsions1, torsions2, c=steps, cmap='cividis', s=15)
82+
# Add colorbar
83+
cbar = fig.colorbar(sca, label='Frame')
84+
ax.set_xlabel(f'{dihedral1[0]}-{dihedral1[1]}-{dihedral1[2]}-{dihedral1[3]} [deg]')
85+
ax.set_ylabel(f'{dihedral2[0]}-{dihedral2[1]}-{dihedral2[2]}-{dihedral2[3]} [deg]')
86+
ax.set_title(f'Torsions: {dihedral1[0]}-{dihedral1[1]}-{dihedral1[2]}-{dihedral1[3]} and {dihedral2[0]}-{dihedral2[1]}-{dihedral2[2]}-{dihedral2[3]}')
87+
88+
89+
# Save the plot
90+
fig.savefig(f'{self.resid}_{dihedral1[0]}-{dihedral1[1]}-{dihedral1[2]}-{dihedral1[3]}_{dihedral2[0]}-{dihedral2[1]}-{dihedral2[2]}-{dihedral2[3]}.png')
6791

6892
if verbose:
69-
# Combine the index numbers, times, and torsions
70-
torsions_h = []
71-
for i, t, d1, d2 in zip(range(self.n_frames), self.times, torsions1, torsions2):
72-
torsions_h.append([i, t, d1, d2])
73-
7493
# Print the output out line by line
7594
for i, t, d1, d2 in torsions_h:
7695
print(f"Frame {i} at time {t} ps is {d1:.1f} deg and {d2:.1f} deg.")
@@ -96,6 +115,7 @@ def get_rmsd(self, reference):
96115

97116
# Directory and title
98117
dir1 = '/biggin/b222/catz0163/pept/dynamics/pept_holo/pept_AF_H87P_D342P_v2/qmmm'
118+
dir1 = '/Users/nfo24278/Documents/dphil/proton_transfer/PyCEC/simulations/pept_AF_H87P_D342P'
99119
title1 = 'PepT2 with AF H87P D342P'
100120

101121
# Load the universe

0 commit comments

Comments
 (0)