-
Notifications
You must be signed in to change notification settings - Fork 0
/
vmdmatplot.py
71 lines (53 loc) · 1.8 KB
/
vmdmatplot.py
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
'''
This is the last file that needs to be run and can be modified to your liking
in order to graph the sphere files and extract valid data.
'''
# This is the last file that can be modified to learn how to use matplotlib.
# this does not need to be edited but can be.
import matplotlib.pyplot as plt
import glob
import numpy as np
from icecream import ic
import operator
def readsphfile(sphfile):
'''
Takes in sph file that acts like a pdb and plots into graph
Args:
sphfile: sph file that is being read
Returns:
Numpy arrays of the radius and path along the x-axis
'''
fin = open(sphfile)
radiuslist,zlist = [],[]
for line in fin.readlines():
if line[0:4] == "ATOM" :
betacolumn = line[61:68]
z = line[47:55]
beta = float(betacolumn)
if beta > 0:
radiuslist.append(beta)
zlist.append(float(z))
fin.close()
return (np.array(radiuslist), np.array(zlist))
def main():
big_radius_lst,big_coordinate_lst = [],[]
holelist = sorted(glob.glob("./sph_files/curved_trimer*sph"))
fig, ax = plt.subplots(1,1)
plt.title("Flattened BMC Shell Pore Radius (No Constant Ratio)")
plt.ylabel("Hole Radius (Å)")
plt.xlabel("Z coordinate")
for sphfile in holelist:
r, z = readsphfile(sphfile)
for i in z:
big_coordinate_lst.append(i)
for x in r:
big_radius_lst.append(x)
#ax.scatter(z, r)
list_zip = zip(big_coordinate_lst,big_radius_lst)
list_zip = sorted(list_zip,key = operator.itemgetter(0))
x_val = [z_coord[0] for z_coord in list_zip]
y_val = [radius_dimensions[1] for radius_dimensions in list_zip]
plt.plot(x_val,y_val)
fig.savefig("flattened_trimer_all_frame.png")
if __name__ == "__main__":
main()